[{"Question":"I am using the Photoshop's javascript API to find the fonts in a given PSD.\nGiven a font name returned by the API, I want to find the actual physical font file that font name corresponds to on the disc.\nThis is all happening in a python program running on OSX so I guess I'm looking for one of:\n\nSome Photoshop javascript\nA Python function\nAn OSX API that I can call from python","AnswerCount":4,"Available Count":2,"Score":1.0,"is_accepted":false,"ViewCount":4225,"Q_Id":469,"Users Score":6,"Answer":"I haven't been able to find anything that does this directly. I think you'll have to iterate through the various font folders on the system: \/System\/Library\/Fonts, \/Library\/Fonts, and there can probably be a user-level directory as well ~\/Library\/Fonts.","Q_Score":47,"Tags":"python,macos,fonts,photoshop","A_Id":518,"CreationDate":"2008-08-02T15:11:00.000","Title":"How can I find the full path to a font from its display name on a 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":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I am using the Photoshop's javascript API to find the fonts in a given PSD.\nGiven a font name returned by the API, I want to find the actual physical font file that font name corresponds to on the disc.\nThis is all happening in a python program running on OSX so I guess I'm looking for one of:\n\nSome Photoshop javascript\nA Python function\nAn OSX API that I can call from python","AnswerCount":4,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":4225,"Q_Id":469,"Users Score":21,"Answer":"Unfortunately the only API that isn't deprecated is located in the ApplicationServices framework, which doesn't have a bridge support file, and thus isn't available in the bridge. If you're wanting to use ctypes, you can use ATSFontGetFileReference after looking up the ATSFontRef.\nCocoa doesn't have any native support, at least as of 10.5, for getting the location of a font.","Q_Score":47,"Tags":"python,macos,fonts,photoshop","A_Id":3040,"CreationDate":"2008-08-02T15:11:00.000","Title":"How can I find the full path to a font from its display name on a 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":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"When asked to create system XYZ and you ask to do it in Python over PHP or Ruby, what are the main features you can mention when they require you to explain it?","AnswerCount":8,"Available Count":6,"Score":0.0748596907,"is_accepted":false,"ViewCount":1421,"Q_Id":4942,"Users Score":3,"Answer":"Focus on the shorter time needed for development\/prototype and possibly easier maintenance (none of this may apply against Ruby).","Q_Score":14,"Tags":"php,python,ruby-on-rails,ruby","A_Id":4958,"CreationDate":"2008-08-07T16:43:00.000","Title":"How to sell Python to a client\/boss\/person","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"When asked to create system XYZ and you ask to do it in Python over PHP or Ruby, what are the main features you can mention when they require you to explain it?","AnswerCount":8,"Available Count":6,"Score":0.0748596907,"is_accepted":false,"ViewCount":1421,"Q_Id":4942,"Users Score":3,"Answer":"I would consider that using python on a new project is completely dependent on what problem you are trying to solve with python. If you want someone to agree with you that you should use python, then show them how python's features apply specifically to that problem.\nIn the case of web development with python, talk about WSGI and other web libraries and frameworks you could use that would make your life easier. One note for python is that most of the frameworks for python web development can be plugged right into any current project. With ruby on rails, you're practically working in a DSL that anyone who uses your project will have to learn. If they know python, then they can figure out what you are doing with django, etc in a day.\nI'm only talking about web development because it appears that's what you are going to be working on seeing ruby, python and PHP in the same list. The real message that's important is applying to whatever it is you like about python directly to some problem you are trying to solve.","Q_Score":14,"Tags":"php,python,ruby-on-rails,ruby","A_Id":5014,"CreationDate":"2008-08-07T16:43:00.000","Title":"How to sell Python to a client\/boss\/person","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"When asked to create system XYZ and you ask to do it in Python over PHP or Ruby, what are the main features you can mention when they require you to explain it?","AnswerCount":8,"Available Count":6,"Score":1.2,"is_accepted":true,"ViewCount":1421,"Q_Id":4942,"Users Score":13,"Answer":"This is one of those cases that really boil down to personal preference or situational details. If you're more comfortable and experienced with Python, then say so. Are they asking you to justify it because they're more comfortable with one of the other environments? After you're done, will the system be passed off to someone else for long-term maintenance?\nIf they ask you to use a technology or language that you're not as familiar with, then make sure they know up-front that it's going to take you longer.","Q_Score":14,"Tags":"php,python,ruby-on-rails,ruby","A_Id":4978,"CreationDate":"2008-08-07T16:43:00.000","Title":"How to sell Python to a client\/boss\/person","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"When asked to create system XYZ and you ask to do it in Python over PHP or Ruby, what are the main features you can mention when they require you to explain it?","AnswerCount":8,"Available Count":6,"Score":0.1243530018,"is_accepted":false,"ViewCount":1421,"Q_Id":4942,"Users Score":5,"Answer":"It's one of the preferred languages over at Google - It's several years ahead of Ruby in terms of \"maturity\" (what ever that really means - but managers like that). Since it's prefered by Google you can also run it on the Google App Engine.\nMircosoft is also embracing Python, and will have a v2.0 of IronPython coming out shortly. They are working on a Ruby implementation as well, but the Python version is way ahead, and is actually \"ready for primetime\". That give you the possibility for easy integration with .NET code, as well as being able to write client side RIAs in Python when Silverlight 2 ships.","Q_Score":14,"Tags":"php,python,ruby-on-rails,ruby","A_Id":15296,"CreationDate":"2008-08-07T16:43:00.000","Title":"How to sell Python to a client\/boss\/person","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"When asked to create system XYZ and you ask to do it in Python over PHP or Ruby, what are the main features you can mention when they require you to explain it?","AnswerCount":8,"Available Count":6,"Score":0.024994793,"is_accepted":false,"ViewCount":1421,"Q_Id":4942,"Users Score":1,"Answer":"Give them a snippet of code in each (no more than a page) that performs some cool function that they will like. (e.g show outliers in a data set).\nShow them each page. One in PHP, Ruby and Python.\nAsk them which they find easiest to understand\/read.\nTell them thats why you want to use Python. It's easier to read if you've not written it, more manageable, less buggy and quicker to build features because it is the most elegant (pythonic)","Q_Score":14,"Tags":"php,python,ruby-on-rails,ruby","A_Id":9420311,"CreationDate":"2008-08-07T16:43:00.000","Title":"How to sell Python to a client\/boss\/person","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"When asked to create system XYZ and you ask to do it in Python over PHP or Ruby, what are the main features you can mention when they require you to explain it?","AnswerCount":8,"Available Count":6,"Score":0.0,"is_accepted":false,"ViewCount":1421,"Q_Id":4942,"Users Score":0,"Answer":"I agree with mreggen. Tell them by working in Python you can get things done faster. Getting things done faster possibly means money saved by the client. In the least it means that you are working with a language you a more comfortable in, meaning faster development, debugging, and refactoring time. There will be less time spent looking up documentation on what function to use to find the length of a string, etc.","Q_Score":14,"Tags":"php,python,ruby-on-rails,ruby","A_Id":15291,"CreationDate":"2008-08-07T16:43:00.000","Title":"How to sell Python to a client\/boss\/person","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I tried to follow a couple of googled up tutorials on setting up mod_python, but failed every time. Do you have a good, step-by step, rock-solid howto?\nMy dev box is OS X, production - Centos.","AnswerCount":4,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":32774,"Q_Id":5102,"Users Score":0,"Answer":"The problem for me wasn't in Apache set up, but in understanding how mod_apache actually uses the .py files. Module-level statements (including those in a if __name__=='__main__' section) are not executed--I assumed that the stdout from running the script at the commandline would be what the server would output, but that's not how it works.\nInstead, I wrote a module-level function called index(), and had it return as a string the HTML of the page. It's also possible to have other module-level functions (e.g., otherFunction()) that can be accessed as further segments in the URI (e.g., testScript\/otherFunction for the file testScript.py.)\nObviously, this makes more sense than my original stdout conception. Better capability of actually using Python as a scripting language and not a humongous markup language.","Q_Score":23,"Tags":"python,apache,apache2","A_Id":14791003,"CreationDate":"2008-08-07T18:24:00.000","Title":"How do you set up Python scripts to work in Apache 2.0?","Data Science and Machine Learning":0,"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},{"Question":"Is there a maintained package I can use to retrieve and set MP3 ID3 metadata using Python?","AnswerCount":16,"Available Count":1,"Score":0.012499349,"is_accepted":false,"ViewCount":140384,"Q_Id":8948,"Users Score":1,"Answer":"After some initial research I thought songdetails might fit my use case, but it doesn't handle .m4b files. Mutagen does. Note that while some have (reasonably) taken issue with Mutagen's surfacing of format-native keys, that vary from format to format (TIT2 for mp3, title for ogg, \\xa9nam for mp4, Title for WMA etc.), mutagen.File() has a (new?) easy=True parameter that provides EasyMP3\/EasyID3 tags, which have a consistent, albeit limited, set of keys. I've only done limited testing so far, but the common keys, like album, artist, albumartist, genre, tracknumber, discnumber, etc. are all present and identical for .mb4 and .mp3 files when using easy=True, making it very convenient for my purposes.","Q_Score":142,"Tags":"python,mp3,metadata","A_Id":31373513,"CreationDate":"2008-08-12T15:16:00.000","Title":"Accessing MP3 metadata 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},{"Question":"This is a difficult and open-ended question I know, but I thought I'd throw it to the floor and see if anyone had any interesting suggestions.\nI have developed a code-generator that takes our python interface to our C++ code (generated via SWIG) and generates code needed to expose this as WebServices. When I developed this code I did it using TDD, but I've found my tests to be brittle as hell. Because each test essentially wanted to verify that for a given bit of input code (which happens to be a C++ header) I'd get a given bit of outputted code I wrote a small engine that reads test definitions from XML input files and generates test cases from these expectations.\nThe problem is I dread going in to modify the code at all. That and the fact that the unit tests themselves are a: complex, and b: brittle.\nSo I'm trying to think of alternative approaches to this problem, and it strikes me I'm perhaps tackling it the wrong way. Maybe I need to focus more on the outcome, IE: does the code I generate actually run and do what I want it to, rather than, does the code look the way I want it to.\nHas anyone got any experiences of something similar to this they would care to share?","AnswerCount":8,"Available Count":5,"Score":0.0,"is_accepted":false,"ViewCount":7527,"Q_Id":11060,"Users Score":0,"Answer":"My recommendation would be to figure out a set of known input-output results, such as some simpler cases that you already have in place, and unit test the code that is produced. It's entirely possible that as you change the generator that the exact string that is produced may be slightly different... but what you really care is whether it is interpreted in the same way. Thus, if you test the results as you would test that code if it were your feature, you will find out if it succeeds in the ways you want.\nBasically, what you really want to know is whether your generator will produce what you expect without physically testing every possible combination (also: impossible). By ensuring that your generator is consistent in the ways you expect, you can feel better that the generator will succeed in ever-more-complex situations.\nIn this way, you can also build up a suite of regression tests (unit tests that need to keep working correctly). This will help you make sure that changes to your generator aren't breaking other forms of code. When you encounter a bug that your unit tests didn't catch, you may want to include it to prevent similar breakage.","Q_Score":29,"Tags":"c++,python,unit-testing,code-generation,swig","A_Id":3331503,"CreationDate":"2008-08-14T13:59:00.000","Title":"How should I unit test a code-generator?","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},{"Question":"This is a difficult and open-ended question I know, but I thought I'd throw it to the floor and see if anyone had any interesting suggestions.\nI have developed a code-generator that takes our python interface to our C++ code (generated via SWIG) and generates code needed to expose this as WebServices. When I developed this code I did it using TDD, but I've found my tests to be brittle as hell. Because each test essentially wanted to verify that for a given bit of input code (which happens to be a C++ header) I'd get a given bit of outputted code I wrote a small engine that reads test definitions from XML input files and generates test cases from these expectations.\nThe problem is I dread going in to modify the code at all. That and the fact that the unit tests themselves are a: complex, and b: brittle.\nSo I'm trying to think of alternative approaches to this problem, and it strikes me I'm perhaps tackling it the wrong way. Maybe I need to focus more on the outcome, IE: does the code I generate actually run and do what I want it to, rather than, does the code look the way I want it to.\nHas anyone got any experiences of something similar to this they would care to share?","AnswerCount":8,"Available Count":5,"Score":0.1243530018,"is_accepted":false,"ViewCount":7527,"Q_Id":11060,"Users Score":5,"Answer":"Recall that \"unit testing\" is only one kind of testing. You should be able to unit test the internal pieces of your code generator. What you're really looking at here is system level testing (a.k.a. regression testing). It's not just semantics... there are different mindsets, approaches, expectations, etc. It's certainly more work, but you probably need to bite the bullet and set up an end-to-end regression test suite: fixed C++ files -> SWIG interfaces -> python modules -> known output. You really want to check the known input (fixed C++ code) against expected output (what comes out of the final Python program). Checking the code generator results directly would be like diffing object files...","Q_Score":29,"Tags":"c++,python,unit-testing,code-generation,swig","A_Id":11443,"CreationDate":"2008-08-14T13:59:00.000","Title":"How should I unit test a code-generator?","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},{"Question":"This is a difficult and open-ended question I know, but I thought I'd throw it to the floor and see if anyone had any interesting suggestions.\nI have developed a code-generator that takes our python interface to our C++ code (generated via SWIG) and generates code needed to expose this as WebServices. When I developed this code I did it using TDD, but I've found my tests to be brittle as hell. Because each test essentially wanted to verify that for a given bit of input code (which happens to be a C++ header) I'd get a given bit of outputted code I wrote a small engine that reads test definitions from XML input files and generates test cases from these expectations.\nThe problem is I dread going in to modify the code at all. That and the fact that the unit tests themselves are a: complex, and b: brittle.\nSo I'm trying to think of alternative approaches to this problem, and it strikes me I'm perhaps tackling it the wrong way. Maybe I need to focus more on the outcome, IE: does the code I generate actually run and do what I want it to, rather than, does the code look the way I want it to.\nHas anyone got any experiences of something similar to this they would care to share?","AnswerCount":8,"Available Count":5,"Score":0.0,"is_accepted":false,"ViewCount":7527,"Q_Id":11060,"Users Score":0,"Answer":"Yes, results are the ONLY thing that matters. The real chore is writing a framework that allows your generated code to run independently... spend your time there.","Q_Score":29,"Tags":"c++,python,unit-testing,code-generation,swig","A_Id":11128,"CreationDate":"2008-08-14T13:59:00.000","Title":"How should I unit test a code-generator?","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},{"Question":"This is a difficult and open-ended question I know, but I thought I'd throw it to the floor and see if anyone had any interesting suggestions.\nI have developed a code-generator that takes our python interface to our C++ code (generated via SWIG) and generates code needed to expose this as WebServices. When I developed this code I did it using TDD, but I've found my tests to be brittle as hell. Because each test essentially wanted to verify that for a given bit of input code (which happens to be a C++ header) I'd get a given bit of outputted code I wrote a small engine that reads test definitions from XML input files and generates test cases from these expectations.\nThe problem is I dread going in to modify the code at all. That and the fact that the unit tests themselves are a: complex, and b: brittle.\nSo I'm trying to think of alternative approaches to this problem, and it strikes me I'm perhaps tackling it the wrong way. Maybe I need to focus more on the outcome, IE: does the code I generate actually run and do what I want it to, rather than, does the code look the way I want it to.\nHas anyone got any experiences of something similar to this they would care to share?","AnswerCount":8,"Available Count":5,"Score":1.2,"is_accepted":true,"ViewCount":7527,"Q_Id":11060,"Users Score":14,"Answer":"I started writing up a summary of my experience with my own code generator, then went back and re-read your question and found you had already touched upon the same issues yourself, focus on the execution results instead of the code layout\/look.\nProblem is, this is hard to test, the generated code might not be suited to actually run in the environment of the unit test system, and how do you encode the expected results?\nI've found that you need to break down the code generator into smaller pieces and unit test those. Unit testing a full code generator is more like integration testing than unit testing if you ask me.","Q_Score":29,"Tags":"c++,python,unit-testing,code-generation,swig","A_Id":11074,"CreationDate":"2008-08-14T13:59:00.000","Title":"How should I unit test a code-generator?","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},{"Question":"This is a difficult and open-ended question I know, but I thought I'd throw it to the floor and see if anyone had any interesting suggestions.\nI have developed a code-generator that takes our python interface to our C++ code (generated via SWIG) and generates code needed to expose this as WebServices. When I developed this code I did it using TDD, but I've found my tests to be brittle as hell. Because each test essentially wanted to verify that for a given bit of input code (which happens to be a C++ header) I'd get a given bit of outputted code I wrote a small engine that reads test definitions from XML input files and generates test cases from these expectations.\nThe problem is I dread going in to modify the code at all. That and the fact that the unit tests themselves are a: complex, and b: brittle.\nSo I'm trying to think of alternative approaches to this problem, and it strikes me I'm perhaps tackling it the wrong way. Maybe I need to focus more on the outcome, IE: does the code I generate actually run and do what I want it to, rather than, does the code look the way I want it to.\nHas anyone got any experiences of something similar to this they would care to share?","AnswerCount":8,"Available Count":5,"Score":0.0,"is_accepted":false,"ViewCount":7527,"Q_Id":11060,"Users Score":0,"Answer":"If you are running on *nux you might consider dumping the unittest framework in favor of a bash script or makefile. on windows you might consider building a shell app\/function that runs the generator and then uses the code (as another process) and unittest that.\nA third option would be to generate the code and then build an app from it that includes nothing but a unittest. Again you would need a shell script or whatnot to run this for each input. As to how to encode the expected behavior, it occurs to me that it could be done in much the same way as you would for the C++ code just using the generated interface rather than the C++ one.","Q_Score":29,"Tags":"c++,python,unit-testing,code-generation,swig","A_Id":11235,"CreationDate":"2008-08-14T13:59:00.000","Title":"How should I unit test a code-generator?","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},{"Question":"I've been having a hard time trying to understand PyPy's translation. It looks like something absolutely revolutionary from simply reading the description, however I'm hard-pressed to find good documentation on actually translating a real world piece of code to something such as LLVM. Does such a thing exist? The official PyPy documentation on it just skims over the functionality, rather than providing anything I can try out myself.","AnswerCount":5,"Available Count":2,"Score":0.1194272985,"is_accepted":false,"ViewCount":1284,"Q_Id":27567,"Users Score":3,"Answer":"PyPy translator is in general, not intended for more public use. We use it for translating\nour own python interpreter (including JIT and GCs, both written in RPython, this restricted\nsubset of Python). The idea is that with good JIT and GC, you'll be able to speedups even\nwithout knowing or using PyPy's translation toolchain (and more importantly, without\nrestricting yourself to RPython).\nCheers,\nfijal","Q_Score":11,"Tags":"python,translation,pypy","A_Id":1041655,"CreationDate":"2008-08-26T08:40:00.000","Title":"Where can I learn more about PyPy's translation 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":0,"Web Development":0},{"Question":"I've been having a hard time trying to understand PyPy's translation. It looks like something absolutely revolutionary from simply reading the description, however I'm hard-pressed to find good documentation on actually translating a real world piece of code to something such as LLVM. Does such a thing exist? The official PyPy documentation on it just skims over the functionality, rather than providing anything I can try out myself.","AnswerCount":5,"Available Count":2,"Score":0.0399786803,"is_accepted":false,"ViewCount":1284,"Q_Id":27567,"Users Score":1,"Answer":"It looks like something absolutely revolutionary from simply reading the description,\n\nAs far as I know, PyPy is novel in the sense that it is the first system expressly designed for implementing languages. Other tools exist to help with much of the very front end, such as parser generators, or for the very back end, such as code generation, but not much existed for connecting the two.","Q_Score":11,"Tags":"python,translation,pypy","A_Id":1041857,"CreationDate":"2008-08-26T08:40:00.000","Title":"Where can I learn more about PyPy's translation 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":0,"Web Development":0},{"Question":"I have a medium sized application that runs as a .net web-service which I do not control,\nand I want to create a loose pythonic API above it to enable easy scripting.\nI wanted to know what is the best\/most practical solution for using web-services in python.\nEdit:\nI need to consume a complex soap WS\nand I have no control over it.","AnswerCount":3,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":1090,"Q_Id":28961,"Users Score":3,"Answer":"If I have to expose APIs, I prefer doing it as JSON. Python has excellent support for JSON objects (JSON Objects are infact python dictionaries)","Q_Score":8,"Tags":"python,web-services,soap","A_Id":31926,"CreationDate":"2008-08-26T19:49:00.000","Title":"What's the best way to use web services 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},{"Question":"This is something that I think would be very useful. Basically, I'd like there to be a way to edit Python source programmatically without requiring human intervention. There are a couple of things I would like to do with this:\n\nEdit the configuration of Python apps that use source modules for configuration.\nSet up a \"template\" so that I can customize a Python source file on the fly. This way, I can set up a \"project\" system on an open source app I'm working on and allow certain files to be customized.\n\nI could probably write something that can do this myself, but I can see that opening up a lot of \"devil's in the details\" type issues. Are there any ways to do this currently, or am I just going to have to bite the bullet and implement it myself?","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1904,"Q_Id":32385,"Users Score":0,"Answer":"I had the same issue and I simply opened the file and did some replace: then reload the file in the Python interpreter. This works fine and is easy to do. \nOtherwise AFAIK you have to use some conf objects.","Q_Score":9,"Tags":"python,file-io","A_Id":33325,"CreationDate":"2008-08-28T14:23:00.000","Title":"Programmatically editing Python 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":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Is there something like the Python descriptor protocol implemented in other languages? It seems like a nice way to increase modularity\/encapsulation without bloating your containing class' implementation, but I've never heard of a similar thing in any other languages. Is it likely absent from other languages because of the lookup overhead?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":888,"Q_Id":34243,"Users Score":4,"Answer":"I've not heard of a direct equivalent either. You could probably achieve the same effect with macros, especially in a language like Lisp which has extremely powerful macros.\nI wouldn't be at all surprised if other languages start to incorporate something similar because it is so powerful.","Q_Score":10,"Tags":"python,language-features,encapsulation","A_Id":34266,"CreationDate":"2008-08-29T09:24:00.000","Title":"Python descriptor protocol analog in other 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},{"Question":"Given a Python object of any kind, is there an easy way to get the list of all methods that this object has?\nOr,\nif this is not possible, is there at least an easy way to check if it has a particular method other than simply checking if an error occurs when the method is called?","AnswerCount":22,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":564030,"Q_Id":34439,"Users Score":132,"Answer":"The simplest method is to use dir(objectname). It will display all the methods available for that object.","Q_Score":592,"Tags":"python,introspection","A_Id":20100900,"CreationDate":"2008-08-29T15:05:00.000","Title":"Finding what methods a Python object has","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Right now I'm developing mostly in C\/C++, but I wrote some small utilities in Python to automatize some tasks and I really love it as language (especially the productivity). \nExcept for the performances (a problem that could be sometimes solved thanks to the ease of interfacing Python with C modules), do you think it is proper for production use in the development of stand-alone complex applications (think for example to a word processor or a graphic tool)?\nWhat IDE would you suggest? The IDLE provided with Python is not enough even for small projects in my opinion.","AnswerCount":13,"Available Count":8,"Score":1.0,"is_accepted":false,"ViewCount":29152,"Q_Id":35753,"Users Score":23,"Answer":"You'll find mostly two answers to that \u2013 the religous one (Yes! Of course! It's the best language ever!) and the other religious one (you gotta be kidding me! Python? No... it's not mature enough). I will maybe skip the last religion (Python?! Use Ruby!). The truth, as always, is far from obvious. \nPros: it's easy, readable, batteries included, has lots of good libraries for pretty much everything. It's expressive and dynamic typing makes it more concise in many cases.\nCons: as a dynamic language, has way worse IDE support (proper syntax completion requires static typing, whether explicit in Java or inferred in SML), its object system is far from perfect (interfaces, anyone?) and it is easy to end up with messy code that has methods returning either int or boolean or object or some sort under unknown circumstances.\nMy take \u2013 I love Python for scripting, automation, tiny webapps and other simple well defined tasks. In my opinion it is by far the best dynamic language on the planet. That said, I would never use it any dynamically typed language to develop an application of substantial size.\nSay \u2013 it would be fine to use it for Stack Overflow, which has three developers and I guess no more than 30k lines of code. For bigger things \u2013 first your development would be super fast, and then once team and codebase grow things are slowing down more than they would with Java or C#. You need to offset lack of compilation time checks by writing more unittests, refactorings get harder cause you never know what your refacoring broke until you run all tests or even the whole big app, etc.\nNow \u2013 decide on how big your team is going to be and how big the app is supposed to be once it is done. If you have 5 or less people and the target size is roughly Stack Overflow, go ahead, write in Python. You will finish in no time and be happy with good codebase. But if you want to write second Google or Yahoo, you will be much better with C# or Java.\nSide-note on C\/C++ you have mentioned: if you are not writing performance critical software (say massive parallel raytracer that will run for three months rendering a film) or a very mission critical system (say Mars lander that will fly three years straight and has only one chance to land right or you lose $400mln) do not use it. For web apps, most desktop apps, most apps in general it is not a good choice. You will die debugging pointers and memory allocation in complex business logic.","Q_Score":29,"Tags":"python,ide","A_Id":35777,"CreationDate":"2008-08-30T07:08:00.000","Title":"Is Python good for big software projects (not web based)?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Right now I'm developing mostly in C\/C++, but I wrote some small utilities in Python to automatize some tasks and I really love it as language (especially the productivity). \nExcept for the performances (a problem that could be sometimes solved thanks to the ease of interfacing Python with C modules), do you think it is proper for production use in the development of stand-alone complex applications (think for example to a word processor or a graphic tool)?\nWhat IDE would you suggest? The IDLE provided with Python is not enough even for small projects in my opinion.","AnswerCount":13,"Available Count":8,"Score":0.0,"is_accepted":false,"ViewCount":29152,"Q_Id":35753,"Users Score":0,"Answer":"I had only one python experience, my trash-cli project.\nI know that probably some or all problems depends of my inexperience with python.\nI found frustrating these things: \n\nthe difficult of finding a good IDE for free\nthe limited support to automatic refactoring\n\nMoreover:\n\nthe need of introduce two level of grouping packages and modules confuses me.\nit seems to me that there is not a widely adopted code naming convention\nit seems to me that there are some standard library APIs docs that are incomplete\nthe fact that some standard libraries are not fully object oriented annoys me\n\nAlthough some python coders tell me that they does not have these problems, or they say these are not problems.","Q_Score":29,"Tags":"python,ide","A_Id":277490,"CreationDate":"2008-08-30T07:08:00.000","Title":"Is Python good for big software projects (not web based)?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Right now I'm developing mostly in C\/C++, but I wrote some small utilities in Python to automatize some tasks and I really love it as language (especially the productivity). \nExcept for the performances (a problem that could be sometimes solved thanks to the ease of interfacing Python with C modules), do you think it is proper for production use in the development of stand-alone complex applications (think for example to a word processor or a graphic tool)?\nWhat IDE would you suggest? The IDLE provided with Python is not enough even for small projects in my opinion.","AnswerCount":13,"Available Count":8,"Score":1.0,"is_accepted":false,"ViewCount":29152,"Q_Id":35753,"Users Score":13,"Answer":"I really like python, it's usually my language of choice these days for small (non-gui) stuff that I do on my own.\nHowever, for some larger Python projects I've tackled, I'm finding that it's not quite the same as programming in say, C++. I was working on a language parser, and needed to represent an AST in Python. This is certainly within the scope of what Python can do, but I had a bit of trouble with some refactoring. I was changing the representation of my AST and changing methods and classes around a lot, and I found I missed the strong typing that would be available to me in a C++ solution. Python's duck typing was almost too flexible and I found myself adding a lot of assert code to try to check my types as the program ran. And then I couldn't really be sure that everything was properly typed unless I had 100% code coverage testing (which I didn't at the time).\nActually, that's another thing that I miss sometimes. It's possible to write syntactically correct code in Python that simply won't run. The compiler is incapable of telling you about it until it actually executes the code, so in infrequently-used code paths such as error handlers you can easily have unseen bugs lurking around. Even code that's as simple as printing an error message with a % format string can fail at runtime because of mismatched types.\nI haven't used Python for any GUI stuff so I can't comment on that aspect.","Q_Score":29,"Tags":"python,ide","A_Id":35759,"CreationDate":"2008-08-30T07:08:00.000","Title":"Is Python good for big software projects (not web based)?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Right now I'm developing mostly in C\/C++, but I wrote some small utilities in Python to automatize some tasks and I really love it as language (especially the productivity). \nExcept for the performances (a problem that could be sometimes solved thanks to the ease of interfacing Python with C modules), do you think it is proper for production use in the development of stand-alone complex applications (think for example to a word processor or a graphic tool)?\nWhat IDE would you suggest? The IDLE provided with Python is not enough even for small projects in my opinion.","AnswerCount":13,"Available Count":8,"Score":0.0,"is_accepted":false,"ViewCount":29152,"Q_Id":35753,"Users Score":0,"Answer":"I know I'm probably stating the obvious, but don't forget that the quality of the development team and their familiarity with the technology will have a major impact on your ability to deliver. \nIf you have a strong team, then it's probably not an issue if they're familiar. But if you have people who are more 9 to 5'rs who aren't familiar with the technology, they will need more support and you'd need to make a call if the productivity gains are worth whatever the cost of that support is.","Q_Score":29,"Tags":"python,ide","A_Id":35838,"CreationDate":"2008-08-30T07:08:00.000","Title":"Is Python good for big software projects (not web based)?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Right now I'm developing mostly in C\/C++, but I wrote some small utilities in Python to automatize some tasks and I really love it as language (especially the productivity). \nExcept for the performances (a problem that could be sometimes solved thanks to the ease of interfacing Python with C modules), do you think it is proper for production use in the development of stand-alone complex applications (think for example to a word processor or a graphic tool)?\nWhat IDE would you suggest? The IDLE provided with Python is not enough even for small projects in my opinion.","AnswerCount":13,"Available Count":8,"Score":0.0153834017,"is_accepted":false,"ViewCount":29152,"Q_Id":35753,"Users Score":1,"Answer":"And as far as I know they use a lot of python inside google too.\n\nWell i'd hope so, the maker of python still works at google if i'm not mistaken? \nAs for the use of Python, i think it's a great language for stand-alone apps. It's heavily used in a lot of Linux programs, and there are a few nice widget sets out there to aid in the development of GUI's.","Q_Score":29,"Tags":"python,ide","A_Id":286449,"CreationDate":"2008-08-30T07:08:00.000","Title":"Is Python good for big software projects (not web based)?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Right now I'm developing mostly in C\/C++, but I wrote some small utilities in Python to automatize some tasks and I really love it as language (especially the productivity). \nExcept for the performances (a problem that could be sometimes solved thanks to the ease of interfacing Python with C modules), do you think it is proper for production use in the development of stand-alone complex applications (think for example to a word processor or a graphic tool)?\nWhat IDE would you suggest? The IDLE provided with Python is not enough even for small projects in my opinion.","AnswerCount":13,"Available Count":8,"Score":0.0153834017,"is_accepted":false,"ViewCount":29152,"Q_Id":35753,"Users Score":1,"Answer":"Python is a delight to use. I use it routinely and also write a lot of code for work in C#. There are two drawbacks to writing UI code in Python. one is that there is not a single ui framework that is accepted by the majority of the community. when you write in c# the .NET runtime and class libraries are all meant to work together. With Python every UI library has at's own semantics which are often at odds with the pythonic mindset in which you are trying to write your program. I am not blaming the library writers. I've tried several libraries (wxwidgets, PythonWin[Wrapper around MFC], Tkinter), When doing so I often felt that I was writing code in a language other than Python (despite the fact that it was python) because the libraries aren't exactly pythonic they are a port from another language be it c, c++, tk.\nSo for me I will write UI code in .NET (for me C#) because of the IDE & the consistency of the libraries. But when I can I will write business logic in python because it is more clear and more fun.","Q_Score":29,"Tags":"python,ide","A_Id":286491,"CreationDate":"2008-08-30T07:08:00.000","Title":"Is Python good for big software projects (not web based)?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Right now I'm developing mostly in C\/C++, but I wrote some small utilities in Python to automatize some tasks and I really love it as language (especially the productivity). \nExcept for the performances (a problem that could be sometimes solved thanks to the ease of interfacing Python with C modules), do you think it is proper for production use in the development of stand-alone complex applications (think for example to a word processor or a graphic tool)?\nWhat IDE would you suggest? The IDLE provided with Python is not enough even for small projects in my opinion.","AnswerCount":13,"Available Count":8,"Score":0.0,"is_accepted":false,"ViewCount":29152,"Q_Id":35753,"Users Score":0,"Answer":"Try Django or Pylons, write a simple app with both of them and then decide which one suits you best. There are others (like Turbogears or Werkzeug) but those are the most used.","Q_Score":29,"Tags":"python,ide","A_Id":3445481,"CreationDate":"2008-08-30T07:08:00.000","Title":"Is Python good for big software projects (not web based)?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Right now I'm developing mostly in C\/C++, but I wrote some small utilities in Python to automatize some tasks and I really love it as language (especially the productivity). \nExcept for the performances (a problem that could be sometimes solved thanks to the ease of interfacing Python with C modules), do you think it is proper for production use in the development of stand-alone complex applications (think for example to a word processor or a graphic tool)?\nWhat IDE would you suggest? The IDLE provided with Python is not enough even for small projects in my opinion.","AnswerCount":13,"Available Count":8,"Score":0.0461211021,"is_accepted":false,"ViewCount":29152,"Q_Id":35753,"Users Score":3,"Answer":"Refactoring is inevitable on larger codebases and the lack of static typing makes this much harder in python than in statically typed languages.","Q_Score":29,"Tags":"python,ide","A_Id":35841,"CreationDate":"2008-08-30T07:08:00.000","Title":"Is Python good for big software projects (not web based)?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Does Python have a unit testing framework compatible with the standard xUnit style of test framework? If so, what is it, where is it, and is it any good?","AnswerCount":9,"Available Count":3,"Score":0.022218565,"is_accepted":false,"ViewCount":8490,"Q_Id":36647,"Users Score":1,"Answer":"I recommend Nose. \nAfter the reasonable simple installation, you just have to run \"nosetests\" in your project folder and Nose will find all your tests and run them. I also like the collection of plugins (coverage, GAE, etc.) and the abilty to call Nose directly from within my Python scripts.","Q_Score":20,"Tags":"python,unit-testing","A_Id":1310119,"CreationDate":"2008-08-31T05:07:00.000","Title":"Unit tests 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},{"Question":"Does Python have a unit testing framework compatible with the standard xUnit style of test framework? If so, what is it, where is it, and is it any good?","AnswerCount":9,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":8490,"Q_Id":36647,"Users Score":0,"Answer":"nose seems to be the best combination of flexibility and convenience. It runs unittests, doctests, coverage (with an extension) and py.test-like tests from one framework and does so admirably. It has enough popularity that it has had some IDE integration done as well for Komodo Edit and I wouldn't be surprised to see it elsewhere as well.\nI like it for one strong reason: I almost always doctest before writing more extensive tests in another framework. This is because, for basic tests, doctests kill two birds with one stone. You get executable tests (although they are a bit clumsy to write well sometimes) as well as API documentation and interactive documentation at the same time. nose will run these with the bundled doctest extension when you use a command-line option (--with-doctest).\nI say this having come from py.test as my former favorite. While it is great, nose tests are similar enough to me that I don't miss it, and I like the integration of the various test methodologies under one roof, so to speak. YMMV, but I recommend taking a good look at nose before choosing another. If you aren't familiar with py.test tests, you should look at them as well. I find them terrific because they are usually written in such a way that they can be easily debugged without the testing framework, which makes one less tricky system involved in the debugging session. I find that alone invaluable, while they are also easier to write than unittest tests in my opinion.","Q_Score":20,"Tags":"python,unit-testing","A_Id":2194729,"CreationDate":"2008-08-31T05:07:00.000","Title":"Unit tests 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},{"Question":"Does Python have a unit testing framework compatible with the standard xUnit style of test framework? If so, what is it, where is it, and is it any good?","AnswerCount":9,"Available Count":3,"Score":0.0444152037,"is_accepted":false,"ViewCount":8490,"Q_Id":36647,"Users Score":2,"Answer":"@Greg: PyUnit is included in the standard library as unittest","Q_Score":20,"Tags":"python,unit-testing","A_Id":36654,"CreationDate":"2008-08-31T05:07:00.000","Title":"Unit tests 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},{"Question":"I'd like to take some time to learn more about dynamic languages built on top of the DLR and I'm not sure which language would be better to learn.\nHaving limited time, I really only have time to look learn one of them.\nAny opinions on which of the two (Iron Ruby or Iron Python) would be more useful in the long run?","AnswerCount":6,"Available Count":3,"Score":0.1651404129,"is_accepted":false,"ViewCount":1222,"Q_Id":42690,"Users Score":5,"Answer":"Without getting into the relative merits of the languages (which would be an entire pissing contest in itself), IronPython (stable 1.1.1, beta 2.0) is further along in development than IronRuby (alpha)","Q_Score":5,"Tags":".net,ironpython,ironruby,dynamic-language-runtime,dynamic-languages","A_Id":42702,"CreationDate":"2008-09-03T21:52:00.000","Title":"Which Dynamic .NET language makes more sense to learn, Iron Ruby or Iron 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},{"Question":"I'd like to take some time to learn more about dynamic languages built on top of the DLR and I'm not sure which language would be better to learn.\nHaving limited time, I really only have time to look learn one of them.\nAny opinions on which of the two (Iron Ruby or Iron Python) would be more useful in the long run?","AnswerCount":6,"Available Count":3,"Score":0.0333209931,"is_accepted":false,"ViewCount":1222,"Q_Id":42690,"Users Score":1,"Answer":"I just want to mention that there is also a DLR version of Javascript(JScript), which is my personal fav. If you are looking for a new language to learn for dlr use, I'd suggest ironpython as mentioned, it is farther along in terms of the dlr. Python is also fairly popular outside the dlr for gui programming, and offers Django for mvc web apps.\nThis is purely subjective, but I think that ruby popularity is waning a bit. In the long run I feel it will be like perl, used and respected, but a drop in the bucket compared to other options. I happen to really like ruby (and perl), but wouldn't suggest it as a new path for your intended purpose.","Q_Score":5,"Tags":".net,ironpython,ironruby,dynamic-language-runtime,dynamic-languages","A_Id":467185,"CreationDate":"2008-09-03T21:52:00.000","Title":"Which Dynamic .NET language makes more sense to learn, Iron Ruby or Iron 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},{"Question":"I'd like to take some time to learn more about dynamic languages built on top of the DLR and I'm not sure which language would be better to learn.\nHaving limited time, I really only have time to look learn one of them.\nAny opinions on which of the two (Iron Ruby or Iron Python) would be more useful in the long run?","AnswerCount":6,"Available Count":3,"Score":1.2,"is_accepted":true,"ViewCount":1222,"Q_Id":42690,"Users Score":4,"Answer":"If this is 'Which language runs better on the CLR,' then right now, IronPython wins hands down.\nFor the long term though, 'which language will teach me more, and serve me better in my career as a programmer', I would definitely say IronRuby (this would be true of CPython vs CRuby also)\nRuby will expose you to more 'concepts' than python does, due to it being more liberal in how it handles things like lambda functions, code blocks, eval, and so on.\nAnyway, this is probably going to descend into a flame-war. Sorry","Q_Score":5,"Tags":".net,ironpython,ironruby,dynamic-language-runtime,dynamic-languages","A_Id":61734,"CreationDate":"2008-09-03T21:52:00.000","Title":"Which Dynamic .NET language makes more sense to learn, Iron Ruby or Iron 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},{"Question":"Let's say you want to save a bunch of files somewhere, for instance in BLOBs. Let's say you want to dish these files out via a web page and have the client automatically open the correct application\/viewer.\nAssumption: The browser figures out which application\/viewer to use by the mime-type (content-type?) header in the HTTP response.\nBased on that assumption, in addition to the bytes of the file, you also want to save the MIME type.\nHow would you find the MIME type of a file? I'm currently on a Mac, but this should also work on Windows. \nDoes the browser add this information when posting the file to the web page?\nIs there a neat python library for finding this information? A WebService or (even better) a downloadable database?","AnswerCount":18,"Available Count":3,"Score":0.0111106539,"is_accepted":false,"ViewCount":233034,"Q_Id":43580,"Users Score":1,"Answer":"The mimetypes module just recognise an file type based on file extension. If you will try to recover a file type of a file without extension, the mimetypes will not works.","Q_Score":242,"Tags":"python,mime","A_Id":11101343,"CreationDate":"2008-09-04T12:07:00.000","Title":"How to find the mime type of 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":0,"Web Development":0},{"Question":"Let's say you want to save a bunch of files somewhere, for instance in BLOBs. Let's say you want to dish these files out via a web page and have the client automatically open the correct application\/viewer.\nAssumption: The browser figures out which application\/viewer to use by the mime-type (content-type?) header in the HTTP response.\nBased on that assumption, in addition to the bytes of the file, you also want to save the MIME type.\nHow would you find the MIME type of a file? I'm currently on a Mac, but this should also work on Windows. \nDoes the browser add this information when posting the file to the web page?\nIs there a neat python library for finding this information? A WebService or (even better) a downloadable database?","AnswerCount":18,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":233034,"Q_Id":43580,"Users Score":0,"Answer":"For byte Array type data you can use \nmagic.from_buffer(_byte_array,mime=True)","Q_Score":242,"Tags":"python,mime","A_Id":51510950,"CreationDate":"2008-09-04T12:07:00.000","Title":"How to find the mime type of 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":0,"Web Development":0},{"Question":"Let's say you want to save a bunch of files somewhere, for instance in BLOBs. Let's say you want to dish these files out via a web page and have the client automatically open the correct application\/viewer.\nAssumption: The browser figures out which application\/viewer to use by the mime-type (content-type?) header in the HTTP response.\nBased on that assumption, in addition to the bytes of the file, you also want to save the MIME type.\nHow would you find the MIME type of a file? I'm currently on a Mac, but this should also work on Windows. \nDoes the browser add this information when posting the file to the web page?\nIs there a neat python library for finding this information? A WebService or (even better) a downloadable database?","AnswerCount":18,"Available Count":3,"Score":1.0,"is_accepted":false,"ViewCount":233034,"Q_Id":43580,"Users Score":11,"Answer":"There are 3 different libraries that wraps libmagic.\n2 of them are available on pypi (so pip install will work):\n\nfilemagic\npython-magic\n\nAnd another, similar to python-magic is available directly in the latest libmagic sources, and it is the one you probably have in your linux distribution.\nIn Debian the package python-magic is about this one and it is used as toivotuo said and it is not obsoleted as Simon Zimmermann said (IMHO).\nIt seems to me another take (by the original author of libmagic).\nToo bad is not available directly on pypi.","Q_Score":242,"Tags":"python,mime","A_Id":12297929,"CreationDate":"2008-09-04T12:07:00.000","Title":"How to find the mime type of 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":0,"Web Development":0},{"Question":"I'm looking to create favicon.ico files programatically from Python, but PIL only has support for reading ico files.","AnswerCount":7,"Available Count":1,"Score":0.0285636566,"is_accepted":false,"ViewCount":25030,"Q_Id":45507,"Users Score":1,"Answer":"I don't know if this applies for all cases, but on WinXP an .ico can be a bmp of size 16x16, 32x32 or 64x64. Just change the extension to ico from bmp and you're ready to go.","Q_Score":32,"Tags":"python,favicon","A_Id":45520,"CreationDate":"2008-09-05T10:26:00.000","Title":"Is there a Python library for generating .ico 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},{"Question":"If I was going to start an open source project using Python what version should I use to ensure that the vast majority of users can use it on their system?\nI'm the kind of person who quickly jumps to the next version (which I'll do when Python 3 comes out) but many people may be more conservative if their current version seems to be working fine. What version would hit the sweet spot but still allow me to enjoy the newest and coolest language enhancements?","AnswerCount":6,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":3460,"Q_Id":47198,"Users Score":0,"Answer":"If the project is going to be mainstream and will be run on Linux the only sensible choise is 2.4 - just because it is a pain to get anything else installed as default on Enterprise Linuxes.\nIn any case, any modern OS will\/can have 2.4 or newer.","Q_Score":15,"Tags":"python,compatibility","A_Id":2036609,"CreationDate":"2008-09-06T02:22:00.000","Title":"Which Version of Python to Use for Maximum Compatibility","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"If I was going to start an open source project using Python what version should I use to ensure that the vast majority of users can use it on their system?\nI'm the kind of person who quickly jumps to the next version (which I'll do when Python 3 comes out) but many people may be more conservative if their current version seems to be working fine. What version would hit the sweet spot but still allow me to enjoy the newest and coolest language enhancements?","AnswerCount":6,"Available Count":2,"Score":0.0333209931,"is_accepted":false,"ViewCount":3460,"Q_Id":47198,"Users Score":1,"Answer":"You can use different versions of python on each machine. \nCoding something new, I would not use anything less than python2.5. You can do apt-get install python2.5 on stock debian stable. \nFor windows, don't really worry about it. It's very easy to install the python2.5 msi. \nIf the users can't be bothered to do that, you can deploy an executable with py2exe (so simple) and build an installer with inno setup (again simple) then it will behave like a standard windows application and will use its own python dlls, so no need to have python installed. \nLike Peter said: keep in mind the transition to 3.0 but don't build on it yet.","Q_Score":15,"Tags":"python,compatibility","A_Id":47264,"CreationDate":"2008-09-06T02:22:00.000","Title":"Which Version of Python to Use for Maximum Compatibility","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've read some about .egg files and I've noticed them in my lib directory but what are the advantages\/disadvantages of using then as a developer?","AnswerCount":6,"Available Count":3,"Score":0.0333209931,"is_accepted":false,"ViewCount":10471,"Q_Id":47953,"Users Score":1,"Answer":"For simple Python programs, you probably don't need to use eggs. Distributing the raw .py files should suffice; it's like distributing source files for GNU\/Linux. You can also use the various OS \"packagers\" (like py2exe or py2app) to create .exe, .dmg, or other files for different operating systems.\nMore complex programs, e.g. Django, pretty much require eggs due to the various modules and dependencies required.","Q_Score":27,"Tags":"python,zip,packaging,software-distribution,egg","A_Id":138090,"CreationDate":"2008-09-06T23:35:00.000","Title":"What are the advantages of packaging your python library\/application as an .egg 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":1,"Web Development":0},{"Question":"I've read some about .egg files and I've noticed them in my lib directory but what are the advantages\/disadvantages of using then as a developer?","AnswerCount":6,"Available Count":3,"Score":0.0333209931,"is_accepted":false,"ViewCount":10471,"Q_Id":47953,"Users Score":1,"Answer":"Whatever you do, do not stop distributing your application, also, as a tarball, as that is the easiest packagable format for operating systems with a package sysetem.","Q_Score":27,"Tags":"python,zip,packaging,software-distribution,egg","A_Id":137903,"CreationDate":"2008-09-06T23:35:00.000","Title":"What are the advantages of packaging your python library\/application as an .egg 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":1,"Web Development":0},{"Question":"I've read some about .egg files and I've noticed them in my lib directory but what are the advantages\/disadvantages of using then as a developer?","AnswerCount":6,"Available Count":3,"Score":0.1325487884,"is_accepted":false,"ViewCount":10471,"Q_Id":47953,"Users Score":4,"Answer":"Eggs are a pretty good way to distribute python apps. Think of it as a platform independent .deb file that will install all dependencies and whatnot. The advantage is that it's easy to use for the end user. The disadvantage are that it can be cumbersome to package your app up as a .egg file.\nYou should also offer an alternative means of installation in addition to .eggs. There are some people who don't like using eggs because they don't like the idea of a software program installing whatever software it wants. These usually tend to be sysadmin types.","Q_Score":27,"Tags":"python,zip,packaging,software-distribution,egg","A_Id":47958,"CreationDate":"2008-09-06T23:35:00.000","Title":"What are the advantages of packaging your python library\/application as an .egg 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":1,"Web Development":0},{"Question":"I would like to call python script files from my c++ program. \nI am not sure that the people I will distribute to will have python installed.\nBasically I'm looking for a .lib file that I can use that has an Apache like distribution license.","AnswerCount":7,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":100997,"Q_Id":49137,"Users Score":0,"Answer":"Using Inter Process Communication (IPC) over socket can be a possible solution. Use a local network socket to listen\/trasfer commands between both.","Q_Score":65,"Tags":"c++,python,embedded-language","A_Id":69672216,"CreationDate":"2008-09-08T03:53:00.000","Title":"Calling python from a c++ program for 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":1,"Web Development":0},{"Question":"The first language I learnt was PHP, but I have more recently picked up Python. As these are all 'high-level' languages, I have found them a bit difficult to pick up. I also tried to learn Objective-C but I gave up.\nSo, what language should I learn to bridge between Python to C","AnswerCount":14,"Available Count":12,"Score":0.0142847425,"is_accepted":false,"ViewCount":871,"Q_Id":49195,"Users Score":1,"Answer":"C is a bridge onto itself.\nK&R is the only programming language book you can read in one sitting and almost never pick it up again ...","Q_Score":4,"Tags":"python,c","A_Id":49246,"CreationDate":"2008-09-08T05:23:00.000","Title":"What language should I learn as a bridge to C (and derivatives)","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"The first language I learnt was PHP, but I have more recently picked up Python. As these are all 'high-level' languages, I have found them a bit difficult to pick up. I also tried to learn Objective-C but I gave up.\nSo, what language should I learn to bridge between Python to C","AnswerCount":14,"Available Count":12,"Score":0.0713073417,"is_accepted":false,"ViewCount":871,"Q_Id":49195,"Users Score":5,"Answer":"I generally agree with most of the others - There's not really a good stepping stone language.\nIt is, however, useful to understand what is difficult about learning C, which might help you understand what's making it difficult for you.\nI'd say the things that would prove difficult in C for someone coming from PHP would be :\n\nPointers and memory management This is pretty much the reason you're learning C I imagine, so there's not really any getting around it. Learning lower level assembly type languages might make this easier, but C is probably a bridge to do that, not the other way around.\nLack of built in data structures PHP and co all have native String types, and useful things like hash tables built in, which is not the case in C. In C, a String is just an array of characters, which means you'll need to do a lot more work, or look seriously at libraries which add the features you're used to.\nLack of built in libraries Languages like PHP nowadays almost always come with stacks of libraries for things like database connections, image manipulation and stacks of other things. In C, this is not the case other than a very thin standard library which revolves mostly around file reading, writing and basic string manipulation. There are almost always good choices available to fill these needs, but you need to include them yourself.\nSuitability for high level tasks If you try to implement the same type of application in C as you might in PHP, you'll find it very slow going. Generating a web page, for example, isn't really something plain C is suited for, so if you're trying to do that, you'll find it very slow going.\nPreprocessor and compilation Most languages these days don't have a preprocessor, and if you're coming from PHP, the compilation cycle will seem painful. Both of these are performance trade offs in a way - Scripting languages make the trade off in terms of developer efficiency, where as C prefers performance.\n\nI'm sure there are more that aren't springing to mind for me right now. The moral of the story is that trying to understand what you're finding difficult in C may help you proceed. If you're trying to generate web pages with it, try doing something lower level. If you're missing hash tables, try writing your own, or find a library. If you're struggling with pointers, stick with it :)","Q_Score":4,"Tags":"python,c","A_Id":49285,"CreationDate":"2008-09-08T05:23:00.000","Title":"What language should I learn as a bridge to C (and derivatives)","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"The first language I learnt was PHP, but I have more recently picked up Python. As these are all 'high-level' languages, I have found them a bit difficult to pick up. I also tried to learn Objective-C but I gave up.\nSo, what language should I learn to bridge between Python to C","AnswerCount":14,"Available Count":12,"Score":0.0,"is_accepted":false,"ViewCount":871,"Q_Id":49195,"Users Score":0,"Answer":"Java might actually be a good option here, believe it or not. It is strongly based on C\/C++, so if you can get the syntax and the strong typing, picking up C might be easier. The benefit is you can learn the lower level syntax without having to learn pointers (since memory is managed for you just like in Python and PHP). You will, however, learn a similar concept... references (or objects in general).\nAlso, it is strongly Object Oriented, so it may be difficult to pick up on that if you haven't dealt with OOP yet.... you might be better off just digging in with C like others suggested, but it is an option.","Q_Score":4,"Tags":"python,c","A_Id":49237,"CreationDate":"2008-09-08T05:23:00.000","Title":"What language should I learn as a bridge to C (and derivatives)","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"The first language I learnt was PHP, but I have more recently picked up Python. As these are all 'high-level' languages, I have found them a bit difficult to pick up. I also tried to learn Objective-C but I gave up.\nSo, what language should I learn to bridge between Python to C","AnswerCount":14,"Available Count":12,"Score":0.0,"is_accepted":false,"ViewCount":871,"Q_Id":49195,"Users Score":0,"Answer":"I think C++ is a good \"bridge\" to C. I learned C++ first at University, and since it's based on C you'll learn a lot of the same concepts - perhaps most notably pointers - but also Object Oriented Design. OO can be applied to all kinds of modern languages, so it's worth learning. \nAfter learning C++, I found it wasn't too hard to pick up the differences between C++ and C as required (for example, when working on devices that didn't support C++).","Q_Score":4,"Tags":"python,c","A_Id":49248,"CreationDate":"2008-09-08T05:23:00.000","Title":"What language should I learn as a bridge to C (and derivatives)","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"The first language I learnt was PHP, but I have more recently picked up Python. As these are all 'high-level' languages, I have found them a bit difficult to pick up. I also tried to learn Objective-C but I gave up.\nSo, what language should I learn to bridge between Python to C","AnswerCount":14,"Available Count":12,"Score":0.0142847425,"is_accepted":false,"ViewCount":871,"Q_Id":49195,"Users Score":1,"Answer":"Forget Java - it is not going to bring you anywhere closer to C (you have allready proved that you don't have a problem learning new syntax).\nEither read K&R or go one lower: Learn about the machine itself. The only tricky part in C is pointers and memory management (which is closely related to pointers, but also has a bit to do with how functions are called). Learning a (simple, maybe even \"fake\" assembly) language should help you out here.\nThen, start reading up on the standard library provided by C. It will be your daily bread and butter.\nOh: another tip! If you really do want to bridge, try FORTH. It helped me get into pointers. Also, using the win32 api from Visual Basic 6.0 can teach you some stuff about pointers ;)","Q_Score":4,"Tags":"python,c","A_Id":49245,"CreationDate":"2008-09-08T05:23:00.000","Title":"What language should I learn as a bridge to C (and derivatives)","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"The first language I learnt was PHP, but I have more recently picked up Python. As these are all 'high-level' languages, I have found them a bit difficult to pick up. I also tried to learn Objective-C but I gave up.\nSo, what language should I learn to bridge between Python to C","AnswerCount":14,"Available Count":12,"Score":0.0,"is_accepted":false,"ViewCount":871,"Q_Id":49195,"Users Score":0,"Answer":"Languages are easy to learn (especially one like C)... the hard part is learning the libraries and\/or coding style of the language. For instance, I know C++ fairly well, but most C\/C++ code I see confuses me because the naming conventions are so different from what I work with on a daily basis.\nAnyway, I guess what I'm trying to say is don't worry too much about the syntax, focus on said language's library. This isn't specific to C, you can say the same about c#, vb.net, java and just about every other language out there.","Q_Score":4,"Tags":"python,c","A_Id":49502,"CreationDate":"2008-09-08T05:23:00.000","Title":"What language should I learn as a bridge to C (and derivatives)","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"The first language I learnt was PHP, but I have more recently picked up Python. As these are all 'high-level' languages, I have found them a bit difficult to pick up. I also tried to learn Objective-C but I gave up.\nSo, what language should I learn to bridge between Python to C","AnswerCount":14,"Available Count":12,"Score":0.0,"is_accepted":false,"ViewCount":871,"Q_Id":49195,"Users Score":0,"Answer":"I'm feeling your pain, I also learned PHP first and I'm trying to learn C++, it's not easy, and I am really struggling, It's been 2 years since I started on c++ and Still the extent of what I can do is cout, cin, and math.\nIf anyone reads this and wonders where to start, START LOWER.","Q_Score":4,"Tags":"python,c","A_Id":49217,"CreationDate":"2008-09-08T05:23:00.000","Title":"What language should I learn as a bridge to C (and derivatives)","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"The first language I learnt was PHP, but I have more recently picked up Python. As these are all 'high-level' languages, I have found them a bit difficult to pick up. I also tried to learn Objective-C but I gave up.\nSo, what language should I learn to bridge between Python to C","AnswerCount":14,"Available Count":12,"Score":0.0,"is_accepted":false,"ViewCount":871,"Q_Id":49195,"Users Score":0,"Answer":"Pascal! Close enough syntax, still requires you to do some memory management, but not as rough for beginners.","Q_Score":4,"Tags":"python,c","A_Id":50673,"CreationDate":"2008-09-08T05:23:00.000","Title":"What language should I learn as a bridge to C (and derivatives)","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"The first language I learnt was PHP, but I have more recently picked up Python. As these are all 'high-level' languages, I have found them a bit difficult to pick up. I also tried to learn Objective-C but I gave up.\nSo, what language should I learn to bridge between Python to C","AnswerCount":14,"Available Count":12,"Score":0.0,"is_accepted":false,"ViewCount":871,"Q_Id":49195,"Users Score":0,"Answer":"try to learn a language which you are comfortable with, try different approach and the basics.","Q_Score":4,"Tags":"python,c","A_Id":49295,"CreationDate":"2008-09-08T05:23:00.000","Title":"What language should I learn as a bridge to C (and derivatives)","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"The first language I learnt was PHP, but I have more recently picked up Python. As these are all 'high-level' languages, I have found them a bit difficult to pick up. I also tried to learn Objective-C but I gave up.\nSo, what language should I learn to bridge between Python to C","AnswerCount":14,"Available Count":12,"Score":0.0142847425,"is_accepted":false,"ViewCount":871,"Q_Id":49195,"Users Score":1,"Answer":"Learning any language takes time, I always ensure I have a measurable goal; I set myself an objective, then start learning the language to achieve this objective, as opposed to trying to learn every nook and cranny of the language and syntax. \nC is not easy, pointers can be hard to comprehend if you\u2019re not coming assembler roots. I first learned C++, then retro fit C to my repertoire but I started with x86 and 68000 assembler.","Q_Score":4,"Tags":"python,c","A_Id":49234,"CreationDate":"2008-09-08T05:23:00.000","Title":"What language should I learn as a bridge to C (and derivatives)","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"The first language I learnt was PHP, but I have more recently picked up Python. As these are all 'high-level' languages, I have found them a bit difficult to pick up. I also tried to learn Objective-C but I gave up.\nSo, what language should I learn to bridge between Python to C","AnswerCount":14,"Available Count":12,"Score":1.2,"is_accepted":true,"ViewCount":871,"Q_Id":49195,"Users Score":15,"Answer":"It's not clear why you need a bridge language. Why don't you start working with C directly? C is a very simple language itself. I think that hardest part for C learner is pointers and everything else related to memory management. Also C lang is oriented on structured programming, so you will need to learn how to implement data structures and algorithms without OOP goodness. Actually, your question is pretty hard, usually people go from low level langs to high level and I can understand frustration of those who goes in other direction.","Q_Score":4,"Tags":"python,c","A_Id":49202,"CreationDate":"2008-09-08T05:23:00.000","Title":"What language should I learn as a bridge to C (and derivatives)","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"The first language I learnt was PHP, but I have more recently picked up Python. As these are all 'high-level' languages, I have found them a bit difficult to pick up. I also tried to learn Objective-C but I gave up.\nSo, what language should I learn to bridge between Python to C","AnswerCount":14,"Available Count":12,"Score":1.0,"is_accepted":false,"ViewCount":871,"Q_Id":49195,"Users Score":7,"Answer":"The best place to start learning C is the book \"The C Programming Language\" by Kernighan and Ritchie.\nYou will recognise a lot of things from PHP, and you will be surprised how much PHP (and Perl, Python etc) do for you.\nOh and you also will need a C compiler, but i guess you knew that.","Q_Score":4,"Tags":"python,c","A_Id":49227,"CreationDate":"2008-09-08T05:23:00.000","Title":"What language should I learn as a bridge to C (and derivatives)","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"Besides the dynamic nature of Python (and the syntax), what are some of the major features of the Python language that Java doesn't have, and vice versa?","AnswerCount":5,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":11654,"Q_Id":49824,"Users Score":47,"Answer":"List comprehensions. I often find myself filtering\/mapping lists, and being able to say [line.replace(\"spam\",\"eggs\") for line in open(\"somefile.txt\") if line.startswith(\"nee\")] is really nice.\nFunctions are first class objects. They can be passed as parameters to other functions, defined inside other function, and have lexical scope. This makes it really easy to say things like people.sort(key=lambda p: p.age) and thus sort a bunch of people on their age without having to define a custom comparator class or something equally verbose.\nEverything is an object. Java has basic types which aren't objects, which is why many classes in the standard library define 9 different versions of functions (for boolean, byte, char, double, float, int, long, Object, short). Array.sort is a good example. Autoboxing helps, although it makes things awkward when something turns out to be null.\nProperties. Python lets you create classes with read-only fields, lazily-generated fields, as well as fields which are checked upon assignment to make sure they're never 0 or null or whatever you want to guard against, etc.'\nDefault and keyword arguments. In Java if you want a constructor that can take up to 5 optional arguments, you must define 6 different versions of that constructor. And there's no way at all to say Student(name=\"Eli\", age=25)\nFunctions can only return 1 thing. In Python you have tuple assignment, so you can say spam, eggs = nee() but in Java you'd need to either resort to mutable out parameters or have a custom class with 2 fields and then have two additional lines of code to extract those fields.\nBuilt-in syntax for lists and dictionaries.\nOperator Overloading.\nGenerally better designed libraries. For example, to parse an XML document in Java, you say\nDocument doc = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(\"test.xml\");\nand in Python you say\ndoc = parse(\"test.xml\")\n\nAnyway, I could go on and on with further examples, but Python is just overall a much more flexible and expressive language. It's also dynamically typed, which I really like, but which comes with some disadvantages.\nJava has much better performance than Python and has way better tool support. Sometimes those things matter a lot and Java is the better language than Python for a task; I continue to use Java for some new projects despite liking Python a lot more. But as a language I think Python is superior for most things I find myself needing to accomplish.","Q_Score":29,"Tags":"java,python","A_Id":49953,"CreationDate":"2008-09-08T14:36:00.000","Title":"Java -> 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},{"Question":"Besides the dynamic nature of Python (and the syntax), what are some of the major features of the Python language that Java doesn't have, and vice versa?","AnswerCount":5,"Available Count":2,"Score":0.0798297691,"is_accepted":false,"ViewCount":11654,"Q_Id":49824,"Users Score":2,"Answer":"Apart from what Eli Courtwright said:\n\nI find iterators in Python more concise. You can use for i in something, and it works with pretty much everything. Yeah, Java has gotten better since 1.5, but for example you can iterate through a string in python with this same construct.\nIntrospection: In python you can get at runtime information about an object or a module about its symbols, methods, or even its docstrings. You can also instantiate them dynamically. Java has some of this, but usually in Java it takes half a page of code to get an instance of a class, whereas in Python it is about 3 lines. And as far as I know the docstrings thing is not available in Java","Q_Score":29,"Tags":"java,python","A_Id":51512,"CreationDate":"2008-09-08T14:36:00.000","Title":"Java -> 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},{"Question":"Been scouring the net for something like firewatir but for python. I'm trying to automate firefox on linux. Any suggestions?","AnswerCount":8,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":21896,"Q_Id":60152,"Users Score":0,"Answer":"The languages of choice of Firefox is Javascript. Unless you have a specific requirement that requires Python, I would advice you to use that.","Q_Score":12,"Tags":"python,linux,firefox,ubuntu,automation","A_Id":60218,"CreationDate":"2008-09-12T23:28:00.000","Title":"Automate firefox 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},{"Question":"Been scouring the net for something like firewatir but for python. I'm trying to automate firefox on linux. Any suggestions?","AnswerCount":8,"Available Count":2,"Score":0.024994793,"is_accepted":false,"ViewCount":21896,"Q_Id":60152,"Users Score":1,"Answer":"I would suggest you to use Selenium instead of Mechanize\/Twill because Mechanize would fail while handling Javascript.","Q_Score":12,"Tags":"python,linux,firefox,ubuntu,automation","A_Id":7610441,"CreationDate":"2008-09-12T23:28:00.000","Title":"Automate firefox 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},{"Question":"If you're writing a library, or an app, where do the unit test files go? \nIt's nice to separate the test files from the main app code, but it's awkward to put them into a \"tests\" subdirectory inside of the app root directory, because it makes it harder to import the modules that you'll be testing. \nIs there a best practice here?","AnswerCount":18,"Available Count":4,"Score":0.0111106539,"is_accepted":false,"ViewCount":112049,"Q_Id":61151,"Users Score":1,"Answer":"In C#, I've generally separated the tests into a separate assembly.\nIn Python -- so far -- I've tended to either write doctests, where the test is in the docstring of a function, or put them in the if __name__ == \"__main__\" block at the bottom of the module.","Q_Score":545,"Tags":"python,unit-testing,code-organization","A_Id":61820,"CreationDate":"2008-09-14T05:41:00.000","Title":"Where do the Python unit tests go?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"If you're writing a library, or an app, where do the unit test files go? \nIt's nice to separate the test files from the main app code, but it's awkward to put them into a \"tests\" subdirectory inside of the app root directory, because it makes it harder to import the modules that you'll be testing. \nIs there a best practice here?","AnswerCount":18,"Available Count":4,"Score":0.0,"is_accepted":false,"ViewCount":112049,"Q_Id":61151,"Users Score":0,"Answer":"When writing a package called \"foo\", I will put unit tests into a separate package \"foo_test\". Modules and subpackages will then have the same name as the SUT package module. E.g. tests for a module foo.x.y are found in foo_test.x.y. The __init__.py files of each testing package then contain an AllTests suite that includes all test suites of the package. setuptools provides a convenient way to specify the main testing package, so that after \"python setup.py develop\" you can just use \"python setup.py test\" or \"python setup.py test -s foo_test.x.SomeTestSuite\" to the just a specific suite.","Q_Score":545,"Tags":"python,unit-testing,code-organization","A_Id":63645,"CreationDate":"2008-09-14T05:41:00.000","Title":"Where do the Python unit tests go?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"If you're writing a library, or an app, where do the unit test files go? \nIt's nice to separate the test files from the main app code, but it's awkward to put them into a \"tests\" subdirectory inside of the app root directory, because it makes it harder to import the modules that you'll be testing. \nIs there a best practice here?","AnswerCount":18,"Available Count":4,"Score":-0.022218565,"is_accepted":false,"ViewCount":112049,"Q_Id":61151,"Users Score":-2,"Answer":"I've recently started to program in Python, so I've not really had chance to find out best practice yet.\nBut, I've written a module that goes and finds all the tests and runs them.\nSo, I have:\n\napp\/\n appfile.py\ntest\/\n appfileTest.py\n\nI'll have to see how it goes as I progress to larger projects.","Q_Score":545,"Tags":"python,unit-testing,code-organization","A_Id":61518,"CreationDate":"2008-09-14T05:41:00.000","Title":"Where do the Python unit tests go?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"If you're writing a library, or an app, where do the unit test files go? \nIt's nice to separate the test files from the main app code, but it's awkward to put them into a \"tests\" subdirectory inside of the app root directory, because it makes it harder to import the modules that you'll be testing. \nIs there a best practice here?","AnswerCount":18,"Available Count":4,"Score":1.0,"is_accepted":false,"ViewCount":112049,"Q_Id":61151,"Users Score":13,"Answer":"I don't believe there is an established \"best practice\".\nI put my tests in another directory outside of the app code. I then add the main app directory to sys.path (allowing you to import the modules from anywhere) in my test runner script (which does some other stuff as well) before running all the tests. This way I never have to remove the tests directory from the main code when I release it, saving me time and effort, if an ever so tiny amount.","Q_Score":545,"Tags":"python,unit-testing,code-organization","A_Id":61168,"CreationDate":"2008-09-14T05:41:00.000","Title":"Where do the Python unit tests go?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"What is the best available method for developing a spell check engine (for example, with aspell_python), that works with apache mod_python?\napache 2.0.59+RHEL4+mod_python+aspell_python seems to crash.\nIs there any alternative to using aspell_python?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":238,"Q_Id":61556,"Users Score":1,"Answer":"Looks like RHEL4 is the culprit. Works well on Fedore 7 (the version of apache is newer and there is no crash)","Q_Score":0,"Tags":"spell-checking,mod-python,aspell","A_Id":61570,"CreationDate":"2008-09-14T18:58:00.000","Title":"Spell Checking Service with python using mod_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},{"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 \/bin.v2\/libs\/python\/build\/\/debug\/ and the release libraries were in \/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},{"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},{"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},{"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},{"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},{"Question":"I am aware of the die() command in PHP which exits a script early.\nHow can I do this in Python?","AnswerCount":12,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":1876007,"Q_Id":73663,"Users Score":0,"Answer":"Just put at the end of your code quit() and that should close a python script.","Q_Score":1288,"Tags":"python,termination","A_Id":70824754,"CreationDate":"2008-09-16T15:35:00.000","Title":"How to terminate a 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},{"Question":"I am aware of the die() command in PHP which exits a script early.\nHow can I do this in Python?","AnswerCount":12,"Available Count":2,"Score":1.0,"is_accepted":false,"ViewCount":1876007,"Q_Id":73663,"Users Score":75,"Answer":"While you should generally prefer sys.exit because it is more \"friendly\" to other code, all it actually does is raise an exception.\nIf you are sure that you need to exit a process immediately, and you might be inside of some exception handler which would catch SystemExit, there is another function - os._exit - which terminates immediately at the C level and does not perform any of the normal tear-down of the interpreter; for example, hooks registered with the \"atexit\" module are not executed.","Q_Score":1288,"Tags":"python,termination","A_Id":76374,"CreationDate":"2008-09-16T15:35:00.000","Title":"How to terminate a 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},{"Question":"Is it possible to call managed code, specifically IronRuby or IronPython from unamanaged code such as C++ or Delphi?\nFor example, we have an application written in Delphi that is being moved to C#.NET We'd like to provide Ruby or Python scripting in our new application to replace VBSCRIPT. However, we would need to provide Ruby\/Python scripting in the old Delphi application. Is it possible to use the managed dlls provided by IronRuby\/IronPython from Delphi code?","AnswerCount":6,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":877,"Q_Id":74386,"Users Score":3,"Answer":"Why not embed CPython instead, which has an API intended to be used directly from C\/C++. You lose the multiple language advantage but probably gain simplicity.","Q_Score":5,"Tags":".net,delphi,ironpython,unmanaged,ironruby","A_Id":934717,"CreationDate":"2008-09-16T16:44:00.000","Title":"Using DLR from Unmanaged 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},{"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},{"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},{"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},{"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},{"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},{"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},{"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},{"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},{"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},{"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},{"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},{"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},{"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},{"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},{"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},{"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},{"Question":"Is there any library available to query Btrieve databases without buying something from Pervasive? I'm looking to code in C# or Python.","AnswerCount":3,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":2923,"Q_Id":80215,"Users Score":0,"Answer":"This depends a lot on the version of Btrieve. I've been working with btrieve for a long time and have found that the best API for the old 6.15 version was in pascal. That having been said there was definately a C api around as well.\nPervasive have recently released a 6.15 ultimate patch. Using this and the C api should allow you to work effectively with older btrieve databases. It is possible for instance to build new modules for python using C.","Q_Score":1,"Tags":"c#,python,btrieve","A_Id":718654,"CreationDate":"2008-09-17T05:15:00.000","Title":"Btrieve without Pervasive?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"Is there any library available to query Btrieve databases without buying something from Pervasive? I'm looking to code in C# or Python.","AnswerCount":3,"Available Count":3,"Score":0.1325487884,"is_accepted":false,"ViewCount":2923,"Q_Id":80215,"Users Score":2,"Answer":"If you download one of the trial versions, you can get\/install the odbc client and connect that way.\nIn our version of pervasive (older version) on the server where the database is installed, you can also find this client install.","Q_Score":1,"Tags":"c#,python,btrieve","A_Id":275524,"CreationDate":"2008-09-17T05:15:00.000","Title":"Btrieve without Pervasive?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"Is there any library available to query Btrieve databases without buying something from Pervasive? I'm looking to code in C# or Python.","AnswerCount":3,"Available Count":3,"Score":1.2,"is_accepted":true,"ViewCount":2923,"Q_Id":80215,"Users Score":1,"Answer":"As far as I know that is not possible. It is not an open source database, so writing drivers for it is really hard.","Q_Score":1,"Tags":"c#,python,btrieve","A_Id":80596,"CreationDate":"2008-09-17T05:15:00.000","Title":"Btrieve without Pervasive?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I wonder why would a C++, C#, Java developer want to learn a dynamic language?\nAssuming the company won't switch its main development language from C++\/C#\/Java to a dynamic one what use is there for a dynamic language?\nWhat helper tasks can be done by the dynamic languages faster or better after only a few days of learning than with the static language that you have been using for several years?\nUpdate\nAfter seeing the first few responses it is clear that there are two issues.\nMy main interest would be something that is justifiable to the employer as an expense.\nThat is, I am looking for justifications for the employer to finance the learning of a dynamic language. Aside from the obvious that the employee will have broader view, the\nemployers are usually looking for some \"real\" benefit.","AnswerCount":35,"Available Count":31,"Score":0.0114280739,"is_accepted":false,"ViewCount":32287,"Q_Id":84340,"Users Score":2,"Answer":"Towards answering the updated question, its a chicken\/egg problem. The best way to justify an expense is to show how it reduces a cost somewhere else, so you may need to spend some extra\/personal time to learn something first to build some kind of functional prototype.\nShow your boss a demo like \"hey, i did this thing, and it saves me this much time [or better yet, this much $$], imagine if everyone could use this how much money we would save\"\nand then after they agree, explain how it is some other technology and that it is worth the expense to get more training, and training for others on how to do it better.","Q_Score":66,"Tags":"c#,java,python,ruby,perl","A_Id":87121,"CreationDate":"2008-09-17T15:16:00.000","Title":"Why learn Perl, Python, Ruby if the company is using C++, C# or Java as the application language?","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},{"Question":"I wonder why would a C++, C#, Java developer want to learn a dynamic language?\nAssuming the company won't switch its main development language from C++\/C#\/Java to a dynamic one what use is there for a dynamic language?\nWhat helper tasks can be done by the dynamic languages faster or better after only a few days of learning than with the static language that you have been using for several years?\nUpdate\nAfter seeing the first few responses it is clear that there are two issues.\nMy main interest would be something that is justifiable to the employer as an expense.\nThat is, I am looking for justifications for the employer to finance the learning of a dynamic language. Aside from the obvious that the employee will have broader view, the\nemployers are usually looking for some \"real\" benefit.","AnswerCount":35,"Available Count":31,"Score":0.0057142235,"is_accepted":false,"ViewCount":32287,"Q_Id":84340,"Users Score":1,"Answer":"Personally I work on a Java app, but I couldn't get by without perl for some supporting scripts. \nI've got scripts to quickly flip what db I'm pointing at, scripts to run build scripts, scripts to scrape data & compare stuff. \nSure I could do all that with java, or maybe shell scripts (I've got some of those too), but who wants to compile a class (making sure the classpath is set right etc) when you just need something quick and dirty. Knowing a scripting language can remove 90% of those boring\/repetitive manual tasks.","Q_Score":66,"Tags":"c#,java,python,ruby,perl","A_Id":84456,"CreationDate":"2008-09-17T15:16:00.000","Title":"Why learn Perl, Python, Ruby if the company is using C++, C# or Java as the application language?","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},{"Question":"I wonder why would a C++, C#, Java developer want to learn a dynamic language?\nAssuming the company won't switch its main development language from C++\/C#\/Java to a dynamic one what use is there for a dynamic language?\nWhat helper tasks can be done by the dynamic languages faster or better after only a few days of learning than with the static language that you have been using for several years?\nUpdate\nAfter seeing the first few responses it is clear that there are two issues.\nMy main interest would be something that is justifiable to the employer as an expense.\nThat is, I am looking for justifications for the employer to finance the learning of a dynamic language. Aside from the obvious that the employee will have broader view, the\nemployers are usually looking for some \"real\" benefit.","AnswerCount":35,"Available Count":31,"Score":0.0057142235,"is_accepted":false,"ViewCount":32287,"Q_Id":84340,"Users Score":1,"Answer":"They're useful for the \"Quick Hack\" that is for plugging a gap in your main language for a quick (and potentially dirty) fix faster than it would take to develop the same in your main language. An example: a simple script in perl to go through a large text file and replace all instances of an email address with another is trivial with an amount of time taken in the 10 minute range. Hacking a console app together to do the same in your main language would take multiples of that.\nYou also have the benefit that exposing yourself to additional languages broadens your abilities and learning to attack problems from a different languages perspective can be as valuable as the language itself.\nFinally, scripting languages are very useful in the realm of extension. Take LUA as an example. You can bolt a lua interpreter into your app with very little overhead and you now have a way to create rich scripting functionality that can be exposed to end users or altered and distributed quickly without requiring a rebuild of the entire app. This is used to great effect in many games most notably World of Warcraft.","Q_Score":66,"Tags":"c#,java,python,ruby,perl","A_Id":84443,"CreationDate":"2008-09-17T15:16:00.000","Title":"Why learn Perl, Python, Ruby if the company is using C++, C# or Java as the application language?","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},{"Question":"I wonder why would a C++, C#, Java developer want to learn a dynamic language?\nAssuming the company won't switch its main development language from C++\/C#\/Java to a dynamic one what use is there for a dynamic language?\nWhat helper tasks can be done by the dynamic languages faster or better after only a few days of learning than with the static language that you have been using for several years?\nUpdate\nAfter seeing the first few responses it is clear that there are two issues.\nMy main interest would be something that is justifiable to the employer as an expense.\nThat is, I am looking for justifications for the employer to finance the learning of a dynamic language. Aside from the obvious that the employee will have broader view, the\nemployers are usually looking for some \"real\" benefit.","AnswerCount":35,"Available Count":31,"Score":0.0057142235,"is_accepted":false,"ViewCount":32287,"Q_Id":84340,"Users Score":1,"Answer":"Im not sure if this is what you are looking for, but we write our main application with Java at the small company I work for, but have used python to write smaller scripts quickly. Backup software, temporary scripts to manipulate data and push out results. It just seems easier sometimes to sit down with python and write a quick script than mess with classes and stuff in java. \nTemp scripts that aren't going to stick around don't need a lot of design time wasted on them.\nAnd I am lazy, but it is good to just learn as much as you can of course and see what features exist in other languages. Knowing more never hurts you in future career changes :)","Q_Score":66,"Tags":"c#,java,python,ruby,perl","A_Id":84423,"CreationDate":"2008-09-17T15:16:00.000","Title":"Why learn Perl, Python, Ruby if the company is using C++, C# or Java as the application language?","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},{"Question":"I wonder why would a C++, C#, Java developer want to learn a dynamic language?\nAssuming the company won't switch its main development language from C++\/C#\/Java to a dynamic one what use is there for a dynamic language?\nWhat helper tasks can be done by the dynamic languages faster or better after only a few days of learning than with the static language that you have been using for several years?\nUpdate\nAfter seeing the first few responses it is clear that there are two issues.\nMy main interest would be something that is justifiable to the employer as an expense.\nThat is, I am looking for justifications for the employer to finance the learning of a dynamic language. Aside from the obvious that the employee will have broader view, the\nemployers are usually looking for some \"real\" benefit.","AnswerCount":35,"Available Count":31,"Score":0.0,"is_accepted":false,"ViewCount":32287,"Q_Id":84340,"Users Score":0,"Answer":"You should also consider learning a functional programming language like Scala. It has many of the advantages of Ruby, including a concise syntax, and powerful features like closures. But it compiles to Java class files and and integrate seamlessly into a Java stack, which may make it much easier for your employer to swallow.\nScala isn't dynamically typed, but its \"implicit conversion\" feature gives many, perhaps even all of the benefits of dynamic typing, while retaining many of the advantages of static typing.","Q_Score":66,"Tags":"c#,java,python,ruby,perl","A_Id":84584,"CreationDate":"2008-09-17T15:16:00.000","Title":"Why learn Perl, Python, Ruby if the company is using C++, C# or Java as the application language?","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},{"Question":"I wonder why would a C++, C#, Java developer want to learn a dynamic language?\nAssuming the company won't switch its main development language from C++\/C#\/Java to a dynamic one what use is there for a dynamic language?\nWhat helper tasks can be done by the dynamic languages faster or better after only a few days of learning than with the static language that you have been using for several years?\nUpdate\nAfter seeing the first few responses it is clear that there are two issues.\nMy main interest would be something that is justifiable to the employer as an expense.\nThat is, I am looking for justifications for the employer to finance the learning of a dynamic language. Aside from the obvious that the employee will have broader view, the\nemployers are usually looking for some \"real\" benefit.","AnswerCount":35,"Available Count":31,"Score":0.0057142235,"is_accepted":false,"ViewCount":32287,"Q_Id":84340,"Users Score":1,"Answer":"Learning something with a flexible OOP system, like Lisp or Perl (see Moose), will allow you to better expand and understand your thoughts on software engineering. Ideally, every language has some unique facet (whether it be CLOS or some other technique) that enhances, extends and grows your abilities as a programmer.","Q_Score":66,"Tags":"c#,java,python,ruby,perl","A_Id":85167,"CreationDate":"2008-09-17T15:16:00.000","Title":"Why learn Perl, Python, Ruby if the company is using C++, C# or Java as the application language?","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},{"Question":"I wonder why would a C++, C#, Java developer want to learn a dynamic language?\nAssuming the company won't switch its main development language from C++\/C#\/Java to a dynamic one what use is there for a dynamic language?\nWhat helper tasks can be done by the dynamic languages faster or better after only a few days of learning than with the static language that you have been using for several years?\nUpdate\nAfter seeing the first few responses it is clear that there are two issues.\nMy main interest would be something that is justifiable to the employer as an expense.\nThat is, I am looking for justifications for the employer to finance the learning of a dynamic language. Aside from the obvious that the employee will have broader view, the\nemployers are usually looking for some \"real\" benefit.","AnswerCount":35,"Available Count":31,"Score":0.0057142235,"is_accepted":false,"ViewCount":32287,"Q_Id":84340,"Users Score":1,"Answer":"If all you have is a hammer, every problem begins to look like a nail.\nThere are times when having a screwdriver or pair of pliers makes a complicated problem trivial.\nNobody asks contractors, carpenters, etc, \"Why learn to use a screwdriver if i already have a hammer?\". Really good contractors\/carpenters have tons of tools and know how to use them well. All programmers should be doing the same thing, learning to use new tools and use them well.\n\nBut before we use any power tools, lets\n take a moment to talk about shop safety. Be sure\n to read, understand, and follow all the\n safety rules that come with your power\n tools. Doing so will greatly reduce\n the risk of personal injury. And remember\n this: there is no more important rule\n than to wear these: safety glasses\n -- Norm","Q_Score":66,"Tags":"c#,java,python,ruby,perl","A_Id":85733,"CreationDate":"2008-09-17T15:16:00.000","Title":"Why learn Perl, Python, Ruby if the company is using C++, C# or Java as the application language?","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},{"Question":"I wonder why would a C++, C#, Java developer want to learn a dynamic language?\nAssuming the company won't switch its main development language from C++\/C#\/Java to a dynamic one what use is there for a dynamic language?\nWhat helper tasks can be done by the dynamic languages faster or better after only a few days of learning than with the static language that you have been using for several years?\nUpdate\nAfter seeing the first few responses it is clear that there are two issues.\nMy main interest would be something that is justifiable to the employer as an expense.\nThat is, I am looking for justifications for the employer to finance the learning of a dynamic language. Aside from the obvious that the employee will have broader view, the\nemployers are usually looking for some \"real\" benefit.","AnswerCount":35,"Available Count":31,"Score":0.0,"is_accepted":false,"ViewCount":32287,"Q_Id":84340,"Users Score":0,"Answer":"Dynamic languages are fantastic for prototyping ideas. Often for performance reasons they won't work for permanent solutions or products. But, with languages like Python, which allow you to embed standard C\/C++\/Java inside them or visa versa, you can speed up the really critical bits but leave it glued together with the flexibility of a dynamic language.\n...and so you get the best of both worlds. If you need to justify this in terms of why more people should learn these languages, just point out much faster you can develop the same software and how much more robust the solution is (because debugging\/fixing problems in dynamic languages is in my experience, considerably easier!).","Q_Score":66,"Tags":"c#,java,python,ruby,perl","A_Id":85789,"CreationDate":"2008-09-17T15:16:00.000","Title":"Why learn Perl, Python, Ruby if the company is using C++, C# or Java as the application language?","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},{"Question":"I wonder why would a C++, C#, Java developer want to learn a dynamic language?\nAssuming the company won't switch its main development language from C++\/C#\/Java to a dynamic one what use is there for a dynamic language?\nWhat helper tasks can be done by the dynamic languages faster or better after only a few days of learning than with the static language that you have been using for several years?\nUpdate\nAfter seeing the first few responses it is clear that there are two issues.\nMy main interest would be something that is justifiable to the employer as an expense.\nThat is, I am looking for justifications for the employer to finance the learning of a dynamic language. Aside from the obvious that the employee will have broader view, the\nemployers are usually looking for some \"real\" benefit.","AnswerCount":35,"Available Count":31,"Score":0.0,"is_accepted":false,"ViewCount":32287,"Q_Id":84340,"Users Score":0,"Answer":"Knowing grep and ruby made it possible to narrow down a problem, and verify the fix for, an issue involving tons of java exceptions on some production servers. Because I threw the solution together in ruby, it was done (designed, implemented, tested, run, bug-fixed, re-run, enhanced, results analyzed) in an afternoon instead of a couple of days. I could have solved the same problem using an all-java solution or a C# solution, but it most likely would have taken me longer.\nHaving dynamic language expertise also sometimes leads you to simpler solutions in less dynamic languages. In ruby, perl or python, you just intuitively reach for associative arrays (hashes, dictionaries, whatever word you want to use) for the smallest things, where you might be tempted to create a complex class hierarchy in a statically typed language when the problem doesn't necessarily demand it.\nPlus you can plug in most scripting languages into most runtimes. So it doesn't have to be either\/or.","Q_Score":66,"Tags":"c#,java,python,ruby,perl","A_Id":85891,"CreationDate":"2008-09-17T15:16:00.000","Title":"Why learn Perl, Python, Ruby if the company is using C++, C# or Java as the application language?","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},{"Question":"I wonder why would a C++, C#, Java developer want to learn a dynamic language?\nAssuming the company won't switch its main development language from C++\/C#\/Java to a dynamic one what use is there for a dynamic language?\nWhat helper tasks can be done by the dynamic languages faster or better after only a few days of learning than with the static language that you have been using for several years?\nUpdate\nAfter seeing the first few responses it is clear that there are two issues.\nMy main interest would be something that is justifiable to the employer as an expense.\nThat is, I am looking for justifications for the employer to finance the learning of a dynamic language. Aside from the obvious that the employee will have broader view, the\nemployers are usually looking for some \"real\" benefit.","AnswerCount":35,"Available Count":31,"Score":0.0114280739,"is_accepted":false,"ViewCount":32287,"Q_Id":84340,"Users Score":2,"Answer":"Learning a new language is a long-term process. In a couple of days you'll learn the basics, yes. But! As you probably know, the real practical applicability of any language is tied to the standard library and other available components. Learning how to use the efficiently requires a lot of hands-on experience. \nPerhaps the only immediate short-term benefit is that developers learn to distinguish the nails that need a Python\/Perl\/Ruby -hammer. And, if they are any good, they can then study some more (online, perhaps!) and become real experts.\nThe long-term benefits are easier to imagine:\n\nThe employee becomes a better developer. Better developer => better quality. We are living in a knowledge economy these days. It's wiser to invest in those brains that already work for you.\nIt is easier to adapt when the next big language emerges. It is very likely that the NBL will have many of the features present in today's scripting languages: first-class functions, closures, streams\/generators, etc. \nNew market possibilities and ability to respond more quickly. Even if you are not writing Python, other people are. Your clients? Another vendor in the project? Perhaps a critical component was written in some other language? It will cost money and time, if you do not have people who can understand the code and interface with it.\nRecruitment. If your company has a reputation of teaching new and interesting stuff to people, it will be easier to recruit the top people. Everyone is doing Java\/C#\/C++. It is not a very effective way to differentiate yourself in the job market.","Q_Score":66,"Tags":"c#,java,python,ruby,perl","A_Id":85898,"CreationDate":"2008-09-17T15:16:00.000","Title":"Why learn Perl, Python, Ruby if the company is using C++, C# or Java as the application language?","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},{"Question":"I wonder why would a C++, C#, Java developer want to learn a dynamic language?\nAssuming the company won't switch its main development language from C++\/C#\/Java to a dynamic one what use is there for a dynamic language?\nWhat helper tasks can be done by the dynamic languages faster or better after only a few days of learning than with the static language that you have been using for several years?\nUpdate\nAfter seeing the first few responses it is clear that there are two issues.\nMy main interest would be something that is justifiable to the employer as an expense.\nThat is, I am looking for justifications for the employer to finance the learning of a dynamic language. Aside from the obvious that the employee will have broader view, the\nemployers are usually looking for some \"real\" benefit.","AnswerCount":35,"Available Count":31,"Score":0.0,"is_accepted":false,"ViewCount":32287,"Q_Id":84340,"Users Score":0,"Answer":"The \"real benefit\" that an employer could see is a better programmer who can implement solutions faster; however, you will not be able to provide any hard numbers to justify the expense and an employer will most likely have you work on what makes money now as opposed to having you work on things that make the future better. \nThe only time you can get training on the employer's dime, is when they perceive a need for it and it's cheaper than hiring a new person who already has that skill-set.","Q_Score":66,"Tags":"c#,java,python,ruby,perl","A_Id":85910,"CreationDate":"2008-09-17T15:16:00.000","Title":"Why learn Perl, Python, Ruby if the company is using C++, C# or Java as the application language?","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},{"Question":"I wonder why would a C++, C#, Java developer want to learn a dynamic language?\nAssuming the company won't switch its main development language from C++\/C#\/Java to a dynamic one what use is there for a dynamic language?\nWhat helper tasks can be done by the dynamic languages faster or better after only a few days of learning than with the static language that you have been using for several years?\nUpdate\nAfter seeing the first few responses it is clear that there are two issues.\nMy main interest would be something that is justifiable to the employer as an expense.\nThat is, I am looking for justifications for the employer to finance the learning of a dynamic language. Aside from the obvious that the employee will have broader view, the\nemployers are usually looking for some \"real\" benefit.","AnswerCount":35,"Available Count":31,"Score":0.0,"is_accepted":false,"ViewCount":32287,"Q_Id":84340,"Users Score":0,"Answer":"Testing.\nIt's often quicker and easier to test your C#\/Java application by using a dynamic language. You can do exploratory testing at the interactive prompt and quickly create automated test scripts.","Q_Score":66,"Tags":"c#,java,python,ruby,perl","A_Id":86366,"CreationDate":"2008-09-17T15:16:00.000","Title":"Why learn Perl, Python, Ruby if the company is using C++, C# or Java as the application language?","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},{"Question":"I wonder why would a C++, C#, Java developer want to learn a dynamic language?\nAssuming the company won't switch its main development language from C++\/C#\/Java to a dynamic one what use is there for a dynamic language?\nWhat helper tasks can be done by the dynamic languages faster or better after only a few days of learning than with the static language that you have been using for several years?\nUpdate\nAfter seeing the first few responses it is clear that there are two issues.\nMy main interest would be something that is justifiable to the employer as an expense.\nThat is, I am looking for justifications for the employer to finance the learning of a dynamic language. Aside from the obvious that the employee will have broader view, the\nemployers are usually looking for some \"real\" benefit.","AnswerCount":35,"Available Count":31,"Score":0.0057142235,"is_accepted":false,"ViewCount":32287,"Q_Id":84340,"Users Score":1,"Answer":"I think the main benefits of dynamic languages can be boiled down to\n\nRapid development\nGlue\n\nThe short design-code-test cycle time makes dynamic languages ideal for prototyping, tools, and quick & dirty one-off scripts. IMHO, the latter two can make a huge impact on a programmer's productivity. It amazes me how many people trudge through things manually instead of whipping up a tool to do it for them. I think it's because they don't have something like Perl in their toolbox.\nThe ability to interface with just about anything (other programs or languages, databases, etc.) makes it easy to reuse existing work and automate tasks that would otherwise need to be done manually.","Q_Score":66,"Tags":"c#,java,python,ruby,perl","A_Id":86657,"CreationDate":"2008-09-17T15:16:00.000","Title":"Why learn Perl, Python, Ruby if the company is using C++, C# or Java as the application language?","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},{"Question":"I wonder why would a C++, C#, Java developer want to learn a dynamic language?\nAssuming the company won't switch its main development language from C++\/C#\/Java to a dynamic one what use is there for a dynamic language?\nWhat helper tasks can be done by the dynamic languages faster or better after only a few days of learning than with the static language that you have been using for several years?\nUpdate\nAfter seeing the first few responses it is clear that there are two issues.\nMy main interest would be something that is justifiable to the employer as an expense.\nThat is, I am looking for justifications for the employer to finance the learning of a dynamic language. Aside from the obvious that the employee will have broader view, the\nemployers are usually looking for some \"real\" benefit.","AnswerCount":35,"Available Count":31,"Score":0.0,"is_accepted":false,"ViewCount":32287,"Q_Id":84340,"Users Score":0,"Answer":"Others have already explained why learning more languages makes you a better programmer.\nAs for convincing your boss it's worth it, this is probably just your company's culture. Some places make career and skill progress a policy (move up or out), some places value it but leave it up to the employee's initiative, and some places are very focused on the bottom line.\nIf you have to explain why learning a language is a good thing to your boss, my advice would be to stay at work only as long as necessary, then go home and study new things on your own.","Q_Score":66,"Tags":"c#,java,python,ruby,perl","A_Id":86738,"CreationDate":"2008-09-17T15:16:00.000","Title":"Why learn Perl, Python, Ruby if the company is using C++, C# or Java as the application language?","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},{"Question":"I wonder why would a C++, C#, Java developer want to learn a dynamic language?\nAssuming the company won't switch its main development language from C++\/C#\/Java to a dynamic one what use is there for a dynamic language?\nWhat helper tasks can be done by the dynamic languages faster or better after only a few days of learning than with the static language that you have been using for several years?\nUpdate\nAfter seeing the first few responses it is clear that there are two issues.\nMy main interest would be something that is justifiable to the employer as an expense.\nThat is, I am looking for justifications for the employer to finance the learning of a dynamic language. Aside from the obvious that the employee will have broader view, the\nemployers are usually looking for some \"real\" benefit.","AnswerCount":35,"Available Count":31,"Score":0.0,"is_accepted":false,"ViewCount":32287,"Q_Id":84340,"Users Score":0,"Answer":"For after work work, for freelance jobs...:) and final to be programming literate as possible as...;)","Q_Score":66,"Tags":"c#,java,python,ruby,perl","A_Id":87164,"CreationDate":"2008-09-17T15:16:00.000","Title":"Why learn Perl, Python, Ruby if the company is using C++, C# or Java as the application language?","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},{"Question":"I wonder why would a C++, C#, Java developer want to learn a dynamic language?\nAssuming the company won't switch its main development language from C++\/C#\/Java to a dynamic one what use is there for a dynamic language?\nWhat helper tasks can be done by the dynamic languages faster or better after only a few days of learning than with the static language that you have been using for several years?\nUpdate\nAfter seeing the first few responses it is clear that there are two issues.\nMy main interest would be something that is justifiable to the employer as an expense.\nThat is, I am looking for justifications for the employer to finance the learning of a dynamic language. Aside from the obvious that the employee will have broader view, the\nemployers are usually looking for some \"real\" benefit.","AnswerCount":35,"Available Count":31,"Score":0.017141178,"is_accepted":false,"ViewCount":32287,"Q_Id":84340,"Users Score":3,"Answer":"Edit: I wrote this before reading the update to the original question. See my other answer for a better answer to the updated question. I will leave this as is as a warning against being the fastest gun in the west =)\nOver a decade ago, when I was learning the ways of the Computer, the Old Wise Men With Beards explained how C and C++ are the tools of the industry. No one used Pascal and only the foolhardy would risk their companies with assembler.\nAnd of course, no one would even mention the awful slow ugly thing called Java. It will not be a tool for serious business.\nSo. Um. Replace the languages in the above story and perhaps you can predict the future. Perhaps you can't. Point is, Java will not be the Last Programming Language ever and also you will most likely switch employers as well. The future is charging at you 24 hours per day. Be prepared.\nLearning new languages is good for you. Also, in some cases it can give you bragging rights for a long time. My first university course was in Scheme. So when people talk to me about the new language du jour, my response is something like \"First-class functions? That's so last century.\"\nAnd of course, you get more stuff done with a high-level language.","Q_Score":66,"Tags":"c#,java,python,ruby,perl","A_Id":84571,"CreationDate":"2008-09-17T15:16:00.000","Title":"Why learn Perl, Python, Ruby if the company is using C++, C# or Java as the application language?","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},{"Question":"I wonder why would a C++, C#, Java developer want to learn a dynamic language?\nAssuming the company won't switch its main development language from C++\/C#\/Java to a dynamic one what use is there for a dynamic language?\nWhat helper tasks can be done by the dynamic languages faster or better after only a few days of learning than with the static language that you have been using for several years?\nUpdate\nAfter seeing the first few responses it is clear that there are two issues.\nMy main interest would be something that is justifiable to the employer as an expense.\nThat is, I am looking for justifications for the employer to finance the learning of a dynamic language. Aside from the obvious that the employee will have broader view, the\nemployers are usually looking for some \"real\" benefit.","AnswerCount":35,"Available Count":31,"Score":1.2,"is_accepted":true,"ViewCount":32287,"Q_Id":84340,"Users Score":80,"Answer":"A lot of times some quick task comes up that isn't part of the main software you are developing. Sometimes the task is one off ie compare this file to the database and let me know the differences. It is a lot easier to do text parsing in Perl\/Ruby\/Python than it is in Java or C# (partially because it is a lot easier to use regular expressions). It will probably take a lot less time to parse the text file using Perl\/Ruby\/Python (or maybe even vbscript cringe and then load it into the database than it would to create a Java\/C# program to do it or to do it by hand.\nAlso, due to the ease at which most of the dynamic languages parse text, they are great for code generation. Sure your final project must be in C#\/Java\/Transact SQL but instead of cutting and pasting 100 times, finding errors, and cutting and pasting another 100 times it is often (but not always) easier just to use a code generator.\nA recent example at work is we needed to get data from one accounting system into our accounting system. The system has an import format, but the old system had a completely different format (fixed width although some things had to be matched). The task is not to create a program to migrate the data over and over again. It is to shove the data into our system and then maintain it there going forward. So even though we are a C# and SQL Server shop, I used Python to convert the data into the format that could be imported by our application. Ultimately it doesn't matter that I used python, it matters that the data is in the system. My boss was pretty impressed.\nWhere I often see the dynamic languages used for is testing. It is much easier to create a Python\/Perl\/Ruby program to link to a web service and throw some data against it than it is to create the equivalent Java program. You can also use python to hit against command line programs, generate a ton of garbage (but still valid) test data, etc.. quite easily.\nThe other thing that dynamic languages are big on is code generation. Creating the C#\/C++\/Java code. Some examples follow:\nThe first code generation task I often see is people using dynamic languages to maintain constants in the system. Instead of hand coding a bunch of enums, a dynamic language can be used to fairly easily parse a text file and create the Java\/C# code with the enums.\nSQL is a whole other ball game but often you get better performance by cut and pasting 100 times instead of trying to do a function (due to caching of execution plans or putting complicated logic in a function causing you to go row by row instead of in a set). In fact it is quite useful to use the table definition to create certain stored procedures automatically.\nIt is always better to get buy in for a code generator. But even if you don't, is it more fun to spend time cutting\/pasting or is it more fun to create a Perl\/Python\/Ruby script once and then have that generate the code? If it takes you hours to hand code something but less time to create a code generator, then even if you use it once you have saved time and hence money. If it takes you longer to create a code generator than it takes to hand code once but you know you will have to update the code more than once, it may still make sense. If it takes you 2 hours to hand code, 4 hours to do the generator but you know you'll have to hand code equivalent work another 5 or 6 times than it is obviously better to create the generator.\nAlso some things are easier with dynamic languages than Java\/C#\/C\/C++. In particular regular expressions come to mind. If you start using regular expressions in Perl and realize their value, you may suddenly start making use of the Java regular expression library if you haven't before. If you have then there may be something else.\nI will leave you with one last example of a task that would have been great for a dynamic language. My work mate had to take a directory full of files and burn them to various cd's for various customers. There were a few customers but a lot of files and you had to look in them to see what they were. He did this task by hand....A Java\/C# program would have saved time, but for one time and with all the development overhead it isn't worth it. However slapping something together in Perl\/Python\/Ruby probably would have been worth it. He spent several hours doing it. It would have taken less than one to create the Python script to inspect each file, match which customer it goes to, and then move the file to the appropriate place.....Again, not part of the standard job. But the task came up as a one off. Is it better to do it yourself, spend the larger amount of time to make Java\/C# do the task, or spend a much smaller amount of time doing it in Python\/Perl\/Ruby. If you are using C or C++ the point is even more dramatic due to the extra concerns of programming in C or C++ (pointers, no array bounds checking, etc.).","Q_Score":66,"Tags":"c#,java,python,ruby,perl","A_Id":84943,"CreationDate":"2008-09-17T15:16:00.000","Title":"Why learn Perl, Python, Ruby if the company is using C++, C# or Java as the application language?","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},{"Question":"I wonder why would a C++, C#, Java developer want to learn a dynamic language?\nAssuming the company won't switch its main development language from C++\/C#\/Java to a dynamic one what use is there for a dynamic language?\nWhat helper tasks can be done by the dynamic languages faster or better after only a few days of learning than with the static language that you have been using for several years?\nUpdate\nAfter seeing the first few responses it is clear that there are two issues.\nMy main interest would be something that is justifiable to the employer as an expense.\nThat is, I am looking for justifications for the employer to finance the learning of a dynamic language. Aside from the obvious that the employee will have broader view, the\nemployers are usually looking for some \"real\" benefit.","AnswerCount":35,"Available Count":31,"Score":0.0,"is_accepted":false,"ViewCount":32287,"Q_Id":84340,"Users Score":0,"Answer":"Often, dynamc languages (especially python and lua) are embedded in programs to add a more plugin-like functionality and because they are high-level languages that make it easy to add certain behavior, where a low\/mid-level language is not needed.\nLua specificially lacks all the low-level system calls because it was designed for easeof-use to add functionality within the program, not as a general programming language.","Q_Score":66,"Tags":"c#,java,python,ruby,perl","A_Id":84400,"CreationDate":"2008-09-17T15:16:00.000","Title":"Why learn Perl, Python, Ruby if the company is using C++, C# or Java as the application language?","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},{"Question":"I wonder why would a C++, C#, Java developer want to learn a dynamic language?\nAssuming the company won't switch its main development language from C++\/C#\/Java to a dynamic one what use is there for a dynamic language?\nWhat helper tasks can be done by the dynamic languages faster or better after only a few days of learning than with the static language that you have been using for several years?\nUpdate\nAfter seeing the first few responses it is clear that there are two issues.\nMy main interest would be something that is justifiable to the employer as an expense.\nThat is, I am looking for justifications for the employer to finance the learning of a dynamic language. Aside from the obvious that the employee will have broader view, the\nemployers are usually looking for some \"real\" benefit.","AnswerCount":35,"Available Count":31,"Score":0.0057142235,"is_accepted":false,"ViewCount":32287,"Q_Id":84340,"Users Score":1,"Answer":"It's all about broadening your horizons as a developer. If you limit yourself to only strong-typed languages, you may not end up the best programmer you could.\nAs for tasks, Python\/Lua\/Ruby\/Perl are great for small simple tasks, like finding some files and renaming them. They also work great when paired with a framework (e.g. Rails, Django, Lua for Windows) for developing simple apps quickly. Hell, 37Signals is based on creating simple yet very useful apps in Ruby on Rails.","Q_Score":66,"Tags":"c#,java,python,ruby,perl","A_Id":84441,"CreationDate":"2008-09-17T15:16:00.000","Title":"Why learn Perl, Python, Ruby if the company is using C++, C# or Java as the application language?","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},{"Question":"I wonder why would a C++, C#, Java developer want to learn a dynamic language?\nAssuming the company won't switch its main development language from C++\/C#\/Java to a dynamic one what use is there for a dynamic language?\nWhat helper tasks can be done by the dynamic languages faster or better after only a few days of learning than with the static language that you have been using for several years?\nUpdate\nAfter seeing the first few responses it is clear that there are two issues.\nMy main interest would be something that is justifiable to the employer as an expense.\nThat is, I am looking for justifications for the employer to finance the learning of a dynamic language. Aside from the obvious that the employee will have broader view, the\nemployers are usually looking for some \"real\" benefit.","AnswerCount":35,"Available Count":31,"Score":0.0,"is_accepted":false,"ViewCount":32287,"Q_Id":84340,"Users Score":0,"Answer":"Philosophical issues aside, I know that I have gotten value from writing quick-and-dirty Ruby scripts to solve brute-force problems that Java was just too big for. Last year I had three separate directory structures that were all more-or-less the same, but with lots of differences among the files (the client hadn't heard of version control and I'll leave the rest to your imagination). \nIt would have taken a great deal of overhead to write an analyzer in Java, but in Ruby I had one working in about 40 minutes.","Q_Score":66,"Tags":"c#,java,python,ruby,perl","A_Id":84383,"CreationDate":"2008-09-17T15:16:00.000","Title":"Why learn Perl, Python, Ruby if the company is using C++, C# or Java as the application language?","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},{"Question":"I wonder why would a C++, C#, Java developer want to learn a dynamic language?\nAssuming the company won't switch its main development language from C++\/C#\/Java to a dynamic one what use is there for a dynamic language?\nWhat helper tasks can be done by the dynamic languages faster or better after only a few days of learning than with the static language that you have been using for several years?\nUpdate\nAfter seeing the first few responses it is clear that there are two issues.\nMy main interest would be something that is justifiable to the employer as an expense.\nThat is, I am looking for justifications for the employer to finance the learning of a dynamic language. Aside from the obvious that the employee will have broader view, the\nemployers are usually looking for some \"real\" benefit.","AnswerCount":35,"Available Count":31,"Score":0.0057142235,"is_accepted":false,"ViewCount":32287,"Q_Id":84340,"Users Score":1,"Answer":"Given the increasing focus to running dynamic languages (da-vinci vm etc.) on the JVM and the increasing number of dynamic languages that do run on it (JRuby, Grrovy, Jython) I think the usecases are just increasing. Some of the scenarios I found really benifited are\n\nPrototyping- use RoR or Grails to build quick prototypes with advantage of being able to runn it on the standard app server and (maybe) reuse existing services etc.\nTesting- right unit tests much much faster in dynamic languages\nPerformance\/automation test scripting- some of these tools are starting to allow the use standard dynamic language of choice to write the test scripts instead of proprietary script languages. Side benefit might be to the able to reuse some unit test code you've already written.","Q_Score":66,"Tags":"c#,java,python,ruby,perl","A_Id":90403,"CreationDate":"2008-09-17T15:16:00.000","Title":"Why learn Perl, Python, Ruby if the company is using C++, C# or Java as the application language?","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},{"Question":"I wonder why would a C++, C#, Java developer want to learn a dynamic language?\nAssuming the company won't switch its main development language from C++\/C#\/Java to a dynamic one what use is there for a dynamic language?\nWhat helper tasks can be done by the dynamic languages faster or better after only a few days of learning than with the static language that you have been using for several years?\nUpdate\nAfter seeing the first few responses it is clear that there are two issues.\nMy main interest would be something that is justifiable to the employer as an expense.\nThat is, I am looking for justifications for the employer to finance the learning of a dynamic language. Aside from the obvious that the employee will have broader view, the\nemployers are usually looking for some \"real\" benefit.","AnswerCount":35,"Available Count":31,"Score":0.0057142235,"is_accepted":false,"ViewCount":32287,"Q_Id":84340,"Users Score":1,"Answer":"Don't tell your employer that you want to learn Ruby. Tell him you want to learn about the state-of-the-art in web framework technologies. it just happens that the hottest ones are Django and Ruby on Rails.","Q_Score":66,"Tags":"c#,java,python,ruby,perl","A_Id":98291,"CreationDate":"2008-09-17T15:16:00.000","Title":"Why learn Perl, Python, Ruby if the company is using C++, C# or Java as the application language?","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},{"Question":"I wonder why would a C++, C#, Java developer want to learn a dynamic language?\nAssuming the company won't switch its main development language from C++\/C#\/Java to a dynamic one what use is there for a dynamic language?\nWhat helper tasks can be done by the dynamic languages faster or better after only a few days of learning than with the static language that you have been using for several years?\nUpdate\nAfter seeing the first few responses it is clear that there are two issues.\nMy main interest would be something that is justifiable to the employer as an expense.\nThat is, I am looking for justifications for the employer to finance the learning of a dynamic language. Aside from the obvious that the employee will have broader view, the\nemployers are usually looking for some \"real\" benefit.","AnswerCount":35,"Available Count":31,"Score":0.0,"is_accepted":false,"ViewCount":32287,"Q_Id":84340,"Users Score":0,"Answer":"Don't bother your employer, spend ~$40 on a book, download some software, and devote some time each day to read\/do exercises. In no time you'll be trained :)","Q_Score":66,"Tags":"c#,java,python,ruby,perl","A_Id":114875,"CreationDate":"2008-09-17T15:16:00.000","Title":"Why learn Perl, Python, Ruby if the company is using C++, C# or Java as the application language?","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},{"Question":"I wonder why would a C++, C#, Java developer want to learn a dynamic language?\nAssuming the company won't switch its main development language from C++\/C#\/Java to a dynamic one what use is there for a dynamic language?\nWhat helper tasks can be done by the dynamic languages faster or better after only a few days of learning than with the static language that you have been using for several years?\nUpdate\nAfter seeing the first few responses it is clear that there are two issues.\nMy main interest would be something that is justifiable to the employer as an expense.\nThat is, I am looking for justifications for the employer to finance the learning of a dynamic language. Aside from the obvious that the employee will have broader view, the\nemployers are usually looking for some \"real\" benefit.","AnswerCount":35,"Available Count":31,"Score":0.0285636566,"is_accepted":false,"ViewCount":32287,"Q_Id":84340,"Users Score":5,"Answer":"A good hockey player plays where the puck is. A great hockey player plays where the puck is going to be.\n- Wayne Gretzky\nOur industry is always changing. No language can be mainstream forever. To me Java, C++, .Net is where the puck is right now. And python, ruby, perl is where the puck is going to be. Decide for yourself if you wanna be good or great!","Q_Score":66,"Tags":"c#,java,python,ruby,perl","A_Id":92642,"CreationDate":"2008-09-17T15:16:00.000","Title":"Why learn Perl, Python, Ruby if the company is using C++, C# or Java as the application language?","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},{"Question":"I wonder why would a C++, C#, Java developer want to learn a dynamic language?\nAssuming the company won't switch its main development language from C++\/C#\/Java to a dynamic one what use is there for a dynamic language?\nWhat helper tasks can be done by the dynamic languages faster or better after only a few days of learning than with the static language that you have been using for several years?\nUpdate\nAfter seeing the first few responses it is clear that there are two issues.\nMy main interest would be something that is justifiable to the employer as an expense.\nThat is, I am looking for justifications for the employer to finance the learning of a dynamic language. Aside from the obvious that the employee will have broader view, the\nemployers are usually looking for some \"real\" benefit.","AnswerCount":35,"Available Count":31,"Score":0.0057142235,"is_accepted":false,"ViewCount":32287,"Q_Id":84340,"Users Score":1,"Answer":"I have often found that learning another language, especially a dynamically typed language, can teach you things about other languages and make you an overall better programmer. Learning ruby, for example, will teach you Object Oriented programming in ways Java wont, and vice versa. All in all, I believe that it is better to be a well rounded programmer than stuck in a single language. It makes you more valuable to the companies\/clients you work for.","Q_Score":66,"Tags":"c#,java,python,ruby,perl","A_Id":84382,"CreationDate":"2008-09-17T15:16:00.000","Title":"Why learn Perl, Python, Ruby if the company is using C++, C# or Java as the application language?","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},{"Question":"I wonder why would a C++, C#, Java developer want to learn a dynamic language?\nAssuming the company won't switch its main development language from C++\/C#\/Java to a dynamic one what use is there for a dynamic language?\nWhat helper tasks can be done by the dynamic languages faster or better after only a few days of learning than with the static language that you have been using for several years?\nUpdate\nAfter seeing the first few responses it is clear that there are two issues.\nMy main interest would be something that is justifiable to the employer as an expense.\nThat is, I am looking for justifications for the employer to finance the learning of a dynamic language. Aside from the obvious that the employee will have broader view, the\nemployers are usually looking for some \"real\" benefit.","AnswerCount":35,"Available Count":31,"Score":0.0,"is_accepted":false,"ViewCount":32287,"Q_Id":84340,"Users Score":0,"Answer":"Dynamic languages are a different way to think and sometimes the practices you learn from a dynamic or functional language can transfer to the more statically typed languages but if you never take the time to learn different languages, you'll never get the benefit of having a knew way to think when you are coding.","Q_Score":66,"Tags":"c#,java,python,ruby,perl","A_Id":90005,"CreationDate":"2008-09-17T15:16:00.000","Title":"Why learn Perl, Python, Ruby if the company is using C++, C# or Java as the application language?","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},{"Question":"I wonder why would a C++, C#, Java developer want to learn a dynamic language?\nAssuming the company won't switch its main development language from C++\/C#\/Java to a dynamic one what use is there for a dynamic language?\nWhat helper tasks can be done by the dynamic languages faster or better after only a few days of learning than with the static language that you have been using for several years?\nUpdate\nAfter seeing the first few responses it is clear that there are two issues.\nMy main interest would be something that is justifiable to the employer as an expense.\nThat is, I am looking for justifications for the employer to finance the learning of a dynamic language. Aside from the obvious that the employee will have broader view, the\nemployers are usually looking for some \"real\" benefit.","AnswerCount":35,"Available Count":31,"Score":1.0,"is_accepted":false,"ViewCount":32287,"Q_Id":84340,"Users Score":21,"Answer":"Let me turn your question on its head by asking what use it is to an American English speaker to learn another language?\nThe languages we speak (and those we program in) inform the way we think. This can happen on a fundamental level, such as c++ versus javascript versus lisp, or on an implementation level, in which a ruby construct provides a eureka moment for a solution in your \"real job.\"\nSpeaking of your real job, if the market goes south and your employer decides to \"right size\" you, how do you think you'll stack up against a guy who is flexible because he's written software in tens of languages, instead of your limited exposure? All things being equal, I think the answer is clear.\nFinally, you program for a living because you love programming... right?","Q_Score":66,"Tags":"c#,java,python,ruby,perl","A_Id":84362,"CreationDate":"2008-09-17T15:16:00.000","Title":"Why learn Perl, Python, Ruby if the company is using C++, C# or Java as the application language?","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},{"Question":"I wonder why would a C++, C#, Java developer want to learn a dynamic language?\nAssuming the company won't switch its main development language from C++\/C#\/Java to a dynamic one what use is there for a dynamic language?\nWhat helper tasks can be done by the dynamic languages faster or better after only a few days of learning than with the static language that you have been using for several years?\nUpdate\nAfter seeing the first few responses it is clear that there are two issues.\nMy main interest would be something that is justifiable to the employer as an expense.\nThat is, I am looking for justifications for the employer to finance the learning of a dynamic language. Aside from the obvious that the employee will have broader view, the\nemployers are usually looking for some \"real\" benefit.","AnswerCount":35,"Available Count":31,"Score":1.0,"is_accepted":false,"ViewCount":32287,"Q_Id":84340,"Users Score":9,"Answer":"I primarily program in Java and C# but use dynamic languages (ruby\/perl) to support smoother deployment, kicking off OS tasks, automated reporting, some log parsing, etc.\nAfter a short time learning and experimenting with ruby or perl you should be able to write some regex manipulating scripts that can alter data formats or grab information from logs. An example of a small ruby\/perl script that could be written quickly would be a script to parse a very large log file and report out only a few events of interest in either a human readable format or a csv format. \nAlso, having experience with a variety of different programming languages should help you think of new ways to tackle problems in more structured languages like Java, C++, and C#.","Q_Score":66,"Tags":"c#,java,python,ruby,perl","A_Id":84437,"CreationDate":"2008-09-17T15:16:00.000","Title":"Why learn Perl, Python, Ruby if the company is using C++, C# or Java as the application language?","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},{"Question":"I wonder why would a C++, C#, Java developer want to learn a dynamic language?\nAssuming the company won't switch its main development language from C++\/C#\/Java to a dynamic one what use is there for a dynamic language?\nWhat helper tasks can be done by the dynamic languages faster or better after only a few days of learning than with the static language that you have been using for several years?\nUpdate\nAfter seeing the first few responses it is clear that there are two issues.\nMy main interest would be something that is justifiable to the employer as an expense.\nThat is, I am looking for justifications for the employer to finance the learning of a dynamic language. Aside from the obvious that the employee will have broader view, the\nemployers are usually looking for some \"real\" benefit.","AnswerCount":35,"Available Count":31,"Score":1.0,"is_accepted":false,"ViewCount":32287,"Q_Id":84340,"Users Score":7,"Answer":"One big reason to learn Perl or Ruby is to help you automate any complicated tasks that you have to do over and over.\nOr if you have to analyse contents of log files and you need more mungeing than available using grep, sed, etc.\nAlso using other languages, e.g. Ruby, that don't have much \"setup cost\" will let you quickly prototype ideas before implementing them in C++, Java, etc.\nHTH\ncheers,\nRob","Q_Score":66,"Tags":"c#,java,python,ruby,perl","A_Id":84535,"CreationDate":"2008-09-17T15:16:00.000","Title":"Why learn Perl, Python, Ruby if the company is using C++, C# or Java as the application language?","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},{"Question":"I wonder why would a C++, C#, Java developer want to learn a dynamic language?\nAssuming the company won't switch its main development language from C++\/C#\/Java to a dynamic one what use is there for a dynamic language?\nWhat helper tasks can be done by the dynamic languages faster or better after only a few days of learning than with the static language that you have been using for several years?\nUpdate\nAfter seeing the first few responses it is clear that there are two issues.\nMy main interest would be something that is justifiable to the employer as an expense.\nThat is, I am looking for justifications for the employer to finance the learning of a dynamic language. Aside from the obvious that the employee will have broader view, the\nemployers are usually looking for some \"real\" benefit.","AnswerCount":35,"Available Count":31,"Score":0.0057142235,"is_accepted":false,"ViewCount":32287,"Q_Id":84340,"Users Score":1,"Answer":"I have found the more that I play with Ruby, the better I understand C#. \n1) As you switch between these languages that each of them has their own constructs and philosophies behind the problems that they try to solve. This will help you when finding the right tool for the job or the domain of a problem.\n2) The role of the compiler (or interpreter for some languages) becomes more prominent. Why is Ruby's type system differ from the .Net\/C# system? What problems do each of these solve? You'll find yourself understanding at a lower level the constructs of the compiler and its influence on the language\n3) Switching between Ruby and C# really helped me to understand Design Patterns better. I really suggest implementing common design patterns in a language like C# and then in a language like Ruby. It often helped me see through some of the compiler ceremony to the philosophy of a particular pattern.\n4) A different community. C#, Java, Ruby, Python, etc all have different communities that can help engage your abilities. It is a great way to take your craft to the next level.\n5) Last, but not least, because new languages are fun :)","Q_Score":66,"Tags":"c#,java,python,ruby,perl","A_Id":2870953,"CreationDate":"2008-09-17T15:16:00.000","Title":"Why learn Perl, Python, Ruby if the company is using C++, C# or Java as the application language?","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},{"Question":"I wonder why would a C++, C#, Java developer want to learn a dynamic language?\nAssuming the company won't switch its main development language from C++\/C#\/Java to a dynamic one what use is there for a dynamic language?\nWhat helper tasks can be done by the dynamic languages faster or better after only a few days of learning than with the static language that you have been using for several years?\nUpdate\nAfter seeing the first few responses it is clear that there are two issues.\nMy main interest would be something that is justifiable to the employer as an expense.\nThat is, I am looking for justifications for the employer to finance the learning of a dynamic language. Aside from the obvious that the employee will have broader view, the\nemployers are usually looking for some \"real\" benefit.","AnswerCount":35,"Available Count":31,"Score":1.0,"is_accepted":false,"ViewCount":32287,"Q_Id":84340,"Users Score":14,"Answer":"I don't think anyone has mentioned this yet. Learning a new language can be fun! Surely that's a good enough reason to try something new.","Q_Score":66,"Tags":"c#,java,python,ruby,perl","A_Id":89272,"CreationDate":"2008-09-17T15:16:00.000","Title":"Why learn Perl, Python, Ruby if the company is using C++, C# or Java as the application language?","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},{"Question":"What would be the best way to implement a simple crash \/ error reporting mechanism? \nDetails: my app is cross-platform (mac\/windows\/linux) and written in Python, so I just need something that will send me a small amount of text, e.g. just a timestamp and a traceback (which I already generate and show in my error dialog). \nIt would be fine if it could simply email it, but I can't think of a way to do this without including a username and password for the smtp server in the application...\nShould I implement a simple web service on the server side and have my app send it an HTTP request with the info? Any better ideas?","AnswerCount":6,"Available Count":4,"Score":0.0,"is_accepted":false,"ViewCount":1475,"Q_Id":85985,"Users Score":0,"Answer":"Whether you use SMTP or HTTP to send the data, you need to have a username\/password in the application to prevent just anyone from sending random data to you.\nWith that in mind, I suspect it would be easier to use SMTP rather than HTTP to send the data.","Q_Score":7,"Tags":"python,cross-platform,error-reporting","A_Id":86022,"CreationDate":"2008-09-17T18:09:00.000","Title":"How to best implement simple crash \/ error reporting?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"What would be the best way to implement a simple crash \/ error reporting mechanism? \nDetails: my app is cross-platform (mac\/windows\/linux) and written in Python, so I just need something that will send me a small amount of text, e.g. just a timestamp and a traceback (which I already generate and show in my error dialog). \nIt would be fine if it could simply email it, but I can't think of a way to do this without including a username and password for the smtp server in the application...\nShould I implement a simple web service on the server side and have my app send it an HTTP request with the info? Any better ideas?","AnswerCount":6,"Available Count":4,"Score":1.2,"is_accepted":true,"ViewCount":1475,"Q_Id":85985,"Users Score":5,"Answer":"The web service is the best way, but there are some caveats:\n\nYou should always ask the user if it is ok to send error feedback information.\nYou should be prepared to fail gracefully if there are network errors. Don't let a failure to report a crash impede recovery!\nYou should avoid including user identifying or sensitive information unless the user knows (see #1) and you should either use SSL or otherwise protect it. Some jurisdictions impose burdens on you that you might not want to deal with, so it's best to simply not save such information.\nLike any web service, make sure your service is not exploitable by miscreants.","Q_Score":7,"Tags":"python,cross-platform,error-reporting","A_Id":86050,"CreationDate":"2008-09-17T18:09:00.000","Title":"How to best implement simple crash \/ error reporting?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"What would be the best way to implement a simple crash \/ error reporting mechanism? \nDetails: my app is cross-platform (mac\/windows\/linux) and written in Python, so I just need something that will send me a small amount of text, e.g. just a timestamp and a traceback (which I already generate and show in my error dialog). \nIt would be fine if it could simply email it, but I can't think of a way to do this without including a username and password for the smtp server in the application...\nShould I implement a simple web service on the server side and have my app send it an HTTP request with the info? Any better ideas?","AnswerCount":6,"Available Count":4,"Score":0.0333209931,"is_accepted":false,"ViewCount":1475,"Q_Id":85985,"Users Score":1,"Answer":"The web hit is the way to go, but make sure you pick a good URL - your app will be hitting it for years to come.","Q_Score":7,"Tags":"python,cross-platform,error-reporting","A_Id":86007,"CreationDate":"2008-09-17T18:09:00.000","Title":"How to best implement simple crash \/ error reporting?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"What would be the best way to implement a simple crash \/ error reporting mechanism? \nDetails: my app is cross-platform (mac\/windows\/linux) and written in Python, so I just need something that will send me a small amount of text, e.g. just a timestamp and a traceback (which I already generate and show in my error dialog). \nIt would be fine if it could simply email it, but I can't think of a way to do this without including a username and password for the smtp server in the application...\nShould I implement a simple web service on the server side and have my app send it an HTTP request with the info? Any better ideas?","AnswerCount":6,"Available Count":4,"Score":0.0,"is_accepted":false,"ViewCount":1475,"Q_Id":85985,"Users Score":0,"Answer":"Some kind of simple web service would suffice. You would have to consider security so not just anyone could make requests to your service..\nOn a larger scale we considered a JMS messaging system. Put a serialized object of data containing the traceback\/error message into a queue and consume it every x minutes generating reports\/alerts from that data.","Q_Score":7,"Tags":"python,cross-platform,error-reporting","A_Id":86069,"CreationDate":"2008-09-17T18:09:00.000","Title":"How to best implement simple crash \/ error reporting?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I'm a little confused about how the standard library will behave now that Python (from 3.0) is unicode-based. Will modules such as CGI and urllib use unicode strings or will they use the new 'bytes' type and just provide encoded data?","AnswerCount":3,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":464,"Q_Id":91205,"Users Score":12,"Answer":"Logically a lot of things like MIME-encoded mail messages, URLs, XML documents, and so on should be returned as bytes not strings. This could cause some consternation as the libraries start to be nailed down for Python 3 and people discover that they have to be more aware of the bytes\/string conversions than they were for str\/unicode ...","Q_Score":12,"Tags":"python,unicode,string,cgi,python-3.x","A_Id":91301,"CreationDate":"2008-09-18T09:29:00.000","Title":"Will everything in the standard library treat strings as unicode in Python 3.0?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"What are metaclasses? What are they used for?","AnswerCount":24,"Available Count":4,"Score":1.0,"is_accepted":false,"ViewCount":1011070,"Q_Id":100003,"Users Score":9,"Answer":"In Python, a metaclass is a subclass of a subclass that determines how a subclass behaves. A class is an instance of another metaclass. In Python, a class specifies how the class's instance will behave.\nSince metaclasses are in charge of class generation, you can\u00a0write your own custom metaclasses to change how classes are created by performing additional actions or injecting code. Custom metaclasses aren't always important, but they can be.","Q_Score":6790,"Tags":"python,oop,metaclass,python-class,python-datamodel","A_Id":67201732,"CreationDate":"2008-09-19T06:10:00.000","Title":"What are metaclasses 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},{"Question":"What are metaclasses? What are they used for?","AnswerCount":24,"Available Count":4,"Score":1.0,"is_accepted":false,"ViewCount":1011070,"Q_Id":100003,"Users Score":9,"Answer":"I saw an interesting use case for metaclasses in a package called classutilities. It checks if all class variables are in upper case format (it is convenient to have unified logic for configuration classes), and checks if there are no instance level methods in class.\nAnother interesting example for metaclases was deactivation of unittests based on complex conditions (checking values of multiple environmental variables).","Q_Score":6790,"Tags":"python,oop,metaclass,python-class,python-datamodel","A_Id":68354618,"CreationDate":"2008-09-19T06:10:00.000","Title":"What are metaclasses 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},{"Question":"What are metaclasses? What are they used for?","AnswerCount":24,"Available Count":4,"Score":1.0,"is_accepted":false,"ViewCount":1011070,"Q_Id":100003,"Users Score":16,"Answer":"In object-oriented programming, a metaclass is a class whose instances are classes. Just as an ordinary class defines the behavior of certain objects, a metaclass defines the behavior of certain class and their instances\nThe term metaclass simply means something used to create classes. In other words, it is the class of a class. The metaclass is used to create the class so like the object being an instance of a class, a class is an instance of a metaclass. In python classes are also considered objects.","Q_Score":6790,"Tags":"python,oop,metaclass,python-class,python-datamodel","A_Id":56945952,"CreationDate":"2008-09-19T06:10:00.000","Title":"What are metaclasses 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},{"Question":"What are metaclasses? What are they used for?","AnswerCount":24,"Available Count":4,"Score":1.0,"is_accepted":false,"ViewCount":1011070,"Q_Id":100003,"Users Score":14,"Answer":"A class, in Python, is an object, and just like any other object, it is an instance of \"something\". This \"something\" is what is termed as a Metaclass. This metaclass is a special type of class that creates other class's objects. Hence, metaclass is responsible for making new classes. This allows the programmer to customize the way classes are generated.\nTo create a metaclass, overriding of new() and init() methods is usually done. new() can be overridden to change the way objects are created, while init() can be overridden to change the way of initializing the object. Metaclass can be created by a number of ways. One of the ways is to use type() function. type() function, when called with 3 parameters, creates a metaclass. The parameters are :-\n\nClass Name\nTuple having base classes inherited by class\nA dictionary having all class methods and class variables\n\nAnother way of creating a metaclass comprises of 'metaclass' keyword. Define the metaclass as a simple class. In the parameters of inherited class, pass metaclass=metaclass_name\nMetaclass can be specifically used in the following situations :-\n\nwhen a particular effect has to be applied to all the subclasses\nAutomatic change of class (on creation) is required\nBy API developers","Q_Score":6790,"Tags":"python,oop,metaclass,python-class,python-datamodel","A_Id":59818321,"CreationDate":"2008-09-19T06:10:00.000","Title":"What are metaclasses 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},{"Question":"A common task in programs I've been working on lately is modifying a text file in some way. (Hey, I'm on Linux. Everything's a file. And I do large-scale system admin.)\nBut the file the code modifies may not exist on my desktop box. And I probably don't want to modify it if it IS on my desktop.\nI've read about unit testing in Dive Into Python, and it's pretty clear what I want to do when testing an app that converts decimal to Roman Numerals (the example in DintoP). The testing is nicely self-contained. You don't need to verify that the program PRINTS the right thing, you just need to verify that the functions are returning the right output to a given input.\nIn my case, however, we need to test that the program is modifying its environment correctly. Here's what I've come up with:\n1) Create the \"original\" file in a standard location, perhaps \/tmp.\n2) Run the function that modifies the file, passing it the path to the file in \/tmp.\n3) Verify that the file in \/tmp was changed correctly; pass\/fail unit test accordingly.\nThis seems kludgy to me. (Gets even kludgier if you want to verify that backup copies of the file are created properly, etc.) Has anyone come up with a better way?","AnswerCount":6,"Available Count":3,"Score":1.0,"is_accepted":false,"ViewCount":4799,"Q_Id":106766,"Users Score":7,"Answer":"You have two levels of testing.\n\nFiltering and Modifying content. These are \"low-level\" operations that don't really require physical file I\/O. These are the tests, decision-making, alternatives, etc. The \"Logic\" of the application.\nFile system operations. Create, copy, rename, delete, backup. Sorry, but those are proper file system operations that -- well -- require a proper file system for testing.\n\nFor this kind of testing, we often use a \"Mock\" object. You can design a \"FileSystemOperations\" class that embodies the various file system operations. You test this to be sure it does basic read, write, copy, rename, etc. There's no real logic in this. Just methods that invoke file system operations.\nYou can then create a MockFileSystem which dummies out the various operations. You can use this Mock object to test your other classes.\nIn some cases, all of your file system operations are in the os module. If that's the case, you can create a MockOS module with mock version of the operations you actually use.\nPut your MockOS module on the PYTHONPATH and you can conceal the real OS module.\nFor production operations you use your well-tested \"Logic\" classes plus your FileSystemOperations class (or the real OS module.)","Q_Score":23,"Tags":"python,linux,unit-testing","A_Id":106780,"CreationDate":"2008-09-20T01:56:00.000","Title":"Unit Testing File Modifications","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"A common task in programs I've been working on lately is modifying a text file in some way. (Hey, I'm on Linux. Everything's a file. And I do large-scale system admin.)\nBut the file the code modifies may not exist on my desktop box. And I probably don't want to modify it if it IS on my desktop.\nI've read about unit testing in Dive Into Python, and it's pretty clear what I want to do when testing an app that converts decimal to Roman Numerals (the example in DintoP). The testing is nicely self-contained. You don't need to verify that the program PRINTS the right thing, you just need to verify that the functions are returning the right output to a given input.\nIn my case, however, we need to test that the program is modifying its environment correctly. Here's what I've come up with:\n1) Create the \"original\" file in a standard location, perhaps \/tmp.\n2) Run the function that modifies the file, passing it the path to the file in \/tmp.\n3) Verify that the file in \/tmp was changed correctly; pass\/fail unit test accordingly.\nThis seems kludgy to me. (Gets even kludgier if you want to verify that backup copies of the file are created properly, etc.) Has anyone come up with a better way?","AnswerCount":6,"Available Count":3,"Score":0.0665680765,"is_accepted":false,"ViewCount":4799,"Q_Id":106766,"Users Score":2,"Answer":"When I touch files in my code, I tend to prefer to mock the actual reading and writing of the file... so then I can give my classes exact contents I want in the test, and then assert that the test is writing back the contents I expect.\nI've done this in Java, and I imagine it is quite simple in Python... but it may require designing your classes\/functions in such a way that it is EASY to mock the use of an actual file.\nFor this, you can try passing in streams and then just pass in a simple string input\/output stream which won't write to a file, or have a function that does the actual \"write this string to a file\" or \"read this string from a file\", and then replace that function in your tests.","Q_Score":23,"Tags":"python,linux,unit-testing","A_Id":106772,"CreationDate":"2008-09-20T01:56:00.000","Title":"Unit Testing File Modifications","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"A common task in programs I've been working on lately is modifying a text file in some way. (Hey, I'm on Linux. Everything's a file. And I do large-scale system admin.)\nBut the file the code modifies may not exist on my desktop box. And I probably don't want to modify it if it IS on my desktop.\nI've read about unit testing in Dive Into Python, and it's pretty clear what I want to do when testing an app that converts decimal to Roman Numerals (the example in DintoP). The testing is nicely self-contained. You don't need to verify that the program PRINTS the right thing, you just need to verify that the functions are returning the right output to a given input.\nIn my case, however, we need to test that the program is modifying its environment correctly. Here's what I've come up with:\n1) Create the \"original\" file in a standard location, perhaps \/tmp.\n2) Run the function that modifies the file, passing it the path to the file in \/tmp.\n3) Verify that the file in \/tmp was changed correctly; pass\/fail unit test accordingly.\nThis seems kludgy to me. (Gets even kludgier if you want to verify that backup copies of the file are created properly, etc.) Has anyone come up with a better way?","AnswerCount":6,"Available Count":3,"Score":0.0333209931,"is_accepted":false,"ViewCount":4799,"Q_Id":106766,"Users Score":1,"Answer":"You might want to setup the test so that it runs inside a chroot jail, so you have all the environment the test needs, even if paths and file locations are hardcoded in the code [not really a good practice, but sometimes one gets the file locations from other places...] and then check the results via the exit code.","Q_Score":23,"Tags":"python,linux,unit-testing","A_Id":106781,"CreationDate":"2008-09-20T01:56:00.000","Title":"Unit Testing File Modifications","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"What I'm trying to do here is get the headers of a given URL so I can determine the MIME type. I want to be able to see if http:\/\/somedomain\/foo\/ will return an HTML document or a JPEG image for example. Thus, I need to figure out how to send a HEAD request so that I can read the MIME type without having to download the content. Does anyone know of an easy way of doing this?","AnswerCount":11,"Available Count":2,"Score":0.0181798149,"is_accepted":false,"ViewCount":72799,"Q_Id":107405,"Users Score":1,"Answer":"As an aside, when using the httplib (at least on 2.5.2), trying to read the response of a HEAD request will block (on readline) and subsequently fail. If you do not issue read on the response, you are unable to send another request on the connection, you will need to open a new one. Or accept a long delay between requests.","Q_Score":117,"Tags":"python,python-2.7,http,http-headers,content-type","A_Id":779985,"CreationDate":"2008-09-20T06:38:00.000","Title":"How do you send a HEAD HTTP request in Python 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},{"Question":"What I'm trying to do here is get the headers of a given URL so I can determine the MIME type. I want to be able to see if http:\/\/somedomain\/foo\/ will return an HTML document or a JPEG image for example. Thus, I need to figure out how to send a HEAD request so that I can read the MIME type without having to download the content. Does anyone know of an easy way of doing this?","AnswerCount":11,"Available Count":2,"Score":0.0181798149,"is_accepted":false,"ViewCount":72799,"Q_Id":107405,"Users Score":1,"Answer":"I have found that httplib is slightly faster than urllib2. I timed two programs - one using httplib and the other using urllib2 - sending HEAD requests to 10,000 URL's. The httplib one was faster by several minutes. httplib's total stats were: real 6m21.334s\n user 0m2.124s\n sys 0m16.372s\nAnd urllib2's total stats were: real 9m1.380s\n user 0m16.666s\n sys 0m28.565s\nDoes anybody else have input on this?","Q_Score":117,"Tags":"python,python-2.7,http,http-headers,content-type","A_Id":2630687,"CreationDate":"2008-09-20T06:38:00.000","Title":"How do you send a HEAD HTTP request in Python 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},{"Question":"Coming from a Perl 5 background, what are the advantages of moving to Perl 6 or Python?","AnswerCount":8,"Available Count":4,"Score":1.0,"is_accepted":false,"ViewCount":3114,"Q_Id":124604,"Users Score":11,"Answer":"In my opinion, Python's syntax is much cleaner, simpler, and consistent. You can define nested data structures the same everywhere, whether you plan to pass them to a function (or return them from one) or use them directly. I like Perl a lot, but as soon as I learned enough Python to \"get\" it, I never turned back.\nIn my experience, random snippets of Python tend to be more readable than random snippets of Perl. The difference really comes down to the culture around each language, where Perl users often appreciate cleverness while Python users more often prefer clarity. That's not to say you can't have clear Perl or devious Python, but those are much less common.\nBoth are fine languages and solve many of the same problems. I personally lean toward Python, if for no other reason in that it seems to be gaining momentum while Perl seems to be losing users to Python and Ruby.\nNote the abundance of weasel words in the above. Honestly, it's really going to come down to personal preference.","Q_Score":26,"Tags":"python,perl,raku","A_Id":124804,"CreationDate":"2008-09-23T23:50:00.000","Title":"I know Perl 5. What are the advantages of learning Perl 6, rather than moving 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},{"Question":"Coming from a Perl 5 background, what are the advantages of moving to Perl 6 or Python?","AnswerCount":8,"Available Count":4,"Score":1.0,"is_accepted":false,"ViewCount":3114,"Q_Id":124604,"Users Score":25,"Answer":"There is no advantage to be gained by switching from Perl to Python. There is also no advantage to be gained by switching from Python to Perl. They are both equally capable. Choose your tools based on what you know and the problem you are trying to solve rather than on some sort of notion that one is somehow inherently better than the other.\nThe only real advantage is if you are switching from a language you don't know to a language you do know, in which case your productivity will likely go up.","Q_Score":26,"Tags":"python,perl,raku","A_Id":124797,"CreationDate":"2008-09-23T23:50:00.000","Title":"I know Perl 5. What are the advantages of learning Perl 6, rather than moving 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},{"Question":"Coming from a Perl 5 background, what are the advantages of moving to Perl 6 or Python?","AnswerCount":8,"Available Count":4,"Score":0.0996679946,"is_accepted":false,"ViewCount":3114,"Q_Id":124604,"Users Score":4,"Answer":"You have not said why you want to move away from Perl*. If my crystal ball is functioning today then it is because you do not fully know the language and so it frustrates you.\nStick with Perl and study the language well. If you do then one day you will be a guru and know why your question is irrelevant. Enlightment comes to those to seek it.\n\nYou called it \"Perl5\" but there is no such language. :P","Q_Score":26,"Tags":"python,perl,raku","A_Id":127627,"CreationDate":"2008-09-23T23:50:00.000","Title":"I know Perl 5. What are the advantages of learning Perl 6, rather than moving 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},{"Question":"Coming from a Perl 5 background, what are the advantages of moving to Perl 6 or Python?","AnswerCount":8,"Available Count":4,"Score":0.0996679946,"is_accepted":false,"ViewCount":3114,"Q_Id":124604,"Users Score":4,"Answer":"IMO python's regexing, esp. when you try to represent something like perl's \/e operator as in s\/whatever\/somethingelse\/e, becomes quite slow. So in doubt, you may need to stay with Perl5 :-)","Q_Score":26,"Tags":"python,perl,raku","A_Id":4294670,"CreationDate":"2008-09-23T23:50:00.000","Title":"I know Perl 5. What are the advantages of learning Perl 6, rather than moving 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},{"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},{"Question":"Are there any good packages or methods for doing extensive CRUD (create-retrieve-update-delete) interfaces in the Turbogears framework. The FastDataGrid widget is too much of a black box to be useful and CRUDTemplate looks like more trouble than rolling my own. Ideas? Suggestions?","AnswerCount":4,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1363,"Q_Id":128689,"Users Score":0,"Answer":"After doing some more digging and hacking it turns out to not be terribly hard to drop the Cakewalk interface into an application. It's not pretty without a lot of work, but it works right away.","Q_Score":3,"Tags":"python,crud,turbogears","A_Id":158626,"CreationDate":"2008-09-24T17:53:00.000","Title":"Doing CRUD in Turbogears","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I am planning on porting a PHP application over to Python. The application is mostly about data collection and processing. The main application runs as a stand alone command line application. There is a web interface to the application which is basically a very light weight reporting interface. \nI did not use a framework in the PHP version, but being new to Python, I am wondering if it would be advantageous to use something like Django or at the very least Genshi. The caveat is I do not want my application distribution to be overwhelmed by the framework parts I would need to distribute with the application. \nIs using only the cgi import in Python the best way to go in this circumstance? I would tend to think a framework is too much overhead, but perhaps I'm not thinking in a very \"python\" way about them. What suggestions do you have in this scenario?","AnswerCount":8,"Available Count":4,"Score":0.049958375,"is_accepted":false,"ViewCount":7200,"Q_Id":136069,"Users Score":2,"Answer":"Go for a framework. Basic stuffs like session handling are a nightmare if you don't use a one because Python is not web specialized like PHP.\nIf you think django is too much, you can try a lighter one like the very small but still handy web.py.","Q_Score":19,"Tags":"python,frameworks","A_Id":138888,"CreationDate":"2008-09-25T20:59:00.000","Title":"Python web development - with or 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},{"Question":"I am planning on porting a PHP application over to Python. The application is mostly about data collection and processing. The main application runs as a stand alone command line application. There is a web interface to the application which is basically a very light weight reporting interface. \nI did not use a framework in the PHP version, but being new to Python, I am wondering if it would be advantageous to use something like Django or at the very least Genshi. The caveat is I do not want my application distribution to be overwhelmed by the framework parts I would need to distribute with the application. \nIs using only the cgi import in Python the best way to go in this circumstance? I would tend to think a framework is too much overhead, but perhaps I'm not thinking in a very \"python\" way about them. What suggestions do you have in this scenario?","AnswerCount":8,"Available Count":4,"Score":0.0,"is_accepted":false,"ViewCount":7200,"Q_Id":136069,"Users Score":0,"Answer":"It depends on the way you are going to distribute your application.\nIf it will only be used internally, go for django. It's a joy to work with it.\nHowever, django really falls short at the distribution-task; django-applications are a pain to set up.","Q_Score":19,"Tags":"python,frameworks","A_Id":136166,"CreationDate":"2008-09-25T20:59:00.000","Title":"Python web development - with or 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},{"Question":"I am planning on porting a PHP application over to Python. The application is mostly about data collection and processing. The main application runs as a stand alone command line application. There is a web interface to the application which is basically a very light weight reporting interface. \nI did not use a framework in the PHP version, but being new to Python, I am wondering if it would be advantageous to use something like Django or at the very least Genshi. The caveat is I do not want my application distribution to be overwhelmed by the framework parts I would need to distribute with the application. \nIs using only the cgi import in Python the best way to go in this circumstance? I would tend to think a framework is too much overhead, but perhaps I'm not thinking in a very \"python\" way about them. What suggestions do you have in this scenario?","AnswerCount":8,"Available Count":4,"Score":0.049958375,"is_accepted":false,"ViewCount":7200,"Q_Id":136069,"Users Score":2,"Answer":"Django makes it possible to whip out a website rapidly, that's for sure. You don't need to be a Python master to use it, and since it's very pythonic in it's design, and there is not really any \"magic\" going on, it will help you learn Python along the way.\nStart with the examples, check out some django screencasts from TwiD and you'll be on your way.\nStart slow, tweaking the admin, and playing with it via shell is the way to start. Once you have a handle on the ORM and get how things work, start building the real stuff!\nThe framework isn't going to cause any performance problems, like S. Lott said, it's code you don't have to maintain, and that's the best kind.","Q_Score":19,"Tags":"python,frameworks","A_Id":136683,"CreationDate":"2008-09-25T20:59:00.000","Title":"Python web development - with or 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},{"Question":"I am planning on porting a PHP application over to Python. The application is mostly about data collection and processing. The main application runs as a stand alone command line application. There is a web interface to the application which is basically a very light weight reporting interface. \nI did not use a framework in the PHP version, but being new to Python, I am wondering if it would be advantageous to use something like Django or at the very least Genshi. The caveat is I do not want my application distribution to be overwhelmed by the framework parts I would need to distribute with the application. \nIs using only the cgi import in Python the best way to go in this circumstance? I would tend to think a framework is too much overhead, but perhaps I'm not thinking in a very \"python\" way about them. What suggestions do you have in this scenario?","AnswerCount":8,"Available Count":4,"Score":0.0996679946,"is_accepted":false,"ViewCount":7200,"Q_Id":136069,"Users Score":4,"Answer":"Depends on the size of the project. If you had only a few previous php-scripts which called your stand alone application then I'd probably go for a cgi-app.\nIf you have use for databases, url rewriting, templating, user management and such, then using a framework is a good idea.\nAnd of course, before you port it, consider if it's worth it just to switch the language or if there are specific Python features you need.\nGood luck!","Q_Score":19,"Tags":"python,frameworks","A_Id":136152,"CreationDate":"2008-09-25T20:59:00.000","Title":"Python web development - with or 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},{"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},{"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},{"Question":"Is it possible to make it appear to a system that a key was pressed, for example I need to make A key be pressed thousands of times, and it is much to time consuming to do it manually, I would like to write something to do it for me, and the only thing I know well enough is Python.\nA better way to put it, I need to emulate a key press, I.E. not capture a key press.\nMore Info (as requested):\nI am running windows XP and need to send the keys to another application.","AnswerCount":11,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":186710,"Q_Id":136734,"Users Score":0,"Answer":"You can use pyautogui module which can be used for automatically moving the mouse and for pressing a key. It can also be used for some GUI(very basic).\nYou can do the following :-\nimport pyautogui\npyautogui.press('A') # presses the 'A' key\nIf you want to do it 1000 times, then you can use a while loop\nHope this is helpful :)","Q_Score":36,"Tags":"python,keypress","A_Id":66835510,"CreationDate":"2008-09-25T22:58:00.000","Title":"Key Presses 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},{"Question":"I've added cookie support to SOAPpy by overriding HTTPTransport. I need functionality beyond that of SOAPpy, so I was planning on moving to ZSI, but I can't figure out how to put the Cookies on the ZSI posts made to the service. Without these cookies, the server will think it is an unauthorized request and it will fail.\nHow can I add cookies from a Python CookieJar to ZSI requests?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":526,"Q_Id":139212,"Users Score":0,"Answer":"Additionally, the Binding class also allows any header to be added. So I figured out that I can just add a \"Cookie\" header for each cookie I need to add. This worked well for the code generated by wsdl2py, just adding the cookies right after the binding is formed in the SOAP client class. Adding a parameter to the generated class to take in the cookies as a dictionary is easy and then they can easily be iterated through and added.","Q_Score":2,"Tags":"python,web-services,cookies,soappy,zsi","A_Id":148379,"CreationDate":"2008-09-26T12:45:00.000","Title":"Adding Cookie to ZSI Posts","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},{"Question":"I understand that IronPython is an implementation of Python on the .NET platform just like IronRuby is an implementation of Ruby and F# is more or less OCaml. \nWhat I can't seem to grasp is whether these languages perform closer to their \"ancestors\" or closer to something like C# in terms of speed. For example, is IronPython somehow \"compiled\" down to the same bytecode used by C# and, therefore, will run just as fast?","AnswerCount":4,"Available Count":3,"Score":0.049958375,"is_accepted":false,"ViewCount":1684,"Q_Id":145191,"Users Score":1,"Answer":"Currently IronRuby is pretty slow in most regards. It's definitely slower than MRI (Matz' Ruby Implementation) overall, though in some places they're faster.\nIronRuby does have the potential to be much faster, though I doubt they'll ever get near C# in terms of speed. In most cases it just doesn't matter. A database call will probably make up 90% of the overall duration of a web request, for example.\nI suspect the team will go for language-completeness rather than performance first. This will allow you to run IronRuby & run most ruby programs when 1.0 ships, then they can improve perf as they go.\nI suspect IronPython has a similar story.","Q_Score":8,"Tags":".net,performance,ironpython","A_Id":145200,"CreationDate":"2008-09-28T04:06:00.000","Title":"Dynamic .NET language 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},{"Question":"I understand that IronPython is an implementation of Python on the .NET platform just like IronRuby is an implementation of Ruby and F# is more or less OCaml. \nWhat I can't seem to grasp is whether these languages perform closer to their \"ancestors\" or closer to something like C# in terms of speed. For example, is IronPython somehow \"compiled\" down to the same bytecode used by C# and, therefore, will run just as fast?","AnswerCount":4,"Available Count":3,"Score":1.2,"is_accepted":true,"ViewCount":1684,"Q_Id":145191,"Users Score":9,"Answer":"IronPython and IronRuby are built on top of the DLR -- dynamic language runtime -- and are compiled to CIL (the bytecode used by .NET) on the fly. They're slower than C# but faaaaaaar faster than their non-.NET counterparts. There aren't any decent benchmarks out there, to my knowledge, but you'll see the difference.","Q_Score":8,"Tags":".net,performance,ironpython","A_Id":145195,"CreationDate":"2008-09-28T04:06:00.000","Title":"Dynamic .NET language 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},{"Question":"I understand that IronPython is an implementation of Python on the .NET platform just like IronRuby is an implementation of Ruby and F# is more or less OCaml. \nWhat I can't seem to grasp is whether these languages perform closer to their \"ancestors\" or closer to something like C# in terms of speed. For example, is IronPython somehow \"compiled\" down to the same bytecode used by C# and, therefore, will run just as fast?","AnswerCount":4,"Available Count":3,"Score":1.0,"is_accepted":false,"ViewCount":1684,"Q_Id":145191,"Users Score":7,"Answer":"IronPython is actually the fastest Python implementation out there. For some definition of \"fastest\", at least: the startup overhead of the CLR, for example, is huge compared to CPython. Also, the optimizing compiler IronPython has, really only makes sense, when code is executed multiple times.\nIronRuby has the potential to be as fast IronPython, since many of the interesting features that make IronPython fast, have been extracted into the Dynamic Language Runtime, on which both IronPython and IronRuby (and Managed JavaScript, Dynamic VB, IronScheme, VistaSmalltalk and others) are built.\nIn general, the speed of a language implementation is pretty much independent of the actual language features, and more dependent on the number of engineering man-years that go into it. IOW: dynamic vs. static doesn't matter, money does.\nE.g., Common Lisp is a language that is even more dynamic than Ruby or Python, and yet there are Common Lisp compilers out there that can even give C a run for its money. Good Smalltalk implementations run as fast as Java (which is no surprise, since both major JVMs, Sun HotSpot and IBM J9, are actually just slightly modified Smalltalk VMs) or C++. In just the past 6 months, the major JavaScript implementations (Mozilla TraceMonkey, Apple SquirrelFish Extreme and the new kid on the block, Google V8) have made ginormous performance improvements, 10x and more, to bring JavaScript head-to-head with un-optimized C.","Q_Score":8,"Tags":".net,performance,ironpython","A_Id":145300,"CreationDate":"2008-09-28T04:06:00.000","Title":"Dynamic .NET language 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},{"Question":"I have Eclipse setup with PyDev and love being able to debug my scripts\/apps. I've just started playing around with Pylons and was wondering if there is a way to start up the paster server through Eclipse so I can debug my webapp?","AnswerCount":7,"Available Count":4,"Score":1.2,"is_accepted":true,"ViewCount":5139,"Q_Id":147650,"Users Score":10,"Answer":"Create a new launch configuration (Python Run)\nMain tab\nUse paster-script.py as main module (you can find it in the Scripts sub-directory in your python installation directory)\nDon't forget to add the root folder of your application in the PYTHONPATH zone\nArguments\nSet the base directory to the root folder also.\nAs Program Arguments use \"serve development.ini\" (or whatever you use to debug your app\")\nCommon Tab\nCheck allocate console and launch in background","Q_Score":11,"Tags":"python,eclipse,pylons,pydev,pyramid","A_Id":147768,"CreationDate":"2008-09-29T05:41:00.000","Title":"Debug Pylons application through 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":1,"Web Development":1},{"Question":"I have Eclipse setup with PyDev and love being able to debug my scripts\/apps. I've just started playing around with Pylons and was wondering if there is a way to start up the paster server through Eclipse so I can debug my webapp?","AnswerCount":7,"Available Count":4,"Score":0.057080742,"is_accepted":false,"ViewCount":5139,"Q_Id":147650,"Users Score":2,"Answer":"I was able to get --reload working by changing the 'Working directory' in the arguments tab to not use default (i.e. select 'Other'->File System->'Root of your Pylons' app where development.ini is stored.","Q_Score":11,"Tags":"python,eclipse,pylons,pydev,pyramid","A_Id":3817880,"CreationDate":"2008-09-29T05:41:00.000","Title":"Debug Pylons application through 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":1,"Web Development":1},{"Question":"I have Eclipse setup with PyDev and love being able to debug my scripts\/apps. I've just started playing around with Pylons and was wondering if there is a way to start up the paster server through Eclipse so I can debug my webapp?","AnswerCount":7,"Available Count":4,"Score":0.0285636566,"is_accepted":false,"ViewCount":5139,"Q_Id":147650,"Users Score":1,"Answer":"On linux that will probably be \/usr\/bin\/paster or \/usr\/local\/bin\/paster for paste script, and for arguments i have: serve ${workspace_loc}${project_path}\/development.ini","Q_Score":11,"Tags":"python,eclipse,pylons,pydev,pyramid","A_Id":2958194,"CreationDate":"2008-09-29T05:41:00.000","Title":"Debug Pylons application through 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":1,"Web Development":1},{"Question":"I have Eclipse setup with PyDev and love being able to debug my scripts\/apps. I've just started playing around with Pylons and was wondering if there is a way to start up the paster server through Eclipse so I can debug my webapp?","AnswerCount":7,"Available Count":4,"Score":0.057080742,"is_accepted":false,"ViewCount":5139,"Q_Id":147650,"Users Score":2,"Answer":"yanjost has it right, just wanted to add that you need to make sure you do not use the --reload option, this will prevent the debugger from properly attaching itself and cause your breakpoints not to work. Just a little thing I ran in to.","Q_Score":11,"Tags":"python,eclipse,pylons,pydev,pyramid","A_Id":1306122,"CreationDate":"2008-09-29T05:41:00.000","Title":"Debug Pylons application through 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":1,"Web Development":1},{"Question":"How do I check if an object is of a given type, or if it inherits from a given type?\nHow do I check if the object o is of type str?","AnswerCount":14,"Available Count":2,"Score":1.0,"is_accepted":false,"ViewCount":1190669,"Q_Id":152580,"Users Score":70,"Answer":"isinstance(o, str) will return True if o is an str or is of a type that inherits from str.\ntype(o) is str will return True if and only if o is a str. It will return False if o is of a type that inherits from str.","Q_Score":1624,"Tags":"python,types","A_Id":152592,"CreationDate":"2008-09-30T11:00:00.000","Title":"What's the canonical way to check for type 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},{"Question":"How do I check if an object is of a given type, or if it inherits from a given type?\nHow do I check if the object o is of type str?","AnswerCount":14,"Available Count":2,"Score":1.0,"is_accepted":false,"ViewCount":1190669,"Q_Id":152580,"Users Score":7,"Answer":"I think the cool thing about using a dynamic language like Python is you really shouldn't have to check something like that.\nI would just call the required methods on your object and catch an AttributeError. Later on this will allow you to call your methods with other (seemingly unrelated) objects to accomplish different tasks, such as mocking an object for testing.\nI've used this a lot when getting data off the web with urllib2.urlopen() which returns a file like object. This can in turn can be passed to almost any method that reads from a file, because it implements the same read() method as a real file.\nBut I'm sure there is a time and place for using isinstance(), otherwise it probably wouldn't be there :)","Q_Score":1624,"Tags":"python,types","A_Id":153032,"CreationDate":"2008-09-30T11:00:00.000","Title":"What's the canonical way to check for type 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},{"Question":"I have a Python script I recently wrote that I call using the command line with some options. I now want a very thin web interface to call this script locally on my Mac.\nI don't want to go through the minor trouble of installing mod_python or mod_wsgi on my Mac, so I was just going to do a system() or popen() from PHP to call the Python script.\nAny better ideas? Thanks in advance!","AnswerCount":9,"Available Count":2,"Score":1.0,"is_accepted":false,"ViewCount":180160,"Q_Id":166944,"Users Score":7,"Answer":"I do this kind of thing all the time for quick-and-dirty scripts. It's quite common to have a CGI or PHP script that just uses system\/popen to call some external program.\nJust be extra careful if your web server is open to the internet at large. Be sure to sanitize your GET\/POST input in this case so as to not allow attackers to run arbitrary commands on your machine.","Q_Score":85,"Tags":"php,python","A_Id":167205,"CreationDate":"2008-10-03T13:44:00.000","Title":"Calling Python 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":1,"Web Development":0},{"Question":"I have a Python script I recently wrote that I call using the command line with some options. I now want a very thin web interface to call this script locally on my Mac.\nI don't want to go through the minor trouble of installing mod_python or mod_wsgi on my Mac, so I was just going to do a system() or popen() from PHP to call the Python script.\nAny better ideas? Thanks in advance!","AnswerCount":9,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":180160,"Q_Id":166944,"Users Score":0,"Answer":"Note that if you are using a virtual environment (as in shared hosting) then you must adjust your path to python, e.g: \/home\/user\/mypython\/bin\/python .\/cgi-bin\/test.py","Q_Score":85,"Tags":"php,python","A_Id":45592623,"CreationDate":"2008-10-03T13:44:00.000","Title":"Calling Python 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":1,"Web Development":0},{"Question":"On a question of just performance, how does Python 3 compare to Python 2.x?","AnswerCount":6,"Available Count":4,"Score":0.0,"is_accepted":false,"ViewCount":10338,"Q_Id":170426,"Users Score":0,"Answer":"I don't if it faster now, but I have to expect that it eventually will be because that is where new performance work will happen and not all of that will be backported.","Q_Score":24,"Tags":"python,performance,python-3.x,python-2.x","A_Id":170568,"CreationDate":"2008-10-04T14:28:00.000","Title":"Performance: Python 3.x vs Python 2.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":0,"Web Development":0},{"Question":"On a question of just performance, how does Python 3 compare to Python 2.x?","AnswerCount":6,"Available Count":4,"Score":0.0996679946,"is_accepted":false,"ViewCount":10338,"Q_Id":170426,"Users Score":3,"Answer":"Unless there are plans for a new VM of some kind (and I haven't heard of any such plans), there is all the reason to believe that in the long run the performance of Py3K will, at least asymptotically, equal that of 2.5\nIt may take a few months, but will eventually happen, as nothing in the new features of Py3k is inherently less performant. \nTo conclude, I don't think there's place to worry about it. Neither to hope for a major improvement of some kind.","Q_Score":24,"Tags":"python,performance,python-3.x,python-2.x","A_Id":170797,"CreationDate":"2008-10-04T14:28:00.000","Title":"Performance: Python 3.x vs Python 2.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":0,"Web Development":0},{"Question":"On a question of just performance, how does Python 3 compare to Python 2.x?","AnswerCount":6,"Available Count":4,"Score":0.1325487884,"is_accepted":false,"ViewCount":10338,"Q_Id":170426,"Users Score":4,"Answer":"I think ultimately it is too early to make that kind of comparison just yet. Wait until it is out of beta before benchmarking it. The interpreter will probably be polished enormously before the release but overall i think for most uses the performance would be comparable and if you are running a really speed conscious app is python really the right language to be using?","Q_Score":24,"Tags":"python,performance,python-3.x,python-2.x","A_Id":170805,"CreationDate":"2008-10-04T14:28:00.000","Title":"Performance: Python 3.x vs Python 2.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":0,"Web Development":0},{"Question":"On a question of just performance, how does Python 3 compare to Python 2.x?","AnswerCount":6,"Available Count":4,"Score":1.0,"is_accepted":false,"ViewCount":10338,"Q_Id":170426,"Users Score":7,"Answer":"I'd say any difference will be below trivial. For example, looping over a list will be the exact same.\nThe idea behind Python 3 is to clean up the language syntax itself - remove ambigious stuff like except Exception1, Exception2, cleanup the standard modules (no urllib, urllib2, httplib etc).\nThere really isn't much you can do to improve it's performance, although I imagine stuff like the garbage collection and memory management code will have had some tweaks, but it's not going to be a \"wow, my database statistic generation code completes in half the time!\" improvement - that's something you get by improving the code, rather than the language!\nReally, performance of the language is irrelevant - all interpreted languages basically function at the same speed.\nWhy I find Python \"faster\" is all the built-in moudles, and the nice-to-write syntax - something that has been improved in Python3, so I guess in those terms, yes, python3's performance is better then python2.x..","Q_Score":24,"Tags":"python,performance,python-3.x,python-2.x","A_Id":170521,"CreationDate":"2008-10-04T14:28:00.000","Title":"Performance: Python 3.x vs Python 2.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":0,"Web Development":0},{"Question":"Has anyone ever heard of a UNIX shell written in a reasonable language, like Python?","AnswerCount":7,"Available Count":3,"Score":0.1418931938,"is_accepted":false,"ViewCount":3377,"Q_Id":171267,"Users Score":5,"Answer":"Well, there's emacs, which is arguably a shell written in lisp :)\nSeriously though, are you looking for a reimplementation of an existing shell design in a different language such as Python? Or are you looking for a new implementation of a shell language that looks similar to your language of choice?","Q_Score":9,"Tags":"python,unix,shell","A_Id":171271,"CreationDate":"2008-10-05T00:42:00.000","Title":"UNIX shell written in a reasonable 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":1,"Web Development":0},{"Question":"Has anyone ever heard of a UNIX shell written in a reasonable language, like Python?","AnswerCount":7,"Available Count":3,"Score":1.0,"is_accepted":false,"ViewCount":3377,"Q_Id":171267,"Users Score":6,"Answer":"From all appearances, Python IS a shell. It runs with #! and it can run interactively. Between the os and shutil packages you have all of the features of standard Unix shells.\nSince you can do anything in Python with simple, powerful scripts, you don't really need to spend any time messing with the other shells.","Q_Score":9,"Tags":"python,unix,shell","A_Id":171304,"CreationDate":"2008-10-05T00:42:00.000","Title":"UNIX shell written in a reasonable 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":1,"Web Development":0},{"Question":"Has anyone ever heard of a UNIX shell written in a reasonable language, like Python?","AnswerCount":7,"Available Count":3,"Score":0.0855049882,"is_accepted":false,"ViewCount":3377,"Q_Id":171267,"Users Score":3,"Answer":"Tclsh is pretty nice (assuming you like Tcl, of course).","Q_Score":9,"Tags":"python,unix,shell","A_Id":171290,"CreationDate":"2008-10-05T00:42:00.000","Title":"UNIX shell written in a reasonable 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":1,"Web Development":0},{"Question":"This is really two questions, but they are so similar, and to keep it simple, I figured I'd just roll them together:\n\nFirstly: Given an established python project, what are some decent ways to speed it up beyond just plain in-code optimization?\nSecondly: When writing a program from scratch in python, what are some good ways to greatly improve performance?\n\nFor the first question, imagine you are handed a decently written project and you need to improve performance, but you can't seem to get much of a gain through refactoring\/optimization. What would you do to speed it up in this case short of rewriting it in something like C?","AnswerCount":19,"Available Count":7,"Score":0.0315684544,"is_accepted":false,"ViewCount":22486,"Q_Id":172720,"Users Score":3,"Answer":"Just a note on using psyco: In some cases it can actually produce slower run-times. Especially when trying to use psyco with code that was written in C. I can't remember the the article I read this, but the map() and reduce() functions were mentioned specifically. Luckily you can tell psyco not to handle specified functions and\/or modules.","Q_Score":46,"Tags":"python,optimization,performance","A_Id":172782,"CreationDate":"2008-10-05T21:46:00.000","Title":"Speeding Up 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},{"Question":"This is really two questions, but they are so similar, and to keep it simple, I figured I'd just roll them together:\n\nFirstly: Given an established python project, what are some decent ways to speed it up beyond just plain in-code optimization?\nSecondly: When writing a program from scratch in python, what are some good ways to greatly improve performance?\n\nFor the first question, imagine you are handed a decently written project and you need to improve performance, but you can't seem to get much of a gain through refactoring\/optimization. What would you do to speed it up in this case short of rewriting it in something like C?","AnswerCount":19,"Available Count":7,"Score":0.0420803986,"is_accepted":false,"ViewCount":22486,"Q_Id":172720,"Users Score":4,"Answer":"Run your app through the Python profiler.\nFind a serious bottleneck.\nRewrite that bottleneck in C.\nRepeat.","Q_Score":46,"Tags":"python,optimization,performance","A_Id":172737,"CreationDate":"2008-10-05T21:46:00.000","Title":"Speeding Up 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},{"Question":"This is really two questions, but they are so similar, and to keep it simple, I figured I'd just roll them together:\n\nFirstly: Given an established python project, what are some decent ways to speed it up beyond just plain in-code optimization?\nSecondly: When writing a program from scratch in python, what are some good ways to greatly improve performance?\n\nFor the first question, imagine you are handed a decently written project and you need to improve performance, but you can't seem to get much of a gain through refactoring\/optimization. What would you do to speed it up in this case short of rewriting it in something like C?","AnswerCount":19,"Available Count":7,"Score":0.0420803986,"is_accepted":false,"ViewCount":22486,"Q_Id":172720,"Users Score":4,"Answer":"People have given some good advice, but you have to be aware that when high performance is needed, the python model is: punt to c. Efforts like psyco may in the future help a bit, but python just isn't a fast language, and it isn't designed to be. Very few languages have the ability to do the dynamic stuff really well and still generate very fast code; at least for the forseeable future (and some of the design works against fast compilation) that will be the case.\nSo, if you really find yourself in this bind, your best bet will be to isolate the parts of your system that are unacceptable slow in (good) python, and design around the idea that you'll rewrite those bits in C. Sorry. Good design can help make this less painful. Prototype it in python first though, then you've easily got a sanity check on your c, as well.\nThis works well enough for things like numpy, after all. I can't emphasize enough how much good design will help you though. If you just iteratively poke at your python bits and replace the slowest ones with C, you may end up with a big mess. Think about exactly where the C bits are needed, and how they can be minimized and encapsulated sensibly.","Q_Score":46,"Tags":"python,optimization,performance","A_Id":172766,"CreationDate":"2008-10-05T21:46:00.000","Title":"Speeding Up 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},{"Question":"This is really two questions, but they are so similar, and to keep it simple, I figured I'd just roll them together:\n\nFirstly: Given an established python project, what are some decent ways to speed it up beyond just plain in-code optimization?\nSecondly: When writing a program from scratch in python, what are some good ways to greatly improve performance?\n\nFor the first question, imagine you are handed a decently written project and you need to improve performance, but you can't seem to get much of a gain through refactoring\/optimization. What would you do to speed it up in this case short of rewriting it in something like C?","AnswerCount":19,"Available Count":7,"Score":1.0,"is_accepted":false,"ViewCount":22486,"Q_Id":172720,"Users Score":28,"Answer":"Rather than just punting to C, I'd suggest:\nMake your code count. Do more with fewer executions of lines:\n\nChange the algorithm to a faster one. It doesn't need to be fancy to be faster in many cases.\nUse python primitives that happens to be written in C. Some things will force an interpreter dispatch where some wont. The latter is preferable\nBeware of code that first constructs a big data structure followed by its consumation. Think the difference between range and xrange. In general it is often worth thinking about memory usage of the program. Using generators can sometimes bring O(n) memory use down to O(1).\nPython is generally non-optimizing. Hoist invariant code out of loops, eliminate common subexpressions where possible in tight loops.\nIf something is expensive, then precompute or memoize it. Regular expressions can be compiled for instance.\nNeed to crunch numbers? You might want to check numpy out.\nMany python programs are slow because they are bound by disk I\/O or database access. Make sure you have something worthwhile to do while you wait on the data to arrive rather than just blocking. A weapon could be something like the Twisted framework.\nNote that many crucial data-processing libraries have C-versions, be it XML, JSON or whatnot. They are often considerably faster than the Python interpreter.\n\nIf all of the above fails for profiled and measured code, then begin thinking about the C-rewrite path.","Q_Score":46,"Tags":"python,optimization,performance","A_Id":173055,"CreationDate":"2008-10-05T21:46:00.000","Title":"Speeding Up 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},{"Question":"This is really two questions, but they are so similar, and to keep it simple, I figured I'd just roll them together:\n\nFirstly: Given an established python project, what are some decent ways to speed it up beyond just plain in-code optimization?\nSecondly: When writing a program from scratch in python, what are some good ways to greatly improve performance?\n\nFor the first question, imagine you are handed a decently written project and you need to improve performance, but you can't seem to get much of a gain through refactoring\/optimization. What would you do to speed it up in this case short of rewriting it in something like C?","AnswerCount":19,"Available Count":7,"Score":0.010525927,"is_accepted":false,"ViewCount":22486,"Q_Id":172720,"Users Score":1,"Answer":"If using psyco, I'd recommend psyco.profile() instead of psyco.full(). For a larger project it will be smarter about the functions that got optimized and use a ton less memory.\nI would also recommend looking at iterators and generators. If your application is using large data sets this will save you many copies of containers.","Q_Score":46,"Tags":"python,optimization,performance","A_Id":175283,"CreationDate":"2008-10-05T21:46:00.000","Title":"Speeding Up 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},{"Question":"This is really two questions, but they are so similar, and to keep it simple, I figured I'd just roll them together:\n\nFirstly: Given an established python project, what are some decent ways to speed it up beyond just plain in-code optimization?\nSecondly: When writing a program from scratch in python, what are some good ways to greatly improve performance?\n\nFor the first question, imagine you are handed a decently written project and you need to improve performance, but you can't seem to get much of a gain through refactoring\/optimization. What would you do to speed it up in this case short of rewriting it in something like C?","AnswerCount":19,"Available Count":7,"Score":1.0,"is_accepted":false,"ViewCount":22486,"Q_Id":172720,"Users Score":9,"Answer":"Cython and pyrex can be used to generate c code using a python-like syntax. Psyco is also fantastic for appropriate projects (sometimes you'll not notice much speed boost, sometimes it'll be as much as 50x as fast).\nI still reckon the best way is to profile your code (cProfile, etc.) and then just code the bottlenecks as c functions for python.","Q_Score":46,"Tags":"python,optimization,performance","A_Id":172740,"CreationDate":"2008-10-05T21:46:00.000","Title":"Speeding Up 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},{"Question":"This is really two questions, but they are so similar, and to keep it simple, I figured I'd just roll them together:\n\nFirstly: Given an established python project, what are some decent ways to speed it up beyond just plain in-code optimization?\nSecondly: When writing a program from scratch in python, what are some good ways to greatly improve performance?\n\nFor the first question, imagine you are handed a decently written project and you need to improve performance, but you can't seem to get much of a gain through refactoring\/optimization. What would you do to speed it up in this case short of rewriting it in something like C?","AnswerCount":19,"Available Count":7,"Score":0.0315684544,"is_accepted":false,"ViewCount":22486,"Q_Id":172720,"Users Score":3,"Answer":"This is the procedure that I try to follow:\n\n import psyco; psyco.full()\n If it's not fast enough, run the code through a profiler, see where the bottlenecks are. (DISABLE psyco for this step!)\n Try to do things such as other people have mentioned to get the code at those bottlenecks as fast as possible.\n Stuff like [str(x) for x in l] or [x.strip() for x in l] is much, much slower than map(str, x) or map(str.strip, x). \n After this, if I still need more speed, it's actually really easy to get PyRex up and running. I first copy a section of python code, put it directly in the pyrex code, and see what happens. Then I twiddle with it until it gets faster and faster.","Q_Score":46,"Tags":"python,optimization,performance","A_Id":172991,"CreationDate":"2008-10-05T21:46:00.000","Title":"Speeding Up 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},{"Question":"I know I'll get a thousand \"Depends on what you're trying to do\" answers, but seriously, there really is no solid information about this online yet. Here are my assumptions - I think they're similar for alot of people right now:\n\nIt is now October 2008. I want to start writing an application for January 2009. I am willing to use beta code and such but by January, I'd like a site that doesn't have 'strange' problems. With that said, if a language is simply 10% slower than another, I don't care about those things as long as the issue is linear. My main concern is developer productivity.\nI'll be using Linux, Apache, MySQL for the application.\nI want the power to do things like run scp and ftp client functions with stable libraries (I only picked those two because they're not web-related but at the same time represent pretty common network protocols that any larger app might use). Technologies like OpenID and Oauth will be used as well.\nExperienced web developers are readily available (i.e. I don't have to find people from financial companies and such).\nWhatever the choice is is common and will be around for a while.\nHere's a kicker. I'd like to be able to use advanced presentation layer tools\/languages similar to HAML, SASS. I definitively want to use JQuery.\nI will be creating a Facebook app and at some point doing things like dealing with SMS messages, iPhone apps, etc...\n\nAt this point, the choices for language are PHP (Cake,Symfony,Zend), Python (Django), Ruby (Merb). I'm really between Django and Merb at this point mostly because everybody else seems to be going that way. \nPlease don't put any technologies in here that aren't made for mainstream. I know Merb is untested mostly, but their stated goal is a solid platform and it has alot of momentum behind it so I'm confident that it's workable. Please don't answer with how great Perl is or .Net.\nFor Future References - these choices were already made:\n\nDebian (Lenny) - For converting CPU cycles into something useful. Trac\n0.11 - For Project Management Gliffy - For wireframes and such \nGoogle Docs\/Apps - For documentation, hosted email, etc... \nAmazon ec2\/S3 - For hosting, storage.\n\nCheers,\nAdam","AnswerCount":13,"Available Count":9,"Score":1.0,"is_accepted":false,"ViewCount":959,"Q_Id":184049,"Users Score":7,"Answer":"All of them will get the job done.\nUse the one that you and your team are most familiar with\nThis will have a far greater impact on the delivery times and stability of your app than any of the other variables.","Q_Score":2,"Tags":"python,ruby-on-rails,django,merb","A_Id":188971,"CreationDate":"2008-10-08T18:07:00.000","Title":"Framework\/Language for new web 2.0 sites (2008 and 2009)","Data Science and Machine Learning":0,"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},{"Question":"I know I'll get a thousand \"Depends on what you're trying to do\" answers, but seriously, there really is no solid information about this online yet. Here are my assumptions - I think they're similar for alot of people right now:\n\nIt is now October 2008. I want to start writing an application for January 2009. I am willing to use beta code and such but by January, I'd like a site that doesn't have 'strange' problems. With that said, if a language is simply 10% slower than another, I don't care about those things as long as the issue is linear. My main concern is developer productivity.\nI'll be using Linux, Apache, MySQL for the application.\nI want the power to do things like run scp and ftp client functions with stable libraries (I only picked those two because they're not web-related but at the same time represent pretty common network protocols that any larger app might use). Technologies like OpenID and Oauth will be used as well.\nExperienced web developers are readily available (i.e. I don't have to find people from financial companies and such).\nWhatever the choice is is common and will be around for a while.\nHere's a kicker. I'd like to be able to use advanced presentation layer tools\/languages similar to HAML, SASS. I definitively want to use JQuery.\nI will be creating a Facebook app and at some point doing things like dealing with SMS messages, iPhone apps, etc...\n\nAt this point, the choices for language are PHP (Cake,Symfony,Zend), Python (Django), Ruby (Merb). I'm really between Django and Merb at this point mostly because everybody else seems to be going that way. \nPlease don't put any technologies in here that aren't made for mainstream. I know Merb is untested mostly, but their stated goal is a solid platform and it has alot of momentum behind it so I'm confident that it's workable. Please don't answer with how great Perl is or .Net.\nFor Future References - these choices were already made:\n\nDebian (Lenny) - For converting CPU cycles into something useful. Trac\n0.11 - For Project Management Gliffy - For wireframes and such \nGoogle Docs\/Apps - For documentation, hosted email, etc... \nAmazon ec2\/S3 - For hosting, storage.\n\nCheers,\nAdam","AnswerCount":13,"Available Count":9,"Score":1.0,"is_accepted":false,"ViewCount":959,"Q_Id":184049,"Users Score":9,"Answer":"Sorry, but your question is wrong. People are probably going to vote me down for this one but I want to say it anyway:\nI wouldn't expect to get an objective answer! Why? That's simple:\n\nAll Ruby advocates will tell to use Ruby.\nAll Python advocates will tell to use Python.\nAll PHP advocates will tell to use PHP.\nInsert additional languages here.\n\nGot the idea?\nI recommend you to try each of the languages you mentioned for yourself. At least a few days each. Afterwards you should have a much better foundation to make your final decision.\nThat said, I would choose Ruby (because I am a Ruby advocate).","Q_Score":2,"Tags":"python,ruby-on-rails,django,merb","A_Id":184278,"CreationDate":"2008-10-08T18:07:00.000","Title":"Framework\/Language for new web 2.0 sites (2008 and 2009)","Data Science and Machine Learning":0,"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},{"Question":"I know I'll get a thousand \"Depends on what you're trying to do\" answers, but seriously, there really is no solid information about this online yet. Here are my assumptions - I think they're similar for alot of people right now:\n\nIt is now October 2008. I want to start writing an application for January 2009. I am willing to use beta code and such but by January, I'd like a site that doesn't have 'strange' problems. With that said, if a language is simply 10% slower than another, I don't care about those things as long as the issue is linear. My main concern is developer productivity.\nI'll be using Linux, Apache, MySQL for the application.\nI want the power to do things like run scp and ftp client functions with stable libraries (I only picked those two because they're not web-related but at the same time represent pretty common network protocols that any larger app might use). Technologies like OpenID and Oauth will be used as well.\nExperienced web developers are readily available (i.e. I don't have to find people from financial companies and such).\nWhatever the choice is is common and will be around for a while.\nHere's a kicker. I'd like to be able to use advanced presentation layer tools\/languages similar to HAML, SASS. I definitively want to use JQuery.\nI will be creating a Facebook app and at some point doing things like dealing with SMS messages, iPhone apps, etc...\n\nAt this point, the choices for language are PHP (Cake,Symfony,Zend), Python (Django), Ruby (Merb). I'm really between Django and Merb at this point mostly because everybody else seems to be going that way. \nPlease don't put any technologies in here that aren't made for mainstream. I know Merb is untested mostly, but their stated goal is a solid platform and it has alot of momentum behind it so I'm confident that it's workable. Please don't answer with how great Perl is or .Net.\nFor Future References - these choices were already made:\n\nDebian (Lenny) - For converting CPU cycles into something useful. Trac\n0.11 - For Project Management Gliffy - For wireframes and such \nGoogle Docs\/Apps - For documentation, hosted email, etc... \nAmazon ec2\/S3 - For hosting, storage.\n\nCheers,\nAdam","AnswerCount":13,"Available Count":9,"Score":0.0153834017,"is_accepted":false,"ViewCount":959,"Q_Id":184049,"Users Score":1,"Answer":"Don't get stuck in the mindset of server-side page layout. Consider technologies like SproutCore, GWT or ExtJS which put the layouting code fully on the client, making the server responsible only for data marshalling and processing (and easily replaced).\nAnd you really, really need to know which server platform you want. Don't pick one because it's the flavor of the month, pick one because you're comfortable with it. Flavors don't last, a solidly built codebase will.","Q_Score":2,"Tags":"python,ruby-on-rails,django,merb","A_Id":189236,"CreationDate":"2008-10-08T18:07:00.000","Title":"Framework\/Language for new web 2.0 sites (2008 and 2009)","Data Science and Machine Learning":0,"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},{"Question":"I know I'll get a thousand \"Depends on what you're trying to do\" answers, but seriously, there really is no solid information about this online yet. Here are my assumptions - I think they're similar for alot of people right now:\n\nIt is now October 2008. I want to start writing an application for January 2009. I am willing to use beta code and such but by January, I'd like a site that doesn't have 'strange' problems. With that said, if a language is simply 10% slower than another, I don't care about those things as long as the issue is linear. My main concern is developer productivity.\nI'll be using Linux, Apache, MySQL for the application.\nI want the power to do things like run scp and ftp client functions with stable libraries (I only picked those two because they're not web-related but at the same time represent pretty common network protocols that any larger app might use). Technologies like OpenID and Oauth will be used as well.\nExperienced web developers are readily available (i.e. I don't have to find people from financial companies and such).\nWhatever the choice is is common and will be around for a while.\nHere's a kicker. I'd like to be able to use advanced presentation layer tools\/languages similar to HAML, SASS. I definitively want to use JQuery.\nI will be creating a Facebook app and at some point doing things like dealing with SMS messages, iPhone apps, etc...\n\nAt this point, the choices for language are PHP (Cake,Symfony,Zend), Python (Django), Ruby (Merb). I'm really between Django and Merb at this point mostly because everybody else seems to be going that way. \nPlease don't put any technologies in here that aren't made for mainstream. I know Merb is untested mostly, but their stated goal is a solid platform and it has alot of momentum behind it so I'm confident that it's workable. Please don't answer with how great Perl is or .Net.\nFor Future References - these choices were already made:\n\nDebian (Lenny) - For converting CPU cycles into something useful. Trac\n0.11 - For Project Management Gliffy - For wireframes and such \nGoogle Docs\/Apps - For documentation, hosted email, etc... \nAmazon ec2\/S3 - For hosting, storage.\n\nCheers,\nAdam","AnswerCount":13,"Available Count":9,"Score":1.2,"is_accepted":true,"ViewCount":959,"Q_Id":184049,"Users Score":5,"Answer":"it depends.\nphp - symfony is a great framework. downsides: php, wordy and directory heavy. propel gets annoying to use. upsides: php is everywhere and labor is cheap. well done framework, and good support. lots of plugins to make your life easier\npython - django is also a great framework. downsides: python programmers can be harder to find, django even harder. changing your db schema can be somewhat difficult since there are no official migrations. doesn't quite do mvc like you'd expect. upsides: does everything you need and has the great python std library and community behind it.\nruby - i've never used merb, so I'll address rails. upsides: there is a plugin, gem, or recipe for almost anything you could want to do. easy to use. downsides: those plugins, gems, and recipes sometimes fail to work in mysterious ways. monkey patching is often evil. the community is.. vocal. opinionated software, and sometimes those opinions are wrong (lack of foreign keys). rails itself seems like a tower of cards waiting to explode and take hours of your life away.\nwith all of that said, I'm a freelance php\/symfony and ruby\/rails developer. I've worked on several projects in both languages and frameworks. My latest project is in Rails solely because of ActiveMerchant. I've been looking for a reason to develop a django app for a while. If there were an ActiveMerchant like library for django, I probably would have used it.","Q_Score":2,"Tags":"python,ruby-on-rails,django,merb","A_Id":184376,"CreationDate":"2008-10-08T18:07:00.000","Title":"Framework\/Language for new web 2.0 sites (2008 and 2009)","Data Science and Machine Learning":0,"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},{"Question":"I know I'll get a thousand \"Depends on what you're trying to do\" answers, but seriously, there really is no solid information about this online yet. Here are my assumptions - I think they're similar for alot of people right now:\n\nIt is now October 2008. I want to start writing an application for January 2009. I am willing to use beta code and such but by January, I'd like a site that doesn't have 'strange' problems. With that said, if a language is simply 10% slower than another, I don't care about those things as long as the issue is linear. My main concern is developer productivity.\nI'll be using Linux, Apache, MySQL for the application.\nI want the power to do things like run scp and ftp client functions with stable libraries (I only picked those two because they're not web-related but at the same time represent pretty common network protocols that any larger app might use). Technologies like OpenID and Oauth will be used as well.\nExperienced web developers are readily available (i.e. I don't have to find people from financial companies and such).\nWhatever the choice is is common and will be around for a while.\nHere's a kicker. I'd like to be able to use advanced presentation layer tools\/languages similar to HAML, SASS. I definitively want to use JQuery.\nI will be creating a Facebook app and at some point doing things like dealing with SMS messages, iPhone apps, etc...\n\nAt this point, the choices for language are PHP (Cake,Symfony,Zend), Python (Django), Ruby (Merb). I'm really between Django and Merb at this point mostly because everybody else seems to be going that way. \nPlease don't put any technologies in here that aren't made for mainstream. I know Merb is untested mostly, but their stated goal is a solid platform and it has alot of momentum behind it so I'm confident that it's workable. Please don't answer with how great Perl is or .Net.\nFor Future References - these choices were already made:\n\nDebian (Lenny) - For converting CPU cycles into something useful. Trac\n0.11 - For Project Management Gliffy - For wireframes and such \nGoogle Docs\/Apps - For documentation, hosted email, etc... \nAmazon ec2\/S3 - For hosting, storage.\n\nCheers,\nAdam","AnswerCount":13,"Available Count":9,"Score":0.0,"is_accepted":false,"ViewCount":959,"Q_Id":184049,"Users Score":0,"Answer":"My experience with various new technologies over the last ten years leads me to recommend that you make stability of the platform a serious criterion. It's all well and good developing with the latest and greatest framework, but when you find it's moved forward a point version and suddenly the way you have done everything is deprecated, that can turn out to result in extra unnecessary work. This was particularly my experience working with rails a little ahead of version 1. For that reason alone I would avoid any platform that wasn't at least at 1.0 when you start work on it.\nRuby is great to work with and will keep your developer productivity high, but if Django is the more stable platform I would favour that for sure.","Q_Score":2,"Tags":"python,ruby-on-rails,django,merb","A_Id":186765,"CreationDate":"2008-10-08T18:07:00.000","Title":"Framework\/Language for new web 2.0 sites (2008 and 2009)","Data Science and Machine Learning":0,"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},{"Question":"I know I'll get a thousand \"Depends on what you're trying to do\" answers, but seriously, there really is no solid information about this online yet. Here are my assumptions - I think they're similar for alot of people right now:\n\nIt is now October 2008. I want to start writing an application for January 2009. I am willing to use beta code and such but by January, I'd like a site that doesn't have 'strange' problems. With that said, if a language is simply 10% slower than another, I don't care about those things as long as the issue is linear. My main concern is developer productivity.\nI'll be using Linux, Apache, MySQL for the application.\nI want the power to do things like run scp and ftp client functions with stable libraries (I only picked those two because they're not web-related but at the same time represent pretty common network protocols that any larger app might use). Technologies like OpenID and Oauth will be used as well.\nExperienced web developers are readily available (i.e. I don't have to find people from financial companies and such).\nWhatever the choice is is common and will be around for a while.\nHere's a kicker. I'd like to be able to use advanced presentation layer tools\/languages similar to HAML, SASS. I definitively want to use JQuery.\nI will be creating a Facebook app and at some point doing things like dealing with SMS messages, iPhone apps, etc...\n\nAt this point, the choices for language are PHP (Cake,Symfony,Zend), Python (Django), Ruby (Merb). I'm really between Django and Merb at this point mostly because everybody else seems to be going that way. \nPlease don't put any technologies in here that aren't made for mainstream. I know Merb is untested mostly, but their stated goal is a solid platform and it has alot of momentum behind it so I'm confident that it's workable. Please don't answer with how great Perl is or .Net.\nFor Future References - these choices were already made:\n\nDebian (Lenny) - For converting CPU cycles into something useful. Trac\n0.11 - For Project Management Gliffy - For wireframes and such \nGoogle Docs\/Apps - For documentation, hosted email, etc... \nAmazon ec2\/S3 - For hosting, storage.\n\nCheers,\nAdam","AnswerCount":13,"Available Count":9,"Score":0.0153834017,"is_accepted":false,"ViewCount":959,"Q_Id":184049,"Users Score":1,"Answer":"I have to preface this with my agreeing with Orion Edwards, choose the one your team is most familiar with.\nHowever, I also have to note the curious lack of ASP.NET languages in your list. Not to provoke the great zealot army, but where's the beef? .NET is a stable, rapid development platform and the labor pool is growing daily. VB.NET and C# are transportable skill sets, and that can mean a lot when you're building a team of developers to work on a diverse set of tasks. .NET also allows you to separate your presentation layer from your backend code, like other languages, but also allows you to expose that backend code as web service for things like your iPhone and Facebook applications.\nTake every suggestion with a grain of salt, and pick what suits the application best. Do your research, and design for function and not the zealots.\nDisclaimer: Once a PHP, ColdFusion and Perl developer. Flex zealot, and Adobe lover. Now writing enterprise .NET applications. ;)\nDon't forget Mono, which will let you run .NET under *nix. Not that I'm saying it will be perfect, just playing devil's advocate.","Q_Score":2,"Tags":"python,ruby-on-rails,django,merb","A_Id":189012,"CreationDate":"2008-10-08T18:07:00.000","Title":"Framework\/Language for new web 2.0 sites (2008 and 2009)","Data Science and Machine Learning":0,"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},{"Question":"I know I'll get a thousand \"Depends on what you're trying to do\" answers, but seriously, there really is no solid information about this online yet. Here are my assumptions - I think they're similar for alot of people right now:\n\nIt is now October 2008. I want to start writing an application for January 2009. I am willing to use beta code and such but by January, I'd like a site that doesn't have 'strange' problems. With that said, if a language is simply 10% slower than another, I don't care about those things as long as the issue is linear. My main concern is developer productivity.\nI'll be using Linux, Apache, MySQL for the application.\nI want the power to do things like run scp and ftp client functions with stable libraries (I only picked those two because they're not web-related but at the same time represent pretty common network protocols that any larger app might use). Technologies like OpenID and Oauth will be used as well.\nExperienced web developers are readily available (i.e. I don't have to find people from financial companies and such).\nWhatever the choice is is common and will be around for a while.\nHere's a kicker. I'd like to be able to use advanced presentation layer tools\/languages similar to HAML, SASS. I definitively want to use JQuery.\nI will be creating a Facebook app and at some point doing things like dealing with SMS messages, iPhone apps, etc...\n\nAt this point, the choices for language are PHP (Cake,Symfony,Zend), Python (Django), Ruby (Merb). I'm really between Django and Merb at this point mostly because everybody else seems to be going that way. \nPlease don't put any technologies in here that aren't made for mainstream. I know Merb is untested mostly, but their stated goal is a solid platform and it has alot of momentum behind it so I'm confident that it's workable. Please don't answer with how great Perl is or .Net.\nFor Future References - these choices were already made:\n\nDebian (Lenny) - For converting CPU cycles into something useful. Trac\n0.11 - For Project Management Gliffy - For wireframes and such \nGoogle Docs\/Apps - For documentation, hosted email, etc... \nAmazon ec2\/S3 - For hosting, storage.\n\nCheers,\nAdam","AnswerCount":13,"Available Count":9,"Score":0.0153834017,"is_accepted":false,"ViewCount":959,"Q_Id":184049,"Users Score":1,"Answer":"Having built apps in Django, I can attest to its utility. If only all frameworks were as elegant (yes Spring, I'm looking at you).\nHowever in terms of betting the farm on Django, one thing you need to factor in is that Python 3 will be released shortly. Python 3 is not backwards compatible and there's a risk that it will fork the language and end up slowing momentum for all Python projects while they deal with the fallout. To be fair, Ruby 2.0 is due soon too, but I don't think it will be as disruptive.","Q_Score":2,"Tags":"python,ruby-on-rails,django,merb","A_Id":208938,"CreationDate":"2008-10-08T18:07:00.000","Title":"Framework\/Language for new web 2.0 sites (2008 and 2009)","Data Science and Machine Learning":0,"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},{"Question":"I know I'll get a thousand \"Depends on what you're trying to do\" answers, but seriously, there really is no solid information about this online yet. Here are my assumptions - I think they're similar for alot of people right now:\n\nIt is now October 2008. I want to start writing an application for January 2009. I am willing to use beta code and such but by January, I'd like a site that doesn't have 'strange' problems. With that said, if a language is simply 10% slower than another, I don't care about those things as long as the issue is linear. My main concern is developer productivity.\nI'll be using Linux, Apache, MySQL for the application.\nI want the power to do things like run scp and ftp client functions with stable libraries (I only picked those two because they're not web-related but at the same time represent pretty common network protocols that any larger app might use). Technologies like OpenID and Oauth will be used as well.\nExperienced web developers are readily available (i.e. I don't have to find people from financial companies and such).\nWhatever the choice is is common and will be around for a while.\nHere's a kicker. I'd like to be able to use advanced presentation layer tools\/languages similar to HAML, SASS. I definitively want to use JQuery.\nI will be creating a Facebook app and at some point doing things like dealing with SMS messages, iPhone apps, etc...\n\nAt this point, the choices for language are PHP (Cake,Symfony,Zend), Python (Django), Ruby (Merb). I'm really between Django and Merb at this point mostly because everybody else seems to be going that way. \nPlease don't put any technologies in here that aren't made for mainstream. I know Merb is untested mostly, but their stated goal is a solid platform and it has alot of momentum behind it so I'm confident that it's workable. Please don't answer with how great Perl is or .Net.\nFor Future References - these choices were already made:\n\nDebian (Lenny) - For converting CPU cycles into something useful. Trac\n0.11 - For Project Management Gliffy - For wireframes and such \nGoogle Docs\/Apps - For documentation, hosted email, etc... \nAmazon ec2\/S3 - For hosting, storage.\n\nCheers,\nAdam","AnswerCount":13,"Available Count":9,"Score":0.0614608973,"is_accepted":false,"ViewCount":959,"Q_Id":184049,"Users Score":4,"Answer":"I would go with Django, if you are comfortable with a Python solution. It's at version 1.0 now, and is maturing nicely, with a large user base and many contributors. Integrating jQuery is no problem, and I've done it without any issues.\nThe only thing is, as far as I can tell, Ruby is much more popular for web development nowadays, so it's easier to find Ruby developers. I get this impression from browsing recent job advertisements - there aren't that many for Python or Django. I don't know much about Merb, so I can't give a fair comparison.\nI've done enough PHP to not recommend starting a new project with it.","Q_Score":2,"Tags":"python,ruby-on-rails,django,merb","A_Id":184107,"CreationDate":"2008-10-08T18:07:00.000","Title":"Framework\/Language for new web 2.0 sites (2008 and 2009)","Data Science and Machine Learning":0,"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},{"Question":"I know I'll get a thousand \"Depends on what you're trying to do\" answers, but seriously, there really is no solid information about this online yet. Here are my assumptions - I think they're similar for alot of people right now:\n\nIt is now October 2008. I want to start writing an application for January 2009. I am willing to use beta code and such but by January, I'd like a site that doesn't have 'strange' problems. With that said, if a language is simply 10% slower than another, I don't care about those things as long as the issue is linear. My main concern is developer productivity.\nI'll be using Linux, Apache, MySQL for the application.\nI want the power to do things like run scp and ftp client functions with stable libraries (I only picked those two because they're not web-related but at the same time represent pretty common network protocols that any larger app might use). Technologies like OpenID and Oauth will be used as well.\nExperienced web developers are readily available (i.e. I don't have to find people from financial companies and such).\nWhatever the choice is is common and will be around for a while.\nHere's a kicker. I'd like to be able to use advanced presentation layer tools\/languages similar to HAML, SASS. I definitively want to use JQuery.\nI will be creating a Facebook app and at some point doing things like dealing with SMS messages, iPhone apps, etc...\n\nAt this point, the choices for language are PHP (Cake,Symfony,Zend), Python (Django), Ruby (Merb). I'm really between Django and Merb at this point mostly because everybody else seems to be going that way. \nPlease don't put any technologies in here that aren't made for mainstream. I know Merb is untested mostly, but their stated goal is a solid platform and it has alot of momentum behind it so I'm confident that it's workable. Please don't answer with how great Perl is or .Net.\nFor Future References - these choices were already made:\n\nDebian (Lenny) - For converting CPU cycles into something useful. Trac\n0.11 - For Project Management Gliffy - For wireframes and such \nGoogle Docs\/Apps - For documentation, hosted email, etc... \nAmazon ec2\/S3 - For hosting, storage.\n\nCheers,\nAdam","AnswerCount":13,"Available Count":9,"Score":0.0307595242,"is_accepted":false,"ViewCount":959,"Q_Id":184049,"Users Score":2,"Answer":"Based in your reasons, I would go with Ruby. I see that you want some administration tools (scp, ftp client) and Ruby has it (net\/sftp and net\/ftp libraries).\nAlso, there are great gems like God for monitoring your system, Vlad the Deployer for deploying, etc. And a lot of alternatives in Merb's field, just use whatever you find it's better for your needs (Thin, Mongrel, ebb, etc).","Q_Score":2,"Tags":"python,ruby-on-rails,django,merb","A_Id":184157,"CreationDate":"2008-10-08T18:07:00.000","Title":"Framework\/Language for new web 2.0 sites (2008 and 2009)","Data Science and Machine Learning":0,"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},{"Question":"I would like to write some scripts in python that do some automated changes to source code. If the script determines it needs to change the file I would like to first check it out of perforce. I don't care about checking in because I will always want to build and test first.","AnswerCount":6,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":19107,"Q_Id":184187,"Users Score":2,"Answer":"You may want to check out the P4Python module. It's available on the perforce site and it makes things very simple.","Q_Score":15,"Tags":"python,scripting,perforce","A_Id":184238,"CreationDate":"2008-10-08T18:33:00.000","Title":"How do I check out a file from perforce 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},{"Question":"I would like to write some scripts in python that do some automated changes to source code. If the script determines it needs to change the file I would like to first check it out of perforce. I don't care about checking in because I will always want to build and test first.","AnswerCount":6,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":19107,"Q_Id":184187,"Users Score":3,"Answer":"Building from p4python source requires downloading and extracting the p4 api recommended for that version. For example, if building the Windows XP x86 version of P4Python 2008.2 for activepython 2.5:\n\ndownload and extract both the p4python and p4api\nfixup the setup.cfg for p4python to\npoint to the p4api directory.\n\nTo open files for edit (do a checkout), on the command line, see 'p4 help open'.\nYou can check out files without making a changelist if you add the file to the default changelist, but it's a good idea to make a changelist first.\nP4Python doesn't currently compile for activepython 2.6 without visual studio 2008; the provided libs are built with 2005 or 2003. Forcing p4python to build against mingw is nearly impossible, even with pexports of python26.dll and reimp\/reassembly of the provided .lib files into .a files.\nIn that case, you'll probably rather use subprocess, and return p4 results as marshalled python objects. You can write your own command wrapper that takes an arg array, constructs and runs the commands, and returns the results dictionary.\nYou might try changing everything, testing, and on success, opening the files that are different with something equivalent to 'p4 diff -se \/\/...'","Q_Score":15,"Tags":"python,scripting,perforce","A_Id":307908,"CreationDate":"2008-10-08T18:33:00.000","Title":"How do I check out a file from perforce 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},{"Question":"I am working with a hosting provider who has installed mod_python for me. I followed the install instructions locally and included it in httpd.conf but they have opted to put it in conf.d\/python.conf.\nIs there any difference\/benefit to doing it either way?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":295,"Q_Id":187195,"Users Score":5,"Answer":"No, all the files are parsed at run time, you can include as many as you want. They've just opted to seperate out the configuration for easier management.","Q_Score":2,"Tags":"mod-python,apache","A_Id":187202,"CreationDate":"2008-10-09T13:15:00.000","Title":"Is there a difference between installing mod_python via httpd.conf and conf.d in 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":0,"Web Development":0},{"Question":"After having looked at each of these two projects, it seems that both are VERY similar. Both run on top of the CLI, both have python style syntax, both use .NET instead of the standard python libraries.\nSo, what are the differences between them and advantages of each?","AnswerCount":7,"Available Count":2,"Score":0.0285636566,"is_accepted":false,"ViewCount":6385,"Q_Id":193862,"Users Score":1,"Answer":"I agree with VolkA here. Being able to run Django is big. It's just such an amazing framework, that Boo will have a hard time redoing it. Today it's more a question of the frameworks that a language provides, than it is the construct that it provides. And Boo doesn't provide much improvements over Python in the constructs it support.","Q_Score":26,"Tags":"ironpython,boo","A_Id":194040,"CreationDate":"2008-10-11T08:44:00.000","Title":"Boo vs. 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},{"Question":"After having looked at each of these two projects, it seems that both are VERY similar. Both run on top of the CLI, both have python style syntax, both use .NET instead of the standard python libraries.\nSo, what are the differences between them and advantages of each?","AnswerCount":7,"Available Count":2,"Score":0.1137907297,"is_accepted":false,"ViewCount":6385,"Q_Id":193862,"Users Score":4,"Answer":"I have written applications in both Boo and IronPython. For me IronPython has been the more robust choice and much of what I've written in CPython ports without changes. All recent projects have been pure IronPython if targeted for .Net Framework.\nSince Jim \"defected\" to Microsoft, IronPython has been elevated to a top tier language. There's even Visual Studio for it.","Q_Score":26,"Tags":"ironpython,boo","A_Id":199236,"CreationDate":"2008-10-11T08:44:00.000","Title":"Boo vs. 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},{"Question":"What to use for a medium to large python WSGI application, Apache + mod_wsgi or Nginx + mod_wsgi?\nWhich combination will need more memory and CPU time?\nWhich one is faster?\nWhich is known for being more stable than the other?\nI am also thinking to use CherryPy's WSGI server but I hear it's not very suitable for a very high-load application, what do you know about this?\n\nNote: I didn't use any Python Web Framework, I just wrote the whole thing from scratch.\nNote': Other suggestions are also welcome.","AnswerCount":4,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":31610,"Q_Id":195534,"Users Score":14,"Answer":"The main difference is that nginx is built to handle large numbers of connections in a much smaller memory space. This makes it very well suited for apps that are doing comet like connections that can have many idle open connections. This also gives it quite a smaller memory foot print.\nFrom a raw performance perspective, nginx is faster, but not so much faster that I would include that as a determining factor.\nApache has the advantage in the area of modules available, and the fact that it is pretty much standard. Any web host you go with will have it installed, and most techs are going to be very familiar with it.\nAlso, if you use mod_wsgi, it is your wsgi server so you don't even need cherrypy.\nOther than that, the best advice I can give is try setting up your app under both and do some benchmarking, since no matter what any one tells you, your mileage may vary.","Q_Score":68,"Tags":"python,apache,nginx,mod-wsgi","A_Id":196580,"CreationDate":"2008-10-12T14:14:00.000","Title":"In production, Apache + mod_wsgi or Nginx + 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},{"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},{"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},{"Question":"The only thing I can get python omnicomplete to work with are system modules. I get nothing for help with modules in my site-packages or modules that I'm currently working on.","AnswerCount":6,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":4900,"Q_Id":199180,"Users Score":3,"Answer":"Once I generated ctags for one of my site-packages, it started working for that package -- so I'm guessing that the omnicomplete function depends on ctags for non-sys modules.\nEDIT: Not true at all.\nHere's the problem -- poor testing on my part -- omnicomplete WAS working for parts of my project, just not most of it.\nThe issue was that I'm working on a django project, and in order to import django.db, you need to have an environment variable set. Since I couldn't import django.db, any class that inherited from django.db, or any module that imported a class that inherited from django.db wouldn't complete.","Q_Score":9,"Tags":"python,vim,omnicomplete","A_Id":213253,"CreationDate":"2008-10-13T22:08:00.000","Title":"Is there any way to get python omnicomplete to work with non-system modules in vim?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I wonder if it is possible to create an executable module from a Python script. I need to have the most performance and the flexibility of Python script, without needing to run in the Python environment. I would use this code to load on demand user modules to customize my application.","AnswerCount":4,"Available Count":1,"Score":0.049958375,"is_accepted":false,"ViewCount":4549,"Q_Id":205062,"Users Score":1,"Answer":"I think you can use jython to compile python to Java bytecode, and then compile that with GCJ.","Q_Score":14,"Tags":"python,module,compilation","A_Id":209176,"CreationDate":"2008-10-15T15:02:00.000","Title":"Is it possible to compile Python natively (beyond pyc byte 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},{"Question":"Python's IDLE has 'Check Module' (Alt-X) to check the syntax which can be called without needing to run the code. Is there an equivalent way to do this in Emacs instead of running and executing the code?","AnswerCount":5,"Available Count":2,"Score":0.0798297691,"is_accepted":false,"ViewCount":8119,"Q_Id":205704,"Users Score":2,"Answer":"Or from emacs (or vim) you could run python -c 'import x' where x is the name of your file minus the .py extension.","Q_Score":15,"Tags":"python,validation,emacs,syntax","A_Id":207059,"CreationDate":"2008-10-15T17:46:00.000","Title":"How can I check the syntax of Python code in Emacs without actually executing 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":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Python's IDLE has 'Check Module' (Alt-X) to check the syntax which can be called without needing to run the code. Is there an equivalent way to do this in Emacs instead of running and executing the code?","AnswerCount":5,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":8119,"Q_Id":205704,"Users Score":0,"Answer":"You can use pylint, pychecker, pyflakes etc. from Emacs' compile command (M-x compile).\nHint: bind a key (say, F5) to recompile.","Q_Score":15,"Tags":"python,validation,emacs,syntax","A_Id":207593,"CreationDate":"2008-10-15T17:46:00.000","Title":"How can I check the syntax of Python code in Emacs without actually executing 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":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am interested in getting some Python code talking to some Ruby code on Windows, Linux and possibly other platforms. Specificlly I would like to access classes in Ruby from Python and call their methods, access their data, create new instances and so on.\nAn obvious way to do this is via something like XML-RPC or maybe CORBA but I would be interested in any other approaches.\nWhat have other people done to get code from Python and Ruby communicating with one another, either locally on the same system or remotely accross a network?\nThanks in advance.","AnswerCount":5,"Available Count":2,"Score":0.0399786803,"is_accepted":false,"ViewCount":2499,"Q_Id":206823,"Users Score":1,"Answer":"Expose your Ruby classes as web services using Sinatra, Rails, or, plain old Rack.\nExpose your Python classes as web services using web.py, flask, Django, or App Engine.\nUse HTTParty for Ruby to build an API into your Python classes.\nUse a Python REST library to build an API into your Ruby classes.","Q_Score":8,"Tags":"python,ruby,interop","A_Id":4859776,"CreationDate":"2008-10-15T22:49:00.000","Title":"Ruby to Python bridge","Data Science and Machine Learning":0,"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},{"Question":"I am interested in getting some Python code talking to some Ruby code on Windows, Linux and possibly other platforms. Specificlly I would like to access classes in Ruby from Python and call their methods, access their data, create new instances and so on.\nAn obvious way to do this is via something like XML-RPC or maybe CORBA but I would be interested in any other approaches.\nWhat have other people done to get code from Python and Ruby communicating with one another, either locally on the same system or remotely accross a network?\nThanks in advance.","AnswerCount":5,"Available Count":2,"Score":0.1194272985,"is_accepted":false,"ViewCount":2499,"Q_Id":206823,"Users Score":3,"Answer":"Please be advised that I don't speak from personal experience here, but I imagine JRuby and Jython (The ruby and python implementations in the JVM) would be able to to easily talk to each other, as well as Java code. You may want to look into that.","Q_Score":8,"Tags":"python,ruby,interop","A_Id":206839,"CreationDate":"2008-10-15T22:49:00.000","Title":"Ruby to Python bridge","Data Science and Machine Learning":0,"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},{"Question":"I currently do my textfile manipulation through a bunch of badly remembered AWK, sed, Bash and a tiny bit of Perl.\nI've seen mentioned a few places that python is good for this kind of thing. How can I use Python to replace shell scripting, AWK, sed and friends?","AnswerCount":17,"Available Count":5,"Score":1.0,"is_accepted":false,"ViewCount":115137,"Q_Id":209470,"Users Score":6,"Answer":"I will give here my opinion based on experience:\nFor shell:\n\nshell can very easily spawn read-only code. Write it and when you come back to it, you will never figure out what you did again. It's very easy to accomplish this.\nshell can do A LOT of text processing, splitting, etc in one line with pipes.\nit is the best glue language when it comes to integrate the call of programs in different programming languages.\n\nFor python:\n\nif you want portability to windows included, use python.\npython can be better when you must manipulate just more than text, such as collections of numbers. For this, I recommend python.\n\nI usually choose bash for most of the things, but when I have something that must cross windows boundaries, I just use python.","Q_Score":242,"Tags":"python,bash,shell","A_Id":20313297,"CreationDate":"2008-10-16T17:11:00.000","Title":"How to implement common bash idioms 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},{"Question":"I currently do my textfile manipulation through a bunch of badly remembered AWK, sed, Bash and a tiny bit of Perl.\nI've seen mentioned a few places that python is good for this kind of thing. How can I use Python to replace shell scripting, AWK, sed and friends?","AnswerCount":17,"Available Count":5,"Score":0.0235250705,"is_accepted":false,"ViewCount":115137,"Q_Id":209470,"Users Score":2,"Answer":"Your best bet is a tool that is specifically geared towards your problem. If it's processing text files, then Sed, Awk and Perl are the top contenders. Python is a general-purpose dynamic language. As with any general purpose language, there's support for file-manipulation, but that isn't what it's core purpose is. I would consider Python or Ruby if I had a requirement for a dynamic language in particular.\nIn short, learn Sed and Awk really well, plus all the other goodies that come with your flavour of *nix (All the Bash built-ins, grep, tr and so forth). If it's text file processing you're interested in, you're already using the right stuff.","Q_Score":242,"Tags":"python,bash,shell","A_Id":209665,"CreationDate":"2008-10-16T17:11:00.000","Title":"How to implement common bash idioms 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},{"Question":"I currently do my textfile manipulation through a bunch of badly remembered AWK, sed, Bash and a tiny bit of Perl.\nI've seen mentioned a few places that python is good for this kind of thing. How can I use Python to replace shell scripting, AWK, sed and friends?","AnswerCount":17,"Available Count":5,"Score":0.0352794699,"is_accepted":false,"ViewCount":115137,"Q_Id":209470,"Users Score":3,"Answer":"I have built semi-long shell scripts (300-500 lines) and Python code which does similar functionality. When many external commands are being executed, I find the shell is easier to use. Perl is also a good option when there is lots of text manipulation.","Q_Score":242,"Tags":"python,bash,shell","A_Id":210429,"CreationDate":"2008-10-16T17:11:00.000","Title":"How to implement common bash idioms 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},{"Question":"I currently do my textfile manipulation through a bunch of badly remembered AWK, sed, Bash and a tiny bit of Perl.\nI've seen mentioned a few places that python is good for this kind of thing. How can I use Python to replace shell scripting, AWK, sed and friends?","AnswerCount":17,"Available Count":5,"Score":1.0,"is_accepted":false,"ViewCount":115137,"Q_Id":209470,"Users Score":16,"Answer":"In the beginning there was sh, sed, and awk (and find, and grep, and...). It was good. But awk can be an odd little beast and hard to remember if you don't use it often. Then the great camel created Perl. Perl was a system administrator's dream. It was like shell scripting on steroids. Text processing, including regular expressions were just part of the language. Then it got ugly... People tried to make big applications with Perl. Now, don't get me wrong, Perl can be an application, but it can (can!) look like a mess if you're not really careful. Then there is all this flat data business. It's enough to drive a programmer nuts.\nEnter Python, Ruby, et al. These are really very good general purpose languages. They support text processing, and do it well (though perhaps not as tightly entwined in the basic core of the language). But they also scale up very well, and still have nice looking code at the end of the day. They also have developed pretty hefty communities with plenty of libraries for most anything.\nNow, much of the negativeness towards Perl is a matter of opinion, and certainly some people can write very clean Perl, but with this many people complaining about it being too easy to create obfuscated code, you know some grain of truth is there. The question really becomes then, are you ever going to use this language for more than simple bash script replacements. If not, learn some more Perl.. it is absolutely fantastic for that. If, on the other hand, you want a language that will grow with you as you want to do more, may I suggest Python or Ruby.\nEither way, good luck!","Q_Score":242,"Tags":"python,bash,shell","A_Id":210290,"CreationDate":"2008-10-16T17:11:00.000","Title":"How to implement common bash idioms 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},{"Question":"I currently do my textfile manipulation through a bunch of badly remembered AWK, sed, Bash and a tiny bit of Perl.\nI've seen mentioned a few places that python is good for this kind of thing. How can I use Python to replace shell scripting, AWK, sed and friends?","AnswerCount":17,"Available Count":5,"Score":1.0,"is_accepted":false,"ViewCount":115137,"Q_Id":209470,"Users Score":7,"Answer":"One reason I love Python is that it is much better standardized than the POSIX tools. I have to double and triple check that each bit is compatible with other operating systems. A program written on a Linux system might not work the same on a BSD system of OSX. With Python, I just have to check that the target system has a sufficiently modern version of Python.\nEven better, a program written in standard Python will even run on Windows!","Q_Score":242,"Tags":"python,bash,shell","A_Id":16726383,"CreationDate":"2008-10-16T17:11:00.000","Title":"How to implement common bash idioms 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},{"Question":"How do I get the inverse of a matrix in python? I've implemented it myself, but it's pure python, and I suspect there are faster modules out there to do it.","AnswerCount":7,"Available Count":1,"Score":0.0285636566,"is_accepted":false,"ViewCount":125109,"Q_Id":211160,"Users Score":1,"Answer":"If you hate numpy, get out RPy and your local copy of R, and use it instead.\n(I would also echo to make you you really need to invert the matrix. In R, for example, linalg.solve and the solve() function don't actually do a full inversion, since it is unnecessary.)","Q_Score":62,"Tags":"python,algorithm,matrix,linear-algebra,matrix-inverse","A_Id":213717,"CreationDate":"2008-10-17T05:30:00.000","Title":"Python Inverse of a Matrix","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},{"Question":"Me and some friends are writing a MORPG in Java, and we would like to use a scripting language to, eg. to create quests.\nWe have non experience with scripting in Java. We have used Python, but we are very inexperienced with it. One of us also have used Javascript. \nWhat scripting language should we use?\nWhat scripting language should we not use?","AnswerCount":11,"Available Count":3,"Score":0.0363476168,"is_accepted":false,"ViewCount":1679,"Q_Id":211536,"Users Score":2,"Answer":"Short version\nDon\u2019t use a scripting language! Instead focus on configurability (which is something that a non-programmer can do well).\nLonger version\nOne oft-used argument in favour of having a scripting language is that it allows for lesser programmers to more trivial tasks. Don't belive this, it will not save you any time, since trivial tasks are already accomplished by real programmers in no time. Aim for configurability instead of scripting, and you will have a much lower risk of bleeding over complex algorithms and concepts into the incapable hands of game designers. :)\nLack of hotswapping (edit-and-continue) would have been a reason to implement a scripting language in an MMOG (you don\u2019t want to reload the whole game for a minor code change), but using Java, with built-in hotswap, you really have no reason for adding a scripting language on top.\nI have spent years pondering these questions; in the day I implemented a complete scripting language, IDE, VM, debugger, etc for an MMOG myself. Since, I have grown wiser.\nIf you still choose to go down the infinitely crappy path of no return, keep the following in mind.\n\nPick a mature language which has been around for a while.\nAuto testing, debugging and editing will suck bigtime until you make your own tools\/plugins\/start hacking around in the VM.\n\nTo date, I have never seen a DSL that improved the situation (getting a more maintainable product). Myself, I integrated Python into my indie game engine, but eventually came to my senses and ripped it out. \"Stackless Python\" is just a way of saying \"unmaintainable but fast\". Please, anyone correct me if I'm wrong?","Q_Score":8,"Tags":"java,javascript,python,scripting-language","A_Id":838738,"CreationDate":"2008-10-17T09:23:00.000","Title":"Scripting 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":1},{"Question":"Me and some friends are writing a MORPG in Java, and we would like to use a scripting language to, eg. to create quests.\nWe have non experience with scripting in Java. We have used Python, but we are very inexperienced with it. One of us also have used Javascript. \nWhat scripting language should we use?\nWhat scripting language should we not use?","AnswerCount":11,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":1679,"Q_Id":211536,"Users Score":0,"Answer":"I am a big fan of Python\/Jython due to the clean syntax - which may suit you if you have some python experience. \nOtherwise Groovy which is based on Java syntax and may be an easier learning curve if most of your developers are Java guys. It also has the advantage of closer ties with the Java language and libraries. \nBeanshell is good if you have simple scripting in mind - it doesn't support classes. However I don't think it has had any support over the last few years (the JSR seemed to kill it off...) so is perhaps a bad choice if support is important to you.","Q_Score":8,"Tags":"java,javascript,python,scripting-language","A_Id":211883,"CreationDate":"2008-10-17T09:23:00.000","Title":"Scripting 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":1},{"Question":"Me and some friends are writing a MORPG in Java, and we would like to use a scripting language to, eg. to create quests.\nWe have non experience with scripting in Java. We have used Python, but we are very inexperienced with it. One of us also have used Javascript. \nWhat scripting language should we use?\nWhat scripting language should we not use?","AnswerCount":11,"Available Count":3,"Score":1.0,"is_accepted":false,"ViewCount":1679,"Q_Id":211536,"Users Score":9,"Answer":"I'm responsible for a fairly large hybrid Java\/Jython system. We use java for core API development, then wire Java objects together using Jython. This is in a scientific computing environment where we need to be able to put together ad-hoc data analysis scripts quickly.\nIf I were starting this system from scratch today, I would not choose Jython as the scripting language. I like Python fine, but I frequently encounter awkward mismatches between the Python type system and the Java type system. For example, if you just want a hashtable, should you use a Python dictionary or a Java HashMap? The decision might be different depending on whether you are just using the data structure locally in Python code or passing it across the Java boundary. Jython does a certain amount of type coercion for you, but it's not perfect. It's annoying to even have to think about issues like this when the purpose of using a scripting language in the first place is to enhance your productivity. \nI assume JavaScript or JRuby would have similar issues. Today I would choose a scripting language that is specifically targeted to the JVM and leverages the Java type system. The obvious candidates are Groovy and Beanshell; Groovy seems to have been picking up momentum lately so I'd look most closely at it.","Q_Score":8,"Tags":"java,javascript,python,scripting-language","A_Id":215096,"CreationDate":"2008-10-17T09:23:00.000","Title":"Scripting 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":1},{"Question":"I am looking for a python webserver which is multithreaded instead of being multi-process (as in case of mod_python for apache). I want it to be multithreaded because I want to have an in memory object cache that will be used by various http threads. My webserver does a lot of expensive stuff and computes some large arrays which needs to be cached in memory for future use to avoid recomputing. This is not possible in a multi-process web server environment. Storing this information in memcache is also not a good idea as the arrays are large and storing them in memcache would lead to deserialization of data coming from memcache apart from the additional overhead of IPC.\nI implemented a simple webserver using BaseHttpServer, it gives good performance but it gets stuck after a few hours time. I need some more matured webserver. Is it possible to configure apache to use mod_python under a thread model so that I can do some object caching?","AnswerCount":11,"Available Count":3,"Score":0.0544914242,"is_accepted":false,"ViewCount":12249,"Q_Id":213483,"Users Score":3,"Answer":"Its hard to give a definitive answer without knowing what kind of site you are working on and what kind of load you are expecting. Sub second performance may be a serious requirement or it may not. If you really need to save that last millisecond then you absolutely need to keep your arrays in memory. However as others have suggested it is more than likely that you don't and could get by with something else. Your usage pattern of the data in the array may affect what kinds of choices you make. You probably don't need access to the entire set of data from the array all at once so you could break your data up into smaller chunks and put those chunks in the cache instead of the one big lump. Depending on how often your array data needs to get updated you might make a choice between memcached, local db (berkley, sqlite, small mysql installation, etc) or a remote db. I'd say memcached for fairly frequent updates. A local db for something in the frequency of hourly and remote for the frequency of daily. One thing to consider also is what happens after a cache miss. If 50 clients all of a sudden get a cache miss and all of them at the same time decide to start regenerating those expensive arrays your box(es) will quickly be reduced to 8086's. So you have to take in to consideration how you will handle that. Many articles out there cover how to recover from cache misses. Hope this is helpful.","Q_Score":13,"Tags":"python,apache,webserver,mod-python","A_Id":213742,"CreationDate":"2008-10-17T19:12:00.000","Title":"A good multithreaded python 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":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am looking for a python webserver which is multithreaded instead of being multi-process (as in case of mod_python for apache). I want it to be multithreaded because I want to have an in memory object cache that will be used by various http threads. My webserver does a lot of expensive stuff and computes some large arrays which needs to be cached in memory for future use to avoid recomputing. This is not possible in a multi-process web server environment. Storing this information in memcache is also not a good idea as the arrays are large and storing them in memcache would lead to deserialization of data coming from memcache apart from the additional overhead of IPC.\nI implemented a simple webserver using BaseHttpServer, it gives good performance but it gets stuck after a few hours time. I need some more matured webserver. Is it possible to configure apache to use mod_python under a thread model so that I can do some object caching?","AnswerCount":11,"Available Count":3,"Score":1.0,"is_accepted":false,"ViewCount":12249,"Q_Id":213483,"Users Score":7,"Answer":"Consider reconsidering your design. Maintaining that much state in your webserver is probably a bad idea. Multi-process is a much better way to go for stability. \nIs there another way to share state between separate processes? What about a service? Database? Index? \nIt seems unlikely that maintaining a huge array of data in memory and relying on a single multi-threaded process to serve all your requests is the best design or architecture for your app.","Q_Score":13,"Tags":"python,apache,webserver,mod-python","A_Id":213572,"CreationDate":"2008-10-17T19:12:00.000","Title":"A good multithreaded python 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":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am looking for a python webserver which is multithreaded instead of being multi-process (as in case of mod_python for apache). I want it to be multithreaded because I want to have an in memory object cache that will be used by various http threads. My webserver does a lot of expensive stuff and computes some large arrays which needs to be cached in memory for future use to avoid recomputing. This is not possible in a multi-process web server environment. Storing this information in memcache is also not a good idea as the arrays are large and storing them in memcache would lead to deserialization of data coming from memcache apart from the additional overhead of IPC.\nI implemented a simple webserver using BaseHttpServer, it gives good performance but it gets stuck after a few hours time. I need some more matured webserver. Is it possible to configure apache to use mod_python under a thread model so that I can do some object caching?","AnswerCount":11,"Available Count":3,"Score":0.0363476168,"is_accepted":false,"ViewCount":12249,"Q_Id":213483,"Users Score":2,"Answer":"web.py has made me happy in the past. Consider checking it out.\nBut it does sound like an architectural redesign might be the proper, though more expensive, solution.","Q_Score":13,"Tags":"python,apache,webserver,mod-python","A_Id":215292,"CreationDate":"2008-10-17T19:12:00.000","Title":"A good multithreaded python 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":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have noticed that my particular instance of Trac is not running quickly and has big lags. This is at the very onset of a project, so not much is in Trac (except for plugins and code loaded into SVN).\nSetup Info: This is via a SELinux system hosted by WebFaction. It is behind Apache, and connections are over SSL. Currently the .htpasswd file is what I use to control access.\nAre there any recommend ways to improve the performance of Trac?","AnswerCount":4,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":2997,"Q_Id":213838,"Users Score":5,"Answer":"It's hard to say without knowing more about your setup, but one easy win is to make sure that Trac is running in something like mod_python, which keeps the Python runtime in memory. Otherwise, every HTTP request will cause Python to run, import all the modules, and then finally handle the request. Using mod_python (or FastCGI, whichever you prefer) will eliminate that loading and skip straight to the good stuff.\nAlso, as your Trac database grows and you get more people using the site, you'll probably outgrow the default SQLite database. At that point, you should think about migrating the database to PostgreSQL or MySQL, because they'll be able to handle concurrent requests much faster.","Q_Score":3,"Tags":"python,performance,trac","A_Id":214162,"CreationDate":"2008-10-17T21:02:00.000","Title":"How to improve Trac's 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},{"Question":"I have noticed that my particular instance of Trac is not running quickly and has big lags. This is at the very onset of a project, so not much is in Trac (except for plugins and code loaded into SVN).\nSetup Info: This is via a SELinux system hosted by WebFaction. It is behind Apache, and connections are over SSL. Currently the .htpasswd file is what I use to control access.\nAre there any recommend ways to improve the performance of Trac?","AnswerCount":4,"Available Count":2,"Score":0.1488850336,"is_accepted":false,"ViewCount":2997,"Q_Id":213838,"Users Score":3,"Answer":"We've had the best luck with FastCGI. Another critical factor was to only use https for authentication but use http for all other traffic -- I was really surprised how much that made a difference.","Q_Score":3,"Tags":"python,performance,trac","A_Id":215084,"CreationDate":"2008-10-17T21:02:00.000","Title":"How to improve Trac's 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},{"Question":"We've been using Trac for task\/defect tracking and things were going well enough, but this morning it started serving up a 500 error. Looking in the Apache error_log, I get a stack trace that culminates in:\n\nPythonHandler trac.web.modpython_frontend:\n ExtractionError: Can't extract file(s) to egg cache\n\nThe following error occurred while trying to extract file(s) to the Python egg\ncache:\n\n [Errno 13] Permission denied: '\/.python-eggs'\n\nThe Python egg cache directory is currently set to:\n\n \/.python-eggs\n\nPerhaps your account does not have write access to this directory? You can\nchange the cache directory by setting the PYTHON_EGG_CACHE environment\nvariable to point to an accessible directory\n\nSo I explicitly set PYTHON_EGG_CACHE to \/srv\/trac\/plugin-cache. I restarted Apache. Yet I get the same error (it still says \"egg cache directory current set to: \\n\\n \/.python_eggs.\")\nHow should I proceed? Is the simplest thing to do to reinstall Trac? If I go that route, what steps do I need to take to ensure that I don't lose existing data?","AnswerCount":5,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":2011,"Q_Id":215267,"Users Score":0,"Answer":"I found that using the PythonOption directive in the site config did not work, but SetEnv did. The environment variable route will also work though.","Q_Score":1,"Tags":"python,configuration,trac,python-egg-cache","A_Id":406119,"CreationDate":"2008-10-18T16:51:00.000","Title":"How do you fix a Trac installation that begins giving errors relating to PYTHON_EGG_CACHE?","Data Science and Machine Learning":0,"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},{"Question":"We've been using Trac for task\/defect tracking and things were going well enough, but this morning it started serving up a 500 error. Looking in the Apache error_log, I get a stack trace that culminates in:\n\nPythonHandler trac.web.modpython_frontend:\n ExtractionError: Can't extract file(s) to egg cache\n\nThe following error occurred while trying to extract file(s) to the Python egg\ncache:\n\n [Errno 13] Permission denied: '\/.python-eggs'\n\nThe Python egg cache directory is currently set to:\n\n \/.python-eggs\n\nPerhaps your account does not have write access to this directory? You can\nchange the cache directory by setting the PYTHON_EGG_CACHE environment\nvariable to point to an accessible directory\n\nSo I explicitly set PYTHON_EGG_CACHE to \/srv\/trac\/plugin-cache. I restarted Apache. Yet I get the same error (it still says \"egg cache directory current set to: \\n\\n \/.python_eggs.\")\nHow should I proceed? Is the simplest thing to do to reinstall Trac? If I go that route, what steps do I need to take to ensure that I don't lose existing data?","AnswerCount":5,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":2011,"Q_Id":215267,"Users Score":0,"Answer":"I had the same problem. In my case the directory wasn't there so I created and chown'ed it over to the apache user (apache on my centos 4.3 box). Then made sure it had read-write permissions on the directory. You could get by with giving rw rights to the directory if the group that owns the directory contains the apache user. A simple ps aux|grep httpd should show you what account your server is running under if you don't know it. If you have trouble finding the directory remember the -a on the ls command since it is a \"hidden\" directory.","Q_Score":1,"Tags":"python,configuration,trac,python-egg-cache","A_Id":219233,"CreationDate":"2008-10-18T16:51:00.000","Title":"How do you fix a Trac installation that begins giving errors relating to PYTHON_EGG_CACHE?","Data Science and Machine Learning":0,"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},{"Question":"We've been using Trac for task\/defect tracking and things were going well enough, but this morning it started serving up a 500 error. Looking in the Apache error_log, I get a stack trace that culminates in:\n\nPythonHandler trac.web.modpython_frontend:\n ExtractionError: Can't extract file(s) to egg cache\n\nThe following error occurred while trying to extract file(s) to the Python egg\ncache:\n\n [Errno 13] Permission denied: '\/.python-eggs'\n\nThe Python egg cache directory is currently set to:\n\n \/.python-eggs\n\nPerhaps your account does not have write access to this directory? You can\nchange the cache directory by setting the PYTHON_EGG_CACHE environment\nvariable to point to an accessible directory\n\nSo I explicitly set PYTHON_EGG_CACHE to \/srv\/trac\/plugin-cache. I restarted Apache. Yet I get the same error (it still says \"egg cache directory current set to: \\n\\n \/.python_eggs.\")\nHow should I proceed? Is the simplest thing to do to reinstall Trac? If I go that route, what steps do I need to take to ensure that I don't lose existing data?","AnswerCount":5,"Available Count":3,"Score":0.0399786803,"is_accepted":false,"ViewCount":2011,"Q_Id":215267,"Users Score":1,"Answer":"I have wrestled many a battle with PYTHON_EGG_CACHE and I never figured out the correct way of setting it - apache's envvars, httpd.conf (SetEnv and PythonOption), nothing worked. In the end I just unpacked all python eggs manually, there were only two or three anyway - problem gone. I never understood why on earth people zip up files weighting no more than a few kilobytes in the first place...","Q_Score":1,"Tags":"python,configuration,trac,python-egg-cache","A_Id":215401,"CreationDate":"2008-10-18T16:51:00.000","Title":"How do you fix a Trac installation that begins giving errors relating to PYTHON_EGG_CACHE?","Data Science and Machine Learning":0,"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},{"Question":"Which are the most advanced frameworks and tools there are available for python for practicing Behavior Driven Development? Especially finding similar tools as rspec and mocha for ruby would be great.","AnswerCount":10,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":46233,"Q_Id":231371,"Users Score":8,"Answer":"The Pyccuracy project is an effort to provide a domain-specific language for BDD in Python. \nUnlike doctest, which works at the API level, it encodes higher-level operations such as loading a web page and submitting a form. I haven't used it but it looks somewhat promising if that is what you're looking for.","Q_Score":133,"Tags":"python,testing,bdd","A_Id":812490,"CreationDate":"2008-10-23T20:30:00.000","Title":"Practicing BDD 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},{"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},{"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},{"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},{"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},{"Question":"What's the best cross-platform way to get file creation and modification dates\/times, that works on both Linux and Windows?","AnswerCount":12,"Available Count":2,"Score":-0.049958375,"is_accepted":false,"ViewCount":1083080,"Q_Id":237079,"Users Score":-3,"Answer":"os.stat does include the creation time. There's just no definition of st_anything for the element of os.stat() that contains the time.\nSo try this:\nos.stat('feedparser.py')[8]\nCompare that with your create date on the file in ls -lah\nThey should be the same.","Q_Score":1205,"Tags":"python,file","A_Id":367166,"CreationDate":"2008-10-25T21:54:00.000","Title":"How do I get file creation and modification date\/times?","Data Science and Machine Learning":0,"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},{"Question":"What's the best cross-platform way to get file creation and modification dates\/times, that works on both Linux and Windows?","AnswerCount":12,"Available Count":2,"Score":1.0,"is_accepted":false,"ViewCount":1083080,"Q_Id":237079,"Users Score":13,"Answer":"os.stat returns a named tuple with st_mtime and st_ctime attributes. The modification time is st_mtime on both platforms; unfortunately, on Windows, ctime means \"creation time\", whereas on POSIX it means \"change time\". I'm not aware of any way to get the creation time on POSIX platforms.","Q_Score":1205,"Tags":"python,file","A_Id":237093,"CreationDate":"2008-10-25T21:54:00.000","Title":"How do I get file creation and modification date\/times?","Data Science and Machine Learning":0,"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},{"Question":"Any python libs for parsing apache config files or if not python anyone aware of such thing in other languages (perl, php, java, c#)?\nAs i'll be able to rewrite them in python.","AnswerCount":6,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":11646,"Q_Id":237209,"Users Score":3,"Answer":"Red Hat's Emerging Technologies group has Augeas (written in C, but with Python bindings available), a generic system configuration tool with \"lenses\" for reading and writing several different configuration file formats. I would consider investigating the availability of a lens for Apache.","Q_Score":12,"Tags":"python,parsing,apache-config","A_Id":237599,"CreationDate":"2008-10-25T23:36:00.000","Title":"Any python libs for parsing apache config 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},{"Question":"I have a third-party product, a terminal emulator, which provides a DLL that can be linked to a C program to basically automate the driving of this product (send keystrokes, detect what's on the screen and so forth).\nI want to drive it from a scripting language (I'm comfortable with Python and slightly less so with Perl) so that we don't have to compile and send out executables to our customers whenever there's a problem found.\nWe also want the customers to be able to write their own scripts using ours as baselines and they won't entertain the idea of writing and compiling C code.\nWhat's a good way of getting Python\/Perl to interface to a Windows DLL. My first thought was to write a server program and have a Python script communicate with it via TCP but there's got to be an easier solution.","AnswerCount":5,"Available Count":1,"Score":0.1586485043,"is_accepted":false,"ViewCount":3922,"Q_Id":239020,"Users Score":4,"Answer":"For Python, you could compile an extension which links to the DLL, so that in Python you could just import it like a normal module. You could do this by hand, by using a library like Boost.Python, or by using a tool such as SWIG (which also supports Perl and other scripting languages) to generate a wrapper automatically.","Q_Score":9,"Tags":"python,perl,dll","A_Id":239098,"CreationDate":"2008-10-27T03:42:00.000","Title":"How can I call a DLL from a scripting 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":1,"Web Development":0},{"Question":"I'm looking for Python code that removes C and C++ comments from a string. (Assume the string contains an entire C source file.)\nI realize that I could .match() substrings with a Regex, but that doesn't solve nesting \/*, or having a \/\/ inside a \/* *\/.\nIdeally, I would prefer a non-naive implementation that properly handles awkward cases.","AnswerCount":13,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":43080,"Q_Id":241327,"Users Score":0,"Answer":"You don't really need a parse tree to do this perfectly, but you do in effect need the token stream equivalent to what is produced by the compiler's front end. Such a token stream must necessarilyy take care of all the weirdness such as line-continued comment start, comment start in string, trigraph normalization, etc. If you have the token stream, deleting the comments is easy. (I have a tool that produces exactly such token streams, as, guess what, the front end of a real parser that produces a real parse tree :). \nThe fact that the tokens are individually recognized by regular expressions suggests that you can, in principle, write a regular expression that will pick out the comment lexemes. The real complexity of the set regular expressions for the tokenizer (at least the one we wrote) suggests you can't do this in practice; writing them individually was hard enough. If you don't want to do it perfectly, well, then, most of the RE solutions above are just fine.\nNow, why you would want strip comments is beyond me, unless you are building a code obfuscator. In this case, you have to have it perfectly right.","Q_Score":48,"Tags":"c++,python,c,regex,comments","A_Id":1078406,"CreationDate":"2008-10-27T20:47:00.000","Title":"Remove C and C++ comments 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},{"Question":"I'm looking for Python code that removes C and C++ comments from a string. (Assume the string contains an entire C source file.)\nI realize that I could .match() substrings with a Regex, but that doesn't solve nesting \/*, or having a \/\/ inside a \/* *\/.\nIdeally, I would prefer a non-naive implementation that properly handles awkward cases.","AnswerCount":13,"Available Count":2,"Score":0.0614608973,"is_accepted":false,"ViewCount":43080,"Q_Id":241327,"Users Score":4,"Answer":"The regular expression cases will fall down in some situations, like where a string literal contains a subsequence which matches the comment syntax. You really need a parse tree to deal with this.","Q_Score":48,"Tags":"c++,python,c,regex,comments","A_Id":242110,"CreationDate":"2008-10-27T20:47:00.000","Title":"Remove C and C++ comments 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},{"Question":"Dear stack overflow community,\nI've been given the task of overhauling a couple of websites for a large corporation I'm working for, as well as developing an internal intranet site for content management and document storage within the organization.\nMy \"problem\" is this: They want me to use a framework\/set of languages\/technologies that I can prove to them are \"stable, enterprise-ready technologies with a proven track record.\"\nThe spec's \"big picture\" really isn't too complicated: Implement an enterprise-class CMS for management of each division's web pages that deal mostly with product information and documentation (i.e. a simpler version of www.linksys.com).\nAs an open-source programmer, I'd like to use Python with TurboGears and build it from scratch, but I can't really find a way to prove to the president that TurboGears has a huge enterprise track record. Zope seems to have a lot of enterprise usage, but it looks a bit bloated to me. Django could be an option, but doesn't seem as flexible as TurboGears.\nI'd rather not use PHP, but Drupal has a very nice resume with the \"right\" names under it (AOL, Sony, MTV); plus it could save me building many of the CMS components from scratch.\nRails might be another option, but I'm not too familiar with it (and as a Python\/PHP programmer, Ruby's syntax drives me crazy).\nWhat would the S.O. community suggest for a project like this? I'm sure many of you have faced the same dilemma. What ended up working\/not working for you? As I said before, my first choice would be Python, second would be PHP, third would be Rails.\nThank you,\nSeth","AnswerCount":14,"Available Count":8,"Score":0.0428309231,"is_accepted":false,"ViewCount":4065,"Q_Id":241575,"Users Score":3,"Answer":"The first thing that comes to mind here is that you're approaching this all wrong. It seems like you're looking for a pet project for yourself and trying to decide what you'd like to do best. You didn't specify the scope of who is going to be managing this site.. which is the real question. Is it just you? Is it the management team? Is it each division? \nMaking a huge decision like this takes a lot of time and thought. We spend a lot of time just helping our clients choose the right CMS for their needs. There are a lot out there and a decision like this is not something to be taken lightly. A lot are good in the right situation and HORRIBLE in others. Also, what is right for you as the developer isn't necessarily right for your end user.\nAs someone up there suggested, you need a lot more research into what the requirements are before anyone (including the developer community) can make any suggestions about what is best to use.","Q_Score":8,"Tags":"python,frameworks,content-management-system,enterprise","A_Id":241773,"CreationDate":"2008-10-27T22:19:00.000","Title":"Framework\/CMS suggestions for enterprise website & intranet (I've got to convince the president its solid!)","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"Dear stack overflow community,\nI've been given the task of overhauling a couple of websites for a large corporation I'm working for, as well as developing an internal intranet site for content management and document storage within the organization.\nMy \"problem\" is this: They want me to use a framework\/set of languages\/technologies that I can prove to them are \"stable, enterprise-ready technologies with a proven track record.\"\nThe spec's \"big picture\" really isn't too complicated: Implement an enterprise-class CMS for management of each division's web pages that deal mostly with product information and documentation (i.e. a simpler version of www.linksys.com).\nAs an open-source programmer, I'd like to use Python with TurboGears and build it from scratch, but I can't really find a way to prove to the president that TurboGears has a huge enterprise track record. Zope seems to have a lot of enterprise usage, but it looks a bit bloated to me. Django could be an option, but doesn't seem as flexible as TurboGears.\nI'd rather not use PHP, but Drupal has a very nice resume with the \"right\" names under it (AOL, Sony, MTV); plus it could save me building many of the CMS components from scratch.\nRails might be another option, but I'm not too familiar with it (and as a Python\/PHP programmer, Ruby's syntax drives me crazy).\nWhat would the S.O. community suggest for a project like this? I'm sure many of you have faced the same dilemma. What ended up working\/not working for you? As I said before, my first choice would be Python, second would be PHP, third would be Rails.\nThank you,\nSeth","AnswerCount":14,"Available Count":8,"Score":0.0,"is_accepted":false,"ViewCount":4065,"Q_Id":241575,"Users Score":0,"Answer":"CMS for a medium-big company is not about Software. It is about proccesses and policies.\n\nVery true! \nAssociation with prestigious names is not necessarily an indicator of pleasing end results. \nI like Sony products, yes, but on the various occasions on which I have sought support from Sony sites I have felt like banging my head against a brick wall! Those head-cracking sites may not have been Drupal-oriented, I have no idea, but the point is: don't be sucked in by big names alone.\nAn issue you should expect is: preconceptions of what may be achieved (or constrained) by a system. \nAllow yourself some learning time with Plone \u2014\u00a0ideally, for a large project such as this, invest in expert advice \u2014\u00a0and you'll realise that traditional-ish ideas of what a system can or should accomplish are mostly exceeded by Plone's capabilities. \nGauge user requirements with a very open mind (not based on simplicities such as \"I'd like a system that's equal to system x\") then come to plone.org | Support | Chat Room to further discuss your requirements.","Q_Score":8,"Tags":"python,frameworks,content-management-system,enterprise","A_Id":294729,"CreationDate":"2008-10-27T22:19:00.000","Title":"Framework\/CMS suggestions for enterprise website & intranet (I've got to convince the president its solid!)","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"Dear stack overflow community,\nI've been given the task of overhauling a couple of websites for a large corporation I'm working for, as well as developing an internal intranet site for content management and document storage within the organization.\nMy \"problem\" is this: They want me to use a framework\/set of languages\/technologies that I can prove to them are \"stable, enterprise-ready technologies with a proven track record.\"\nThe spec's \"big picture\" really isn't too complicated: Implement an enterprise-class CMS for management of each division's web pages that deal mostly with product information and documentation (i.e. a simpler version of www.linksys.com).\nAs an open-source programmer, I'd like to use Python with TurboGears and build it from scratch, but I can't really find a way to prove to the president that TurboGears has a huge enterprise track record. Zope seems to have a lot of enterprise usage, but it looks a bit bloated to me. Django could be an option, but doesn't seem as flexible as TurboGears.\nI'd rather not use PHP, but Drupal has a very nice resume with the \"right\" names under it (AOL, Sony, MTV); plus it could save me building many of the CMS components from scratch.\nRails might be another option, but I'm not too familiar with it (and as a Python\/PHP programmer, Ruby's syntax drives me crazy).\nWhat would the S.O. community suggest for a project like this? I'm sure many of you have faced the same dilemma. What ended up working\/not working for you? As I said before, my first choice would be Python, second would be PHP, third would be Rails.\nThank you,\nSeth","AnswerCount":14,"Available Count":8,"Score":0.0428309231,"is_accepted":false,"ViewCount":4065,"Q_Id":241575,"Users Score":3,"Answer":"I agree with Will's, braveterry's and Divamatrix's comments. Fully.\nThere are tons of questions\/issues\/risks\/considerations to take in order to succesfully launch a CMS solution for a medium\/big enterprise. I will not repeat what Will and braveterry had said, instead of it I will offer a different point of view:\nCMS for a medium-big company is not about Software. It is about proccesses and policies.\nWhich framework\/tool to use must be dependent on exact requirements (kind of content, sources for content, who will be responsible to capture and create content, what are their abilities, who will be approving content updates, which departments will have a voice on what goes into the home page?, under which policies will be selected the content for the home page?, what will be the puropose for the home page? (marketing? sales? technical? branding?).\nIf the answers to these questions (there are lot more) are not clear to you or even if you do not get why are SO important. Then I think you need to contract a seasoned consulting firm.\nPS: This gives me the idea to publish some sort of paper about this topic but that would take some days as I currently do not have the time to prepare it.","Q_Score":8,"Tags":"python,frameworks,content-management-system,enterprise","A_Id":241785,"CreationDate":"2008-10-27T22:19:00.000","Title":"Framework\/CMS suggestions for enterprise website & intranet (I've got to convince the president its solid!)","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"Dear stack overflow community,\nI've been given the task of overhauling a couple of websites for a large corporation I'm working for, as well as developing an internal intranet site for content management and document storage within the organization.\nMy \"problem\" is this: They want me to use a framework\/set of languages\/technologies that I can prove to them are \"stable, enterprise-ready technologies with a proven track record.\"\nThe spec's \"big picture\" really isn't too complicated: Implement an enterprise-class CMS for management of each division's web pages that deal mostly with product information and documentation (i.e. a simpler version of www.linksys.com).\nAs an open-source programmer, I'd like to use Python with TurboGears and build it from scratch, but I can't really find a way to prove to the president that TurboGears has a huge enterprise track record. Zope seems to have a lot of enterprise usage, but it looks a bit bloated to me. Django could be an option, but doesn't seem as flexible as TurboGears.\nI'd rather not use PHP, but Drupal has a very nice resume with the \"right\" names under it (AOL, Sony, MTV); plus it could save me building many of the CMS components from scratch.\nRails might be another option, but I'm not too familiar with it (and as a Python\/PHP programmer, Ruby's syntax drives me crazy).\nWhat would the S.O. community suggest for a project like this? I'm sure many of you have faced the same dilemma. What ended up working\/not working for you? As I said before, my first choice would be Python, second would be PHP, third would be Rails.\nThank you,\nSeth","AnswerCount":14,"Available Count":8,"Score":0.0142847425,"is_accepted":false,"ViewCount":4065,"Q_Id":241575,"Users Score":1,"Answer":"No matter what you choose, don't use Typo3. It is a huge unhackable mess with its own idiotic template \"script\" language, near impossible to learn quickly, hard to teach to your enterprise users and damn ugly. No wonder there are shops which earn a living just doing Typo3 consulting. It is somewhat popular but don't think there is any decent documentation.","Q_Score":8,"Tags":"python,frameworks,content-management-system,enterprise","A_Id":241593,"CreationDate":"2008-10-27T22:19:00.000","Title":"Framework\/CMS suggestions for enterprise website & intranet (I've got to convince the president its solid!)","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"Dear stack overflow community,\nI've been given the task of overhauling a couple of websites for a large corporation I'm working for, as well as developing an internal intranet site for content management and document storage within the organization.\nMy \"problem\" is this: They want me to use a framework\/set of languages\/technologies that I can prove to them are \"stable, enterprise-ready technologies with a proven track record.\"\nThe spec's \"big picture\" really isn't too complicated: Implement an enterprise-class CMS for management of each division's web pages that deal mostly with product information and documentation (i.e. a simpler version of www.linksys.com).\nAs an open-source programmer, I'd like to use Python with TurboGears and build it from scratch, but I can't really find a way to prove to the president that TurboGears has a huge enterprise track record. Zope seems to have a lot of enterprise usage, but it looks a bit bloated to me. Django could be an option, but doesn't seem as flexible as TurboGears.\nI'd rather not use PHP, but Drupal has a very nice resume with the \"right\" names under it (AOL, Sony, MTV); plus it could save me building many of the CMS components from scratch.\nRails might be another option, but I'm not too familiar with it (and as a Python\/PHP programmer, Ruby's syntax drives me crazy).\nWhat would the S.O. community suggest for a project like this? I'm sure many of you have faced the same dilemma. What ended up working\/not working for you? As I said before, my first choice would be Python, second would be PHP, third would be Rails.\nThank you,\nSeth","AnswerCount":14,"Available Count":8,"Score":0.0285636566,"is_accepted":false,"ViewCount":4065,"Q_Id":241575,"Users Score":2,"Answer":"You'd like to build an Enterprise Class CMS from scratch? Just for one project? Are you crazy? Unless plan to go into the CMS business and have thousands and thousands of hours of development time there absolutely is no point to create a new one. There are excellent CMS's already out there. Drupal and Plone are the best in my opinion. I like Plone because its delightful to use. It's used by CIA, NASA, Akami, Novell and Ebay. \nBest wishes, \nTony","Q_Score":8,"Tags":"python,frameworks,content-management-system,enterprise","A_Id":243952,"CreationDate":"2008-10-27T22:19:00.000","Title":"Framework\/CMS suggestions for enterprise website & intranet (I've got to convince the president its solid!)","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"Dear stack overflow community,\nI've been given the task of overhauling a couple of websites for a large corporation I'm working for, as well as developing an internal intranet site for content management and document storage within the organization.\nMy \"problem\" is this: They want me to use a framework\/set of languages\/technologies that I can prove to them are \"stable, enterprise-ready technologies with a proven track record.\"\nThe spec's \"big picture\" really isn't too complicated: Implement an enterprise-class CMS for management of each division's web pages that deal mostly with product information and documentation (i.e. a simpler version of www.linksys.com).\nAs an open-source programmer, I'd like to use Python with TurboGears and build it from scratch, but I can't really find a way to prove to the president that TurboGears has a huge enterprise track record. Zope seems to have a lot of enterprise usage, but it looks a bit bloated to me. Django could be an option, but doesn't seem as flexible as TurboGears.\nI'd rather not use PHP, but Drupal has a very nice resume with the \"right\" names under it (AOL, Sony, MTV); plus it could save me building many of the CMS components from scratch.\nRails might be another option, but I'm not too familiar with it (and as a Python\/PHP programmer, Ruby's syntax drives me crazy).\nWhat would the S.O. community suggest for a project like this? I'm sure many of you have faced the same dilemma. What ended up working\/not working for you? As I said before, my first choice would be Python, second would be PHP, third would be Rails.\nThank you,\nSeth","AnswerCount":14,"Available Count":8,"Score":1.0,"is_accepted":false,"ViewCount":4065,"Q_Id":241575,"Users Score":9,"Answer":"This is a contradictory statement: \"The spec's \"big picture\" really isn't too complicated: Implement an enterprise-class CMS for management of each division's web pages\".\n\"Enterprise Class\" and \"isn't too complicated\" do not belong in the same sentence. Seriously.\n\"Enterprise Class\" stuff is complicated because \"enterprise class\" tasks and environments are complicated.\nMind, just because something is deployed within an enterprise doesn't mean it requires an \"enterprise class\" tool. But those that DO have \"enterprise class\" requirements ARE complicated because the problem domain and deployment environment are complicated.\nSo, you need to be more clear on your specs than \"buzzword compliant\", \"my boss has heard of it\", \"never breaks\", etc.\nCMS seems deceptively simple, but it's not. If it's geeks managing stuff for geeks, that's one thing, but CMSs tend to have great impact on non-technical end users which can dramatically complicate user interfaces, security, workflows, support, etc. Think \"marketing wants to maintain the website\", and that they're going to let their junior intern do it.\nSo, seriously, without REAL requirements it's hard to suggest anything. And without REAL requirements, and a solid understanding of your user base, you most certainly should NOT just \"roll your own\".","Q_Score":8,"Tags":"python,frameworks,content-management-system,enterprise","A_Id":241637,"CreationDate":"2008-10-27T22:19:00.000","Title":"Framework\/CMS suggestions for enterprise website & intranet (I've got to convince the president its solid!)","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"Dear stack overflow community,\nI've been given the task of overhauling a couple of websites for a large corporation I'm working for, as well as developing an internal intranet site for content management and document storage within the organization.\nMy \"problem\" is this: They want me to use a framework\/set of languages\/technologies that I can prove to them are \"stable, enterprise-ready technologies with a proven track record.\"\nThe spec's \"big picture\" really isn't too complicated: Implement an enterprise-class CMS for management of each division's web pages that deal mostly with product information and documentation (i.e. a simpler version of www.linksys.com).\nAs an open-source programmer, I'd like to use Python with TurboGears and build it from scratch, but I can't really find a way to prove to the president that TurboGears has a huge enterprise track record. Zope seems to have a lot of enterprise usage, but it looks a bit bloated to me. Django could be an option, but doesn't seem as flexible as TurboGears.\nI'd rather not use PHP, but Drupal has a very nice resume with the \"right\" names under it (AOL, Sony, MTV); plus it could save me building many of the CMS components from scratch.\nRails might be another option, but I'm not too familiar with it (and as a Python\/PHP programmer, Ruby's syntax drives me crazy).\nWhat would the S.O. community suggest for a project like this? I'm sure many of you have faced the same dilemma. What ended up working\/not working for you? As I said before, my first choice would be Python, second would be PHP, third would be Rails.\nThank you,\nSeth","AnswerCount":14,"Available Count":8,"Score":0.0285636566,"is_accepted":false,"ViewCount":4065,"Q_Id":241575,"Users Score":2,"Answer":"\"They want me to use a framework\/set of languages\/technologies that I can prove to them are \"stable, enterprise-ready technologies with a proven track record.\"\"\nThere's no proof of those features. None.\nIs there some incumbent technology that they want you to use? If so, you might be swimming upstream.\n\nIf you're fighting for your preferred technology, you probably can't win their hearts and minds without a serious proof of concept or pilot project or something.\nIf they're willing to listen, they'd be more willing to listen if you had a demo that showed how rock-solid your preferred approach is.\n\nif there is no incumbent, then they're just wringing their hands. In this case, you'll need some evidence they actually believe -- a pilot project or a proof of concept.\nThere's no Proof in this industry. For every technology you can find a proponent and an opponent. Even crap technology has proponents. Forget proof. \nJust pick something that you can use very rapidly. Get something up and running so quickly, with such high quality that you're obviously right and the rest of your opinions must be equally right.\nFor this reason, flexibility has no value. Go with Django and get something to run ASAP.","Q_Score":8,"Tags":"python,frameworks,content-management-system,enterprise","A_Id":241831,"CreationDate":"2008-10-27T22:19:00.000","Title":"Framework\/CMS suggestions for enterprise website & intranet (I've got to convince the president its solid!)","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"Dear stack overflow community,\nI've been given the task of overhauling a couple of websites for a large corporation I'm working for, as well as developing an internal intranet site for content management and document storage within the organization.\nMy \"problem\" is this: They want me to use a framework\/set of languages\/technologies that I can prove to them are \"stable, enterprise-ready technologies with a proven track record.\"\nThe spec's \"big picture\" really isn't too complicated: Implement an enterprise-class CMS for management of each division's web pages that deal mostly with product information and documentation (i.e. a simpler version of www.linksys.com).\nAs an open-source programmer, I'd like to use Python with TurboGears and build it from scratch, but I can't really find a way to prove to the president that TurboGears has a huge enterprise track record. Zope seems to have a lot of enterprise usage, but it looks a bit bloated to me. Django could be an option, but doesn't seem as flexible as TurboGears.\nI'd rather not use PHP, but Drupal has a very nice resume with the \"right\" names under it (AOL, Sony, MTV); plus it could save me building many of the CMS components from scratch.\nRails might be another option, but I'm not too familiar with it (and as a Python\/PHP programmer, Ruby's syntax drives me crazy).\nWhat would the S.O. community suggest for a project like this? I'm sure many of you have faced the same dilemma. What ended up working\/not working for you? As I said before, my first choice would be Python, second would be PHP, third would be Rails.\nThank you,\nSeth","AnswerCount":14,"Available Count":8,"Score":0.0285636566,"is_accepted":false,"ViewCount":4065,"Q_Id":241575,"Users Score":2,"Answer":"\"Enterprise\" is a marketing term. It has pretty much zero technical meaning. If your boss wants to hear Enterprise, then he will, but this won't mean that a given system is suitable for your needs. \nBeware of lists of companies that use a given suite of software. \"Ebay uses Plone\", and \"Ebay runs on Plone\" are two very different statements. \nMostly, if you're doing \"Enterprise\" CMS (for whatever that term is worth) you should expect to have a learning curve that will only just begin to flatten out by the end of a significant project. \nFor your project, I'd suggest you try to figure out what you really need. If you think TurboGears (or any other framework) is a good fit, discuss some risk management strategies with your boss. Maybe a small pilot to start with. Adopting a new technology is risky. Many \"large corporation\" web sites are mission-critical these days. \nFor what it's worth. I like Plone, but I've only ever used it for non-corporate stuff. I don't personally know of any \"Enterprise\" implementations. At work I use Tridion, and I know of numerous implementations at that level. (If you're looking for a choice that will let you work in Python, Tridion isn't a good fit.)","Q_Score":8,"Tags":"python,frameworks,content-management-system,enterprise","A_Id":1384018,"CreationDate":"2008-10-27T22:19:00.000","Title":"Framework\/CMS suggestions for enterprise website & intranet (I've got to convince the president its solid!)","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"which would you recommend?\nwhich is faster, reliable?\napache mod_python or nginx\/lighttpd FastCGI?","AnswerCount":7,"Available Count":6,"Score":0.057080742,"is_accepted":false,"ViewCount":5251,"Q_Id":245237,"Users Score":2,"Answer":"I'm using it with nginx. not sure if it's really faster, but certainly less RAM\/CPU load. Also it's easier to run several Django processes and have nginx map each URL prefix to a different socket. still not taking full advantage of nginx's memcached module, but first tests show huge speed advantage.","Q_Score":20,"Tags":"python,django,apache,fastcgi","A_Id":245464,"CreationDate":"2008-10-28T23:16:00.000","Title":"Running Django with FastCGI or with mod_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},{"Question":"which would you recommend?\nwhich is faster, reliable?\napache mod_python or nginx\/lighttpd FastCGI?","AnswerCount":7,"Available Count":6,"Score":0.057080742,"is_accepted":false,"ViewCount":5251,"Q_Id":245237,"Users Score":2,"Answer":"There's also mod_wsgi, it seems to be faster than mod_python and the daemon mode operates similar to FastCGI","Q_Score":20,"Tags":"python,django,apache,fastcgi","A_Id":245484,"CreationDate":"2008-10-28T23:16:00.000","Title":"Running Django with FastCGI or with mod_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},{"Question":"which would you recommend?\nwhich is faster, reliable?\napache mod_python or nginx\/lighttpd FastCGI?","AnswerCount":7,"Available Count":6,"Score":0.057080742,"is_accepted":false,"ViewCount":5251,"Q_Id":245237,"Users Score":2,"Answer":"Personally I've had it working with FastCGI for some time now (6 months or so) and the response times 'seem' quicker when loading a page that way vs mod___python. The critical reason for me though is that I couldn't see an obvious way to do multiple sites from the same apache \/ mod_python install whereas FastCGI was a relative no-brainer.\nI've not conducted any particularly thorough experiments though :-)\n[Edit] Speaking from experience though, setting up FastCGI can be a bit of a pain the first time around. I keep meaning to write a guide..!","Q_Score":20,"Tags":"python,django,apache,fastcgi","A_Id":245259,"CreationDate":"2008-10-28T23:16:00.000","Title":"Running Django with FastCGI or with mod_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},{"Question":"which would you recommend?\nwhich is faster, reliable?\napache mod_python or nginx\/lighttpd FastCGI?","AnswerCount":7,"Available Count":6,"Score":0.1418931938,"is_accepted":false,"ViewCount":5251,"Q_Id":245237,"Users Score":5,"Answer":"Nginx with mod_wsgi","Q_Score":20,"Tags":"python,django,apache,fastcgi","A_Id":258159,"CreationDate":"2008-10-28T23:16:00.000","Title":"Running Django with FastCGI or with mod_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},{"Question":"which would you recommend?\nwhich is faster, reliable?\napache mod_python or nginx\/lighttpd FastCGI?","AnswerCount":7,"Available Count":6,"Score":1.2,"is_accepted":true,"ViewCount":5251,"Q_Id":245237,"Users Score":21,"Answer":"I've done both, and Apache\/mod_python tended to be easier to work with and more stable. But these days I've jumped over to Apache\/mod_wsgi, which is everything I've ever wanted and more:\n\nEasy management of daemon processes.\nAs a result, much better process isolation (running multiple sites in the same Apache config with mod_python almost always ends in trouble -- environment variables and C extensions leak across sites when you do that).\nEasy code reloads (set it up right and you can just touch the .wsgi file to reload instead of restarting Apache).\nMore predictable resource usage. With mod_python, a given Apache child process' memory use can jump around a lot. With mod_wsgi it's pretty stable: once everything's loaded, you know that's how much memory it'll use.","Q_Score":20,"Tags":"python,django,apache,fastcgi","A_Id":245660,"CreationDate":"2008-10-28T23:16:00.000","Title":"Running Django with FastCGI or with mod_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},{"Question":"which would you recommend?\nwhich is faster, reliable?\napache mod_python or nginx\/lighttpd FastCGI?","AnswerCount":7,"Available Count":6,"Score":1.0,"is_accepted":false,"ViewCount":5251,"Q_Id":245237,"Users Score":6,"Answer":"lighttpd with FastCGI will be nominally faster, but really the time it takes to run your python code and any database hits it does is going to absolutely dwarf any performance benefit you get between web servers.\nmod_python and apache will give you a bit more flexibility feature-wise if you want to write code outside of django that does stuff like digest auth, or any fancy HTTP header getting\/setting. Perhaps you want to use other builtin features of apache such as mod_rewrite.\nIf memory is a concern, staying away form apache\/mod_python will help a lot. Apache tends to use a lot of RAM, and the mod_python code that glues into all of the apache functionality occupies a lot of memory-space as well. Not to mention the multiprocess nature of apache tends to eat up more RAM, as each process grows to the size of it's most intensive request.","Q_Score":20,"Tags":"python,django,apache,fastcgi","A_Id":245264,"CreationDate":"2008-10-28T23:16:00.000","Title":"Running Django with FastCGI or with mod_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},{"Question":"When I see Lua, the only thing I ever read is \"great for embedding\", \"fast\", \"lightweight\" and more often than anything else: \"World of Warcraft\" or in short \"WoW\".\nWhy is it limited to embedding the whole thing into another application? Why not write general-purpose scripts like you do with Python or Perl?\nLua seems to be doing great in aspects like speed and memory-usage (The fastest scripting language afaik) so why is it that I never see Lua being used as a \"Desktop scripting-language\" to automate tasks? For example:\n\nRenaming a bunch of files\nDownload some files from the web\nWebscraping\n\nIs it the lack of the standard library?","AnswerCount":11,"Available Count":4,"Score":1.2,"is_accepted":true,"ViewCount":12626,"Q_Id":250151,"Users Score":12,"Answer":"Just because it is \"marketed\" (in some general sense) as a special-purpose language for embedded script engines, does not mean that it is limited to that. In fact, WoW could probably just as well have chosen Python as their embedded scripting language.","Q_Score":37,"Tags":"python,scripting,lua","A_Id":250158,"CreationDate":"2008-10-30T13:21:00.000","Title":"Lua as a general-purpose scripting 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},{"Question":"When I see Lua, the only thing I ever read is \"great for embedding\", \"fast\", \"lightweight\" and more often than anything else: \"World of Warcraft\" or in short \"WoW\".\nWhy is it limited to embedding the whole thing into another application? Why not write general-purpose scripts like you do with Python or Perl?\nLua seems to be doing great in aspects like speed and memory-usage (The fastest scripting language afaik) so why is it that I never see Lua being used as a \"Desktop scripting-language\" to automate tasks? For example:\n\nRenaming a bunch of files\nDownload some files from the web\nWebscraping\n\nIs it the lack of the standard library?","AnswerCount":11,"Available Count":4,"Score":0.0544914242,"is_accepted":false,"ViewCount":12626,"Q_Id":250151,"Users Score":3,"Answer":"In order for Lua to be easy to embed it has to have few dependencies and be small. That makes it poorly suited as a general purpose scripting language. Because using it as a general purpose script language would require a lot of standard libraries. But if Lua had a lot of standard libraries it would be harder to embed (due to dependencies and memory footprint.)","Q_Score":37,"Tags":"python,scripting,lua","A_Id":781316,"CreationDate":"2008-10-30T13:21:00.000","Title":"Lua as a general-purpose scripting 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},{"Question":"When I see Lua, the only thing I ever read is \"great for embedding\", \"fast\", \"lightweight\" and more often than anything else: \"World of Warcraft\" or in short \"WoW\".\nWhy is it limited to embedding the whole thing into another application? Why not write general-purpose scripts like you do with Python or Perl?\nLua seems to be doing great in aspects like speed and memory-usage (The fastest scripting language afaik) so why is it that I never see Lua being used as a \"Desktop scripting-language\" to automate tasks? For example:\n\nRenaming a bunch of files\nDownload some files from the web\nWebscraping\n\nIs it the lack of the standard library?","AnswerCount":11,"Available Count":4,"Score":0.072599319,"is_accepted":false,"ViewCount":12626,"Q_Id":250151,"Users Score":4,"Answer":"I think the answer about it being a \"marketing\" thing is probably correct, along with the lack of a large set of libraries to choose from. I would like to point out another case of this: Ruby. Ruby is meant to be a general purpose scripting language. The problem is that since Ruby on Rails has risen to be so popular, it is becoming hard to find something that is unrelated to Rails. I'm afraid Lua will suffer this as well, being popular because of a few major things using it, but never able to break free of that stigma.","Q_Score":37,"Tags":"python,scripting,lua","A_Id":253659,"CreationDate":"2008-10-30T13:21:00.000","Title":"Lua as a general-purpose scripting 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},{"Question":"When I see Lua, the only thing I ever read is \"great for embedding\", \"fast\", \"lightweight\" and more often than anything else: \"World of Warcraft\" or in short \"WoW\".\nWhy is it limited to embedding the whole thing into another application? Why not write general-purpose scripts like you do with Python or Perl?\nLua seems to be doing great in aspects like speed and memory-usage (The fastest scripting language afaik) so why is it that I never see Lua being used as a \"Desktop scripting-language\" to automate tasks? For example:\n\nRenaming a bunch of files\nDownload some files from the web\nWebscraping\n\nIs it the lack of the standard library?","AnswerCount":11,"Available Count":4,"Score":1.0,"is_accepted":false,"ViewCount":12626,"Q_Id":250151,"Users Score":6,"Answer":"Definitely a lack of standard libraries. It's also lesser known than Python, Perl or Ruby.","Q_Score":37,"Tags":"python,scripting,lua","A_Id":251372,"CreationDate":"2008-10-30T13:21:00.000","Title":"Lua as a general-purpose scripting 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},{"Question":"What's the difference between these two?\nWhich is better\/faster\/reliable?","AnswerCount":3,"Available Count":2,"Score":1.0,"is_accepted":false,"ViewCount":16163,"Q_Id":257481,"Users Score":12,"Answer":"SCGI (like FastCGI) is a (serialized) protocol suitable for inter-process communication between a web-server and a web-application.\nWSGI is a Python API, connecting two (or more) Python WSGI-compatible modules inside the same process (Python interpreter). One module represents the web-server (being either a Python in-process web-server implementation or a gateway to a web-server in another process via e.g. SCGI). The other module is or represents the web application. Additionally, zero or more modules between theses two modules, may serve as WSGI \"middleware\" modules, doing things like session\/cookie management, content caching, authentication, etc. The WSGI API uses Python language features like iteration\/generators and passing of callable objects between the cooperating WSGI-compatible modules.","Q_Score":19,"Tags":"python,wsgi,scgi","A_Id":778530,"CreationDate":"2008-11-02T22:22:00.000","Title":"What's the difference between scgi and 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":0},{"Question":"What's the difference between these two?\nWhich is better\/faster\/reliable?","AnswerCount":3,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":16163,"Q_Id":257481,"Users Score":27,"Answer":"SCGI is a language-neutral means of connecting a front-end web server and a web application. WSGI is a Python-specific interface standard for web applications.\nThough they both have roots in CGI, they're rather different in scope and you could indeed quite reasonably use both at once, for example having a mod_scgi on the webserver talk to a WSGI app run as an SCGI server. There are multiple library implementations that will run WSGI applications as SCGI servers for you (eg. wsgitools, cherrypy).\nThey are both 'reliable', in as much as you can consider a specification reliable as opposed to a particular implementation. These days you would probably write your application as a WSGI callable, and consider the question of deployment separately.\nMaybe an Apache+mod_wsgi (embedded) interface might be a bit faster than an Apache+mod_scgi+(SCGI wrapper lib), but in all likelihood it's not going to be hugely different. More valuable is the ability to run the application on a variety of servers, platforms and connection standards.","Q_Score":19,"Tags":"python,wsgi,scgi","A_Id":257642,"CreationDate":"2008-11-02T22:22:00.000","Title":"What's the difference between scgi and 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":0},{"Question":"Considering the criteria listed below, which of Python, Groovy or Ruby would you use?\n\nCriteria (Importance out of 10, 10 being most important)\nRichness of API\/libraries available (eg. maths, plotting, networking) (9)\nAbility to embed in desktop (java\/c++) applications (8)\nEase of deployment (8)\nAbility to interface with DLLs\/Shared Libraries (7)\nAbility to generate GUIs (7)\nCommunity\/User support (6)\nPortability (6)\nDatabase manipulation (3)\nLanguage\/Semantics (2)","AnswerCount":10,"Available Count":7,"Score":0.0599281035,"is_accepted":false,"ViewCount":36111,"Q_Id":257730,"Users Score":3,"Answer":"This sort of adding-up-scores-by-features is not a good way to choose a programming language. You'd be better off choosing whichever you know the best. If you don't know any of them, try them out for a little while. If you have a really specific project in mind, then maybe some programming languages would be better, but if you just have general preferences you will never come to a consensus.\nThat said, Python is pretty flexible, it's the most popular on your list so the easiest to solve whatever sorts of problems you have by searching, so I'd recommend Python.","Q_Score":35,"Tags":"python,ruby,scripting,groovy","A_Id":257770,"CreationDate":"2008-11-03T01:31:00.000","Title":"Python vs Groovy vs Ruby? (based on criteria listed in 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":0,"Web Development":1},{"Question":"Considering the criteria listed below, which of Python, Groovy or Ruby would you use?\n\nCriteria (Importance out of 10, 10 being most important)\nRichness of API\/libraries available (eg. maths, plotting, networking) (9)\nAbility to embed in desktop (java\/c++) applications (8)\nEase of deployment (8)\nAbility to interface with DLLs\/Shared Libraries (7)\nAbility to generate GUIs (7)\nCommunity\/User support (6)\nPortability (6)\nDatabase manipulation (3)\nLanguage\/Semantics (2)","AnswerCount":10,"Available Count":7,"Score":1.2,"is_accepted":true,"ViewCount":36111,"Q_Id":257730,"Users Score":33,"Answer":"I think it's going to be difficult to get an objective comparison. I personally prefer Python. To address one of your criteria, Python was designed from the start to be an embeddable language. It has a very rich C API, and the interpreter is modularized to make it easy to call from C. If Java is your host environment, you should look at Jython, an implementation of Python inside the Java environment (VM and libs).","Q_Score":35,"Tags":"python,ruby,scripting,groovy","A_Id":257746,"CreationDate":"2008-11-03T01:31:00.000","Title":"Python vs Groovy vs Ruby? (based on criteria listed in 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":0,"Web Development":1},{"Question":"Considering the criteria listed below, which of Python, Groovy or Ruby would you use?\n\nCriteria (Importance out of 10, 10 being most important)\nRichness of API\/libraries available (eg. maths, plotting, networking) (9)\nAbility to embed in desktop (java\/c++) applications (8)\nEase of deployment (8)\nAbility to interface with DLLs\/Shared Libraries (7)\nAbility to generate GUIs (7)\nCommunity\/User support (6)\nPortability (6)\nDatabase manipulation (3)\nLanguage\/Semantics (2)","AnswerCount":10,"Available Count":7,"Score":1.0,"is_accepted":false,"ViewCount":36111,"Q_Id":257730,"Users Score":28,"Answer":"Having worked with all 3 of them, this is what I can say:\n\nPython \n\nhas very mature libraries\nlibraries are documented\ndocumentation can be accessed from your debugger\/shell at runtime through the docstrings\nyou can develop code without an IDE\n\nRuby\n\nhas some great libraries ( even though some are badly documented )\nRuby's instrospection mechanisms are great. They make writing code pretty easy ( even if documentation is not available )\nyou can develop code without an IDE\n\nGroovy\n\nyou can benefit from everything Java has to offer\nsyntax is somewhat inspired from Ruby\nit's hard to write code without an IDE. You have no way to debug stuff from your console ( this is something you can easily do in Python\/Ruby ) and the available Groovy plugins have a lot of catching up to do. I wrote some apps using Groovy and as they get bigger I regret not going with Ruby\/Python ( debugging would have been WAY more easier ). If you'll only develop from an IDE, Groovy's a cool language.","Q_Score":35,"Tags":"python,ruby,scripting,groovy","A_Id":1401616,"CreationDate":"2008-11-03T01:31:00.000","Title":"Python vs Groovy vs Ruby? (based on criteria listed in 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":0,"Web Development":1},{"Question":"Considering the criteria listed below, which of Python, Groovy or Ruby would you use?\n\nCriteria (Importance out of 10, 10 being most important)\nRichness of API\/libraries available (eg. maths, plotting, networking) (9)\nAbility to embed in desktop (java\/c++) applications (8)\nEase of deployment (8)\nAbility to interface with DLLs\/Shared Libraries (7)\nAbility to generate GUIs (7)\nCommunity\/User support (6)\nPortability (6)\nDatabase manipulation (3)\nLanguage\/Semantics (2)","AnswerCount":10,"Available Count":7,"Score":1.0,"is_accepted":false,"ViewCount":36111,"Q_Id":257730,"Users Score":8,"Answer":"try Groovy .. it has all features that you need there. You can use existing java lib without any modification on its classes. \nbasically .. groovy is java++, it is more dynamic and fun to learn (just like ruby)\nI dont like ruby or python syntax so I will put them behind. Groovy is just like C\/C++ syntax so I like him lol :)","Q_Score":35,"Tags":"python,ruby,scripting,groovy","A_Id":326962,"CreationDate":"2008-11-03T01:31:00.000","Title":"Python vs Groovy vs Ruby? (based on criteria listed in 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":0,"Web Development":1},{"Question":"Considering the criteria listed below, which of Python, Groovy or Ruby would you use?\n\nCriteria (Importance out of 10, 10 being most important)\nRichness of API\/libraries available (eg. maths, plotting, networking) (9)\nAbility to embed in desktop (java\/c++) applications (8)\nEase of deployment (8)\nAbility to interface with DLLs\/Shared Libraries (7)\nAbility to generate GUIs (7)\nCommunity\/User support (6)\nPortability (6)\nDatabase manipulation (3)\nLanguage\/Semantics (2)","AnswerCount":10,"Available Count":7,"Score":1.0,"is_accepted":false,"ViewCount":36111,"Q_Id":257730,"Users Score":7,"Answer":"Python has all nine criteria. It scores a 56.\nI'm sure Ruby has everything Python has. It seems to have fewer libraries. So it scores a 51.\nI don't know if Groovy has every feature.\nSince Python is 56 and Ruby is a 51, Python just barely edges out Ruby.\nHowever, I think this kind of decision can still boil down to some subjective issues outside these nine criteria.","Q_Score":35,"Tags":"python,ruby,scripting,groovy","A_Id":257831,"CreationDate":"2008-11-03T01:31:00.000","Title":"Python vs Groovy vs Ruby? (based on criteria listed in 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":0,"Web Development":1},{"Question":"Considering the criteria listed below, which of Python, Groovy or Ruby would you use?\n\nCriteria (Importance out of 10, 10 being most important)\nRichness of API\/libraries available (eg. maths, plotting, networking) (9)\nAbility to embed in desktop (java\/c++) applications (8)\nEase of deployment (8)\nAbility to interface with DLLs\/Shared Libraries (7)\nAbility to generate GUIs (7)\nCommunity\/User support (6)\nPortability (6)\nDatabase manipulation (3)\nLanguage\/Semantics (2)","AnswerCount":10,"Available Count":7,"Score":1.0,"is_accepted":false,"ViewCount":36111,"Q_Id":257730,"Users Score":24,"Answer":"Just to muddy the waters...\nGroovy give you access to Java. Java has an extremely rich set of APIs\/Libraries, applications, etc.\nGroovy is embeddable, although easiest in Java.\nDLLs\/Libraries (if you're talking about non-Groovy\/Java) may be somewhat problematic, although there are ways and some APIs to help.\nI've done some Python programming, but being more familiar with Java, Groovy comes a lot easier to me.","Q_Score":35,"Tags":"python,ruby,scripting,groovy","A_Id":257776,"CreationDate":"2008-11-03T01:31:00.000","Title":"Python vs Groovy vs Ruby? (based on criteria listed in 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":0,"Web Development":1},{"Question":"Considering the criteria listed below, which of Python, Groovy or Ruby would you use?\n\nCriteria (Importance out of 10, 10 being most important)\nRichness of API\/libraries available (eg. maths, plotting, networking) (9)\nAbility to embed in desktop (java\/c++) applications (8)\nEase of deployment (8)\nAbility to interface with DLLs\/Shared Libraries (7)\nAbility to generate GUIs (7)\nCommunity\/User support (6)\nPortability (6)\nDatabase manipulation (3)\nLanguage\/Semantics (2)","AnswerCount":10,"Available Count":7,"Score":0.0,"is_accepted":false,"ViewCount":36111,"Q_Id":257730,"Users Score":0,"Answer":"I know it's not on your list, but at least look at perl.\n\nRichness of Api\/Libraries to sink a ship. \nRuns on more systems than most people realise exists. \nWorks well with Binary libraries. \nHas a huge community.\nPortability, See above.\nDatabase manipulation: more ways to do it. ( Pick your favorite module ) \nAnd one of the most expressive\/terse languages around.","Q_Score":35,"Tags":"python,ruby,scripting,groovy","A_Id":257738,"CreationDate":"2008-11-03T01:31:00.000","Title":"Python vs Groovy vs Ruby? (based on criteria listed in 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":0,"Web Development":1},{"Question":"A colleague is looking to generate UML class diagrams from heaps of Python source code. \nHe's primarily interested in the inheritance relationships, and mildly interested in compositional relationships, and doesn't care much about class attributes that are just Python primitives.\nThe source code is pretty straightforward and not tremendously evil--it doesn't do any fancy metaclass magic, for example. (It's mostly from the days of Python 1.5.2, with some sprinklings of \"modern\" 2.3ish stuff.) \nWhat's the best existing solution to recommend?","AnswerCount":10,"Available Count":2,"Score":1.0,"is_accepted":false,"ViewCount":274257,"Q_Id":260165,"Users Score":14,"Answer":"Certain classes of well-behaved programs may be diagrammable, but in the general case, it can't be done. Python objects can be extended at run time, and objects of any type can be assigned to any instance variable. Figuring out what classes an object can contain pointers to (composition) would require a full understanding of the runtime behavior of the program.\nPython's metaclass capabilities mean that reasoning about the inheritance structure would also require a full understanding of the runtime behavior of the program.\nTo prove that these are impossible, you argue that if such a UML diagrammer existed, then you could take an arbitrary program, convert \"halt\" statements into statements that would impact the UML diagram, and use the UML diagrammer to solve the halting problem, which as we know is impossible.","Q_Score":355,"Tags":"python,uml,diagram","A_Id":260196,"CreationDate":"2008-11-03T22:08:00.000","Title":"What's the best way to generate a UML diagram from Python source 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},{"Question":"A colleague is looking to generate UML class diagrams from heaps of Python source code. \nHe's primarily interested in the inheritance relationships, and mildly interested in compositional relationships, and doesn't care much about class attributes that are just Python primitives.\nThe source code is pretty straightforward and not tremendously evil--it doesn't do any fancy metaclass magic, for example. (It's mostly from the days of Python 1.5.2, with some sprinklings of \"modern\" 2.3ish stuff.) \nWhat's the best existing solution to recommend?","AnswerCount":10,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":274257,"Q_Id":260165,"Users Score":5,"Answer":"Umbrello does that too. in the menu go to Code -> import project and then point to the root deirectory of your project. then it reverses the code for ya...","Q_Score":355,"Tags":"python,uml,diagram","A_Id":6606829,"CreationDate":"2008-11-03T22:08:00.000","Title":"What's the best way to generate a UML diagram from Python source 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},{"Question":"How can I play audio (it would be like a 1 second sound) from a Python script?\nIt would be best if it was platform independent, but firstly it needs to work on a Mac.\nI know I could just execute the afplay file.mp3 command from within Python, but is it possible to do it in raw Python? I would also be better if it didn't rely on external libraries.","AnswerCount":25,"Available Count":1,"Score":-0.0079998293,"is_accepted":false,"ViewCount":259664,"Q_Id":260738,"Users Score":-1,"Answer":"If you're on OSX, you can use the \"os\" module or \"subprocess\" etc. to call the OSX \"play\" command. From the OSX shell, it looks like \nplay \"bah.wav\"\nIt starts to play in about a half-second on my machine.","Q_Score":135,"Tags":"python,audio","A_Id":22689253,"CreationDate":"2008-11-04T03:11:00.000","Title":"Play audio 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},{"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},{"Question":"I'm writing some mail-processing software in Python that is encountering strange bytes in header fields. I suspect this is just malformed mail; the message itself claims to be us-ascii, so I don't think there is a true encoding, but I'd like to get out a unicode string approximating the original one without throwing a UnicodeDecodeError.\nSo, I'm looking for a function that takes a str and optionally some hints and does its darndest to give me back a unicode. I could write one of course, but if such a function exists its author has probably thought a bit deeper about the best way to go about this.\nI also know that Python's design prefers explicit to implicit and that the standard library is designed to avoid implicit magic in decoding text. I just want to explicitly say \"go ahead and guess\".","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":12045,"Q_Id":269060,"Users Score":1,"Answer":"The best way to do this that I've found is to iteratively try decoding a prospective with each of the most common encodings inside of a try except block.","Q_Score":18,"Tags":"python,email,character-encoding,invalid-characters","A_Id":271058,"CreationDate":"2008-11-06T15:18:00.000","Title":"Is there a Python library function which attempts to guess the character-encoding of some bytes?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a web API that returns python dictionaries or lists as a response that I eval() in python scripts that use the API, for completness I wanted to set a proper content-type but not sure what would be best to use \"text\/x-python\" or maybe \"application\/python\", or something else? \n[edit] I'm also outputting JSON, I'm doing Python as an option mainly for internal use.[\/edit]","AnswerCount":2,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":3601,"Q_Id":269292,"Users Score":8,"Answer":"I doubt there's an established MIME type. Have you considered using JSON instead, it is almost the same as a Python dict, and has a better established culture of tools and techniques.","Q_Score":3,"Tags":"python,http,mime-types","A_Id":269364,"CreationDate":"2008-11-06T16:19:00.000","Title":"What mime-type should I return for a python 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},{"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},{"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},{"Question":"I'm currently working on a project were I had to wrap the C++ classes with Python to be able to script the program. So my specific experience also involved embedding the Python interpreter in our program.\nThe alternatives I tried were:\n\nBoost.Python\nI liked the cleaner API produced by Boost.Python, but the fact that it would have required that users install an additional dependency made us switch to SWIG.\nSWIG\nSWIG's main advantage for us was that it doesn't require end users to install it to use the final program.\n\nWhat have you used to do this, and what has been your experience with it?","AnswerCount":5,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":12800,"Q_Id":276761,"Users Score":23,"Answer":"I've used both (for the same project): Boost is better integrated with the STL, and especially C++ exceptions. Also, its memory management mechanism (which tries to bridge C++ memory management and Python GC) is way more flexible than SWIG's. However, SWIG has much better documentation, no external dependencies, and if you get the library wrapped in SWIG for Python you're more than half-way there to getting a Java\/Perl\/Ruby wrapper as well.\nI don't think there's a clear-cut choice: for smaller projects, I'd go with Boost.Python again, for larger long-lived projects, the extra investment in SWIG is worth it.","Q_Score":41,"Tags":"c++,python,boost,swig","A_Id":277306,"CreationDate":"2008-11-10T00:34:00.000","Title":"Exposing a C++ API 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":0,"Web Development":0},{"Question":"I'm currently working on a project were I had to wrap the C++ classes with Python to be able to script the program. So my specific experience also involved embedding the Python interpreter in our program.\nThe alternatives I tried were:\n\nBoost.Python\nI liked the cleaner API produced by Boost.Python, but the fact that it would have required that users install an additional dependency made us switch to SWIG.\nSWIG\nSWIG's main advantage for us was that it doesn't require end users to install it to use the final program.\n\nWhat have you used to do this, and what has been your experience with it?","AnswerCount":5,"Available Count":2,"Score":0.0798297691,"is_accepted":false,"ViewCount":12800,"Q_Id":276761,"Users Score":2,"Answer":"A big plus for Boost::Python is that it allows for tab completion in the ipython shell: You import a C++ class, exposed by Boost directly, or you subclass it, and from then on, it really behaves like a pure Python class.\nThe downside: It takes so long to install and use Boost that all the Tab-completion time-saving won't ever amortize ;-(\nSo I prefer Swig: No bells and whistles, but works reliably after a short introductory example.","Q_Score":41,"Tags":"c++,python,boost,swig","A_Id":847688,"CreationDate":"2008-11-10T00:34:00.000","Title":"Exposing a C++ API 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":0,"Web Development":0},{"Question":"I am opening a process (with os.popen() ) that, for some commands, detects certain keypresses (e.g. ESC - not the character, the key). Is there a way to send keypress events to the process?","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":2607,"Q_Id":279434,"Users Score":0,"Answer":"What platform is this on? \nYou may have to actually feed events into the event loop, if it's running on Win32.","Q_Score":1,"Tags":"python,keypress,popen","A_Id":279627,"CreationDate":"2008-11-10T22:41:00.000","Title":"Python: How do I generate a keypress?","Data Science and Machine Learning":0,"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},{"Question":"I am opening a process (with os.popen() ) that, for some commands, detects certain keypresses (e.g. ESC - not the character, the key). Is there a way to send keypress events to the process?","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":2607,"Q_Id":279434,"Users Score":0,"Answer":"The obvious way would be to start the process in it's own shell.\nsomething like os.popen(\"sh command\")","Q_Score":1,"Tags":"python,keypress,popen","A_Id":279460,"CreationDate":"2008-11-10T22:41:00.000","Title":"Python: How do I generate a keypress?","Data Science and Machine Learning":0,"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},{"Question":"I have a j2me client that would post some chunked encoded data to a webserver. I'd like to process the data in python. The script is being run as a CGI one, but apparently apache will refuse a chunked encoded post request to a CGI script. As far as I could see mod_python, WSGI and FastCGI are no go too.\nI'd like to know if there is a way to have a python script process this kind of input. I'm open to any suggestion (e.g. a confoguration setting in apache2 that would assemble the chunks, a standalone python server that would do the same, etc.) I did quite a bit of googling and didn't find anything usable, which is quite strange.\nI know that resorting to java on the server side would be a solution, but I just can't imagine that this can't be solved with apache + python.","AnswerCount":5,"Available Count":2,"Score":0.0399786803,"is_accepted":false,"ViewCount":5471,"Q_Id":284741,"Users Score":1,"Answer":"Maybe it is a configuration issue? Django can be fronted with Apache by mod_python, WSGI and FastCGI and it can accept file uploads.","Q_Score":5,"Tags":"python,http,post,java-me,midlet","A_Id":284857,"CreationDate":"2008-11-12T17:50:00.000","Title":"Processing chunked encoded HTTP POST requests in python (or generic CGI under 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":0,"Web Development":1},{"Question":"I have a j2me client that would post some chunked encoded data to a webserver. I'd like to process the data in python. The script is being run as a CGI one, but apparently apache will refuse a chunked encoded post request to a CGI script. As far as I could see mod_python, WSGI and FastCGI are no go too.\nI'd like to know if there is a way to have a python script process this kind of input. I'm open to any suggestion (e.g. a confoguration setting in apache2 that would assemble the chunks, a standalone python server that would do the same, etc.) I did quite a bit of googling and didn't find anything usable, which is quite strange.\nI know that resorting to java on the server side would be a solution, but I just can't imagine that this can't be solved with apache + python.","AnswerCount":5,"Available Count":2,"Score":0.0798297691,"is_accepted":false,"ViewCount":5471,"Q_Id":284741,"Users Score":2,"Answer":"Apache 2.2 mod_cgi works fine for me, Apache transparently unchunks the request as it is passed to the CGI application.\nWSGI currently disallows chunked requests, and mod_wsgi does indeed block them with a 411 response. It's on the drawing board for WSGI 2.0. But congratulations on finding something that does chunk requests, I've never seen one before!","Q_Score":5,"Tags":"python,http,post,java-me,midlet","A_Id":284869,"CreationDate":"2008-11-12T17:50:00.000","Title":"Processing chunked encoded HTTP POST requests in python (or generic CGI under 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":0,"Web Development":1},{"Question":"Let's say I wanted to make a python script interface with a site like Twitter.\nWhat would I use to do that? I'm used to using curl\/wget from bash, but Python seems to be much nicer to use. What's the equivalent?\n(This isn't Python run from a webserver, but run locally via the command line)","AnswerCount":5,"Available Count":1,"Score":0.0798297691,"is_accepted":false,"ViewCount":839,"Q_Id":285226,"Users Score":2,"Answer":"Python has a very nice httplib module as well as a url module which together will probably accomplish most of what you need (at least with regards to wget functionality).","Q_Score":6,"Tags":"python,web-services,twitter","A_Id":285252,"CreationDate":"2008-11-12T20:28:00.000","Title":"What Python tools can I use to interface with a website's 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},{"Question":"I need to connect to an Exchange mailbox in a Python script, without using any profile setup on the local machine (including using Outlook). If I use win32com to create a MAPI.Session I could logon (with the Logon() method) with an existing profile, but I want to just provide a username & password.\nIs this possible? If so, could someone provide example code? I would prefer if it only used the standard library and the pywin32 package. Unfortunately, enabling IMAP access for the Exchange server (and then using imaplib) is not possible.\nIn case it is necessary: all the script will be doing is connecting to the mailbox, and running through the messages in the Inbox, retrieving the contents. I can handle writing the code for that, if I can get a connection in the first place!\nTo clarify regarding Outlook: Outlook will be installed on the local machine, but it does not have any accounts setup (i.e. all the appropriate libraries will be available, but I need to operate independently from anything setup inside of Outlook).","AnswerCount":4,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":107535,"Q_Id":288546,"Users Score":1,"Answer":"I'm pretty sure this is going to be impossible without using Outlook and a MAPI profile. If you can sweet talk your mail admin into enabling IMAP on the Exchange server it would make your life a lot easier.","Q_Score":26,"Tags":"python,email,connection,exchange-server,pywin32","A_Id":288569,"CreationDate":"2008-11-13T22:19:00.000","Title":"Connect to Exchange mailbox 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},{"Question":"I would like my python script to search through a directory in SVN, locate the files ending with a particular extension (eg. *.exe), and copy these files to a directory that has been created in my C drive. How can I do this? I'm new to Python so a detailed response and\/or point in the right direction would be very much appreciated. \nFollow-up:\nWhen using os.walk what parameter would I pass in to ensure that I'm copying files with a specific extension (eg. *.exe)?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1000,"Q_Id":291467,"Users Score":2,"Answer":"I think it is easiest to check out (or, better, export) the source tree using the svn command line utility: you can use os.system to invoke it. There are also direct Python-to-svn API bindings, but I would advise against using them if you are new to Python.\nYou can then traverse the checkout folder, e.g. using os.walk; the copying itself can be done with shutil.copy.","Q_Score":2,"Tags":"python,svn,file","A_Id":291477,"CreationDate":"2008-11-14T21:16:00.000","Title":"Search directory in SVN for files with specific file extension and copy to another 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":1,"Web Development":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},{"Question":"I have a port scanning application that uses work queues and threads.\nIt uses simple TCP connections and spends a lot of time waiting for packets to come back (up to half a second). Thus the threads don't need to fully execute (i.e. first half sends a packet, context switch, does stuff, comes back to thread which has network data waiting for it).\nI suspect I can improve performance by modifying the sys.setcheckinterval from the default of 100 (which lets up to 100 bytecodes execute before switching to another thread).\nBut without knowing how many bytecodes are actually executing in a thread or function I'm flying blind and simply guessing values, testing and relying on the testing shows a measurable difference (which is difficult since the amount of code being executed is minimal; a simple socket connection, thus network jitter will likely affect any measurements more than changing sys.setcheckinterval).\nThus I would like to find out how many bytecodes are in certain code executions (i.e. total for a function or in execution of a thread) so I can make more intelligent guesses at what to set sys.setcheckinterval to.","AnswerCount":3,"Available Count":1,"Score":0.1325487884,"is_accepted":false,"ViewCount":728,"Q_Id":294963,"Users Score":2,"Answer":"Reasoning about a system of this complexity will rarely produce the right answer. Measure the results, and use the setting that runs the fastest. If as you say, testing can't measure the difference in various settings of setcheckinterval, then why bother changing it? Only measurable differences are interesting. If your test run is too short to provide meaningful data, then make the run longer until it does.","Q_Score":1,"Tags":"python,performance,multithreading,internals","A_Id":297747,"CreationDate":"2008-11-17T05:44:00.000","Title":"How do I count bytecodes in Python so I can modify sys.setcheckinterval appropriately","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"We're looking into transport\/protocol solutions and were about to do various performance tests, so I thought I'd check with the community if they've already done this:\nHas anyone done server performance tests for simple echo services as well as serialization\/deserialization for various messages sizes comparing EJB3, Thrift, and Protocol Buffers on Linux?\nPrimarily languages will be Java, C\/C++, Python, and PHP.\nUpdate: I'm still very interested in this, if anyone has done any further benchmarks please let me know. Also, very interesting benchmark showing compressed JSON performing similar \/ better than Thrift \/ Protocol Buffers, so I'm throwing JSON into this question as well.","AnswerCount":8,"Available Count":3,"Score":1.0,"is_accepted":false,"ViewCount":64229,"Q_Id":296650,"Users Score":8,"Answer":"I did test performance of PB with number of other data formats (xml, json, default object serialization, hessian, one proprietary one) and libraries (jaxb, fast infoset, hand-written) for data binding task (both reading and writing), but thrift's format(s) was not included. Performance for formats with multiple converters (like xml) had very high variance, from very slow to pretty-darn-fast. Correlation between claims of authors and perceived performance was rather weak. Especially so for packages that made wildest claims.\nFor what it is worth, I found PB performance to be bit over hyped (usually not by its authors, but others who only know who wrote it). With default settings it did not beat fastest textual xml alternative. With optimized mode (why is this not default?), it was bit faster, comparable with the fastest JSON package. Hessian was rather fast, textual json also. Properietary binary format (no name here, it was company internal) was the slowest. Java object serialization was fast for larger messages, less so for small objects (i.e. high fixed per-operation noverhead).\nWith PB message size was compact, but given all trade-offs you have to do (data is not self-descriptive: if you lose the schema, you lose data; there are indexes of course, and value types, but from what you have reverse-engineer back to field names if you want), I personally would only choose it for specific use cases -- size-sensitive, closely coupled system where interface\/format never (or very very rarely) changes.\nMy opinion in this is that (a) implementation often matters more than specification (of data format), (b) end-to-end, differences between best-of-breed (for different formats) are usually not big enough to dictate the choice.\nThat is, you may be better off choosing format+API\/lib\/framework you like using most (or has best tool support), find best implementation, and see if that works fast enough.\nIf (and only if!) not, consider next best alternative.\nps. Not sure what EJB3 here would be. Maybe just plain of Java serialization?","Q_Score":70,"Tags":"java,python,performance,protocol-buffers,thrift","A_Id":628329,"CreationDate":"2008-11-17T19:48:00.000","Title":"Performance comparison of Thrift, Protocol Buffers, JSON, EJB, other?","Data Science and Machine Learning":0,"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},{"Question":"We're looking into transport\/protocol solutions and were about to do various performance tests, so I thought I'd check with the community if they've already done this:\nHas anyone done server performance tests for simple echo services as well as serialization\/deserialization for various messages sizes comparing EJB3, Thrift, and Protocol Buffers on Linux?\nPrimarily languages will be Java, C\/C++, Python, and PHP.\nUpdate: I'm still very interested in this, if anyone has done any further benchmarks please let me know. Also, very interesting benchmark showing compressed JSON performing similar \/ better than Thrift \/ Protocol Buffers, so I'm throwing JSON into this question as well.","AnswerCount":8,"Available Count":3,"Score":0.1243530018,"is_accepted":false,"ViewCount":64229,"Q_Id":296650,"Users Score":5,"Answer":"If the raw net performance is the target, then nothing beats IIOP (see RMI\/IIOP).\nSmallest possible footprint -- only binary data, no markup at all. Serialization\/deserialization is very fast too.\nSince it's IIOP (that is CORBA), almost all languages have bindings.\nBut I presume the performance is not the only requirement, right?","Q_Score":70,"Tags":"java,python,performance,protocol-buffers,thrift","A_Id":297193,"CreationDate":"2008-11-17T19:48:00.000","Title":"Performance comparison of Thrift, Protocol Buffers, JSON, EJB, other?","Data Science and Machine Learning":0,"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},{"Question":"We're looking into transport\/protocol solutions and were about to do various performance tests, so I thought I'd check with the community if they've already done this:\nHas anyone done server performance tests for simple echo services as well as serialization\/deserialization for various messages sizes comparing EJB3, Thrift, and Protocol Buffers on Linux?\nPrimarily languages will be Java, C\/C++, Python, and PHP.\nUpdate: I'm still very interested in this, if anyone has done any further benchmarks please let me know. Also, very interesting benchmark showing compressed JSON performing similar \/ better than Thrift \/ Protocol Buffers, so I'm throwing JSON into this question as well.","AnswerCount":8,"Available Count":3,"Score":0.0996679946,"is_accepted":false,"ViewCount":64229,"Q_Id":296650,"Users Score":4,"Answer":"One of the things near the top of my \"to-do\" list for PBs is to port Google's internal Protocol Buffer performance benchmark - it's mostly a case of taking confidential message formats and turning them into entirely bland ones, and then doing the same for the data.\nWhen that's been done, I'd imagine you could build the same messages in Thrift and then compare the performance.\nIn other words, I don't have the data for you yet - but hopefully in the next couple of weeks...","Q_Score":70,"Tags":"java,python,performance,protocol-buffers,thrift","A_Id":296677,"CreationDate":"2008-11-17T19:48:00.000","Title":"Performance comparison of Thrift, Protocol Buffers, JSON, EJB, other?","Data Science and Machine Learning":0,"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},{"Question":"I've got a large amount of data (a couple gigs) I need to write to a zip file in Python. I can't load it all into memory at once to pass to the .writestr method of ZipFile, and I really don't want to feed it all out to disk using temporary files and then read it back.\nIs there a way to feed a generator or a file-like object to the ZipFile library? Or is there some reason this capability doesn't seem to be supported?\nBy zip file, I mean zip file. As supported in the Python zipfile package.","AnswerCount":10,"Available Count":1,"Score":0.0199973338,"is_accepted":false,"ViewCount":14983,"Q_Id":297345,"Users Score":1,"Answer":"Some (many? most?) compression algorithms are based on looking at redundancies across the entire file.\nSome compression libraries will choose between several compression algorithms based on which works best on the file.\nI believe the ZipFile module does this, so it wants to see the entire file, not just pieces at a time.\nHence, it won't work with generators or files to big to load in memory. That would explain the limitation of the Zipfile library.","Q_Score":23,"Tags":"python,zip","A_Id":297444,"CreationDate":"2008-11-17T23:27:00.000","Title":"Create a zip file from a generator 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},{"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},{"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},{"Question":"We have developers with knowledge of these languages - Ruby , Python, .Net or Java. We are developing an application which will mainly handle XML documents. Most of the work is to convert predefined XML files into database tables, providing mapping between XML documents through database, creating reports from database etc. Which language will be the easiest and fastest to work with?\n(It is a web-app)","AnswerCount":9,"Available Count":1,"Score":0.0444152037,"is_accepted":false,"ViewCount":18193,"Q_Id":301493,"Users Score":2,"Answer":"either C# or VB.Net using LiNQ to XML. LiNQ to XML is very very powerful and easy to implement","Q_Score":21,"Tags":"java,.net,python,xml,ruby","A_Id":301538,"CreationDate":"2008-11-19T10:35:00.000","Title":"Which language is easiest and fastest to work with XML content?","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},{"Question":"Is there anyone out there using iPython with emacs 23? The documents on the emacs wiki are a bit of a muddle and I would be interested in hearing from anyone using emacs for Python development. Do you use the download python-mode and ipython.el? What do you recommend?","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":13374,"Q_Id":304049,"Users Score":0,"Answer":"I've used ipython with emacs cvs (which has been emacs 23 for some time now) in my python development. I, however, use it the other way around: I call emacs from the ipython promt through the $EDITOR environment variable. I tried it the other way around, but got a bit tired of all the process buffers and what not.\nEmacs is great, but a command-line far more versatile.","Q_Score":24,"Tags":"python,emacs,ipython,emacs23","A_Id":492173,"CreationDate":"2008-11-20T01:12:00.000","Title":"Emacs 23 and 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":1,"System Administration and DevOps":0,"Web Development":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},{"Question":"What's the easiest way to play a sound file (.wav) in Python? By easiest I mean both most platform independent and requiring the least dependencies. pygame is certainly an option, but it seems overkill for just sound.","AnswerCount":10,"Available Count":1,"Score":0.0399786803,"is_accepted":false,"ViewCount":468055,"Q_Id":307305,"Users Score":2,"Answer":"wxPython has support for playing wav files on Windows and Unix - I am not sure if this includes Macs. However it only support wav files as far as I can tell - it does not support other common formats such as mp3 or ogg.","Q_Score":111,"Tags":"python,audio,platform-independent","A_Id":1852392,"CreationDate":"2008-11-20T23:40:00.000","Title":"Play a Sound 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},{"Question":"I'm using Notepad++ for python development, and few days ago I found out about free Komodo Edit.\nI need Pros and Cons for Python development between this two editors...","AnswerCount":9,"Available Count":8,"Score":1.0,"is_accepted":false,"ViewCount":27320,"Q_Id":309135,"Users Score":8,"Answer":"I use Komodo edit. The main reasons are: Intellisense (not as good as VisualStudio, but Python's a hard language to do intellisense for) and cross-platform compatibility. It's nice being able to use the same editor on my Windows machine, my linux machine, and my macbook with little to no change in feel.","Q_Score":16,"Tags":"python,editor,notepad++,komodo,komodoedit","A_Id":314915,"CreationDate":"2008-11-21T15:38:00.000","Title":"Komodo Edit and Notepad++ ::: Pros & Cons ::: Python dev","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm using Notepad++ for python development, and few days ago I found out about free Komodo Edit.\nI need Pros and Cons for Python development between this two editors...","AnswerCount":9,"Available Count":8,"Score":1.0,"is_accepted":false,"ViewCount":27320,"Q_Id":309135,"Users Score":9,"Answer":"I just downloaded and started using Komodo Edit. I've been using Notepad++ for awhile. Here is what I think about some of the features:\nKomodo Edit Pros:\n\nYou can jump to a function definition, even if it's in another file (I love this)\nThere is a plugin that displays the list of classes, functions and such for the current file on the side. Notepad++ used to have a plugin like this, but it no longer works with the current version and hasn't been updated in a while.\n\nNotepad++ Pros:\n\nIf you select a word, it will highlight all of those words in the current document (makes it easier to find misspellings), without having to hit Ctrl+F.\nWhen working with HTML, when the cursor is on\/in a tag, the starting and ending tags are both highlighted\n\nAnyone know if either of those last 2 things is possible in Komodo Edit?","Q_Score":16,"Tags":"python,editor,notepad++,komodo,komodoedit","A_Id":314865,"CreationDate":"2008-11-21T15:38:00.000","Title":"Komodo Edit and Notepad++ ::: Pros & Cons ::: Python dev","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm using Notepad++ for python development, and few days ago I found out about free Komodo Edit.\nI need Pros and Cons for Python development between this two editors...","AnswerCount":9,"Available Count":8,"Score":0.022218565,"is_accepted":false,"ViewCount":27320,"Q_Id":309135,"Users Score":1,"Answer":"If I had to choose between Notepad++ and Komodo i would choose PyScripter ;.)\nSeriously I consider PyScripter as a great alternative...","Q_Score":16,"Tags":"python,editor,notepad++,komodo,komodoedit","A_Id":500622,"CreationDate":"2008-11-21T15:38:00.000","Title":"Komodo Edit and Notepad++ ::: Pros & Cons ::: Python dev","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm using Notepad++ for python development, and few days ago I found out about free Komodo Edit.\nI need Pros and Cons for Python development between this two editors...","AnswerCount":9,"Available Count":8,"Score":0.0886555158,"is_accepted":false,"ViewCount":27320,"Q_Id":309135,"Users Score":4,"Answer":"A downside I found of Notepad++ for Python is that it tends (for me) to silently mix tabs and spaces. I know this is configurable, but it caught me out, especially when trying to work with other people using different editors \/ IDE's, so take care.","Q_Score":16,"Tags":"python,editor,notepad++,komodo,komodoedit","A_Id":314871,"CreationDate":"2008-11-21T15:38:00.000","Title":"Komodo Edit and Notepad++ ::: Pros & Cons ::: Python dev","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm using Notepad++ for python development, and few days ago I found out about free Komodo Edit.\nI need Pros and Cons for Python development between this two editors...","AnswerCount":9,"Available Count":8,"Score":0.022218565,"is_accepted":false,"ViewCount":27320,"Q_Id":309135,"Users Score":1,"Answer":"I haven't used Komodo yet (the download never quite finished on the slow connection I was on at the time), but I use Eclipse with PyDev regularly and enjoy the \"IDE\" features described by the other respondents. However, I'm also regularly frustrated by how much of a resource hog it is.\nI downloaded Notepad++ recently (much smaller download size ;-) ) and have been enjoying it quite a bit. The editor itself is nice and fast and it looks to be extensible. I'm hoping to copy some of my favorite features from IDE into Notepad++ and migrate, at some distant point in the future.","Q_Score":16,"Tags":"python,editor,notepad++,komodo,komodoedit","A_Id":311426,"CreationDate":"2008-11-21T15:38:00.000","Title":"Komodo Edit and Notepad++ ::: Pros & Cons ::: Python dev","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm using Notepad++ for python development, and few days ago I found out about free Komodo Edit.\nI need Pros and Cons for Python development between this two editors...","AnswerCount":9,"Available Count":8,"Score":0.1106561105,"is_accepted":false,"ViewCount":27320,"Q_Id":309135,"Users Score":5,"Answer":"As far as I know , Notepad++ doesn't show you the docstring each method has .","Q_Score":16,"Tags":"python,editor,notepad++,komodo,komodoedit","A_Id":309140,"CreationDate":"2008-11-21T15:38:00.000","Title":"Komodo Edit and Notepad++ ::: Pros & Cons ::: Python dev","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm using Notepad++ for python development, and few days ago I found out about free Komodo Edit.\nI need Pros and Cons for Python development between this two editors...","AnswerCount":9,"Available Count":8,"Score":1.0,"is_accepted":false,"ViewCount":27320,"Q_Id":309135,"Users Score":7,"Answer":"I use both Komodo Edit and Notepad++.\nNotepad++ is a lot quicker to launch and it's more lightweight, so I often use it for quick one-off editing.\nI use Komodo Edit for major projects, like my django and wxPython applications. KE is a full-featured IDE, so it has a lot more features. \nMain advantages of Komodo Edit for programming Python:\n\nManage groups of files as projects\nUse custom commands to run files, run nosetests\/pylint, etc.\nAuto complete & syntax checking\nMozilla extension system, with several useful extensions available\nWrite macros in JavaScript or Python\nSpell checking\n\nSome of the little things that Notepad++ is missing for Python development:\n\nDoesn't auto-indent after a colon\nYou can't set tabs\/spaces on a file-type basis (I like to use tabs for HTML)\nNo code completion or tooltips\nNo on-the-fly syntax checking","Q_Score":16,"Tags":"python,editor,notepad++,komodo,komodoedit","A_Id":501832,"CreationDate":"2008-11-21T15:38:00.000","Title":"Komodo Edit and Notepad++ ::: Pros & Cons ::: Python dev","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm using Notepad++ for python development, and few days ago I found out about free Komodo Edit.\nI need Pros and Cons for Python development between this two editors...","AnswerCount":9,"Available Count":8,"Score":-1.0,"is_accepted":false,"ViewCount":27320,"Q_Id":309135,"Users Score":-4,"Answer":"Downloaded both myself. Like Komodo better. \nKomodo Pros: Like it better. Does more. Looks like an IDE. Edits Django templates\nNotepad++ Cons: Don't like it as much. Does less. Looks less like and IDE.","Q_Score":16,"Tags":"python,editor,notepad++,komodo,komodoedit","A_Id":310252,"CreationDate":"2008-11-21T15:38:00.000","Title":"Komodo Edit and Notepad++ ::: Pros & Cons ::: Python dev","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Comparable to cacti or mrtg.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1942,"Q_Id":310759,"Users Score":0,"Answer":"or you can start building your own solution (like me), you will be surprised how much can you do with few lines of code using for instance cherryp for web server, pysnmp, and python rrd module.","Q_Score":1,"Tags":"python,django,pylons,snmp,turbogears","A_Id":541516,"CreationDate":"2008-11-22T02:26:00.000","Title":"Does anyone know of a python based web ui for snmp monitoring?","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},{"Question":"Ghostscript curls up and dies, throwing an exception to stdout which I cannot catch and log. I am pretty sure it gets sick when I give it asian fonts. Has anybody backed into this problem and solved it?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":416,"Q_Id":316518,"Users Score":1,"Answer":"It may be that you need to read stderr from the child process.","Q_Score":0,"Tags":"python,jython,tiff,ghostscript","A_Id":317300,"CreationDate":"2008-11-25T06:41:00.000","Title":"Ghostscript PDF -> TIFF throws an untrappable exception, when consuming files with asian fonts","Data Science and Machine Learning":0,"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},{"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},{"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},{"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},{"Question":"Writing a python script and it needs to find out what language a block of code is written in. I could easily write this myself, but I'd like to know if a solution already exists.\nPygments is insufficient and unreliable.","AnswerCount":9,"Available Count":2,"Score":0.022218565,"is_accepted":false,"ViewCount":4415,"Q_Id":325165,"Users Score":1,"Answer":"what language a block of code is written in\n\nWhat are your alternatives, among what languages? There is no way to determine this universally. But if you narrow your focus there is probably a tool somewhere","Q_Score":22,"Tags":"python","A_Id":325180,"CreationDate":"2008-11-28T06:40:00.000","Title":"Is there a library that will detect the source code language of a block of 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},{"Question":"Writing a python script and it needs to find out what language a block of code is written in. I could easily write this myself, but I'd like to know if a solution already exists.\nPygments is insufficient and unreliable.","AnswerCount":9,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":4415,"Q_Id":325165,"Users Score":0,"Answer":"As other have said Pygments will be your best bet.","Q_Score":22,"Tags":"python","A_Id":346832,"CreationDate":"2008-11-28T06:40:00.000","Title":"Is there a library that will detect the source code language of a block of 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},{"Question":"I've been wondering this for some time. As the title say, which is faster, the actual function or simply raising to the half power?\nUPDATE\nThis is not a matter of premature optimization. This is simply a question of how the underlying code actually works. What is the theory of how Python code works?\nI sent Guido van Rossum an email cause I really wanted to know the differences in these methods.\nMy email:\n\nThere are at least 3 ways to do a square root in Python: math.sqrt, the\n '**' operator and pow(x,.5). I'm just curious as to the differences in\n the implementation of each of these. When it comes to efficiency which\n is better?\n\nHis response:\n\npow and ** are equivalent; math.sqrt doesn't work for complex numbers,\n and links to the C sqrt() function. As to which one is\n faster, I have no idea...","AnswerCount":15,"Available Count":4,"Score":1.0,"is_accepted":false,"ViewCount":100568,"Q_Id":327002,"Users Score":9,"Answer":"How many square roots are you really performing? Are you trying to write some 3D graphics engine in Python? If not, then why go with code which is cryptic over code that is easy to read? The time difference is would be less than anybody could notice in just about any application I could forsee. I really don't mean to put down your question, but it seems that you're going a little too far with premature optimization.","Q_Score":236,"Tags":"python,performance","A_Id":327009,"CreationDate":"2008-11-29T01:24:00.000","Title":"Which is faster in Python: x**.5 or math.sqrt(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":0,"Web Development":0},{"Question":"I've been wondering this for some time. As the title say, which is faster, the actual function or simply raising to the half power?\nUPDATE\nThis is not a matter of premature optimization. This is simply a question of how the underlying code actually works. What is the theory of how Python code works?\nI sent Guido van Rossum an email cause I really wanted to know the differences in these methods.\nMy email:\n\nThere are at least 3 ways to do a square root in Python: math.sqrt, the\n '**' operator and pow(x,.5). I'm just curious as to the differences in\n the implementation of each of these. When it comes to efficiency which\n is better?\n\nHis response:\n\npow and ** are equivalent; math.sqrt doesn't work for complex numbers,\n and links to the C sqrt() function. As to which one is\n faster, I have no idea...","AnswerCount":15,"Available Count":4,"Score":0.0532828229,"is_accepted":false,"ViewCount":100568,"Q_Id":327002,"Users Score":4,"Answer":"using Claudiu's code, on my machine even with \"from math import sqrt\" x**.5 is faster but using psyco.full() sqrt(x) becomes much faster, at least by 200%","Q_Score":236,"Tags":"python,performance","A_Id":327063,"CreationDate":"2008-11-29T01:24:00.000","Title":"Which is faster in Python: x**.5 or math.sqrt(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":0,"Web Development":0},{"Question":"I've been wondering this for some time. As the title say, which is faster, the actual function or simply raising to the half power?\nUPDATE\nThis is not a matter of premature optimization. This is simply a question of how the underlying code actually works. What is the theory of how Python code works?\nI sent Guido van Rossum an email cause I really wanted to know the differences in these methods.\nMy email:\n\nThere are at least 3 ways to do a square root in Python: math.sqrt, the\n '**' operator and pow(x,.5). I'm just curious as to the differences in\n the implementation of each of these. When it comes to efficiency which\n is better?\n\nHis response:\n\npow and ** are equivalent; math.sqrt doesn't work for complex numbers,\n and links to the C sqrt() function. As to which one is\n faster, I have no idea...","AnswerCount":15,"Available Count":4,"Score":0.0399786803,"is_accepted":false,"ViewCount":100568,"Q_Id":327002,"Users Score":3,"Answer":"Most likely math.sqrt(x), because it's optimized for square rooting.\nBenchmarks will provide you the answer you are looking for.","Q_Score":236,"Tags":"python,performance","A_Id":327005,"CreationDate":"2008-11-29T01:24:00.000","Title":"Which is faster in Python: x**.5 or math.sqrt(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":0,"Web Development":0},{"Question":"I've been wondering this for some time. As the title say, which is faster, the actual function or simply raising to the half power?\nUPDATE\nThis is not a matter of premature optimization. This is simply a question of how the underlying code actually works. What is the theory of how Python code works?\nI sent Guido van Rossum an email cause I really wanted to know the differences in these methods.\nMy email:\n\nThere are at least 3 ways to do a square root in Python: math.sqrt, the\n '**' operator and pow(x,.5). I'm just curious as to the differences in\n the implementation of each of these. When it comes to efficiency which\n is better?\n\nHis response:\n\npow and ** are equivalent; math.sqrt doesn't work for complex numbers,\n and links to the C sqrt() function. As to which one is\n faster, I have no idea...","AnswerCount":15,"Available Count":4,"Score":-1.0,"is_accepted":false,"ViewCount":100568,"Q_Id":327002,"Users Score":-4,"Answer":"What would be even faster is if you went into math.py and copied the function \"sqrt\" into your program. It takes time for your program to find math.py, then open it, find the function you are looking for, and then bring that back to your program. If that function is faster even with the \"lookup\" steps, then the function itself has to be awfully fast. Probably will cut your time in half. IN summary:\n\nGo to math.py\nFind the function \"sqrt\"\nCopy it\nPaste function into your program as the sqrt finder.\nTime it.","Q_Score":236,"Tags":"python,performance","A_Id":29231648,"CreationDate":"2008-11-29T01:24:00.000","Title":"Which is faster in Python: x**.5 or math.sqrt(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":0,"Web Development":0},{"Question":"I have a small lightweight application that is used as part of a larger solution. Currently it is written in C but I am looking to rewrite it using a cross-platform scripting language. The solution needs to run on Windows, Linux, Solaris, AIX and HP-UX.\nThe existing C application works fine but I want to have a single script I can maintain for all platforms. At the same time, I do not want to lose a lot of performance but am willing to lose some.\nStartup cost of the script is very important. This script can be called anywhere from every minute to many times per second. As a consequence, keeping it's memory and startup time low are important.\nSo basically I'm looking for the best scripting languages that is:\n\nCross platform.\nCapable of XML parsing and HTTP Posts.\nLow memory and low startup time.\n\nPossible choices include but are not limited to: bash\/ksh + curl, Perl, Python and Ruby. What would you recommend for this type of a scenario?","AnswerCount":13,"Available Count":9,"Score":0.0461211021,"is_accepted":false,"ViewCount":8004,"Q_Id":328041,"Users Score":3,"Answer":"If Low memory and low startup time are truly important you might want to consider doing the work to keep the C code cross platform, however I have found this is rarely necessary.\nPersonally I would use Ruby or Python for this type of job, they both make it very easy to make clear understandable code that others can maintain (or you can maintain after not looking at it for 6 months). If you have the control to do so I would also suggest getting the latest version of the interpreter, as both Ruby and Python have made notable improvements around performance recently.\nIt is a bit of a personal thing. Programming Ruby makes me happy, C code does not (nor bash scripting for anything non-trivial).","Q_Score":10,"Tags":"python,ruby,perl,bash,scripting-language","A_Id":328062,"CreationDate":"2008-11-29T21:34:00.000","Title":"Scripting language choice for initial 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":1,"Web Development":0},{"Question":"I have a small lightweight application that is used as part of a larger solution. Currently it is written in C but I am looking to rewrite it using a cross-platform scripting language. The solution needs to run on Windows, Linux, Solaris, AIX and HP-UX.\nThe existing C application works fine but I want to have a single script I can maintain for all platforms. At the same time, I do not want to lose a lot of performance but am willing to lose some.\nStartup cost of the script is very important. This script can be called anywhere from every minute to many times per second. As a consequence, keeping it's memory and startup time low are important.\nSo basically I'm looking for the best scripting languages that is:\n\nCross platform.\nCapable of XML parsing and HTTP Posts.\nLow memory and low startup time.\n\nPossible choices include but are not limited to: bash\/ksh + curl, Perl, Python and Ruby. What would you recommend for this type of a scenario?","AnswerCount":13,"Available Count":9,"Score":0.0,"is_accepted":false,"ViewCount":8004,"Q_Id":328041,"Users Score":0,"Answer":"I agree with others in that you should probably try to make this a more portable C app instead of porting it over to something else since any scripting language is going to introduce significant overhead from a startup perspective, have a much larger memory footprint, and will probably be much slower.\nIn my experience, Python is the most efficient of the three, followed by Perl and then Ruby with the difference between Perl and Ruby being particularly large in certain areas. If you really want to try porting this to a scripting language, I would put together a prototype in the language you are most comfortable with and see if it comes close to your requirements. If you don't have a preference, start with Python as it is easy to learn and use and if it is too slow with Python, Perl and Ruby probably won't be able to do any better.","Q_Score":10,"Tags":"python,ruby,perl,bash,scripting-language","A_Id":328075,"CreationDate":"2008-11-29T21:34:00.000","Title":"Scripting language choice for initial 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":1,"Web Development":0},{"Question":"I have a small lightweight application that is used as part of a larger solution. Currently it is written in C but I am looking to rewrite it using a cross-platform scripting language. The solution needs to run on Windows, Linux, Solaris, AIX and HP-UX.\nThe existing C application works fine but I want to have a single script I can maintain for all platforms. At the same time, I do not want to lose a lot of performance but am willing to lose some.\nStartup cost of the script is very important. This script can be called anywhere from every minute to many times per second. As a consequence, keeping it's memory and startup time low are important.\nSo basically I'm looking for the best scripting languages that is:\n\nCross platform.\nCapable of XML parsing and HTTP Posts.\nLow memory and low startup time.\n\nPossible choices include but are not limited to: bash\/ksh + curl, Perl, Python and Ruby. What would you recommend for this type of a scenario?","AnswerCount":13,"Available Count":9,"Score":0.0767717131,"is_accepted":false,"ViewCount":8004,"Q_Id":328041,"Users Score":5,"Answer":"When written properly, C should be platform independant and would only need a recompile for those different platforms. You might have to jump through some #ifdef hoops for the headers (not all systems use the same headers), but most normal (non-win32 API) calls are very portable.\nFor web access (which I presume you need as you mention bash+curl), you could take a look at libcurl, it's available for all the platforms you mentioned, and shouldn't be that hard to work with.\nWith execution time and memory cost in mind, I doubt you could go any faster than properly written C with any scripting language as you would lose at least some time on interpreting the script...","Q_Score":10,"Tags":"python,ruby,perl,bash,scripting-language","A_Id":328054,"CreationDate":"2008-11-29T21:34:00.000","Title":"Scripting language choice for initial 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":1,"Web Development":0},{"Question":"I have a small lightweight application that is used as part of a larger solution. Currently it is written in C but I am looking to rewrite it using a cross-platform scripting language. The solution needs to run on Windows, Linux, Solaris, AIX and HP-UX.\nThe existing C application works fine but I want to have a single script I can maintain for all platforms. At the same time, I do not want to lose a lot of performance but am willing to lose some.\nStartup cost of the script is very important. This script can be called anywhere from every minute to many times per second. As a consequence, keeping it's memory and startup time low are important.\nSo basically I'm looking for the best scripting languages that is:\n\nCross platform.\nCapable of XML parsing and HTTP Posts.\nLow memory and low startup time.\n\nPossible choices include but are not limited to: bash\/ksh + curl, Perl, Python and Ruby. What would you recommend for this type of a scenario?","AnswerCount":13,"Available Count":9,"Score":0.0614608973,"is_accepted":false,"ViewCount":8004,"Q_Id":328041,"Users Score":4,"Answer":"I concur with Lua: it is super-portable, it has XML libraries, either native or by binding C libraries like Expat, it has a good socket library (LuaSocket) plus, for complex stuff, some cURL bindings, and is well known for being very lightweight (often embedded in low memory devices), very fast (one of the fastest scripting languages), and powerful. And very easy to code!\nIt is coded in pure Ansi C, and lot of people claim it has one of the best C biding API (calling C routines from Lua, calling Lua code from C...).","Q_Score":10,"Tags":"python,ruby,perl,bash,scripting-language","A_Id":328120,"CreationDate":"2008-11-29T21:34:00.000","Title":"Scripting language choice for initial 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":1,"Web Development":0},{"Question":"I have a small lightweight application that is used as part of a larger solution. Currently it is written in C but I am looking to rewrite it using a cross-platform scripting language. The solution needs to run on Windows, Linux, Solaris, AIX and HP-UX.\nThe existing C application works fine but I want to have a single script I can maintain for all platforms. At the same time, I do not want to lose a lot of performance but am willing to lose some.\nStartup cost of the script is very important. This script can be called anywhere from every minute to many times per second. As a consequence, keeping it's memory and startup time low are important.\nSo basically I'm looking for the best scripting languages that is:\n\nCross platform.\nCapable of XML parsing and HTTP Posts.\nLow memory and low startup time.\n\nPossible choices include but are not limited to: bash\/ksh + curl, Perl, Python and Ruby. What would you recommend for this type of a scenario?","AnswerCount":13,"Available Count":9,"Score":1.2,"is_accepted":true,"ViewCount":8004,"Q_Id":328041,"Users Score":9,"Answer":"Because of your requirement for fast startup time and a calling frequency greater than 1Hz I'd recommend either staying with C and figuring out how to make it portable (not always as easy as a few ifdefs) or exploring the possibility of turning it into a service daemon that is always running. Of course this depends on how \nPython can have lower startup times if you compile the module and run the .pyc file, but it is still generally considered slow. Perl, in my experience, in the fastest of the scripting languages so you might have good luck with a perl daemon.\nYou could also look at cross platform frameworks like gtk, wxWidgets and Qt. While they are targeted at GUIs they do have low level cross platform data types and network libraries that could make the job of using a fast C based application easier.","Q_Score":10,"Tags":"python,ruby,perl,bash,scripting-language","A_Id":328065,"CreationDate":"2008-11-29T21:34:00.000","Title":"Scripting language choice for initial 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":1,"Web Development":0},{"Question":"I have a small lightweight application that is used as part of a larger solution. Currently it is written in C but I am looking to rewrite it using a cross-platform scripting language. The solution needs to run on Windows, Linux, Solaris, AIX and HP-UX.\nThe existing C application works fine but I want to have a single script I can maintain for all platforms. At the same time, I do not want to lose a lot of performance but am willing to lose some.\nStartup cost of the script is very important. This script can be called anywhere from every minute to many times per second. As a consequence, keeping it's memory and startup time low are important.\nSo basically I'm looking for the best scripting languages that is:\n\nCross platform.\nCapable of XML parsing and HTTP Posts.\nLow memory and low startup time.\n\nPossible choices include but are not limited to: bash\/ksh + curl, Perl, Python and Ruby. What would you recommend for this type of a scenario?","AnswerCount":13,"Available Count":9,"Score":1.0,"is_accepted":false,"ViewCount":8004,"Q_Id":328041,"Users Score":23,"Answer":"Lua is a scripting language that meets your criteria. It's certainly the fastest and lowest memory scripting language available.","Q_Score":10,"Tags":"python,ruby,perl,bash,scripting-language","A_Id":328045,"CreationDate":"2008-11-29T21:34:00.000","Title":"Scripting language choice for initial 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":1,"Web Development":0},{"Question":"I have a small lightweight application that is used as part of a larger solution. Currently it is written in C but I am looking to rewrite it using a cross-platform scripting language. The solution needs to run on Windows, Linux, Solaris, AIX and HP-UX.\nThe existing C application works fine but I want to have a single script I can maintain for all platforms. At the same time, I do not want to lose a lot of performance but am willing to lose some.\nStartup cost of the script is very important. This script can be called anywhere from every minute to many times per second. As a consequence, keeping it's memory and startup time low are important.\nSo basically I'm looking for the best scripting languages that is:\n\nCross platform.\nCapable of XML parsing and HTTP Posts.\nLow memory and low startup time.\n\nPossible choices include but are not limited to: bash\/ksh + curl, Perl, Python and Ruby. What would you recommend for this type of a scenario?","AnswerCount":13,"Available Count":9,"Score":0.0,"is_accepted":false,"ViewCount":8004,"Q_Id":328041,"Users Score":0,"Answer":"Port your app to Ruby. If your app is too slow, profile it and rewrite the those parts in C.","Q_Score":10,"Tags":"python,ruby,perl,bash,scripting-language","A_Id":328519,"CreationDate":"2008-11-29T21:34:00.000","Title":"Scripting language choice for initial 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":1,"Web Development":0},{"Question":"I have a small lightweight application that is used as part of a larger solution. Currently it is written in C but I am looking to rewrite it using a cross-platform scripting language. The solution needs to run on Windows, Linux, Solaris, AIX and HP-UX.\nThe existing C application works fine but I want to have a single script I can maintain for all platforms. At the same time, I do not want to lose a lot of performance but am willing to lose some.\nStartup cost of the script is very important. This script can be called anywhere from every minute to many times per second. As a consequence, keeping it's memory and startup time low are important.\nSo basically I'm looking for the best scripting languages that is:\n\nCross platform.\nCapable of XML parsing and HTTP Posts.\nLow memory and low startup time.\n\nPossible choices include but are not limited to: bash\/ksh + curl, Perl, Python and Ruby. What would you recommend for this type of a scenario?","AnswerCount":13,"Available Count":9,"Score":1.0,"is_accepted":false,"ViewCount":8004,"Q_Id":328041,"Users Score":6,"Answer":"\"called anywhere from every minute to many times per second. As a consequence, keeping it's memory and startup time low are important.\"\nThis doesn't sound like a script to me at all.\nThis sounds like a server handling requests that arrive from every minute to several times a second.\nIf it's a server, handling requests, start-up time doesn't mean as much as responsiveness. In which case, Python might work out well, and still keep performance up.\nRather than restarting, you're just processing another request. You get to keep as much state as you need to optimize performance.","Q_Score":10,"Tags":"python,ruby,perl,bash,scripting-language","A_Id":328129,"CreationDate":"2008-11-29T21:34:00.000","Title":"Scripting language choice for initial 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":1,"Web Development":0},{"Question":"I have a small lightweight application that is used as part of a larger solution. Currently it is written in C but I am looking to rewrite it using a cross-platform scripting language. The solution needs to run on Windows, Linux, Solaris, AIX and HP-UX.\nThe existing C application works fine but I want to have a single script I can maintain for all platforms. At the same time, I do not want to lose a lot of performance but am willing to lose some.\nStartup cost of the script is very important. This script can be called anywhere from every minute to many times per second. As a consequence, keeping it's memory and startup time low are important.\nSo basically I'm looking for the best scripting languages that is:\n\nCross platform.\nCapable of XML parsing and HTTP Posts.\nLow memory and low startup time.\n\nPossible choices include but are not limited to: bash\/ksh + curl, Perl, Python and Ruby. What would you recommend for this type of a scenario?","AnswerCount":13,"Available Count":9,"Score":0.0,"is_accepted":false,"ViewCount":8004,"Q_Id":328041,"Users Score":0,"Answer":"Can you instead have it be a long-running process and answer http or rpc requests?\nThis would satisfy the latency requirements in almost any scenario, but I don't know if that would break your memory footprint constraints.","Q_Score":10,"Tags":"python,ruby,perl,bash,scripting-language","A_Id":328132,"CreationDate":"2008-11-29T21:34:00.000","Title":"Scripting language choice for initial 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":1,"Web Development":0},{"Question":"I'm a long time C++\/Java developer trying to get into Python and am looking for the stereotypical \"Python for C++ Developers\" article, but coming up blank. I've seen these sort of things for C#, Java, etc, and they're incredibly useful for getting up to speed on language features and noteworthy differences. Anyone have any references?\nAs a secondary bonus question, what open source Python program would you suggest looking at for clean design, commenting, and use of the language as a point of reference for study?\nThanks in advance.","AnswerCount":8,"Available Count":3,"Score":0.0996679946,"is_accepted":false,"ViewCount":43679,"Q_Id":328577,"Users Score":4,"Answer":"I learned a lot about Python by reading the source of the standard library that ships with Python. I seem to remember having a few \"a-ha!\" moments when reading urllib2.py in particular.","Q_Score":56,"Tags":"c++,python","A_Id":328599,"CreationDate":"2008-11-30T07:14:00.000","Title":"Python for C++ Developers","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},{"Question":"I'm a long time C++\/Java developer trying to get into Python and am looking for the stereotypical \"Python for C++ Developers\" article, but coming up blank. I've seen these sort of things for C#, Java, etc, and they're incredibly useful for getting up to speed on language features and noteworthy differences. Anyone have any references?\nAs a secondary bonus question, what open source Python program would you suggest looking at for clean design, commenting, and use of the language as a point of reference for study?\nThanks in advance.","AnswerCount":8,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":43679,"Q_Id":328577,"Users Score":0,"Answer":"For the best examples of code of a language, the language's standard library is often a good place to look. Pick a recent piece, though - old parts are probably written for older versions and also sometimes were written before the library became big enough to warrant big standards - like PHP and Erlang's libraries, which have internal inconsistency.\nFor Python in particular, Python 3000 is cleaning up the library a lot, and so is probably a great source of good Python code (though it is written for a future Python version).","Q_Score":56,"Tags":"c++,python","A_Id":328598,"CreationDate":"2008-11-30T07:14:00.000","Title":"Python for C++ Developers","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},{"Question":"I'm a long time C++\/Java developer trying to get into Python and am looking for the stereotypical \"Python for C++ Developers\" article, but coming up blank. I've seen these sort of things for C#, Java, etc, and they're incredibly useful for getting up to speed on language features and noteworthy differences. Anyone have any references?\nAs a secondary bonus question, what open source Python program would you suggest looking at for clean design, commenting, and use of the language as a point of reference for study?\nThanks in advance.","AnswerCount":8,"Available Count":3,"Score":0.024994793,"is_accepted":false,"ViewCount":43679,"Q_Id":328577,"Users Score":1,"Answer":"C# and Java are seen as cleaner replacements for C++ in many application areas so there is often a \"migration\" from one to the other - which is why there are books available.\nPython and C++ are very different beasts, and although they are both considered general purpose programming languages they are targetted towards different ends of the programming spectrum.\nDon't try to write C++ in Python; in fact, try to forget C++ when writing Python.\nI found it far better to learn the common Python paradigms and techniques and apply them to my C++ programs than the other way around.","Q_Score":56,"Tags":"c++,python","A_Id":328689,"CreationDate":"2008-11-30T07:14:00.000","Title":"Python for C++ Developers","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},{"Question":"I need to check whether a page is being redirected or not without actually downloading the content. I just need the final URL. What's the best way of doing this is Python?\nThanks!","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":3318,"Q_Id":331855,"Users Score":1,"Answer":"When you open the URL with urllib2, and you're redirected, you get a status 30x for redirection. Check the info to see the location to which you're redirected. You don't need to read the page to read the info() that's part of the response.","Q_Score":5,"Tags":"python,http,http-headers","A_Id":331871,"CreationDate":"2008-12-01T19:10:00.000","Title":"How to determine if a page is being redirected","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},{"Question":"We know that Python provides a lot of productivity over any compiled languages. We have programming in C# & need to write the unit test cases in C# itself. If we see the amount of code we write for unit test is approximately ten times more than the original code. \nIs it ideal choice to write unit test cases in IronPython instead of C#? Any body has done like that? I wrote few test cases, they seems to be good. But hairy pointy managers won't accept.","AnswerCount":8,"Available Count":6,"Score":0.0,"is_accepted":false,"ViewCount":3355,"Q_Id":340128,"Users Score":0,"Answer":"Very interesting. \nWhat would happen if you write all your code with IronPython (not just the unit tests)? Would you end up with approximately 10 times less code? \nMaybe I should learn IronPython too.","Q_Score":13,"Tags":"c#,python,unit-testing,ironpython","A_Id":342457,"CreationDate":"2008-12-04T10:21:00.000","Title":"IronPython For Unit Testing over 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":0,"Web Development":0},{"Question":"We know that Python provides a lot of productivity over any compiled languages. We have programming in C# & need to write the unit test cases in C# itself. If we see the amount of code we write for unit test is approximately ten times more than the original code. \nIs it ideal choice to write unit test cases in IronPython instead of C#? Any body has done like that? I wrote few test cases, they seems to be good. But hairy pointy managers won't accept.","AnswerCount":8,"Available Count":6,"Score":0.0,"is_accepted":false,"ViewCount":3355,"Q_Id":340128,"Users Score":0,"Answer":"I gotta go with Will and Jon..\nI would prefer my tests be in the same language as the code I'm testing; it causes fewer cognitive context switches. But maybe I'm just not as mentally agile as I once was.\n\nJon","Q_Score":13,"Tags":"c#,python,unit-testing,ironpython","A_Id":443959,"CreationDate":"2008-12-04T10:21:00.000","Title":"IronPython For Unit Testing over 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":0,"Web Development":0},{"Question":"We know that Python provides a lot of productivity over any compiled languages. We have programming in C# & need to write the unit test cases in C# itself. If we see the amount of code we write for unit test is approximately ten times more than the original code. \nIs it ideal choice to write unit test cases in IronPython instead of C#? Any body has done like that? I wrote few test cases, they seems to be good. But hairy pointy managers won't accept.","AnswerCount":8,"Available Count":6,"Score":0.0748596907,"is_accepted":false,"ViewCount":3355,"Q_Id":340128,"Users Score":3,"Answer":"Actually testing is a great opportunity to try integrating a new language. Languages like Python shine especially well in testing, and it's a low risk project to try - the worst case is not too bad at all.\nAs far as experience testing another language in Python, I've tested C and C++ systems like this and it was excellent. I think it's definitely worth a shot.\nWhat Jon says is true, though - the level of tooling for Python in general, and IronPython in particular, is nowhere near that of C#. How much that affects you is something you'll find out in your pilot.","Q_Score":13,"Tags":"c#,python,unit-testing,ironpython","A_Id":342490,"CreationDate":"2008-12-04T10:21:00.000","Title":"IronPython For Unit Testing over 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":0,"Web Development":0},{"Question":"We know that Python provides a lot of productivity over any compiled languages. We have programming in C# & need to write the unit test cases in C# itself. If we see the amount of code we write for unit test is approximately ten times more than the original code. \nIs it ideal choice to write unit test cases in IronPython instead of C#? Any body has done like that? I wrote few test cases, they seems to be good. But hairy pointy managers won't accept.","AnswerCount":8,"Available Count":6,"Score":0.0748596907,"is_accepted":false,"ViewCount":3355,"Q_Id":340128,"Users Score":3,"Answer":"Python being a much less verbose language than C# might actually lower the barrier to writing unit tests since there is still a lot of developers that are resistant to doing automated unit testing in general. Introducing and having them use a language like IronPython that typically tends to take less time to write the equivalent code in C# might actually encourage more unit tests to be written which is always a good thing.\nPlus, by using IronPython for your test code, you might end up with less lines of code (LOC) for your project overall meaning that your unit tests might be more likely to be maintained in the long run versus being ignored and\/or discarded.","Q_Score":13,"Tags":"c#,python,unit-testing,ironpython","A_Id":341683,"CreationDate":"2008-12-04T10:21:00.000","Title":"IronPython For Unit Testing over 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":0,"Web Development":0},{"Question":"We know that Python provides a lot of productivity over any compiled languages. We have programming in C# & need to write the unit test cases in C# itself. If we see the amount of code we write for unit test is approximately ten times more than the original code. \nIs it ideal choice to write unit test cases in IronPython instead of C#? Any body has done like that? I wrote few test cases, they seems to be good. But hairy pointy managers won't accept.","AnswerCount":8,"Available Count":6,"Score":1.0,"is_accepted":false,"ViewCount":3355,"Q_Id":340128,"Users Score":6,"Answer":"Python is excellent for UnitTesting C# code. Our app is 75% in Python and 25% C#(Python.Net), and our unit tests are 100% python. \nI find that it's much easier to make use of stubs and mocks in Python which is probably one of the most critical components that enable one to write effective unittests.","Q_Score":13,"Tags":"c#,python,unit-testing,ironpython","A_Id":346907,"CreationDate":"2008-12-04T10:21:00.000","Title":"IronPython For Unit Testing over 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":0,"Web Development":0},{"Question":"We know that Python provides a lot of productivity over any compiled languages. We have programming in C# & need to write the unit test cases in C# itself. If we see the amount of code we write for unit test is approximately ten times more than the original code. \nIs it ideal choice to write unit test cases in IronPython instead of C#? Any body has done like that? I wrote few test cases, they seems to be good. But hairy pointy managers won't accept.","AnswerCount":8,"Available Count":6,"Score":0.049958375,"is_accepted":false,"ViewCount":3355,"Q_Id":340128,"Users Score":2,"Answer":"There's an obvious disadvantage which is that everyone working on the code now needs to be proficient in two languages, not just one. I'm fairly hairy but not very pointy, but I do see why managers might be sceptical.","Q_Score":13,"Tags":"c#,python,unit-testing,ironpython","A_Id":340152,"CreationDate":"2008-12-04T10:21:00.000","Title":"IronPython For Unit Testing over 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":0,"Web Development":0},{"Question":"I have some old apps written in PHP that I'm thinking of converting to Python - both are websites that started as simple static html, then progressed to PHP and now include blogs with admin areas, rss etc. I'm thinking of rewriting them in Python to improve maintainability as well as to take advantage of my increase in experience to write things more robustly.\nIs this worth the effort?","AnswerCount":11,"Available Count":8,"Score":1.2,"is_accepted":true,"ViewCount":1366,"Q_Id":340318,"Users Score":14,"Answer":"You need to take some parts into mind here,\n\nWhat will you gain from re-writing\nIs it an economically wise decision\nWill the code be easier to handle for new programmers\nPerformance-wise, will this be a good option?\n\nThese four points is something that is important, will the work be more efficient after you re-write the code? Probably. But will it be worth the cost of re-development?\nOne important step to follow, if you decide to re-write, make 3 documents, first Analyze the project, what needs to be done? How should everything work? Then put up a document with Requirements, what specificly do we need and how should this be done? Last but not least, the design document, where you put all your final class diagrams, the system operations and how the design and flow of the page should work.\nThis will help a new developer, and old ones, to actually think about \"do we really need to re-write?\".","Q_Score":6,"Tags":"php,python","A_Id":340338,"CreationDate":"2008-12-04T11:48:00.000","Title":"Is rewriting a PHP app into Python a productive step?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I have some old apps written in PHP that I'm thinking of converting to Python - both are websites that started as simple static html, then progressed to PHP and now include blogs with admin areas, rss etc. I'm thinking of rewriting them in Python to improve maintainability as well as to take advantage of my increase in experience to write things more robustly.\nIs this worth the effort?","AnswerCount":11,"Available Count":8,"Score":0.0181798149,"is_accepted":false,"ViewCount":1366,"Q_Id":340318,"Users Score":1,"Answer":"As others have said, re-writing will take a lot longer than you think and fixing all the bugs and making use everything worked like in the old version will take even longer. Chances are you are better off simply improving and refactoring the php code you have. There are only a few good reasons to port a project from one language to another:\n\nPerformance. Some languages are simply faster than others, and there comes a point where there is nothing left to optimize and throwing hardware at the problem ceases to be effective. \nMaintainability. Sometimes it is hard to find good people who know some obscure language which your legacy code is written in. In those cases it might be a good idea to re-write it in a more popular language to ease maintenance down the road.\nPorting to a different platform. If you all of a sudden need to make your old VB program run on OS X and Linux as well as Windows then you\u2019re probably looking at a re-write in a different language\n\nIn your case it doesn't seem like any of the above points hold. Of course if it's an unimportant app and you want to do it for the learning experience then by all means go for it, but from a business or economic point of view I'd take a long hard look at what such a re-write will cost and what exactly you hope to gain.","Q_Score":6,"Tags":"php,python","A_Id":340792,"CreationDate":"2008-12-04T11:48:00.000","Title":"Is rewriting a PHP app into Python a productive step?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I have some old apps written in PHP that I'm thinking of converting to Python - both are websites that started as simple static html, then progressed to PHP and now include blogs with admin areas, rss etc. I'm thinking of rewriting them in Python to improve maintainability as well as to take advantage of my increase in experience to write things more robustly.\nIs this worth the effort?","AnswerCount":11,"Available Count":8,"Score":0.0,"is_accepted":false,"ViewCount":1366,"Q_Id":340318,"Users Score":0,"Answer":"Other issues include how business critical are the applications and how hard will it be to find maintainers. If the pages are hobbies of yours then I don't see a reason why you shouldn't rewrite them since if you introduce bugs or the rewrite doesn't go according to schedule a business won't lose money. If the application is central to a business I wouldn\u2019t rewrite it unless you are running into limitations with the current design that can not be overcome with out a complete rewrite at which point the language choice is secondary to the fact that you need to throw out several years of work because it\u2019s not maintainable and no longer meets your needs.","Q_Score":6,"Tags":"php,python","A_Id":340719,"CreationDate":"2008-12-04T11:48:00.000","Title":"Is rewriting a PHP app into Python a productive step?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I have some old apps written in PHP that I'm thinking of converting to Python - both are websites that started as simple static html, then progressed to PHP and now include blogs with admin areas, rss etc. I'm thinking of rewriting them in Python to improve maintainability as well as to take advantage of my increase in experience to write things more robustly.\nIs this worth the effort?","AnswerCount":11,"Available Count":8,"Score":0.0181798149,"is_accepted":false,"ViewCount":1366,"Q_Id":340318,"Users Score":1,"Answer":"If you are going to add more features to the code you already have working, then it might be a good idea to port it to python. After all, it will get you increased productivity. You just have to balance it, whether the rewriting task will not outweigh the potential gain... \nAnd also, when you do that, try to unittest as much as you can.","Q_Score":6,"Tags":"php,python","A_Id":340685,"CreationDate":"2008-12-04T11:48:00.000","Title":"Is rewriting a PHP app into Python a productive step?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I have some old apps written in PHP that I'm thinking of converting to Python - both are websites that started as simple static html, then progressed to PHP and now include blogs with admin areas, rss etc. I'm thinking of rewriting them in Python to improve maintainability as well as to take advantage of my increase in experience to write things more robustly.\nIs this worth the effort?","AnswerCount":11,"Available Count":8,"Score":0.0363476168,"is_accepted":false,"ViewCount":1366,"Q_Id":340318,"Users Score":2,"Answer":"Well, it depends... ;) If you're going to use the old code together with new Python code, it might be useful, not so much for speed but for easier integration. But usually: \"If it ain't broke, don't fix it\". Allso rewriting can result in better code, but only do it if you need to.\nAs a hobby project of course it's worth it, cause the process is the goal.","Q_Score":6,"Tags":"php,python","A_Id":340342,"CreationDate":"2008-12-04T11:48:00.000","Title":"Is rewriting a PHP app into Python a productive step?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I have some old apps written in PHP that I'm thinking of converting to Python - both are websites that started as simple static html, then progressed to PHP and now include blogs with admin areas, rss etc. I'm thinking of rewriting them in Python to improve maintainability as well as to take advantage of my increase in experience to write things more robustly.\nIs this worth the effort?","AnswerCount":11,"Available Count":8,"Score":0.0181798149,"is_accepted":false,"ViewCount":1366,"Q_Id":340318,"Users Score":1,"Answer":"I did a conversion between a PHP site and a Turbogears(Python) site for my company. The initial reason for doing so was two fold, first so a redesign would be easier and second that features could be easily added. It did take a while to get the full conversion done, but what we end up with was a very flexible back end and an even more flexible and readable front end. We've added several features that would have been very hard in PHP and we are currently doing a complete overhaul of the front end, which is turning out to be very easy.\nIn short it's something I would recommend, and my boss would probably say the same thing. Some people here are making good points though. Python isn't as fast as what PHP can give you, but what it lacks in performance it more then makes up for in versatility.","Q_Score":6,"Tags":"php,python","A_Id":341834,"CreationDate":"2008-12-04T11:48:00.000","Title":"Is rewriting a PHP app into Python a productive step?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I have some old apps written in PHP that I'm thinking of converting to Python - both are websites that started as simple static html, then progressed to PHP and now include blogs with admin areas, rss etc. I'm thinking of rewriting them in Python to improve maintainability as well as to take advantage of my increase in experience to write things more robustly.\nIs this worth the effort?","AnswerCount":11,"Available Count":8,"Score":0.0363476168,"is_accepted":false,"ViewCount":1366,"Q_Id":340318,"Users Score":2,"Answer":"As others have said, look at why you are doing it.\nFor instance, at work I am rewriting our existing inventory\/sales system to a Python\/django backend. Why? Because the existing PHP code base is stale, and is going to scale poorly as we grow our business (plus it was built when our business model was different, then patched up to match our current needs which resulted in some spaghetti code)\nSo basically, if you think you're going to benefit from it in ways that aren't just \"sweet this is in python now!\" then go for it.","Q_Score":6,"Tags":"php,python","A_Id":340604,"CreationDate":"2008-12-04T11:48:00.000","Title":"Is rewriting a PHP app into Python a productive step?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I have some old apps written in PHP that I'm thinking of converting to Python - both are websites that started as simple static html, then progressed to PHP and now include blogs with admin areas, rss etc. I'm thinking of rewriting them in Python to improve maintainability as well as to take advantage of my increase in experience to write things more robustly.\nIs this worth the effort?","AnswerCount":11,"Available Count":8,"Score":0.0181798149,"is_accepted":false,"ViewCount":1366,"Q_Id":340318,"Users Score":1,"Answer":"Is your aim purely to improve the applications, or is it that you want to learn\/work with Python?\nIf it's the first, I would say you should stick with PHP, since you already know that.","Q_Score":6,"Tags":"php,python","A_Id":340334,"CreationDate":"2008-12-04T11:48:00.000","Title":"Is rewriting a PHP app into Python a productive step?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I have a directory full (~103, 104) of XML files from which I need to extract the contents of several fields. \nI've tested different xml parsers, and since I don't need to validate the contents (expensive) I was thinking of simply using xml.parsers.expat (the fastest one) to go through the files, one by one to extract the data. \n\nIs there a more efficient way? (simple text matching doesn't work)\nDo I need to issue a new ParserCreate() for each new file (or string) or can I reuse the same one for every file?\nAny caveats?\n\nThanks!","AnswerCount":4,"Available Count":3,"Score":0.049958375,"is_accepted":false,"ViewCount":572,"Q_Id":344559,"Users Score":1,"Answer":"If you know that the XML files are generated using the ever-same algorithm, it might be more efficient to not do any XML parsing at all. E.g. if you know that the data is in lines 3, 4, and 5, you might read through the file line-by-line, and then use regular expressions.\nOf course, that approach would fail if the files are not machine-generated, or originate from different generators, or if the generator changes over time. However, I'm optimistic that it would be more efficient.\nWhether or not you recycle the parser objects is largely irrelevant. Many more objects will get created, so a single parser object doesn't really count much.","Q_Score":3,"Tags":"python,xml,performance,large-files,expat-parser","A_Id":344641,"CreationDate":"2008-12-05T17:15:00.000","Title":"What is the most efficient way of extracting information from a large number of xml files 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},{"Question":"I have a directory full (~103, 104) of XML files from which I need to extract the contents of several fields. \nI've tested different xml parsers, and since I don't need to validate the contents (expensive) I was thinking of simply using xml.parsers.expat (the fastest one) to go through the files, one by one to extract the data. \n\nIs there a more efficient way? (simple text matching doesn't work)\nDo I need to issue a new ParserCreate() for each new file (or string) or can I reuse the same one for every file?\nAny caveats?\n\nThanks!","AnswerCount":4,"Available Count":3,"Score":0.049958375,"is_accepted":false,"ViewCount":572,"Q_Id":344559,"Users Score":1,"Answer":"One thing you didn't indicate is whether or not you're reading the XML into a DOM of some kind. I'm guessing that you're probably not, but on the off chance you are, don't. Use xml.sax instead. Using SAX instead of DOM will get you a significant performance boost.","Q_Score":3,"Tags":"python,xml,performance,large-files,expat-parser","A_Id":345650,"CreationDate":"2008-12-05T17:15:00.000","Title":"What is the most efficient way of extracting information from a large number of xml files 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},{"Question":"I have a directory full (~103, 104) of XML files from which I need to extract the contents of several fields. \nI've tested different xml parsers, and since I don't need to validate the contents (expensive) I was thinking of simply using xml.parsers.expat (the fastest one) to go through the files, one by one to extract the data. \n\nIs there a more efficient way? (simple text matching doesn't work)\nDo I need to issue a new ParserCreate() for each new file (or string) or can I reuse the same one for every file?\nAny caveats?\n\nThanks!","AnswerCount":4,"Available Count":3,"Score":1.2,"is_accepted":true,"ViewCount":572,"Q_Id":344559,"Users Score":3,"Answer":"The quickest way would be to match strings (with, e.g., regular expressions) instead of parsing XML - depending on your XMLs this could actually work.\nBut the most important thing is this: instead of thinking through several options, just implement them and time them on a small set. This will take roughly the same amount of time, and will give you real numbers do drive you forward.\nEDIT:\n\nAre the files on a local drive or network drive? Network I\/O will kill you here.\nThe problem parallelizes trivially - you can split the work among several computers (or several processes on a multicore computer).","Q_Score":3,"Tags":"python,xml,performance,large-files,expat-parser","A_Id":344694,"CreationDate":"2008-12-05T17:15:00.000","Title":"What is the most efficient way of extracting information from a large number of xml files 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},{"Question":"How can I receive and send email in python? A 'mail server' of sorts.\nI am looking into making an app that listens to see if it receives an email addressed to foo@bar.domain.com, and sends an email to the sender.\nNow, am I able to do this all in python, would it be best to use 3rd party libraries?","AnswerCount":9,"Available Count":4,"Score":0.0444152037,"is_accepted":false,"ViewCount":51409,"Q_Id":348392,"Users Score":2,"Answer":"Depending on the amount of mail you are sending you might want to look into using a real mail server like postifx or sendmail (*nix systems) Both of those programs have the ability to send a received mail to a program based on the email address.","Q_Score":43,"Tags":"python,email","A_Id":348579,"CreationDate":"2008-12-08T00:12:00.000","Title":"Receive and send emails 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},{"Question":"How can I receive and send email in python? A 'mail server' of sorts.\nI am looking into making an app that listens to see if it receives an email addressed to foo@bar.domain.com, and sends an email to the sender.\nNow, am I able to do this all in python, would it be best to use 3rd party libraries?","AnswerCount":9,"Available Count":4,"Score":0.0886555158,"is_accepted":false,"ViewCount":51409,"Q_Id":348392,"Users Score":4,"Answer":"poplib and smtplib will be your friends when developing your app.","Q_Score":43,"Tags":"python,email","A_Id":348403,"CreationDate":"2008-12-08T00:12:00.000","Title":"Receive and send emails 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},{"Question":"How can I receive and send email in python? A 'mail server' of sorts.\nI am looking into making an app that listens to see if it receives an email addressed to foo@bar.domain.com, and sends an email to the sender.\nNow, am I able to do this all in python, would it be best to use 3rd party libraries?","AnswerCount":9,"Available Count":4,"Score":1.0,"is_accepted":false,"ViewCount":51409,"Q_Id":348392,"Users Score":12,"Answer":"I do not think it would be a good idea to write a real mail server in Python. This is certainly possible (see mcrute's and Manuel Ceron's posts to have details) but it is a lot of work when you think of everything that a real mail server must handle (queuing, retransmission, dealing with spam, etc).\nYou should explain in more detail what you need. If you just want to react to incoming email, I would suggest to configure the mail server to call a program when it receives the email. This program could do what it wants (updating a database, creating a file, talking to another Python program).\nTo call an arbitrary program from the mail server, you have several choices:\n\nFor sendmail and Postfix, a ~\/.forward containing \"|\/path\/to\/program\"\nIf you use procmail, a recipe action of |path\/to\/program\nAnd certainly many others","Q_Score":43,"Tags":"python,email","A_Id":349352,"CreationDate":"2008-12-08T00:12:00.000","Title":"Receive and send emails 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},{"Question":"How can I receive and send email in python? A 'mail server' of sorts.\nI am looking into making an app that listens to see if it receives an email addressed to foo@bar.domain.com, and sends an email to the sender.\nNow, am I able to do this all in python, would it be best to use 3rd party libraries?","AnswerCount":9,"Available Count":4,"Score":1.0,"is_accepted":false,"ViewCount":51409,"Q_Id":348392,"Users Score":7,"Answer":"Python has an SMTPD module that will be helpful to you for writing a server. You'll probably also want the SMTP module to do the re-send. Both modules are in the standard library at least since version 2.3.","Q_Score":43,"Tags":"python,email","A_Id":348423,"CreationDate":"2008-12-08T00:12:00.000","Title":"Receive and send emails 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},{"Question":"I'm curious to know if there is an easy way to mock an IMAP server (a la the imaplib module) in Python, without doing a lot of work.\nIs there a pre-existing solution? Ideally I could connect to the existing IMAP server, do a dump, and have the mock server run off the real mailbox\/email structure.\nSome background into the laziness: I have a nasty feeling that this small script I'm writing will grow over time and would like to create a proper testing environment, but given that it might not grow over time, I don't want to do much work to get the mock server running.","AnswerCount":4,"Available Count":3,"Score":1.2,"is_accepted":true,"ViewCount":4288,"Q_Id":351656,"Users Score":10,"Answer":"I found it quite easy to write an IMAP server in twisted last time I tried. It comes with support for writing IMAP servers and you have a huge amount of flexibility.","Q_Score":11,"Tags":"python,testing,imap,mocking","A_Id":351675,"CreationDate":"2008-12-09T02:57:00.000","Title":"How do I mock an IMAP server in Python, despite extreme laziness?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I'm curious to know if there is an easy way to mock an IMAP server (a la the imaplib module) in Python, without doing a lot of work.\nIs there a pre-existing solution? Ideally I could connect to the existing IMAP server, do a dump, and have the mock server run off the real mailbox\/email structure.\nSome background into the laziness: I have a nasty feeling that this small script I'm writing will grow over time and would like to create a proper testing environment, but given that it might not grow over time, I don't want to do much work to get the mock server running.","AnswerCount":4,"Available Count":3,"Score":1.0,"is_accepted":false,"ViewCount":4288,"Q_Id":351656,"Users Score":7,"Answer":"How much of it do you really need for any one test? If you start to build something on the order of complexity of a real server so that you can use it on all your tests, you've already gone wrong. Just mock the bits any one tests needs. \nDon't bother trying so hard to share a mock implementation. They're not supposed to be assets, but discardable bits-n-pieces.","Q_Score":11,"Tags":"python,testing,imap,mocking","A_Id":353175,"CreationDate":"2008-12-09T02:57:00.000","Title":"How do I mock an IMAP server in Python, despite extreme laziness?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I'm curious to know if there is an easy way to mock an IMAP server (a la the imaplib module) in Python, without doing a lot of work.\nIs there a pre-existing solution? Ideally I could connect to the existing IMAP server, do a dump, and have the mock server run off the real mailbox\/email structure.\nSome background into the laziness: I have a nasty feeling that this small script I'm writing will grow over time and would like to create a proper testing environment, but given that it might not grow over time, I don't want to do much work to get the mock server running.","AnswerCount":4,"Available Count":3,"Score":0.049958375,"is_accepted":false,"ViewCount":4288,"Q_Id":351656,"Users Score":1,"Answer":"I never tried but, if I had to, I would start with the existing SMTP server.","Q_Score":11,"Tags":"python,testing,imap,mocking","A_Id":352194,"CreationDate":"2008-12-09T02:57:00.000","Title":"How do I mock an IMAP server in Python, despite extreme laziness?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I'm trying to get started with unit testing in Python and I was wondering if someone could explain the advantages and disadvantages of doctest and unittest. \nWhat conditions would you use each for?","AnswerCount":11,"Available Count":9,"Score":1.0,"is_accepted":false,"ViewCount":29175,"Q_Id":361675,"Users Score":31,"Answer":"I work as a bioinformatician, and most of the code I write is \"one time, one task\" scripts, code that will be run only once or twice and that execute a single specific task.\nIn this situation, writing big unittests may be overkill, and doctests are an useful compromise. They are quicker to write, and since they are usually incorporated in the code, they allow to always keep an eye on how the code should behave, without having to have another file open. That's useful when writing small script.\nAlso, doctests are useful when you have to pass your script to a researcher that is not expert in programming. Some people find it very difficult to understand how unittests are structured; on the other hand, doctests are simple examples of usage, so people can just copy and paste them to see how to use them.\nSo, to resume my answer: doctests are useful when you have to write small scripts, and when you have to pass them or show them to researchers that are not computer scientists.","Q_Score":169,"Tags":"python,unit-testing,comparison,doctest","A_Id":10861736,"CreationDate":"2008-12-12T01:50:00.000","Title":"Python - doctest vs. unittest","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to get started with unit testing in Python and I was wondering if someone could explain the advantages and disadvantages of doctest and unittest. \nWhat conditions would you use each for?","AnswerCount":11,"Available Count":9,"Score":1.0,"is_accepted":false,"ViewCount":29175,"Q_Id":361675,"Users Score":37,"Answer":"Another advantage of doctesting is that you get to make sure your code does what your documentation says it does. After a while, software changes can make your documentation and code do different things. :-)","Q_Score":169,"Tags":"python,unit-testing,comparison,doctest","A_Id":667829,"CreationDate":"2008-12-12T01:50:00.000","Title":"Python - doctest vs. unittest","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to get started with unit testing in Python and I was wondering if someone could explain the advantages and disadvantages of doctest and unittest. \nWhat conditions would you use each for?","AnswerCount":11,"Available Count":9,"Score":1.0,"is_accepted":false,"ViewCount":29175,"Q_Id":361675,"Users Score":7,"Answer":"Using both is a valid and rather simple option. The doctest module provides the DoctTestSuite and DocFileSuite methods which create a unittest-compatible testsuite from a module or file, respectively.\nSo I use both and typically use doctest for simple tests with functions that require little or no setup (simple types for arguments). I actually think a few doctest tests help document the function, rather than detract from it.\nBut for more complicated cases, and for a more comprehensive set of test cases, I use unittest which provides more control and flexibility.","Q_Score":169,"Tags":"python,unit-testing,comparison,doctest","A_Id":361788,"CreationDate":"2008-12-12T01:50:00.000","Title":"Python - doctest vs. unittest","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to get started with unit testing in Python and I was wondering if someone could explain the advantages and disadvantages of doctest and unittest. \nWhat conditions would you use each for?","AnswerCount":11,"Available Count":9,"Score":1.0,"is_accepted":false,"ViewCount":29175,"Q_Id":361675,"Users Score":7,"Answer":"I use unittest exclusively; I think doctest clutters up the main module too much. This probably has to do with writing thorough tests.","Q_Score":169,"Tags":"python,unit-testing,comparison,doctest","A_Id":361703,"CreationDate":"2008-12-12T01:50:00.000","Title":"Python - doctest vs. unittest","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to get started with unit testing in Python and I was wondering if someone could explain the advantages and disadvantages of doctest and unittest. \nWhat conditions would you use each for?","AnswerCount":11,"Available Count":9,"Score":1.0,"is_accepted":false,"ViewCount":29175,"Q_Id":361675,"Users Score":50,"Answer":"I use unittest almost exclusively.\nOnce in a while, I'll put some stuff in a docstring that's usable by doctest.\n95% of the test cases are unittest.\nWhy? I like keeping docstrings somewhat shorter and more to the point. Sometimes test cases help clarify a docstring. Most of the time, the application's test cases are too long for a docstring.","Q_Score":169,"Tags":"python,unit-testing,comparison,doctest","A_Id":361680,"CreationDate":"2008-12-12T01:50:00.000","Title":"Python - doctest vs. unittest","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to get started with unit testing in Python and I was wondering if someone could explain the advantages and disadvantages of doctest and unittest. \nWhat conditions would you use each for?","AnswerCount":11,"Available Count":9,"Score":1.0,"is_accepted":false,"ViewCount":29175,"Q_Id":361675,"Users Score":8,"Answer":"I don't use doctest as a replacement for unittest. Although they overlap a bit, the two modules don't have the same function:\n\nI use unittest as a unit testing framework, meaning it helps me determine quickly the impact of any modification on the rest of the code.\nI use doctest as a guarantee that comments (namely docstrings) are still relevant to current version of the code. \n\nThe widely documented benefits of test driven development I get from unittest. doctest solves the far more subtle danger of having outdated comments misleading the maintenance of the code.","Q_Score":169,"Tags":"python,unit-testing,comparison,doctest","A_Id":13722080,"CreationDate":"2008-12-12T01:50:00.000","Title":"Python - doctest vs. unittest","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to get started with unit testing in Python and I was wondering if someone could explain the advantages and disadvantages of doctest and unittest. \nWhat conditions would you use each for?","AnswerCount":11,"Available Count":9,"Score":0.072599319,"is_accepted":false,"ViewCount":29175,"Q_Id":361675,"Users Score":4,"Answer":"I almost never use doctests. I want my code to be self documenting, and the docstrings provide the documentation to the user. IMO adding hundreds of lines of tests to a module makes the docstrings far less readable. I also find unit tests easier to modify when needed.","Q_Score":169,"Tags":"python,unit-testing,comparison,doctest","A_Id":361698,"CreationDate":"2008-12-12T01:50:00.000","Title":"Python - doctest vs. unittest","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to get started with unit testing in Python and I was wondering if someone could explain the advantages and disadvantages of doctest and unittest. \nWhat conditions would you use each for?","AnswerCount":11,"Available Count":9,"Score":0.0544914242,"is_accepted":false,"ViewCount":29175,"Q_Id":361675,"Users Score":3,"Answer":"I prefer the discovery based systems (\"nose\" and \"py.test\", using the former currently).\ndoctest is nice when the test is also good as a documentation, otherwise they tend to clutter the code too much.","Q_Score":169,"Tags":"python,unit-testing,comparison,doctest","A_Id":361886,"CreationDate":"2008-12-12T01:50:00.000","Title":"Python - doctest vs. unittest","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to get started with unit testing in Python and I was wondering if someone could explain the advantages and disadvantages of doctest and unittest. \nWhat conditions would you use each for?","AnswerCount":11,"Available Count":9,"Score":1.0,"is_accepted":false,"ViewCount":29175,"Q_Id":361675,"Users Score":14,"Answer":"If you're just getting started with the idea of unit testing, I would start with doctest because it is so simple to use. It also naturally provides some level of documentation. And for more comprehensive testing with doctest, you can place tests in an external file so it doesn't clutter up your documentation.\nI would suggest unittest if you're coming from a background of having used JUnit or something similar, where you want to be able to write unit tests in generally the same way as you have been elsewhere.","Q_Score":169,"Tags":"python,unit-testing,comparison,doctest","A_Id":361683,"CreationDate":"2008-12-12T01:50:00.000","Title":"Python - doctest vs. unittest","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'd like to try out Eclipse, but I'm a bit baffled with all the different distributions of it. I mainly program in Python doing web development, but I also need to maintain PHP and Perl apps. It looks like EasyEclipse is a bit behind. Should I just grab the base Eclipse and start loading plug-ins?","AnswerCount":7,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":2130,"Q_Id":364486,"Users Score":0,"Answer":"I develop in PHP, python, C(python modules), SQL and JS\/HTML\/CSS all on eclipse. I do this\nby installing PDT, CDT, pydev and SQL tools onto the eclipse-platform, and then using different workspaces for mixed projects. \nTwo workspaces to be specific, one for PHP web development and another for Python\/C. I do run it on a rather powerful machine so I allow eclipse the luxury of added memory (2G).\nWorks like a charm and it is very nice to be able to use the same IDE for everything :)","Q_Score":4,"Tags":"php,python,perl,eclipse","A_Id":6481753,"CreationDate":"2008-12-12T23:26:00.000","Title":"Which Eclipse distribution is good for web development using Python, PHP, or 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":0,"Web Development":1},{"Question":"I'd like to try out Eclipse, but I'm a bit baffled with all the different distributions of it. I mainly program in Python doing web development, but I also need to maintain PHP and Perl apps. It looks like EasyEclipse is a bit behind. Should I just grab the base Eclipse and start loading plug-ins?","AnswerCount":7,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":2130,"Q_Id":364486,"Users Score":0,"Answer":"I use the javascript eclipse helios and added pydev plugin to it for django support it seems to do everything I need.","Q_Score":4,"Tags":"php,python,perl,eclipse","A_Id":18023885,"CreationDate":"2008-12-12T23:26:00.000","Title":"Which Eclipse distribution is good for web development using Python, PHP, or 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":0,"Web Development":1},{"Question":"I'd like to try out Eclipse, but I'm a bit baffled with all the different distributions of it. I mainly program in Python doing web development, but I also need to maintain PHP and Perl apps. It looks like EasyEclipse is a bit behind. Should I just grab the base Eclipse and start loading plug-ins?","AnswerCount":7,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":2130,"Q_Id":364486,"Users Score":0,"Answer":"PyDev is pretty decent as I'm sure you know. It can fit on top of all the Eclipse distributions (provided they meet the minimum version requirements). If you're doing webdev stuff, you'll probably find the closest fit with Aptana. \nThat said, I find Aptana hideously clunky when compared to a decent text editor. I build sites using django and for that I use Eclipse (pure) and PyDev to do the python and gedit (gnome's souped up notepad) for writing the HTML for templates\/CSS\/JS\/etc.\nAt the end of the day, whatever suits you best is what you'll go with.","Q_Score":4,"Tags":"php,python,perl,eclipse","A_Id":364517,"CreationDate":"2008-12-12T23:26:00.000","Title":"Which Eclipse distribution is good for web development using Python, PHP, or 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":0,"Web Development":1},{"Question":"What are the main differences among them? And in which typical scenarios is it better to use each language?","AnswerCount":5,"Available Count":4,"Score":1.0,"is_accepted":false,"ViewCount":86075,"Q_Id":366980,"Users Score":17,"Answer":"First, there are two unrelated things in the list \"Perl, Python awk and sed\".\nThing 1 - simplistic text manipulation tools.\n\nsed. It has a fixed, relatively simple scope of work defined by the idea of reading and examining each line of a file. sed is not designed to be particularly readable. It is designed to be very small and very efficient on very tiny unix servers.\nawk. It has a slightly less fixed, less simple scope of work. However, the main loop of an awk program is defined by the implicit reading of lines of a source file. \n\nThese are not \"complete\" programming languages. While you can -- with some work -- write fairly sophisticated programs in awk, it rapidly gets complicated and difficult to read.\nThing 2 - general-purposes programming languages. These have a rich variety of statement types, numerous built-in data structures, and no wired-in assumptions or shortcuts to speak of.\n\nPerl.\nPython. \n\nWhen to use them.\n\nsed. Never. It really doesn't have any value in the modern era of computers with more than 32K of memory. Perl or Python do the same things more clearly.\nawk. Never. Like sed, it reflects an earlier era of computing. Rather than maintain this language (in addition to all the other required for a successful system), it's more pleasant to simply do everything in one pleasant language.\nPerl. Any programming problem of any kind. If you like free-thinking syntax, where there are many, many ways to do the same thing, perl is fun.\nPython. Any programming problem of any kind. If you like fairly limited syntax, where there are fewer choices, less subtlety, and (perhaps) more clarity. Python's object-oriented nature makes it more suitable for large, complex problems.\n\nBackground -- I'm not bashing sed and awk out of ignorance. I learned awk over 20 years ago. Did many things with it; used to teach it as a core unix skill. I learned Perl about 15 years ago. Did many sophisticated things with it. I've left both behind because I can do the same things in Python -- and it is simpler and more clear.\nThere are two serious problems with sed and awk, neither of which are their age.\n\nThe incompleteness of their implementation. Everything sed and awk do can be done in Python or Perl, often more simply and sometimes faster, too. A shell pipeline has some performance advantages because of its multi-processing. Python offers a subprocess module to allow me to recover those advantages.\nThe need to learn yet another language. By doing things in Python (or Perl) your implementation depends on fewer languages, with a resulting increase in clarity.","Q_Score":274,"Tags":"python,perl,sed,awk,language-comparisons","A_Id":367082,"CreationDate":"2008-12-14T21:00:00.000","Title":"What are the differences between Perl, Python, AWK and sed?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"What are the main differences among them? And in which typical scenarios is it better to use each language?","AnswerCount":5,"Available Count":4,"Score":1.2,"is_accepted":true,"ViewCount":86075,"Q_Id":366980,"Users Score":588,"Answer":"In order of appearance, the languages are sed, awk, perl, python.\nThe sed program is a stream editor and is designed to apply the actions from a script to each line (or, more generally, to specified ranges of lines) of the input file or files. Its language is based on ed, the Unix editor, and although it has conditionals and so on, it is hard to work with for complex tasks. You can work minor miracles with it - but at a cost to the hair on your head. However, it is probably the fastest of the programs when attempting tasks within its remit. (It has the least powerful regular expressions of the programs discussed - adequate for many purposes, but certainly not PCRE - Perl-Compatible Regular Expressions)\nThe awk program (name from the initials of its authors - Aho, Weinberger, and Kernighan) is a tool initially for formatting reports. It can be used as a souped-up sed; in its more recent versions, it is computationally complete. It uses an interesting idea - the program is based on 'patterns matched' and 'actions taken when the pattern matches'. The patterns are fairly powerful (Extended Regular Expressions). The language for the actions is similar to C. One of the key features of awk is that it splits the input automatically into records and each record into fields.\nPerl was written in part as an awk-killer and sed-killer. Two of the programs provided with it are a2p and s2p for converting awk scripts and sed scripts into Perl. Perl is one of the earliest of the next generation of scripting languages (Tcl\/Tk can probably claim primacy). It has powerful integrated regular expression handling with a vastly more powerful language. It provides access to almost all system calls and has the extensibility of the CPAN modules. (Neither awk nor sed is extensible.) One of Perl's mottos is \"TMTOWTDI - There's more than one way to do it\" (pronounced \"tim-toady\"). Perl has 'objects', but it is more of an add-on than a fundamental part of the language.\nPython was written last, and probably in part as a reaction to Perl. It has some interesting syntactic ideas (indenting to indicate levels - no braces or equivalents). It is more fundamentally object-oriented than Perl; it is just as extensible as Perl.\nOK - when to use each?\n\nSed - when you need to do simple text transforms on files.\nAwk - when you only need simple formatting and summarisation or transformation of data.\nPerl - for almost any task, but especially when the task needs complex regular expressions.\nPython - for the same tasks that you could use Perl for.\n\nI'm not aware of anything that Perl can do that Python can't, nor vice versa. The choice between the two would depend on other factors. I learned Perl before there was a Python, so I tend to use it. Python has less accreted syntax and is generally somewhat simpler to learn. Perl 6, when it becomes available, will be a fascinating development.\n(Note that the 'overviews' of Perl and Python, in particular, are woefully incomplete; whole books could be written on the topic.)","Q_Score":274,"Tags":"python,perl,sed,awk,language-comparisons","A_Id":367014,"CreationDate":"2008-12-14T21:00:00.000","Title":"What are the differences between Perl, Python, AWK and sed?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"What are the main differences among them? And in which typical scenarios is it better to use each language?","AnswerCount":5,"Available Count":4,"Score":1.0,"is_accepted":false,"ViewCount":86075,"Q_Id":366980,"Users Score":100,"Answer":"After mastering a few dozen languages, you get tired of people like S. Lott (see his controversial answer to this question, nearly half as many down-votes as up (+45\/-22) six years after answering).\nSed is the best tool for extremely simple command-line pipelines. In the hands of a sed master, it's suitable for one-offs of arbitrary complexity, but it should not be used in production code except in very simple substitution pipelines. Stuff like 's\/this\/that\/.'\nGawk (the GNU awk) is by far the best choice for complex data reformatting when there is only a single input source and a single output (or, multiple outputs sequentially written). Since a great deal of real-world work conforms to this description, and a good programmer can learn gawk in two hours, it is the best choice. On this planet, simpler and faster is better!\nPerl or Python are far better than any version of awk or sed when you have very complex input\/output scenarios. The more complex the problem is, the better off you are using python, from a maintenance and readability standpoint. Note, however, that a good programmer can write readable code in any language, and a bad programmer can write unmaintainable crap in any useful language, so the choice of perl or python can safely be left to the preferences of the programmer if said programmer is skilled and clever.","Q_Score":274,"Tags":"python,perl,sed,awk,language-comparisons","A_Id":2905791,"CreationDate":"2008-12-14T21:00:00.000","Title":"What are the differences between Perl, Python, AWK and sed?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"What are the main differences among them? And in which typical scenarios is it better to use each language?","AnswerCount":5,"Available Count":4,"Score":1.0,"is_accepted":false,"ViewCount":86075,"Q_Id":366980,"Users Score":22,"Answer":"I wouldn't call sed a fully-fledged programming language, it is a stream editor with language constructs aimed at editing text files programmatically.\nAwk is a little more of a general purpose language but it is still best suited for text processing.\nPerl and Python are fully fledged, general purpose programming languages. Perl has its roots in text processing and has a number of awk-like constructs (there is even an awk-to-perl script floating around on the net). There are many differences between Perl and Python, your best bet is probably to read the summaries of both languages on something like Wikipedia to get a good grasp on what they are.","Q_Score":274,"Tags":"python,perl,sed,awk,language-comparisons","A_Id":367002,"CreationDate":"2008-12-14T21:00:00.000","Title":"What are the differences between Perl, Python, AWK and sed?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I know of python -c '', but I'm wondering if there's a more elegant python equivalent to perl -pi -e ''. I still use it quite a bit for things like find and replace in a whole directory (perl -pi -e s\/foo\/bar\/g * or even find . | xargs perl -pi -e s\/foo\/bar\/g for sub-directories).\nI actually feel that that which makes Perl Perl (free form Tim Toady-ness) is what makes perl -pi -e work so well, while with Python you'd have to do something along the lines of importing the re module, creating an re instance and then capture stdin, but maybe there's a Python shortcut that does all that and I missed it (sorely missed it)...","AnswerCount":6,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":3183,"Q_Id":367115,"Users Score":10,"Answer":"The command line usage from 'python -h' certainly strongly suggests there is no such equivalent. Perl tends to make extensive use of '$_' (your examples make implicit use of it), and I don't think Python supports any similar concept, thereby making Python equivalents of the Perl one-liners much harder.","Q_Score":17,"Tags":"python,perl,command-line,language-features","A_Id":367181,"CreationDate":"2008-12-14T22:57:00.000","Title":"Is there a Python equivalent to `perl -pi -e`?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want something simple in order to experiment\/hack. I've created a lot interpreters\/compilers for c and I just want something simple. A basic BASIC :D\nIf you don't know any (I've done my google search...), yacc\/bison is the only way?\nThx","AnswerCount":6,"Available Count":1,"Score":-0.0333209931,"is_accepted":false,"ViewCount":2470,"Q_Id":369391,"Users Score":-1,"Answer":"There is pybasic (python basic), rockit-minibasic (rubybasic).\nTo make these able to use the gui, then one has to develop extensions with kivy and shoes gui toolkits for pybasic and rockit-minibasic respectively and similarly prima gui for perlbasic if ever exists.","Q_Score":2,"Tags":"python,ruby,interpreter","A_Id":12280987,"CreationDate":"2008-12-15T19:12:00.000","Title":"Is there an OpenSource BASIC interpreter in Ruby\/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},{"Question":"How would I only allow users authenticated via Python code to access certain files on the server?\nFor instance, say I have \/static\/book.txt which I want to protect. When a user accesses \/some\/path\/that\/validates\/him, a Python script deems him worthy of accessing \/static\/book.txt and redirects him to that path.\nHow would I stop users who bypass the script and directly access \/static\/book.txt?","AnswerCount":2,"Available Count":1,"Score":0.2913126125,"is_accepted":false,"ViewCount":274,"Q_Id":372465,"Users Score":3,"Answer":"You might want to just have your Python script open the file and dump the contents as its output if the user is properly authenticated. Put the files you want to protect in a folder that is outside of the webserver root.","Q_Score":0,"Tags":"python,security,apache,download,lighttpd","A_Id":372488,"CreationDate":"2008-12-16T19:50:00.000","Title":"Protecting online static 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},{"Question":"I have a large set of data (a data cube of 250,000 X 1,000 doubles, about a 4 gig file) and I want to manipulate it using a previous set of OOP classes I have written in Python. Currently the data set is already so large that to read into my machine memory I have to at least split it in half so computing overhead is a concern. My OOP classes create new objects (in this case I will need 250,000 new objects, each object is an array of 1,000 doubles) to handle the data. What is the overhead in terms of memory and computing required in creating objects for a generic OOP language? In python? What about in C++?\nYes, I realize I could make a new class that is an array. But 1) I already have these classes finished and 2) I put each object that I create back into an array for access later anyways. The question is pedagogical \n*update: I want to be efficient with time, my time and the computers. I don't want to rewrite a program I already have if I don't have to and spending time optimizing the code wastes my time, I don't care that much if I waste the computers time. I actually do have a 64bit machine with 4Gig ram. The data is an image and I need to do several filters on each pixel.*","AnswerCount":14,"Available Count":11,"Score":0.0142847425,"is_accepted":false,"ViewCount":3461,"Q_Id":372511,"Users Score":1,"Answer":"Actual C++ OO memory overhead is one pointer (4-8 bytes, depending) per object with virtual methods. However, as mentioned in other answers, the default memory allocation overhead from dynamic allocation is likely to be significantly greater than this.\nIf you're doing things halfway reasonably, neither overhead is likely to be significant compared with an 1000*8-byte double array. If you're actually worried about allocation overhead, you can write your own allocator -- but, check first to see if it will actually buy you a significant improvement.","Q_Score":2,"Tags":"python,oop,data-analysis","A_Id":372779,"CreationDate":"2008-12-16T20:04:00.000","Title":"What is the object oriented programming computing overhead cost?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a large set of data (a data cube of 250,000 X 1,000 doubles, about a 4 gig file) and I want to manipulate it using a previous set of OOP classes I have written in Python. Currently the data set is already so large that to read into my machine memory I have to at least split it in half so computing overhead is a concern. My OOP classes create new objects (in this case I will need 250,000 new objects, each object is an array of 1,000 doubles) to handle the data. What is the overhead in terms of memory and computing required in creating objects for a generic OOP language? In python? What about in C++?\nYes, I realize I could make a new class that is an array. But 1) I already have these classes finished and 2) I put each object that I create back into an array for access later anyways. The question is pedagogical \n*update: I want to be efficient with time, my time and the computers. I don't want to rewrite a program I already have if I don't have to and spending time optimizing the code wastes my time, I don't care that much if I waste the computers time. I actually do have a 64bit machine with 4Gig ram. The data is an image and I need to do several filters on each pixel.*","AnswerCount":14,"Available Count":11,"Score":0.0,"is_accepted":false,"ViewCount":3461,"Q_Id":372511,"Users Score":0,"Answer":"Since you can split the data in half and operate on it, I'm assuming that you're working on each record individually? It sounds to me like you need to change your deserialiser to read one record at a time, manipulate it, and then store out the results.\nBasically you need a string parser class that does a Peek() which returns a char, knows how to skip whitespace, etc. Wrap a class around that that understands your data format, and you should be able to have it spit out an object at a time as it reads the file.","Q_Score":2,"Tags":"python,oop,data-analysis","A_Id":372848,"CreationDate":"2008-12-16T20:04:00.000","Title":"What is the object oriented programming computing overhead cost?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a large set of data (a data cube of 250,000 X 1,000 doubles, about a 4 gig file) and I want to manipulate it using a previous set of OOP classes I have written in Python. Currently the data set is already so large that to read into my machine memory I have to at least split it in half so computing overhead is a concern. My OOP classes create new objects (in this case I will need 250,000 new objects, each object is an array of 1,000 doubles) to handle the data. What is the overhead in terms of memory and computing required in creating objects for a generic OOP language? In python? What about in C++?\nYes, I realize I could make a new class that is an array. But 1) I already have these classes finished and 2) I put each object that I create back into an array for access later anyways. The question is pedagogical \n*update: I want to be efficient with time, my time and the computers. I don't want to rewrite a program I already have if I don't have to and spending time optimizing the code wastes my time, I don't care that much if I waste the computers time. I actually do have a 64bit machine with 4Gig ram. The data is an image and I need to do several filters on each pixel.*","AnswerCount":14,"Available Count":11,"Score":0.0,"is_accepted":false,"ViewCount":3461,"Q_Id":372511,"Users Score":0,"Answer":"Impossible to answer without knowing the shape of the data and the structure that you've designed to contain it.","Q_Score":2,"Tags":"python,oop,data-analysis","A_Id":372517,"CreationDate":"2008-12-16T20:04:00.000","Title":"What is the object oriented programming computing overhead cost?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a large set of data (a data cube of 250,000 X 1,000 doubles, about a 4 gig file) and I want to manipulate it using a previous set of OOP classes I have written in Python. Currently the data set is already so large that to read into my machine memory I have to at least split it in half so computing overhead is a concern. My OOP classes create new objects (in this case I will need 250,000 new objects, each object is an array of 1,000 doubles) to handle the data. What is the overhead in terms of memory and computing required in creating objects for a generic OOP language? In python? What about in C++?\nYes, I realize I could make a new class that is an array. But 1) I already have these classes finished and 2) I put each object that I create back into an array for access later anyways. The question is pedagogical \n*update: I want to be efficient with time, my time and the computers. I don't want to rewrite a program I already have if I don't have to and spending time optimizing the code wastes my time, I don't care that much if I waste the computers time. I actually do have a 64bit machine with 4Gig ram. The data is an image and I need to do several filters on each pixel.*","AnswerCount":14,"Available Count":11,"Score":0.0,"is_accepted":false,"ViewCount":3461,"Q_Id":372511,"Users Score":0,"Answer":"A friend of mine was a professor at MIT and a student asked him why his image analysis program was running so slow. How was it built? Every pixel was an object, and would send messages to its neighbors!\nIf I were you I'd try it in a throw-away program. My suspicion is, unless your classes are very carefully coded, you're going to find it spending a lot of time allocating, initializing, and de-allocating objects, and as Brian said, you might be able to spool the data through a set of re-used objects.\nEdit: Excuse me. You said you are re-using objects, so that's good. In any case, when you get it running you could profile it or (if you were me) just read the call stack a few random times, and that will answer any questions about where the time goes.","Q_Score":2,"Tags":"python,oop,data-analysis","A_Id":372801,"CreationDate":"2008-12-16T20:04:00.000","Title":"What is the object oriented programming computing overhead cost?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a large set of data (a data cube of 250,000 X 1,000 doubles, about a 4 gig file) and I want to manipulate it using a previous set of OOP classes I have written in Python. Currently the data set is already so large that to read into my machine memory I have to at least split it in half so computing overhead is a concern. My OOP classes create new objects (in this case I will need 250,000 new objects, each object is an array of 1,000 doubles) to handle the data. What is the overhead in terms of memory and computing required in creating objects for a generic OOP language? In python? What about in C++?\nYes, I realize I could make a new class that is an array. But 1) I already have these classes finished and 2) I put each object that I create back into an array for access later anyways. The question is pedagogical \n*update: I want to be efficient with time, my time and the computers. I don't want to rewrite a program I already have if I don't have to and spending time optimizing the code wastes my time, I don't care that much if I waste the computers time. I actually do have a 64bit machine with 4Gig ram. The data is an image and I need to do several filters on each pixel.*","AnswerCount":14,"Available Count":11,"Score":0.0,"is_accepted":false,"ViewCount":3461,"Q_Id":372511,"Users Score":0,"Answer":"Please define \"manipulate\". If you really want to manipulate 4 gigs of data why do you want to manipulate it by pulling it ALL into memory right away?\nI mean, who needs 4 gig of RAM anyway? :)","Q_Score":2,"Tags":"python,oop,data-analysis","A_Id":372724,"CreationDate":"2008-12-16T20:04:00.000","Title":"What is the object oriented programming computing overhead cost?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a large set of data (a data cube of 250,000 X 1,000 doubles, about a 4 gig file) and I want to manipulate it using a previous set of OOP classes I have written in Python. Currently the data set is already so large that to read into my machine memory I have to at least split it in half so computing overhead is a concern. My OOP classes create new objects (in this case I will need 250,000 new objects, each object is an array of 1,000 doubles) to handle the data. What is the overhead in terms of memory and computing required in creating objects for a generic OOP language? In python? What about in C++?\nYes, I realize I could make a new class that is an array. But 1) I already have these classes finished and 2) I put each object that I create back into an array for access later anyways. The question is pedagogical \n*update: I want to be efficient with time, my time and the computers. I don't want to rewrite a program I already have if I don't have to and spending time optimizing the code wastes my time, I don't care that much if I waste the computers time. I actually do have a 64bit machine with 4Gig ram. The data is an image and I need to do several filters on each pixel.*","AnswerCount":14,"Available Count":11,"Score":0.0285636566,"is_accepted":false,"ViewCount":3461,"Q_Id":372511,"Users Score":2,"Answer":"I wouldn't consider it fair to blame any shortcomings of your design to OOP. Just like any other programming platform out there OO can be used for both good and less than optimal design. Rarely will this be the fault of the programming model itself. \nBut to try to answer your question: Allocating 250000 new object requires some overhead in all OO language that I'm aware of, so if you can get away with streaming the data through the same instance, you're probably better off.","Q_Score":2,"Tags":"python,oop,data-analysis","A_Id":372524,"CreationDate":"2008-12-16T20:04:00.000","Title":"What is the object oriented programming computing overhead cost?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a large set of data (a data cube of 250,000 X 1,000 doubles, about a 4 gig file) and I want to manipulate it using a previous set of OOP classes I have written in Python. Currently the data set is already so large that to read into my machine memory I have to at least split it in half so computing overhead is a concern. My OOP classes create new objects (in this case I will need 250,000 new objects, each object is an array of 1,000 doubles) to handle the data. What is the overhead in terms of memory and computing required in creating objects for a generic OOP language? In python? What about in C++?\nYes, I realize I could make a new class that is an array. But 1) I already have these classes finished and 2) I put each object that I create back into an array for access later anyways. The question is pedagogical \n*update: I want to be efficient with time, my time and the computers. I don't want to rewrite a program I already have if I don't have to and spending time optimizing the code wastes my time, I don't care that much if I waste the computers time. I actually do have a 64bit machine with 4Gig ram. The data is an image and I need to do several filters on each pixel.*","AnswerCount":14,"Available Count":11,"Score":0.0,"is_accepted":false,"ViewCount":3461,"Q_Id":372511,"Users Score":0,"Answer":"I don't think the question is overhead coming from OO.\nIf we accept C++ as an OO language and remember that the C++ compiler is a preprocessor to C (at least it used to be, when I used C++), anything done in C++ is really done in C. C has very little overhead. So it would depend on the libraries.\nI think any overhead would come from interpretation, managed execution or memory management. For those that have the tools and the know-how, it would be very easy to find out which is most efficient, C++ or Python.\nI can't see where C++ would add much avoidable overhead. I don't know much about Python.","Q_Score":2,"Tags":"python,oop,data-analysis","A_Id":372658,"CreationDate":"2008-12-16T20:04:00.000","Title":"What is the object oriented programming computing overhead cost?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a large set of data (a data cube of 250,000 X 1,000 doubles, about a 4 gig file) and I want to manipulate it using a previous set of OOP classes I have written in Python. Currently the data set is already so large that to read into my machine memory I have to at least split it in half so computing overhead is a concern. My OOP classes create new objects (in this case I will need 250,000 new objects, each object is an array of 1,000 doubles) to handle the data. What is the overhead in terms of memory and computing required in creating objects for a generic OOP language? In python? What about in C++?\nYes, I realize I could make a new class that is an array. But 1) I already have these classes finished and 2) I put each object that I create back into an array for access later anyways. The question is pedagogical \n*update: I want to be efficient with time, my time and the computers. I don't want to rewrite a program I already have if I don't have to and spending time optimizing the code wastes my time, I don't care that much if I waste the computers time. I actually do have a 64bit machine with 4Gig ram. The data is an image and I need to do several filters on each pixel.*","AnswerCount":14,"Available Count":11,"Score":0.0,"is_accepted":false,"ViewCount":3461,"Q_Id":372511,"Users Score":0,"Answer":"Like the other posters have stated. I do not believe Objects are going to lend a significant amount of overhead to your process. It will need to store a pointer to the object but the rest of the 'doubles' will be taking 99% of your program's memory.\nCan you partition this data into much smaller subsets? What is the task that you are trying to accomplish? I would be interested in seeing what you need all the data in memory for. Perhaps you can just serialize it, or use something like lazy evaluation in haskell.\nPlease post a follow up so we can understand your problem domain better.","Q_Score":2,"Tags":"python,oop,data-analysis","A_Id":372641,"CreationDate":"2008-12-16T20:04:00.000","Title":"What is the object oriented programming computing overhead cost?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a large set of data (a data cube of 250,000 X 1,000 doubles, about a 4 gig file) and I want to manipulate it using a previous set of OOP classes I have written in Python. Currently the data set is already so large that to read into my machine memory I have to at least split it in half so computing overhead is a concern. My OOP classes create new objects (in this case I will need 250,000 new objects, each object is an array of 1,000 doubles) to handle the data. What is the overhead in terms of memory and computing required in creating objects for a generic OOP language? In python? What about in C++?\nYes, I realize I could make a new class that is an array. But 1) I already have these classes finished and 2) I put each object that I create back into an array for access later anyways. The question is pedagogical \n*update: I want to be efficient with time, my time and the computers. I don't want to rewrite a program I already have if I don't have to and spending time optimizing the code wastes my time, I don't care that much if I waste the computers time. I actually do have a 64bit machine with 4Gig ram. The data is an image and I need to do several filters on each pixel.*","AnswerCount":14,"Available Count":11,"Score":0.0428309231,"is_accepted":false,"ViewCount":3461,"Q_Id":372511,"Users Score":3,"Answer":"You'd have similar issues with procedural\/functional programming languages. How do you store that much data in memory? A struct or array wouldn't work either. \nYou need to take special steps to manage this scale of data.\nBTW: I wouldn't use this as a reason to pick either an OO language or not.","Q_Score":2,"Tags":"python,oop,data-analysis","A_Id":372566,"CreationDate":"2008-12-16T20:04:00.000","Title":"What is the object oriented programming computing overhead cost?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a large set of data (a data cube of 250,000 X 1,000 doubles, about a 4 gig file) and I want to manipulate it using a previous set of OOP classes I have written in Python. Currently the data set is already so large that to read into my machine memory I have to at least split it in half so computing overhead is a concern. My OOP classes create new objects (in this case I will need 250,000 new objects, each object is an array of 1,000 doubles) to handle the data. What is the overhead in terms of memory and computing required in creating objects for a generic OOP language? In python? What about in C++?\nYes, I realize I could make a new class that is an array. But 1) I already have these classes finished and 2) I put each object that I create back into an array for access later anyways. The question is pedagogical \n*update: I want to be efficient with time, my time and the computers. I don't want to rewrite a program I already have if I don't have to and spending time optimizing the code wastes my time, I don't care that much if I waste the computers time. I actually do have a 64bit machine with 4Gig ram. The data is an image and I need to do several filters on each pixel.*","AnswerCount":14,"Available Count":11,"Score":0.0,"is_accepted":false,"ViewCount":3461,"Q_Id":372511,"Users Score":0,"Answer":"The \"overhead\" depends largely on the platform and the implementation you chose.\nNow if you have a memory problem reading millions of data from a multiple Gb file, you're having an algorithm problem where the memory consumption of objects is definitely not the biggest concern, the concern yould be more about how you do fetch, process and store the data.","Q_Score":2,"Tags":"python,oop,data-analysis","A_Id":372595,"CreationDate":"2008-12-16T20:04:00.000","Title":"What is the object oriented programming computing overhead cost?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a large set of data (a data cube of 250,000 X 1,000 doubles, about a 4 gig file) and I want to manipulate it using a previous set of OOP classes I have written in Python. Currently the data set is already so large that to read into my machine memory I have to at least split it in half so computing overhead is a concern. My OOP classes create new objects (in this case I will need 250,000 new objects, each object is an array of 1,000 doubles) to handle the data. What is the overhead in terms of memory and computing required in creating objects for a generic OOP language? In python? What about in C++?\nYes, I realize I could make a new class that is an array. But 1) I already have these classes finished and 2) I put each object that I create back into an array for access later anyways. The question is pedagogical \n*update: I want to be efficient with time, my time and the computers. I don't want to rewrite a program I already have if I don't have to and spending time optimizing the code wastes my time, I don't care that much if I waste the computers time. I actually do have a 64bit machine with 4Gig ram. The data is an image and I need to do several filters on each pixel.*","AnswerCount":14,"Available Count":11,"Score":0.0,"is_accepted":false,"ViewCount":3461,"Q_Id":372511,"Users Score":0,"Answer":"compared to the size of your data set, the overhead of 250K objects is negligible\ni think you're on the wrong path; don't blame objects for that ;-)","Q_Score":2,"Tags":"python,oop,data-analysis","A_Id":372706,"CreationDate":"2008-12-16T20:04:00.000","Title":"What is the object oriented programming computing overhead cost?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm using python and I need to map locations like \"Bloomington, IN\" to GPS coordinates so I can measure distances between them.\nWhat Geocoding libraries\/APIs do you recommend? Solutions in other languages are also welcome.","AnswerCount":9,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":13754,"Q_Id":373383,"Users Score":0,"Answer":"You can have better look in Geopy module.And it is worth enough to use as it contains Google map, yahoo map geocoders with which you can implement geocodings.","Q_Score":23,"Tags":"python,api,rest,geocoding","A_Id":2229732,"CreationDate":"2008-12-17T01:19:00.000","Title":"Geocoding libraries","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},{"Question":"Beyond offering an API for my website, I'd like to offer users the ability to write simple scripts that would run on my servers . The scripts would have access to objects owned by the user and be able to manipulate, modify, and otherwise process their data.\nI'd like to be able to limit resources taken by these scripts at a fine level (eg. max execution time should be 100ms). I'd also like to ensure a secure sandbox such that each user will have access to only a limited set of data and resources, and be prevented from accessing disk, other people's data, etc.\nGenerally the scripts will be very simple (eg. create the sum or average of the values that match certain criteria), and they'll often be used in templates (eg. fill in the value of this cell or html element with the average or sum).\nIdeally I'd like to use a sandboxed subset of a well know, commonly available programming language so it's easy for users to pick up. The backend is written in Python, so a Python based language could have benefits, but I'm open to other languages and technologies. Javascript is also attractive due to its simple nature and common availability.\nThe languages should support creation of DSLs and libraries. \nThe target audience is a general user base for a web based application, not necessarily very technical. In other words, it's not targeted at a base with particular knowledge of any particular programming language. My expectation is a subset of users will create scripts that will be used by the larger majority. \nAny ideas or recommendations for the language and technology? Any examples of others trying this and the successes and failures they encountered?","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":421,"Q_Id":373406,"Users Score":2,"Answer":"I use Lua for this, but it's directed at a Lua capable community. So my answer would be who are your users?\nIf your users are internal, like my case, and proficient with Python use Python. However if this is something for the world wide web, I'd probably choose javascript, because its the lingua franca, (every developer knows it, and its easy to pickup). As for an Engine... well V8 would be nice, but its not 100% thread safe, in that you can't run several engine within the same process in a lock free manner, as you can with SpiderMonkey. So You might want to use that. Also since javascript is sandboxed by default you won't have to worry about implementing much on your side.","Q_Score":7,"Tags":"javascript,python,sandbox","A_Id":373415,"CreationDate":"2008-12-17T01:38:00.000","Title":"Secure, sandboxable user exposed programming language \/ 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},{"Question":"In Python properties are used instead of the Java-style getters, setters. So one rarely sees get... or set.. methods in the public interfaces of classes.\nBut in cases were a property is not appropriate one might still end up with methods that behave like getters or setters. Now my questions: Should these method names start with get_ \/ set_? Or is this unpythonic vebosity since it is often obvious what is meant (and one can still use the docstring to clarify non-obvious situations)?\nThis might be a matter of personal taste, but I would be interested in what the majority thinks about this? What would you prefer as an API user?\nExample: Say we have an object representing multiple cities. One might have a method get_city_by_postalcode(postalcode) or one could use the shorter name city_by_postalcode. I tend towards the later.","AnswerCount":5,"Available Count":3,"Score":0.0399786803,"is_accepted":false,"ViewCount":4305,"Q_Id":374763,"Users Score":1,"Answer":"I've seen it done both ways. Coming from an Objective-C background, I usually do foo()\/set_foo() if I can't use a property (although I try to use properties whenever possible). It doesn't really matter that much, though, as long as you're consistent.\n(Of course, in your example, I wouldn't call the method get_city_by_postalcode() at all; I'd probably go with translate_postalcode or something similar that uses a better action verb in the name.)","Q_Score":18,"Tags":"python,coding-style","A_Id":374860,"CreationDate":"2008-12-17T14:49:00.000","Title":"Should I use get_\/set_ prefixes in Python method names?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"In Python properties are used instead of the Java-style getters, setters. So one rarely sees get... or set.. methods in the public interfaces of classes.\nBut in cases were a property is not appropriate one might still end up with methods that behave like getters or setters. Now my questions: Should these method names start with get_ \/ set_? Or is this unpythonic vebosity since it is often obvious what is meant (and one can still use the docstring to clarify non-obvious situations)?\nThis might be a matter of personal taste, but I would be interested in what the majority thinks about this? What would you prefer as an API user?\nExample: Say we have an object representing multiple cities. One might have a method get_city_by_postalcode(postalcode) or one could use the shorter name city_by_postalcode. I tend towards the later.","AnswerCount":5,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":4305,"Q_Id":374763,"Users Score":0,"Answer":"If I have to use a getter\/setter, I like it this way:\nSuppose you have a variable self._x. Then x() would return the value of self._x, and setX(x) would set the value of self._x","Q_Score":18,"Tags":"python,coding-style","A_Id":375661,"CreationDate":"2008-12-17T14:49:00.000","Title":"Should I use get_\/set_ prefixes in Python method names?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"In Python properties are used instead of the Java-style getters, setters. So one rarely sees get... or set.. methods in the public interfaces of classes.\nBut in cases were a property is not appropriate one might still end up with methods that behave like getters or setters. Now my questions: Should these method names start with get_ \/ set_? Or is this unpythonic vebosity since it is often obvious what is meant (and one can still use the docstring to clarify non-obvious situations)?\nThis might be a matter of personal taste, but I would be interested in what the majority thinks about this? What would you prefer as an API user?\nExample: Say we have an object representing multiple cities. One might have a method get_city_by_postalcode(postalcode) or one could use the shorter name city_by_postalcode. I tend towards the later.","AnswerCount":5,"Available Count":3,"Score":1.2,"is_accepted":true,"ViewCount":4305,"Q_Id":374763,"Users Score":4,"Answer":"I think shorter is better, so I tend to prefer the later. But what's important is to consistent with your project: don't mix the two methods. If you jump into someone else's project, keep what the other developers chose initially.","Q_Score":18,"Tags":"python,coding-style","A_Id":374856,"CreationDate":"2008-12-17T14:49:00.000","Title":"Should I use get_\/set_ prefixes in Python method names?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":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},{"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},{"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},{"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},{"Question":"In Python, is there a portable and simple way to test if an executable program exists?\nBy simple I mean something like the which command which would be just perfect. I don't want to search PATH manually or something involving trying to execute it with Popen & al and see if it fails (that's what I'm doing now, but imagine it's launchmissiles)","AnswerCount":15,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":167325,"Q_Id":377017,"Users Score":0,"Answer":"So basically you want to find a file in mounted filesystem (not necessarily in PATH directories only) and check if it is executable. This translates to following plan: \n\nenumerate all files in locally mounted filesystems\nmatch results with name pattern\nfor each file found check if it is executable\n\nI'd say, doing this in a portable way will require lots of computing power and time. Is it really what you need?","Q_Score":337,"Tags":"python,path","A_Id":377590,"CreationDate":"2008-12-18T05:55:00.000","Title":"Test if executable exists 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},{"Question":"I have some old python code that uses the pywin32 extensions. Starting out with .net, I would like to port it to ironpython.\nThe old python code uses things like pythoncom.com_error, pywintypes.Time and interfaces a COM module that implements the IDispatch interface. \nDoes the .net libraries of ironpython have all I need for communicating with the COM module?\nSpecifically, does it have something to replace com_error and Time?\nThanks.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":887,"Q_Id":384761,"Users Score":3,"Answer":"Answering my own post.. :-)\n\ncom_error may be replaced by System.Runtime.InteropServices.COMException\nThe pywintypes.Time may be replaced by System.DateTime, (DATE in IDispatch interface)\n\nStill, if anybody knows about any good documentation on IronPython, COM interoperability and moving from pywin32 to .net, please respond..","Q_Score":1,"Tags":".net,com,ironpython","A_Id":385013,"CreationDate":"2008-12-21T18:22:00.000","Title":"Does ironpython have libraries that replace the pywin32 extensions?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":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},{"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},{"Question":"Has anyone ever had code in Python, that turned out not to perform fast enough?\nI mean, you were forced to choose another language because of it?\nWe are investigating using Python for a couple of larger projects, and my feeling is that in most cases, Python is plenty fast enough for most scenarios (compared to say, Java) because it relies on optimized C routines.\nI wanted to see if people had instances where they started out in Python, but ended up having to go with something else because of performance.\nThanks.","AnswerCount":19,"Available Count":14,"Score":0.0210495219,"is_accepted":false,"ViewCount":8929,"Q_Id":386655,"Users Score":2,"Answer":"I used to prototype lots of things in python for doing things like log processing. When they didn't run fast enough, I'd rewrite them in ocaml.\nIn many cases, the python was fine and I was happy with it. In some cases, as it started approaching 23 hours to do a days' logs, I'd get to rewriting. :)\nI would like to point out that even in those cases, I may have been better off just profiling the python code and finding a happier python implementation.","Q_Score":47,"Tags":"python,performance,optimization,rewrite","A_Id":386689,"CreationDate":"2008-12-22T16:23:00.000","Title":"Python Performance - have you ever had to rewrite in 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":0},{"Question":"Has anyone ever had code in Python, that turned out not to perform fast enough?\nI mean, you were forced to choose another language because of it?\nWe are investigating using Python for a couple of larger projects, and my feeling is that in most cases, Python is plenty fast enough for most scenarios (compared to say, Java) because it relies on optimized C routines.\nI wanted to see if people had instances where they started out in Python, but ended up having to go with something else because of performance.\nThanks.","AnswerCount":19,"Available Count":14,"Score":1.0,"is_accepted":false,"ViewCount":8929,"Q_Id":386655,"Users Score":19,"Answer":"This is a much more difficult question to answer than people are willing to admit. \nFor example, it may be that I am able to write a program that performs better in Python than it does in C. The fallacious conclusion from that statement is \"Python is therefore faster than C\". In reality, it may be because I have much more recent experience in Python and its best practices and standard libraries. \nIn fact no one can really answer your question unless they are certain that they can create an optimal solution in both languages, which is unlikely. In other words \"My C solution was faster than my Python solution\" is not the same as \"C is faster than Python\"\nI'm willing to bet that Guido Van Rossum could have written Python solutions for adam and Dustin's problems that performed quite well.\nMy rule of thumb is that unless you are writing the sort of application that requires you to count clock cycles, you can probably achieve acceptable performance in Python.","Q_Score":47,"Tags":"python,performance,optimization,rewrite","A_Id":386702,"CreationDate":"2008-12-22T16:23:00.000","Title":"Python Performance - have you ever had to rewrite in 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":0},{"Question":"Has anyone ever had code in Python, that turned out not to perform fast enough?\nI mean, you were forced to choose another language because of it?\nWe are investigating using Python for a couple of larger projects, and my feeling is that in most cases, Python is plenty fast enough for most scenarios (compared to say, Java) because it relies on optimized C routines.\nI wanted to see if people had instances where they started out in Python, but ended up having to go with something else because of performance.\nThanks.","AnswerCount":19,"Available Count":14,"Score":0.010525927,"is_accepted":false,"ViewCount":8929,"Q_Id":386655,"Users Score":1,"Answer":"A month ago i had this little program written in Python (for work) that analyzes logs.\nWhen then number of log files grew, the program begun to be very slow and i thought i could rewrite it in Java.\nI was very interesting. It took a whole day to migrate the same algorithm from Python to Java. At the end of the day, a few benchmark trials showed me clearly that the Java program was some 20% \/ 25% slower than its Python counterpart. It was a surprise to me.\nWriting for the second time the algorithm also showed me that some optimization was possible. So in two hours i completely rewrote the whole thing in Python and it was some 40% faster than the original Python implementation (hence orders of time faster than the Java version I had).\nSo:\n\nPython is a slow language but still it can be faster, for certain tasks, that other supposedly faster languages\nIf you have to spend time writing something in a language whose execution is faster but whose development time is slower (most languages), consider using the same time to analyze the problem, search for libraries, profile and then write better Python code.","Q_Score":47,"Tags":"python,performance,optimization,rewrite","A_Id":393185,"CreationDate":"2008-12-22T16:23:00.000","Title":"Python Performance - have you ever had to rewrite in 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":0},{"Question":"Has anyone ever had code in Python, that turned out not to perform fast enough?\nI mean, you were forced to choose another language because of it?\nWe are investigating using Python for a couple of larger projects, and my feeling is that in most cases, Python is plenty fast enough for most scenarios (compared to say, Java) because it relies on optimized C routines.\nI wanted to see if people had instances where they started out in Python, but ended up having to go with something else because of performance.\nThanks.","AnswerCount":19,"Available Count":14,"Score":0.0210495219,"is_accepted":false,"ViewCount":8929,"Q_Id":386655,"Users Score":2,"Answer":"You can always write parts of your application in Python. Not every component is equally important for performance. Python integrates easily with C++ natively, or with Java via Jython, or with .NET via IronPython.\nBy the way, IronPython is more efficient than the C implementation of Python on some benchmarks.","Q_Score":47,"Tags":"python,performance,optimization,rewrite","A_Id":386706,"CreationDate":"2008-12-22T16:23:00.000","Title":"Python Performance - have you ever had to rewrite in 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":0},{"Question":"Has anyone ever had code in Python, that turned out not to perform fast enough?\nI mean, you were forced to choose another language because of it?\nWe are investigating using Python for a couple of larger projects, and my feeling is that in most cases, Python is plenty fast enough for most scenarios (compared to say, Java) because it relies on optimized C routines.\nI wanted to see if people had instances where they started out in Python, but ended up having to go with something else because of performance.\nThanks.","AnswerCount":19,"Available Count":14,"Score":1.0,"is_accepted":false,"ViewCount":8929,"Q_Id":386655,"Users Score":7,"Answer":"Not so far. I work for a company that has a molecular simulation engine and a bunch of programs written in python for processing the large multi-gigabyte datasets. All of our analysis software is now being written in Python because of the huge advantages in development flexibility and time. \nIf something is not fast enough we profile it with cProfile and find the bottlenecks. Usually there are one or two functions which take up 80 or 90% of the runtime. We then take those functions and rewrite them in C, something which Python makes dead easy with its C API. In many cases this results in an order of magnitude or more speedup. Problem gone. We then go on our merry way continuing to write everything else in Python. Rinse and repeat...\nFor entire modules or classes we tend to use Boost.python, it can be a bit of a bear but ultimately works well. If it's just a function or two, we sometimes inline it with scipy.weave if the project is already using scipy.","Q_Score":47,"Tags":"python,performance,optimization,rewrite","A_Id":386999,"CreationDate":"2008-12-22T16:23:00.000","Title":"Python Performance - have you ever had to rewrite in 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":0},{"Question":"Has anyone ever had code in Python, that turned out not to perform fast enough?\nI mean, you were forced to choose another language because of it?\nWe are investigating using Python for a couple of larger projects, and my feeling is that in most cases, Python is plenty fast enough for most scenarios (compared to say, Java) because it relies on optimized C routines.\nI wanted to see if people had instances where they started out in Python, but ended up having to go with something else because of performance.\nThanks.","AnswerCount":19,"Available Count":14,"Score":1.0,"is_accepted":false,"ViewCount":8929,"Q_Id":386655,"Users Score":7,"Answer":"While at uni we were writing a computer vision system for analysing human behaviour based on video clips. We used python because of the excellent PIL, to speed up development and let us get easy access to the image frames we'd extracted from the video for converting to arrays etc.\nFor 90% of what we wanted it was fine and since the images were reasonably low resolution the speed wasn't bad. However, a few of the processes required some complex pixel-by-pixel computations as well as convolutions which are notoriously slow. For these particular areas we re-wrote the innermost parts of the loops in C and just updated the old Python functions to call the C functions.\nThis gave us the best of both worlds. We had the ease of data access that python provides, which enabled to develop fast, and then the straight-line speed of C for the most intensive computations.","Q_Score":47,"Tags":"python,performance,optimization,rewrite","A_Id":386770,"CreationDate":"2008-12-22T16:23:00.000","Title":"Python Performance - have you ever had to rewrite in 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":0},{"Question":"Has anyone ever had code in Python, that turned out not to perform fast enough?\nI mean, you were forced to choose another language because of it?\nWe are investigating using Python for a couple of larger projects, and my feeling is that in most cases, Python is plenty fast enough for most scenarios (compared to say, Java) because it relies on optimized C routines.\nI wanted to see if people had instances where they started out in Python, but ended up having to go with something else because of performance.\nThanks.","AnswerCount":19,"Available Count":14,"Score":0.0210495219,"is_accepted":false,"ViewCount":8929,"Q_Id":386655,"Users Score":2,"Answer":"I've been working for a while now, developing an application that operate on large structured data, stored in several-gigabytes-thick-database and well, Python is good enough for that. The application has GUI client with a multitude of controls (lists, trees, notebooks, virtual lists and more), and a console server. \nWe had some performance issues, but those were mostly related more to poor algorithm design or database engine limitations (we use Oracle, MS-SQL, MySQL and had short romance with BerkeleyDB used for speed optimizations) than to Python itself. Once you know how to use standard libraries (written in C) properly you can make your code really quick. \nAs others say - any computation intensive algorithm, code that depends on bit-stuffing, some memory constrained computation - can be done in raw C\/C++ for CPU\/memory saving (or any other tricks), but the whole user interaction, logging, database handling, error handling - all that makes the application actually run, can be written in Python and it will maintain responsiveness and decent overall performance.","Q_Score":47,"Tags":"python,performance,optimization,rewrite","A_Id":386752,"CreationDate":"2008-12-22T16:23:00.000","Title":"Python Performance - have you ever had to rewrite in 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":0},{"Question":"Has anyone ever had code in Python, that turned out not to perform fast enough?\nI mean, you were forced to choose another language because of it?\nWe are investigating using Python for a couple of larger projects, and my feeling is that in most cases, Python is plenty fast enough for most scenarios (compared to say, Java) because it relies on optimized C routines.\nI wanted to see if people had instances where they started out in Python, but ended up having to go with something else because of performance.\nThanks.","AnswerCount":19,"Available Count":14,"Score":0.0,"is_accepted":false,"ViewCount":8929,"Q_Id":386655,"Users Score":0,"Answer":"I generally don't rewrite to C before I :\n\nprofile\nrewrite with bette algorithms (generally this is enough)\nrewrite python code with low level performance in mind (but never to the point of having non pythonic \/ non readable code)\nspend some time rechecking a library cannot do this (first in stdlib, or an external lib)\ntried psyco \/ other implementations (rarely achieves to get a REAL speed boost in my case)\n\nThen sometimes I created a shared library to do heavy matrix computation code (which couldn't be done with numarray) and called it with ctypes : \n\nsimple to write\/build\/test a .so \/ dll in pure C, \nsimple to encapsulate the C to python function (ie. you don't if you use basic datatypes since ctypes does all the work of calling the right arguments for you) and certainly fast enough then .","Q_Score":47,"Tags":"python,performance,optimization,rewrite","A_Id":1900043,"CreationDate":"2008-12-22T16:23:00.000","Title":"Python Performance - have you ever had to rewrite in 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":0},{"Question":"Has anyone ever had code in Python, that turned out not to perform fast enough?\nI mean, you were forced to choose another language because of it?\nWe are investigating using Python for a couple of larger projects, and my feeling is that in most cases, Python is plenty fast enough for most scenarios (compared to say, Java) because it relies on optimized C routines.\nI wanted to see if people had instances where they started out in Python, but ended up having to go with something else because of performance.\nThanks.","AnswerCount":19,"Available Count":14,"Score":0.0210495219,"is_accepted":false,"ViewCount":8929,"Q_Id":386655,"Users Score":2,"Answer":"Yes, twice:\n\nAn audio DSP application I wound up completely rewriting in C++ because I couldn't get appropriate performance in Python; I don't consider the Python implementation wasted because it let me prototype the concept very easily, and the C++ port went smoothly because I had a working reference implementaton.\nA procedural graphic rendering project, where generating large 2D texture maps in Python was taking a long time; I wrote a C++ DLL and used ctypes\/windll to use it from Python.","Q_Score":47,"Tags":"python,performance,optimization,rewrite","A_Id":3122149,"CreationDate":"2008-12-22T16:23:00.000","Title":"Python Performance - have you ever had to rewrite in 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":0},{"Question":"Has anyone ever had code in Python, that turned out not to perform fast enough?\nI mean, you were forced to choose another language because of it?\nWe are investigating using Python for a couple of larger projects, and my feeling is that in most cases, Python is plenty fast enough for most scenarios (compared to say, Java) because it relies on optimized C routines.\nI wanted to see if people had instances where they started out in Python, but ended up having to go with something else because of performance.\nThanks.","AnswerCount":19,"Available Count":14,"Score":0.010525927,"is_accepted":false,"ViewCount":8929,"Q_Id":386655,"Users Score":1,"Answer":"No, I've never had to rewrite. In fact, I started using Python in Maya 8.5. Before Maya 8, the only scripting language available was the built in MEL (Maya Expression Language). Python is actually faster than the built in language that it wraps.\nPython's ability to work with complex data types also made it faster because MEL can only store single dimensional arrays (and no pointers). This would require multi-dimensional arrays be faked by either using multiple parallel arrays, or by using slow string concatenation.","Q_Score":47,"Tags":"python,performance,optimization,rewrite","A_Id":387988,"CreationDate":"2008-12-22T16:23:00.000","Title":"Python Performance - have you ever had to rewrite in 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":0},{"Question":"Has anyone ever had code in Python, that turned out not to perform fast enough?\nI mean, you were forced to choose another language because of it?\nWe are investigating using Python for a couple of larger projects, and my feeling is that in most cases, Python is plenty fast enough for most scenarios (compared to say, Java) because it relies on optimized C routines.\nI wanted to see if people had instances where they started out in Python, but ended up having to go with something else because of performance.\nThanks.","AnswerCount":19,"Available Count":14,"Score":0.0210495219,"is_accepted":false,"ViewCount":8929,"Q_Id":386655,"Users Score":2,"Answer":"I am developing in python for several years now. Recently i had to list all files in a directory and build a struct with filename, size, attributes and modification date. I did this with os.listdir and os.stat. The code was quite fast, but the more entries in the directories, the slower my code became comapred to other filemanagers listing the same directory, so i rewrote the code using SWIG\/C++ and was really surprised how much faster the code was.","Q_Score":47,"Tags":"python,performance,optimization,rewrite","A_Id":501942,"CreationDate":"2008-12-22T16:23:00.000","Title":"Python Performance - have you ever had to rewrite in 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":0},{"Question":"Has anyone ever had code in Python, that turned out not to perform fast enough?\nI mean, you were forced to choose another language because of it?\nWe are investigating using Python for a couple of larger projects, and my feeling is that in most cases, Python is plenty fast enough for most scenarios (compared to say, Java) because it relies on optimized C routines.\nI wanted to see if people had instances where they started out in Python, but ended up having to go with something else because of performance.\nThanks.","AnswerCount":19,"Available Count":14,"Score":0.010525927,"is_accepted":false,"ViewCount":8929,"Q_Id":386655,"Users Score":1,"Answer":"I once had to write a pseudo-random number generator for a simulator. I wrote it in Python first, but Python proved to be way too slow; I ended up rewriting it in C, and even that was slow, but not nearly as slow as Python.\nLuckily, it's fairly easy to bridge Python and C, so I was able to write the PRNG as a C module and still write the rest of the simulator in Python.","Q_Score":47,"Tags":"python,performance,optimization,rewrite","A_Id":393200,"CreationDate":"2008-12-22T16:23:00.000","Title":"Python Performance - have you ever had to rewrite in 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":0},{"Question":"Has anyone ever had code in Python, that turned out not to perform fast enough?\nI mean, you were forced to choose another language because of it?\nWe are investigating using Python for a couple of larger projects, and my feeling is that in most cases, Python is plenty fast enough for most scenarios (compared to say, Java) because it relies on optimized C routines.\nI wanted to see if people had instances where they started out in Python, but ended up having to go with something else because of performance.\nThanks.","AnswerCount":19,"Available Count":14,"Score":0.0420803986,"is_accepted":false,"ViewCount":8929,"Q_Id":386655,"Users Score":4,"Answer":"This kind of question is likely to start a religious war among language people so let me answer it a little bit differently.\nFor most cases in today's computing environments your choice of programming language should be based on what you can program efficiently, program well and what makes you happy not the performance characteristics of the language. Also, optimization should generally be the last concern when programming any system. \nThe typical python way to do things is to start out writing your program in python and then if you notice the performance suffering profile the application and attempt to optimize the hot-spots in python first. If optimizing the python code still isn't good enough the areas of the code that are weighing you down should be re-written as a python module in C. If even after all of that your program isn't fast enough you can either change languages or look at scaling up in hardware or concurrency.\nThat's the long answer, to answer your question directly; no, python (sometimes with C extensions) has been fast enough for everything I need it to do. The only time I really dip into C is to get access to stuff that donesn't have python bindings.\nEdit: My background is a python programmer at a large .com where we use python for everything from the front-end of our websites all the way down to all the back-office systems. Python is very much an enterprise-grade language.","Q_Score":47,"Tags":"python,performance,optimization,rewrite","A_Id":390700,"CreationDate":"2008-12-22T16:23:00.000","Title":"Python Performance - have you ever had to rewrite in 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":0},{"Question":"Has anyone ever had code in Python, that turned out not to perform fast enough?\nI mean, you were forced to choose another language because of it?\nWe are investigating using Python for a couple of larger projects, and my feeling is that in most cases, Python is plenty fast enough for most scenarios (compared to say, Java) because it relies on optimized C routines.\nI wanted to see if people had instances where they started out in Python, but ended up having to go with something else because of performance.\nThanks.","AnswerCount":19,"Available Count":14,"Score":0.0525830348,"is_accepted":false,"ViewCount":8929,"Q_Id":386655,"Users Score":5,"Answer":"Whenever I find a Python bottleneck, I rewrite that code in C as a Python module.\nFor example, I have some hardware that sends image pixels as 4-byte 0RGB. Converting 8M from 0RGB to RGB in Python takes too long so I rewrote it as a Python module.\nWriting Python (or other higher level languages) is much faster than writing in C so I use Python until I can't.","Q_Score":47,"Tags":"python,performance,optimization,rewrite","A_Id":386909,"CreationDate":"2008-12-22T16:23:00.000","Title":"Python Performance - have you ever had to rewrite in 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":0},{"Question":"So far I've found it impossible to produce usable tracebacks when Mako templates aren't coded correctly.\nIs there any way to debug templates besides iterating for every line of code?","AnswerCount":6,"Available Count":1,"Score":0.0333209931,"is_accepted":false,"ViewCount":10962,"Q_Id":390409,"Users Score":1,"Answer":"I break them down into pieces, and then reassemble the pieces when I've found the problem.\nNot good, but it's really hard to tell what went wrong in a big, complex template.","Q_Score":41,"Tags":"python,debugging,templates,jinja2,mako","A_Id":390603,"CreationDate":"2008-12-23T23:43:00.000","Title":"How do you debug Mako templates?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I have a friend who likes to use metaclasses, and regularly offers them as a solution.\nI am of the mind that you almost never need to use metaclasses. Why? because I figure if you are doing something like that to a class, you should probably be doing it to an object. And a small redesign\/refactor is in order.\nBeing able to use metaclasses has caused a lot of people in a lot of places to use classes as some kind of second rate object, which just seems disastrous to me. Is programming to be replaced by meta-programming? The addition of class decorators has unfortunately made it even more acceptable.\nSo please, I am desperate to know your valid (concrete) use-cases for metaclasses in Python. Or to be enlightened as to why mutating classes is better than mutating objects, sometimes.\nI will start:\n\nSometimes when using a third-party\n library it is useful to be able to\n mutate the class in a certain way.\n\n(This is the only case I can think of, and it's not concrete)","AnswerCount":21,"Available Count":4,"Score":1.0,"is_accepted":false,"ViewCount":32950,"Q_Id":392160,"Users Score":20,"Answer":"Let's start with Tim Peter's classic quote:\n\nMetaclasses are deeper magic than 99%\n of users should ever worry about. If\n you wonder whether you need them, you\n don't (the people who actually need\n them know with certainty that they\n need them, and don't need an\n explanation about why). Tim Peters\n (c.l.p post 2002-12-22)\n\nHaving said that, I have (periodically) run across true uses of metaclasses. The one that comes to mind is in Django where all of your models inherit from models.Model. models.Model, in turn, does some serious magic to wrap your DB models with Django's ORM goodness. That magic happens by way of metaclasses. It creates all manner of exception classes, manager classes, etc. etc.\nSee django\/db\/models\/base.py, class ModelBase() for the beginning of the story.","Q_Score":148,"Tags":"python,metaclass","A_Id":392442,"CreationDate":"2008-12-24T20:13:00.000","Title":"What are some (concrete) use-cases for metaclasses?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a friend who likes to use metaclasses, and regularly offers them as a solution.\nI am of the mind that you almost never need to use metaclasses. Why? because I figure if you are doing something like that to a class, you should probably be doing it to an object. And a small redesign\/refactor is in order.\nBeing able to use metaclasses has caused a lot of people in a lot of places to use classes as some kind of second rate object, which just seems disastrous to me. Is programming to be replaced by meta-programming? The addition of class decorators has unfortunately made it even more acceptable.\nSo please, I am desperate to know your valid (concrete) use-cases for metaclasses in Python. Or to be enlightened as to why mutating classes is better than mutating objects, sometimes.\nI will start:\n\nSometimes when using a third-party\n library it is useful to be able to\n mutate the class in a certain way.\n\n(This is the only case I can think of, and it's not concrete)","AnswerCount":21,"Available Count":4,"Score":1.0,"is_accepted":false,"ViewCount":32950,"Q_Id":392160,"Users Score":8,"Answer":"A reasonable pattern of metaclass use is doing something once when a class is defined rather than repeatedly whenever the same class is instantiated.\nWhen multiple classes share the same special behaviour, repeating __metaclass__=X is obviously better than repeating the special purpose code and\/or introducing ad-hoc shared superclasses.\nBut even with only one special class and no foreseeable extension, __new__ and __init__ of a metaclass are a cleaner way to initialize class variables or other global data than intermixing special-purpose code and normal def and class statements in the class definition body.","Q_Score":148,"Tags":"python,metaclass","A_Id":7057480,"CreationDate":"2008-12-24T20:13:00.000","Title":"What are some (concrete) use-cases for metaclasses?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a friend who likes to use metaclasses, and regularly offers them as a solution.\nI am of the mind that you almost never need to use metaclasses. Why? because I figure if you are doing something like that to a class, you should probably be doing it to an object. And a small redesign\/refactor is in order.\nBeing able to use metaclasses has caused a lot of people in a lot of places to use classes as some kind of second rate object, which just seems disastrous to me. Is programming to be replaced by meta-programming? The addition of class decorators has unfortunately made it even more acceptable.\nSo please, I am desperate to know your valid (concrete) use-cases for metaclasses in Python. Or to be enlightened as to why mutating classes is better than mutating objects, sometimes.\nI will start:\n\nSometimes when using a third-party\n library it is useful to be able to\n mutate the class in a certain way.\n\n(This is the only case I can think of, and it's not concrete)","AnswerCount":21,"Available Count":4,"Score":0.047583087,"is_accepted":false,"ViewCount":32950,"Q_Id":392160,"Users Score":5,"Answer":"The only legitimate use-case of a metaclass is to keep other nosy developers from touching your code. Once a nosy developer masters metaclasses and starts poking around with yours, throw in another level or two to keep them out. If that doesn't work, start using type.__new__ or perhaps some scheme using a recursive metaclass.\n(written tongue in cheek, but I've seen this kind of obfuscation done. Django is a perfect example)","Q_Score":148,"Tags":"python,metaclass","A_Id":5330521,"CreationDate":"2008-12-24T20:13:00.000","Title":"What are some (concrete) use-cases for metaclasses?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a friend who likes to use metaclasses, and regularly offers them as a solution.\nI am of the mind that you almost never need to use metaclasses. Why? because I figure if you are doing something like that to a class, you should probably be doing it to an object. And a small redesign\/refactor is in order.\nBeing able to use metaclasses has caused a lot of people in a lot of places to use classes as some kind of second rate object, which just seems disastrous to me. Is programming to be replaced by meta-programming? The addition of class decorators has unfortunately made it even more acceptable.\nSo please, I am desperate to know your valid (concrete) use-cases for metaclasses in Python. Or to be enlightened as to why mutating classes is better than mutating objects, sometimes.\nI will start:\n\nSometimes when using a third-party\n library it is useful to be able to\n mutate the class in a certain way.\n\n(This is the only case I can think of, and it's not concrete)","AnswerCount":21,"Available Count":4,"Score":0.0190453158,"is_accepted":false,"ViewCount":32950,"Q_Id":392160,"Users Score":2,"Answer":"This is a minor use, but... one thing I've found metaclasses useful for is to invoke a function whenever a subclass is created. I codified this into a metaclass which looks for an __initsubclass__ attribute: whenever a subclass is created, all parent classes which define that method are invoked with __initsubclass__(cls, subcls). This allows creation of a parent class which then registers all subclasses with some global registry, runs invariant checks on subclasses whenever they are defined, perform late-binding operations, etc... all without have to manually call functions or to create custom metaclasses that perform each of these separate duties. \nMind you, I've slowly come to realize the implicit magicalness of this behavior is somewhat undesirable, since it's unexpected if looking at a class definition out of context... and so I've moved away from using that solution for anything serious besides initializing a __super attribute for each class and instance.","Q_Score":148,"Tags":"python,metaclass","A_Id":7058179,"CreationDate":"2008-12-24T20:13:00.000","Title":"What are some (concrete) use-cases for metaclasses?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I was just wondering what language would be a good choice for developing a game server to support a large (thousands) number of users? I dabbled in python, but realized that it would just be too much trouble since it doesn't spawn threads across cores (meaning an 8 core server=1 core server). I also didn't really like the language (that \"self\" stuff grossed me out).\nI know that C++ is the language for the job in terms of performance, but I hate it. I don't want to deal with its sloppy syntax and I like my hand to be held by managed languages. This brings me to C# and Java, but I am open to other languages. I love the simplicity of .NET, but I was wondering if, speed wise, this would be good for the job. Keep in mind since this will be deployed on a Linux server, it would be running on the Mono framework - not sure if that matters. I know that Java is syntax-wise very similar to .Net, but my experience with it is limited. Are there any frameworks out there for it or anthing to ease in the development?\nPlease help me and my picky self arrive on a solution.\nUPDATE: I didn't mean to sound so picky, and I really don't think I was. The only language I really excluded was C++, Python I don't like because of the scalability problem. I know that there are ways of communicating between processes, but if I have an 8 core server, why should I need to make 8 processes? Is there a more elegant solution?","AnswerCount":15,"Available Count":9,"Score":-0.0133325433,"is_accepted":false,"ViewCount":16457,"Q_Id":392624,"Users Score":-1,"Answer":"C++ and Java are quite slow compared to C. The language should be a tool but not a crutch.","Q_Score":15,"Tags":"c#,java,python,networking","A_Id":393963,"CreationDate":"2008-12-25T08:25:00.000","Title":"Good language to develop a game server 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":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I was just wondering what language would be a good choice for developing a game server to support a large (thousands) number of users? I dabbled in python, but realized that it would just be too much trouble since it doesn't spawn threads across cores (meaning an 8 core server=1 core server). I also didn't really like the language (that \"self\" stuff grossed me out).\nI know that C++ is the language for the job in terms of performance, but I hate it. I don't want to deal with its sloppy syntax and I like my hand to be held by managed languages. This brings me to C# and Java, but I am open to other languages. I love the simplicity of .NET, but I was wondering if, speed wise, this would be good for the job. Keep in mind since this will be deployed on a Linux server, it would be running on the Mono framework - not sure if that matters. I know that Java is syntax-wise very similar to .Net, but my experience with it is limited. Are there any frameworks out there for it or anthing to ease in the development?\nPlease help me and my picky self arrive on a solution.\nUPDATE: I didn't mean to sound so picky, and I really don't think I was. The only language I really excluded was C++, Python I don't like because of the scalability problem. I know that there are ways of communicating between processes, but if I have an 8 core server, why should I need to make 8 processes? Is there a more elegant solution?","AnswerCount":15,"Available Count":9,"Score":0.0,"is_accepted":false,"ViewCount":16457,"Q_Id":392624,"Users Score":0,"Answer":"What are your objectives? Not the creation of the game itself, but why are you creating it?\nIf you're doing it to learn a new language, then pick the one that seems the most interesting to you (i.e., the one you most want to learn).\nIf it is for any other reason, then the best language will be the one that you already know best and enjoy using most. This will allow you to focus on working out the game logic and getting something up and running so that you can see progress and remain motivated to continue, rather than getting bogged down in details of the language you're using and losing interest.\nIf your favorite language proves inadequate in some ways (too slow, not expressive enough, whatever), then you can rewrite the problem sections in a more suitable language when issues come up - and you won't know the best language to address the specific problems until you know what the problems end up being. Even if your chosen language proves entirely unsuitable for final production use and the whole thing has to be rewritten, it will give you a working prototype with tested game logic, which will make dealing with the new language far easier.","Q_Score":15,"Tags":"c#,java,python,networking","A_Id":392874,"CreationDate":"2008-12-25T08:25:00.000","Title":"Good language to develop a game server 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":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I was just wondering what language would be a good choice for developing a game server to support a large (thousands) number of users? I dabbled in python, but realized that it would just be too much trouble since it doesn't spawn threads across cores (meaning an 8 core server=1 core server). I also didn't really like the language (that \"self\" stuff grossed me out).\nI know that C++ is the language for the job in terms of performance, but I hate it. I don't want to deal with its sloppy syntax and I like my hand to be held by managed languages. This brings me to C# and Java, but I am open to other languages. I love the simplicity of .NET, but I was wondering if, speed wise, this would be good for the job. Keep in mind since this will be deployed on a Linux server, it would be running on the Mono framework - not sure if that matters. I know that Java is syntax-wise very similar to .Net, but my experience with it is limited. Are there any frameworks out there for it or anthing to ease in the development?\nPlease help me and my picky self arrive on a solution.\nUPDATE: I didn't mean to sound so picky, and I really don't think I was. The only language I really excluded was C++, Python I don't like because of the scalability problem. I know that there are ways of communicating between processes, but if I have an 8 core server, why should I need to make 8 processes? Is there a more elegant solution?","AnswerCount":15,"Available Count":9,"Score":0.0399786803,"is_accepted":false,"ViewCount":16457,"Q_Id":392624,"Users Score":3,"Answer":"More details about this game server might help folks better answer your question. Is this a game server in the sense of something like a Counter Strike dedicated server which sits in the background and hosts multiplayer interactions or are you writing something which will be hosted on an HTTP webserver?\nPersonally, if it were me, I'd be considering Java or C++. My personal preference and skill set would probably lead me towards C++ because I find Java clumsy to work with on both platforms (moreso on Linux) and don't have the confidence that C# is ready for prime-time in Linux yet.\nThat said, you also need to have a pretty significant community hammering on said server before performance of your language is going to be so problematic. My advise would be to write it in whatever language you can at the moment and if your game grows to be of sufficient size, invest in a rewrite at that time.","Q_Score":15,"Tags":"c#,java,python,networking","A_Id":392831,"CreationDate":"2008-12-25T08:25:00.000","Title":"Good language to develop a game server 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":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I was just wondering what language would be a good choice for developing a game server to support a large (thousands) number of users? I dabbled in python, but realized that it would just be too much trouble since it doesn't spawn threads across cores (meaning an 8 core server=1 core server). I also didn't really like the language (that \"self\" stuff grossed me out).\nI know that C++ is the language for the job in terms of performance, but I hate it. I don't want to deal with its sloppy syntax and I like my hand to be held by managed languages. This brings me to C# and Java, but I am open to other languages. I love the simplicity of .NET, but I was wondering if, speed wise, this would be good for the job. Keep in mind since this will be deployed on a Linux server, it would be running on the Mono framework - not sure if that matters. I know that Java is syntax-wise very similar to .Net, but my experience with it is limited. Are there any frameworks out there for it or anthing to ease in the development?\nPlease help me and my picky self arrive on a solution.\nUPDATE: I didn't mean to sound so picky, and I really don't think I was. The only language I really excluded was C++, Python I don't like because of the scalability problem. I know that there are ways of communicating between processes, but if I have an 8 core server, why should I need to make 8 processes? Is there a more elegant solution?","AnswerCount":15,"Available Count":9,"Score":0.0133325433,"is_accepted":false,"ViewCount":16457,"Q_Id":392624,"Users Score":1,"Answer":"It may depend a lot on what language your \"game logic\" (you may know this term as \"business logic\") is best expressed in. For example, if the game logic is best expressed in Python (or any other particular language) it might be best to just write it in Python and deal with the performance issues the hard way with either multi-threading or clustering. Even though it may cost you a lot of time to get the performance you want out of Python it will be less that the time it will take you to express \"player A now casts a level 70 Spell of darkness in the radius of 7 units effecting all units that have spoken with player B and .... \" in C++.\nSomething else to consider is what protocol you will be using to communicate with the clients. If you have a complex binary protocol C++ may be easier (esp. if you already had experience doing it before) while a JSON (or similar) may be easier to parse in Python. Yes, i know C++ and python aren't languages you are limited to (or even considering) but i'm refer to them generally here.\nProbably comes down to what language you are the best at. A poorly written program which you hated writing will be worse that one written in a language you know and enjoy, even if the poorly written program was in an arguable more powerful language.","Q_Score":15,"Tags":"c#,java,python,networking","A_Id":392645,"CreationDate":"2008-12-25T08:25:00.000","Title":"Good language to develop a game server 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":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I was just wondering what language would be a good choice for developing a game server to support a large (thousands) number of users? I dabbled in python, but realized that it would just be too much trouble since it doesn't spawn threads across cores (meaning an 8 core server=1 core server). I also didn't really like the language (that \"self\" stuff grossed me out).\nI know that C++ is the language for the job in terms of performance, but I hate it. I don't want to deal with its sloppy syntax and I like my hand to be held by managed languages. This brings me to C# and Java, but I am open to other languages. I love the simplicity of .NET, but I was wondering if, speed wise, this would be good for the job. Keep in mind since this will be deployed on a Linux server, it would be running on the Mono framework - not sure if that matters. I know that Java is syntax-wise very similar to .Net, but my experience with it is limited. Are there any frameworks out there for it or anthing to ease in the development?\nPlease help me and my picky self arrive on a solution.\nUPDATE: I didn't mean to sound so picky, and I really don't think I was. The only language I really excluded was C++, Python I don't like because of the scalability problem. I know that there are ways of communicating between processes, but if I have an 8 core server, why should I need to make 8 processes? Is there a more elegant solution?","AnswerCount":15,"Available Count":9,"Score":0.0266603475,"is_accepted":false,"ViewCount":16457,"Q_Id":392624,"Users Score":2,"Answer":"You could as well use Java and compile the code using GCC to a native executable.\nThat way you don't get the performance hit of the bytecode engine (Yes, I know - Java out of the box is as fast as C++. It must be just me who always measures a factor 5 performance difference). The drawback is that the GCC Java-frontend does not support all of the Java 1.6 language features. \nAnother choice would be to use your language of choice, get the code working first and then move the performance critical stuff into native code. Nearly all languages support binding to compiled libraries.\nThat does not solve your \"python does not multithread well\"-problem, but it gives you more choices.","Q_Score":15,"Tags":"c#,java,python,networking","A_Id":392764,"CreationDate":"2008-12-25T08:25:00.000","Title":"Good language to develop a game server 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":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I was just wondering what language would be a good choice for developing a game server to support a large (thousands) number of users? I dabbled in python, but realized that it would just be too much trouble since it doesn't spawn threads across cores (meaning an 8 core server=1 core server). I also didn't really like the language (that \"self\" stuff grossed me out).\nI know that C++ is the language for the job in terms of performance, but I hate it. I don't want to deal with its sloppy syntax and I like my hand to be held by managed languages. This brings me to C# and Java, but I am open to other languages. I love the simplicity of .NET, but I was wondering if, speed wise, this would be good for the job. Keep in mind since this will be deployed on a Linux server, it would be running on the Mono framework - not sure if that matters. I know that Java is syntax-wise very similar to .Net, but my experience with it is limited. Are there any frameworks out there for it or anthing to ease in the development?\nPlease help me and my picky self arrive on a solution.\nUPDATE: I didn't mean to sound so picky, and I really don't think I was. The only language I really excluded was C++, Python I don't like because of the scalability problem. I know that there are ways of communicating between processes, but if I have an 8 core server, why should I need to make 8 processes? Is there a more elegant solution?","AnswerCount":15,"Available Count":9,"Score":1.0,"is_accepted":false,"ViewCount":16457,"Q_Id":392624,"Users Score":18,"Answer":"I might be going slightly off-topic here, but the topic interests me as I have (hobby-wise) worked on quite a few game servers (MMORPG servers) - on others' code as well as mine. There is literature out there that will be of interest to you, drop me a note if you want some references.\nOne thing that strikes me in your question is the want to serve a thousand users off a multithreaded application. From my humble experience, that does not work too well. :-) \nWhen you serve thousands of users you want a design that is as modular as possible, because one of your primary goals will be to keep the service as a whole up and running. Game servers tend to be rather complex, so there will be quite a few show-stopping bugs. Don't make your life miserable with a single point of failure (one application!).\nInstead, try to build multiple processes that can run on a multitude of hosts. My humble suggestion is the following:\n\nMake them independent, so a failing process will be irrelevant to the service.\nMake them small, so that the different parts of the service and how they interact are easy to grasp.\nDon't let users communicate with the gamelogic OR DB directly. Write a proxy - network stacks can and will show odd behaviour on different architectures when you have a multitude of users. Also make sure that you can later \"clean\"\/filter what the proxies forward.\nHave a process that will only monitor other processes to see if they are still working properly, with the ability to restart parts.\nMake them distributable. Coordinate processes via TCP from the start or you will run into scalability problems.\nIf you have large landscapes, consider means to dynamically divide load by dividing servers by geography. Don't have every backend process hold all the data in memory.\n\nI have ported a few such engines written in C++ and C# for hosts operating on Linux, FreeBSD and also Solaris (on an old UltraSparc IIi - yes, mono still runs there :). From my experience, C# is well fast enough, considering on what ancient hardware it operates on that sparc machine.\nThe industry (as far as I know) tends to use a lot of C++ for the serving work and embeds scripting languages for the actual game logic. Ah, written too much already - way cool topic.","Q_Score":15,"Tags":"c#,java,python,networking","A_Id":392911,"CreationDate":"2008-12-25T08:25:00.000","Title":"Good language to develop a game server 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":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I was just wondering what language would be a good choice for developing a game server to support a large (thousands) number of users? I dabbled in python, but realized that it would just be too much trouble since it doesn't spawn threads across cores (meaning an 8 core server=1 core server). I also didn't really like the language (that \"self\" stuff grossed me out).\nI know that C++ is the language for the job in terms of performance, but I hate it. I don't want to deal with its sloppy syntax and I like my hand to be held by managed languages. This brings me to C# and Java, but I am open to other languages. I love the simplicity of .NET, but I was wondering if, speed wise, this would be good for the job. Keep in mind since this will be deployed on a Linux server, it would be running on the Mono framework - not sure if that matters. I know that Java is syntax-wise very similar to .Net, but my experience with it is limited. Are there any frameworks out there for it or anthing to ease in the development?\nPlease help me and my picky self arrive on a solution.\nUPDATE: I didn't mean to sound so picky, and I really don't think I was. The only language I really excluded was C++, Python I don't like because of the scalability problem. I know that there are ways of communicating between processes, but if I have an 8 core server, why should I need to make 8 processes? Is there a more elegant solution?","AnswerCount":15,"Available Count":9,"Score":1.0,"is_accepted":false,"ViewCount":16457,"Q_Id":392624,"Users Score":7,"Answer":"What kind of performance do you need?\ntwisted is great for servers that need lots of concurrency, as is erlang. Either supports massive concurrency easily and has facilities for distributed computing.\nIf you want to span more than one core in a python app, do the same thing you'd do if you wanted to span more than one machine \u2014 run more than one process.","Q_Score":15,"Tags":"c#,java,python,networking","A_Id":392650,"CreationDate":"2008-12-25T08:25:00.000","Title":"Good language to develop a game server 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":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I was just wondering what language would be a good choice for developing a game server to support a large (thousands) number of users? I dabbled in python, but realized that it would just be too much trouble since it doesn't spawn threads across cores (meaning an 8 core server=1 core server). I also didn't really like the language (that \"self\" stuff grossed me out).\nI know that C++ is the language for the job in terms of performance, but I hate it. I don't want to deal with its sloppy syntax and I like my hand to be held by managed languages. This brings me to C# and Java, but I am open to other languages. I love the simplicity of .NET, but I was wondering if, speed wise, this would be good for the job. Keep in mind since this will be deployed on a Linux server, it would be running on the Mono framework - not sure if that matters. I know that Java is syntax-wise very similar to .Net, but my experience with it is limited. Are there any frameworks out there for it or anthing to ease in the development?\nPlease help me and my picky self arrive on a solution.\nUPDATE: I didn't mean to sound so picky, and I really don't think I was. The only language I really excluded was C++, Python I don't like because of the scalability problem. I know that there are ways of communicating between processes, but if I have an 8 core server, why should I need to make 8 processes? Is there a more elegant solution?","AnswerCount":15,"Available Count":9,"Score":1.0,"is_accepted":false,"ViewCount":16457,"Q_Id":392624,"Users Score":21,"Answer":"I hate to say it, and I know I'm risking a down mod here, but it doesn't sound like there's a language out there for you. All programming languages have their quirks and programmers simply have to adapt to them. It's completely possible to write a working server in Python without classes (eliminating the \"self\" variable class references) and likewise just as easy to write C++ with clean syntax.\nIf you're looking to deploy cross-platform and want to develop cross-platform as well, your best bet would probably be Java. It shorter development cycles than compiled languages like C and C++, but is higher performance (arguable, but I've always been anti-Java =P) than interpreted languages like Python and Perl and you don't have to work with unofficial implementations like Mono that may from time to time not support all of a language's features.","Q_Score":15,"Tags":"c#,java,python,networking","A_Id":392627,"CreationDate":"2008-12-25T08:25:00.000","Title":"Good language to develop a game server 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":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I was just wondering what language would be a good choice for developing a game server to support a large (thousands) number of users? I dabbled in python, but realized that it would just be too much trouble since it doesn't spawn threads across cores (meaning an 8 core server=1 core server). I also didn't really like the language (that \"self\" stuff grossed me out).\nI know that C++ is the language for the job in terms of performance, but I hate it. I don't want to deal with its sloppy syntax and I like my hand to be held by managed languages. This brings me to C# and Java, but I am open to other languages. I love the simplicity of .NET, but I was wondering if, speed wise, this would be good for the job. Keep in mind since this will be deployed on a Linux server, it would be running on the Mono framework - not sure if that matters. I know that Java is syntax-wise very similar to .Net, but my experience with it is limited. Are there any frameworks out there for it or anthing to ease in the development?\nPlease help me and my picky self arrive on a solution.\nUPDATE: I didn't mean to sound so picky, and I really don't think I was. The only language I really excluded was C++, Python I don't like because of the scalability problem. I know that there are ways of communicating between processes, but if I have an 8 core server, why should I need to make 8 processes? Is there a more elegant solution?","AnswerCount":15,"Available Count":9,"Score":0.0266603475,"is_accepted":false,"ViewCount":16457,"Q_Id":392624,"Users Score":2,"Answer":"The obvious candidates are Java and Erlang:\nPro Java:\n\nease of development\ngood development environments\nstability, good stack traces\nwell-known (easy to find experienced programmers, lots of libraries, books, ...)\nquite fast, mature VM\n\nPro Erlang:\n\nproven in systems that need >99.9% uptime\nability to have software updates without downtime\nscalable (not only multi-core, but also multi-machine)\n\nContra Erlang:\n\nunfamiliar syntax and programming paradigm\nnot so well known; hard to get experienced programmers for\nVM is not nearly as fast as java\n\nIf your game server mainly works as a event dispatcher (with a bit of a database tucked on), Erlang's message-driven paradigm should be a good match.\nIn this day and age, I would not consider using an unmanaged language (like C or C++); the marginal performance benefits simply aren't worth the hassle.","Q_Score":15,"Tags":"c#,java,python,networking","A_Id":392844,"CreationDate":"2008-12-25T08:25:00.000","Title":"Good language to develop a game server 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":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"For those of you who have had the opportunity of writing web applications in PHP and then as an application server (eg. Python-based solutions like CherryPy or Pylons), in what context are application servers a better alternative to PHP?\nI tend to favor PHP simply because it's available on just about any web server (especially shared host), but I'm looking for other good reasons to make an informed choice. Thank you.","AnswerCount":5,"Available Count":3,"Score":0.0399786803,"is_accepted":false,"ViewCount":1413,"Q_Id":395960,"Users Score":1,"Answer":"Python web-apps tend to require more initial setup and development than the equivalent PHP site (particularly so for small sites). There also tend to be more reusable pieces for PHP (ie Wordpress as a blog). Configuring a server to run Python web-apps can be a difficult process, and not always well documented. PHP tends to be very easy to get running with Apache.\nAlso, as PHP is very widely used and is heavily used by beginners, there tends to be very good documentation for it.\nHowever, Python is much more fun, and much more maintainable. It scales well (in development complexity terms, rather than traffic).\nPersonally, I would also say that using Python tends to train you to solve problems in a better way. I am definitely a better developer for having learned the Pythonic way of doing things.","Q_Score":5,"Tags":"php,python","A_Id":397669,"CreationDate":"2008-12-28T07:56:00.000","Title":"PHP vs. application 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},{"Question":"For those of you who have had the opportunity of writing web applications in PHP and then as an application server (eg. Python-based solutions like CherryPy or Pylons), in what context are application servers a better alternative to PHP?\nI tend to favor PHP simply because it's available on just about any web server (especially shared host), but I'm looking for other good reasons to make an informed choice. Thank you.","AnswerCount":5,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":1413,"Q_Id":395960,"Users Score":0,"Answer":"Using application servers like Pylons, Django, etc. require much more work to setup and deploy then PHP applications which are generally supported out of the box. I run a few Django apps and had to learn a bit of configuring apache with mod_python in order to get things to work. I put forth the effort because coding in python is much more enjoyable to me than PHP and after you get the Apache config right once you never really have to mess with it again.\nOn another note, if you decide to go with a framework like Django, Rails, Pylons, .... they tend to solve a lot of small repetitive tasks that you would otherwise do on your own. But frameworks are their own huge topic of discussion.","Q_Score":5,"Tags":"php,python","A_Id":396717,"CreationDate":"2008-12-28T07:56:00.000","Title":"PHP vs. application 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},{"Question":"For those of you who have had the opportunity of writing web applications in PHP and then as an application server (eg. Python-based solutions like CherryPy or Pylons), in what context are application servers a better alternative to PHP?\nI tend to favor PHP simply because it's available on just about any web server (especially shared host), but I'm looking for other good reasons to make an informed choice. Thank you.","AnswerCount":5,"Available Count":3,"Score":0.1973753202,"is_accepted":false,"ViewCount":1413,"Q_Id":395960,"Users Score":5,"Answer":"I have a feeling that some of the responses didn't address the initial question directly, so I decided to post my own. I understand that the question was about the difference between the mod_php deployment model and the application server deployment model.\nIn simple words, PHP executes a given script on every request, and the application has no knowledge of what has happened before (unless it is emulated somehow). Moreover even the source code is being parsed on every request (unless you use a bytecode cache like APC). This process can be slow, especially if you have a framework with complex initialization.\nIn contrast to this, the application server has to be started once, and then it waits for a request to be processed. The application server should clean up resources after every requests (allocated memory, open descriptors, etc.), it can also pool certain resources (like database connections) that can be reused between requests for extra performance.\nThis later model (application server) is more efficient in most cases, but on the other hand more difficult to setup and maintain. It is also more demanding, as you have to pay more attention to the resources you utilize, in order to avoid resource leaks.","Q_Score":5,"Tags":"php,python","A_Id":397730,"CreationDate":"2008-12-28T07:56:00.000","Title":"PHP vs. application 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},{"Question":"I am a C++ developer, slowly getting into web development. I like LISP a lot but don't like AllegroCL and web-frameworks available for LISP. I am looking for more freedom and ability to do cool hacks on language level. I don't consider tabs as a crime against nature.\nWhich one is closer to LISP: Python or Ruby? \nI can't seem to be able to choose from Python and Ruby: they seem very similar but apparently Ruby is more functional and object-oriented, which are good things, while Python is more like Perl: a simple scripting language. Do I have the right impression?\nPS - This might seem like a flame bait but it's not really, I'm just trying not to go crazy from OCD about switching from RoR to Python\/Django and back.","AnswerCount":12,"Available Count":6,"Score":0.0,"is_accepted":false,"ViewCount":5716,"Q_Id":405165,"Users Score":0,"Answer":"pick the most popular one for your domain so your work gets the most visibility. some might say ruby\/rails for web, python for everything else. picking a language just because its like lisp is really not appropriate for a professional.","Q_Score":21,"Tags":"python,ruby,lisp","A_Id":405577,"CreationDate":"2009-01-01T17:12:00.000","Title":"Please advise on Ruby vs Python, for someone who likes LISP a lot","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I am a C++ developer, slowly getting into web development. I like LISP a lot but don't like AllegroCL and web-frameworks available for LISP. I am looking for more freedom and ability to do cool hacks on language level. I don't consider tabs as a crime against nature.\nWhich one is closer to LISP: Python or Ruby? \nI can't seem to be able to choose from Python and Ruby: they seem very similar but apparently Ruby is more functional and object-oriented, which are good things, while Python is more like Perl: a simple scripting language. Do I have the right impression?\nPS - This might seem like a flame bait but it's not really, I'm just trying not to go crazy from OCD about switching from RoR to Python\/Django and back.","AnswerCount":12,"Available Count":6,"Score":0.049958375,"is_accepted":false,"ViewCount":5716,"Q_Id":405165,"Users Score":3,"Answer":"I am a Pythonista; however, based on your requirements, especially the \"cool hacks on the language level\", I would suggest you work on Ruby. Ruby is more flexible in the Perl way and you can do a lot of hacks; Python is targeted towards readability, which is a very good thing, and generally language hacks are a little frowned upon. Ruby's basic types can be modified in a hackish way that typically prototype languages allow, while Python's basic types are more suited for subclassing.\nBy the way, I would add a minor correction: both Ruby and Python are very, very object-oriented, and neither is intended to be used for quick-and-dirty scripts the Perl way. Among the two, Ruby is syntactically more similar to Perl than Python.","Q_Score":21,"Tags":"python,ruby,lisp","A_Id":405382,"CreationDate":"2009-01-01T17:12:00.000","Title":"Please advise on Ruby vs Python, for someone who likes LISP a lot","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I am a C++ developer, slowly getting into web development. I like LISP a lot but don't like AllegroCL and web-frameworks available for LISP. I am looking for more freedom and ability to do cool hacks on language level. I don't consider tabs as a crime against nature.\nWhich one is closer to LISP: Python or Ruby? \nI can't seem to be able to choose from Python and Ruby: they seem very similar but apparently Ruby is more functional and object-oriented, which are good things, while Python is more like Perl: a simple scripting language. Do I have the right impression?\nPS - This might seem like a flame bait but it's not really, I'm just trying not to go crazy from OCD about switching from RoR to Python\/Django and back.","AnswerCount":12,"Available Count":6,"Score":0.0166651236,"is_accepted":false,"ViewCount":5716,"Q_Id":405165,"Users Score":1,"Answer":"If you need Unicode support, remember to check how well supported it is. AFAIK, Python's support for Unicode is better than Ruby's, especially since Python 3.0. On the other hand, Python 3 is still missing some popular packages and 3rd party libraries, so that might play against.","Q_Score":21,"Tags":"python,ruby,lisp","A_Id":405317,"CreationDate":"2009-01-01T17:12:00.000","Title":"Please advise on Ruby vs Python, for someone who likes LISP a lot","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I am a C++ developer, slowly getting into web development. I like LISP a lot but don't like AllegroCL and web-frameworks available for LISP. I am looking for more freedom and ability to do cool hacks on language level. I don't consider tabs as a crime against nature.\nWhich one is closer to LISP: Python or Ruby? \nI can't seem to be able to choose from Python and Ruby: they seem very similar but apparently Ruby is more functional and object-oriented, which are good things, while Python is more like Perl: a simple scripting language. Do I have the right impression?\nPS - This might seem like a flame bait but it's not really, I'm just trying not to go crazy from OCD about switching from RoR to Python\/Django and back.","AnswerCount":12,"Available Count":6,"Score":0.0,"is_accepted":false,"ViewCount":5716,"Q_Id":405165,"Users Score":0,"Answer":"I'm a Rubyist who chose the language based on very similar criteria. Python is a good language and I enjoy working with it too, but I think Ruby is somewhat more Lispy in the degree of freedom it gives to the programmer. Python seems to impose its opinions a little bit more (which can be a good thing, but isn't according to our criteria here).\nPython certainly isn't more Perlish\u2014 Ruby is essentially a Smalltalk\/Perl mashup (some of its less-used features are pulled directly from Perl), whereas Python is only distantly related to either.","Q_Score":21,"Tags":"python,ruby,lisp","A_Id":405474,"CreationDate":"2009-01-01T17:12:00.000","Title":"Please advise on Ruby vs Python, for someone who likes LISP a lot","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I am a C++ developer, slowly getting into web development. I like LISP a lot but don't like AllegroCL and web-frameworks available for LISP. I am looking for more freedom and ability to do cool hacks on language level. I don't consider tabs as a crime against nature.\nWhich one is closer to LISP: Python or Ruby? \nI can't seem to be able to choose from Python and Ruby: they seem very similar but apparently Ruby is more functional and object-oriented, which are good things, while Python is more like Perl: a simple scripting language. Do I have the right impression?\nPS - This might seem like a flame bait but it's not really, I'm just trying not to go crazy from OCD about switching from RoR to Python\/Django and back.","AnswerCount":12,"Available Count":6,"Score":1.0,"is_accepted":false,"ViewCount":5716,"Q_Id":405165,"Users Score":8,"Answer":"Both Ruby and Python are fairly distant from the Lisp traditions of immutable data, programs as data, and macros. But Ruby is very nearly a clone of Smalltalk (and I hope will grow more like Smalltalk as the Perlish cruft is deprecated), and Smalltalk, like Lisp, is a language that takes one idea to extremes. Based on your desire to do cool hacks on the language level I'd go with Ruby, as it inherits a lot of the metaprogramming mindset from Smalltalk, and that mindset is connected to the Lisp tradition.","Q_Score":21,"Tags":"python,ruby,lisp","A_Id":405310,"CreationDate":"2009-01-01T17:12:00.000","Title":"Please advise on Ruby vs Python, for someone who likes LISP a lot","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I am a C++ developer, slowly getting into web development. I like LISP a lot but don't like AllegroCL and web-frameworks available for LISP. I am looking for more freedom and ability to do cool hacks on language level. I don't consider tabs as a crime against nature.\nWhich one is closer to LISP: Python or Ruby? \nI can't seem to be able to choose from Python and Ruby: they seem very similar but apparently Ruby is more functional and object-oriented, which are good things, while Python is more like Perl: a simple scripting language. Do I have the right impression?\nPS - This might seem like a flame bait but it's not really, I'm just trying not to go crazy from OCD about switching from RoR to Python\/Django and back.","AnswerCount":12,"Available Count":6,"Score":1.0,"is_accepted":false,"ViewCount":5716,"Q_Id":405165,"Users Score":12,"Answer":"Speaking as a \"Rubyist\", I'd agree with Kiv. The two languages both grant a nice amount of leeway when it comes to programming paradigms, but are also have benefits\/shortcomings. I think that the compromises you make either way are a lot about your own programming style and taste.\nPersonally, I think Ruby can read more like pseudo-code than Python. First, Python has active whitespace, which while elegant in the eyes of many, doesn't tend to enter the equation when writing pseudo-code. Also, Ruby's syntax is quite flexible. That flexibility causes a lot of quirks that can confuse, but also allows code that's quite expressive and pretty to look at.\nFinally, I'd really say that Ruby feels more Perl-ish to me. That's partly because I'm far more comfortable with it, so I can hack out scripts rather quickly. A lot of Ruby's syntax was borrowed from Perl though, and I haven't seen much Python code that feels similar (though again, I have little experience with Python).\nDepending on the approach to web programming you'd like to take, I think that the types of web frameworks available in each language could perhaps be a factor in deciding as well. I'd say try them both. You can get a working knowledge of each of them in an afternoon, and while you won't be writing awesome Ruby or Python, you can probably establish a feel for each, and decide which you like more.\nUpdate: I think your question should actually be two separate discussions: one with Ruby, one with Python. The comparisons are less important because you start debating the merits of the differences, as opposed to which language will work better for you. If you have questions about Ruby, I'd be more than happy to answer as best I can.","Q_Score":21,"Tags":"python,ruby,lisp","A_Id":405228,"CreationDate":"2009-01-01T17:12:00.000","Title":"Please advise on Ruby vs Python, for someone who likes LISP a lot","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I've been using mutagen for reading and writing MP3 tags, but I want to be able to embed album art directly into the file.","AnswerCount":5,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":21737,"Q_Id":409949,"Users Score":0,"Answer":"A nice small CLI tool which helped me a lot with checking what I did while developing id3 stuff is mid3v2 which is the mutagen version of id3v2. It comes bundled with the Python mutagen library. The source of this little tool gave me also lots of answers about how to use mutagen.","Q_Score":32,"Tags":"python,mp3,metadata,id3,albumart","A_Id":1961919,"CreationDate":"2009-01-03T21:59:00.000","Title":"How do you embed album art into an MP3 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},{"Question":"For something like a personal recommendation system, machine learning type of stuff on a website, what language would be best?","AnswerCount":5,"Available Count":4,"Score":0.0,"is_accepted":false,"ViewCount":2360,"Q_Id":410183,"Users Score":0,"Answer":"I happen to know a world-class expert in machine learning. He likes Prolog, especially for the higher level logic of the system. Hadn't even heard anyone mention that in a long time. Personally, I like Java. But if you're going to do intensive machine learning, you should be concerned about the speed of math processing. C++ for the math, in my view.","Q_Score":0,"Tags":"php,python,ruby,artificial-intelligence,recommendation-engine","A_Id":7620095,"CreationDate":"2009-01-04T00:49:00.000","Title":"Interested in Collective Programming for the web -- Ruby or Python or 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":1},{"Question":"For something like a personal recommendation system, machine learning type of stuff on a website, what language would be best?","AnswerCount":5,"Available Count":4,"Score":-0.0798297691,"is_accepted":false,"ViewCount":2360,"Q_Id":410183,"Users Score":-2,"Answer":"I recently did some research into this for a project at my day job. It was for a recommendation system and the options were php,perl or python.\nPHP was out almost immediately, there were no good 3rd party open source libraries and the language itself is not as well suited to any kind of complex real programming.\nPython had a few libraries that i wanted to try out and Perl didn't, so I went with Python. In the end, none of those libraries were useful to me but besides library support I prefer python personally anyway so that was the right decision.\nBecause your question is very vague I can only suggest that you don't use PHP and select the language based on library support for your specific problem area and your comfort in that language. I would say that library support is the biggest factor in your decision and language familiarity\/preference is a close second.","Q_Score":0,"Tags":"php,python,ruby,artificial-intelligence,recommendation-engine","A_Id":636664,"CreationDate":"2009-01-04T00:49:00.000","Title":"Interested in Collective Programming for the web -- Ruby or Python or 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":1},{"Question":"For something like a personal recommendation system, machine learning type of stuff on a website, what language would be best?","AnswerCount":5,"Available Count":4,"Score":0.0,"is_accepted":false,"ViewCount":2360,"Q_Id":410183,"Users Score":0,"Answer":"All of the points that Bill Karwin have brought up are entirely valid: You should really operate in what you are most comfortable with.\nIf that isn't a factor, I would personally suggest Ruby. It's an incredibly powerful language that draws a lot of commonalities with Lisp and is probably just as good, if not better, for AI programming for all the same reasons Lisp was: it's an extremely dynamic, self-modifiable language. As an added benefit Ruby has a really nice standard library including some great libs like the distributed computed library \"dRuby\".","Q_Score":0,"Tags":"php,python,ruby,artificial-intelligence,recommendation-engine","A_Id":636639,"CreationDate":"2009-01-04T00:49:00.000","Title":"Interested in Collective Programming for the web -- Ruby or Python or 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":1},{"Question":"For something like a personal recommendation system, machine learning type of stuff on a website, what language would be best?","AnswerCount":5,"Available Count":4,"Score":1.0,"is_accepted":false,"ViewCount":2360,"Q_Id":410183,"Users Score":16,"Answer":"The language you know best would be best.\nI mean that half-seriously. Given the brief description of your project, there's no reason to believe any of the languages you list would be any better or worse than the others. Those three languages are adequate for approximately similar tasks, so you should pick the one you are most comfortable with and proceed.\nAny other recommendations would be advocacy for one language or the other, with no real basis on which to evaluate them. Your description is just too vague.","Q_Score":0,"Tags":"php,python,ruby,artificial-intelligence,recommendation-engine","A_Id":410193,"CreationDate":"2009-01-04T00:49:00.000","Title":"Interested in Collective Programming for the web -- Ruby or Python or 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":1},{"Question":"What are good online resources to learn Python, quickly, for some who can code decently in other languages?\nedit: It'll help if you could explain why you think that resource is useful.","AnswerCount":9,"Available Count":1,"Score":0.022218565,"is_accepted":false,"ViewCount":5777,"Q_Id":412482,"Users Score":1,"Answer":"Search \"Alex Martelli - Python For Programmers\" on Google Video. Good introductory (but fast-paced) talk. Related videos are also worth watching.","Q_Score":2,"Tags":"python","A_Id":412584,"CreationDate":"2009-01-05T07:23:00.000","Title":"Resources for moving 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},{"Question":"I've got an IronPython script that configures log4net, then calls .NET code that uses log4net. log4net is properly configured, as I log a message to indicate that it is initialized. But when I try to use my .NET class, it reports \"could not load file or assembly 'log4net, ...'.\nSome useful facts:\n\nlog4net is not installed to the GAC\nthe .NET class is correct, I've called it from other .NET code\nthe log4net assembly being loaded in IPY is in the same folder as my .NET assembly.\nfilemon shows that all log4net.dll access is successfully resolved from the expected location\nfuslogvw doesn't report any binding errors\nI'm adding both the log4net reference and the .NET assembly references using AddReferenceToFileAndPath( )\n\nWhat's strange is that the log4net assembly has already been loaded. It must be loading the .NET assembly in another AppDomain. If that's how it works, it would be helpful to know. \nAny ideas out there? Thanks.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1015,"Q_Id":415015,"Users Score":2,"Answer":"I was able to solve the problem by using absolute reference paths rather than relative ones.","Q_Score":0,"Tags":"log4net,ironpython,dynamic-language-runtime","A_Id":417084,"CreationDate":"2009-01-06T00:15:00.000","Title":"Calling .NET code from IronPython, getting error loading the log4net assembly","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"How can you raise an exception when you import a module that is less or greater than a given value for its __version__?\nThere are a lot of different ways you could do it, but I feel like there must be some really simple way that eludes me at the moment. In this case the version number is of the format x.x.x","AnswerCount":5,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":453,"Q_Id":419010,"Users Score":0,"Answer":"You should be using setuptools: \nIt allows you to lock the dependancies of an application, so even if multiple versions of an egg or package exist on a system only the right one will ever be used. \nThis is a better way of working: Rather than fail if the wrong version of a dependancy is present it is better to ensure that the right version is present. \nSetuptools provides an installer which guarantees that everything required to run the application is present at install-time. It also gives you the means to select which of the many versions of a package which may be present on your PC is the one that gets loaded when you issue an import statement.","Q_Score":4,"Tags":"python,versioning","A_Id":420029,"CreationDate":"2009-01-07T02:39:00.000","Title":"How to raise an exception on the version number of 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},{"Question":"I've been wanting to have a play with either Ruby or Python while at the same time I've been wanting to do a bit of Cocoa programming.\nSo I thought the best way to achieve both these goals is to develop something using either a Ruby or Python to Objective-C bridge (PyObjc or RubyCocoa).\nI know that ideally to get the best learning experience I would learn each techonology independently but I don't have the time. :)\nSo my question is which is a more mature platform, PyObc or RubyCocoa, main things I am looking for:\n\nDocumentation of API\nTutorials\nTools\nSupportive Community\nCompletness of Cocoa API avaialble through the bridge \n\nRegarding point 5 I don't expect that the entire Cocoa API will be availble through either bridge but I need to have enough Cocoa APIs available to develop a functioning application.","AnswerCount":5,"Available Count":3,"Score":0.1194272985,"is_accepted":false,"ViewCount":2518,"Q_Id":426607,"Users Score":3,"Answer":"Both are roughly equal, I'd say. Better in some places, worse in others. But I wouldn't recommend learning Cocoa with either. Like Chris said, Cocoa requires some understanding of Objective-C. I like Ruby better than Objective-C, but I still don't recommend using it to learn Cocoa. Once you have a solid foundation (no pun intended) in Cocoa\/Objective-C, then the bridges can be useful to you.","Q_Score":8,"Tags":"python,ruby,cocoa,pyobjc,ruby-cocoa","A_Id":426733,"CreationDate":"2009-01-09T00:16:00.000","Title":"PyObjc vs RubyCocoa for Mac development: Which is more mature?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I've been wanting to have a play with either Ruby or Python while at the same time I've been wanting to do a bit of Cocoa programming.\nSo I thought the best way to achieve both these goals is to develop something using either a Ruby or Python to Objective-C bridge (PyObjc or RubyCocoa).\nI know that ideally to get the best learning experience I would learn each techonology independently but I don't have the time. :)\nSo my question is which is a more mature platform, PyObc or RubyCocoa, main things I am looking for:\n\nDocumentation of API\nTutorials\nTools\nSupportive Community\nCompletness of Cocoa API avaialble through the bridge \n\nRegarding point 5 I don't expect that the entire Cocoa API will be availble through either bridge but I need to have enough Cocoa APIs available to develop a functioning application.","AnswerCount":5,"Available Count":3,"Score":1.0,"is_accepted":false,"ViewCount":2518,"Q_Id":426607,"Users Score":12,"Answer":"While you say you \"don't have time\" to learn technologies independently the fastest route to learning Cocoa will still be to learn it in its native language: Objective-C. Once you understand Objective-C and have gotten over the initial learning curve of the Cocoa frameworks you'll have a much easier time picking up either PyObjC or RubyCocoa.","Q_Score":8,"Tags":"python,ruby,cocoa,pyobjc,ruby-cocoa","A_Id":426703,"CreationDate":"2009-01-09T00:16:00.000","Title":"PyObjc vs RubyCocoa for Mac development: Which is more mature?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I've been wanting to have a play with either Ruby or Python while at the same time I've been wanting to do a bit of Cocoa programming.\nSo I thought the best way to achieve both these goals is to develop something using either a Ruby or Python to Objective-C bridge (PyObjc or RubyCocoa).\nI know that ideally to get the best learning experience I would learn each techonology independently but I don't have the time. :)\nSo my question is which is a more mature platform, PyObc or RubyCocoa, main things I am looking for:\n\nDocumentation of API\nTutorials\nTools\nSupportive Community\nCompletness of Cocoa API avaialble through the bridge \n\nRegarding point 5 I don't expect that the entire Cocoa API will be availble through either bridge but I need to have enough Cocoa APIs available to develop a functioning application.","AnswerCount":5,"Available Count":3,"Score":0.0399786803,"is_accepted":false,"ViewCount":2518,"Q_Id":426607,"Users Score":1,"Answer":"ObjectiveC is nowhere near as much fun or as productive as either Python or Ruby. That is why people want to pick a python or ruby with good Objective C access. Advising them to learn Objective C first misses the point imo. I have really good things to say about pyobjc. Its ability to interoperate painlessly with Objective C frameworks is superb. I have less experience with Ruby Cocoa and that was partly because when I last looked it didn't seem to have as clean and relatively painless interoperability. I feel hesitant about MacRuby because it seems to go too far. In pyobjc you can write plain python and only subclass\/use Foundation and Cocoa objects when you really want\/mean to. From what I understand of MacRuby it is a Ruby on top of Cocoa. So a string is always an NSString. I am less happy with that. YMMV.","Q_Score":8,"Tags":"python,ruby,cocoa,pyobjc,ruby-cocoa","A_Id":3930584,"CreationDate":"2009-01-09T00:16:00.000","Title":"PyObjc vs RubyCocoa for Mac development: Which is more mature?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I use python cgi for our intranet application.\nWhen I measure time, the script takes 4s to finish. But after that, it still takes another 11s to show the screen in the browser. \nThe screen is build with tables (size: 10 KB, 91 KB uncompressed) and has a large css file (5 KB, 58 KB uncompressed).\nI used YSlow and did as much optimization as suggested. Gzipping etc. \nFirebug Net says: 11s for the file.\nHow do I measure where these last 11 seconds are needed for?\nIs it just the size of the HTML, or the table structure?\nAnyone more ideas for tweaking?","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":653,"Q_Id":428704,"Users Score":1,"Answer":"with that much html to render I would also consider the speed of the computer. you can test this by saving the html file and opening it from your local hard drive :)","Q_Score":2,"Tags":"python,html,css,browser,cgi","A_Id":428832,"CreationDate":"2009-01-09T16:19:00.000","Title":"Measure load time for 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":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I use python cgi for our intranet application.\nWhen I measure time, the script takes 4s to finish. But after that, it still takes another 11s to show the screen in the browser. \nThe screen is build with tables (size: 10 KB, 91 KB uncompressed) and has a large css file (5 KB, 58 KB uncompressed).\nI used YSlow and did as much optimization as suggested. Gzipping etc. \nFirebug Net says: 11s for the file.\nHow do I measure where these last 11 seconds are needed for?\nIs it just the size of the HTML, or the table structure?\nAnyone more ideas for tweaking?","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":653,"Q_Id":428704,"Users Score":1,"Answer":"I think I'd grab a copy of Ethereal and watch the TCP connection between the browser and the script, if I were concerned about whether the server is not getting its job done in an acceptable amount of time. If you see the TCP socket close before that 11s gap, you know that your issue is entirely on the browser side. If the TCP close comes well into the 11s gap, then you're going to have to do some debugging on the http server side.\nI think that Ethereal has changed it's name to WireShark. Whatever it is calling itself recently, it's a must-have tool for this sort of work. I was using it just the other day to find out why I couldn't connect to my virtualized http server.","Q_Score":2,"Tags":"python,html,css,browser,cgi","A_Id":428767,"CreationDate":"2009-01-09T16:19:00.000","Title":"Measure load time for 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":0,"System Administration and DevOps":0,"Web Development":1},{"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},{"Question":"I am creating an interface for Python scripting.\nLater I will be dong Python scripting also for automated testing.\nIs it necessary the at i must use class in my code.Now I have created the code\nwith dictionaries,lists,functions,global and local variables.\nIs class necessary?\nHelp me in this.","AnswerCount":4,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":2284,"Q_Id":438149,"Users Score":0,"Answer":"not necessary since python is not a purely object oriented language but certain things are better written in classes (encapsulation).it becomes easier to build a large project using classes","Q_Score":0,"Tags":"python,class,scripting","A_Id":1992389,"CreationDate":"2009-01-13T06:42:00.000","Title":"Help needed--Is class necessary in Python 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":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am creating an interface for Python scripting.\nLater I will be dong Python scripting also for automated testing.\nIs it necessary the at i must use class in my code.Now I have created the code\nwith dictionaries,lists,functions,global and local variables.\nIs class necessary?\nHelp me in this.","AnswerCount":4,"Available Count":3,"Score":0.049958375,"is_accepted":false,"ViewCount":2284,"Q_Id":438149,"Users Score":1,"Answer":"It's not needed to make it work, but I would argue that it will become messy to maintain if you do not encapsulate certain things in classes. Classes are something that schould help the programmer to organizes his\/her code, not just nice to have fluff.","Q_Score":0,"Tags":"python,class,scripting","A_Id":438239,"CreationDate":"2009-01-13T06:42:00.000","Title":"Help needed--Is class necessary in Python 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":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am creating an interface for Python scripting.\nLater I will be dong Python scripting also for automated testing.\nIs it necessary the at i must use class in my code.Now I have created the code\nwith dictionaries,lists,functions,global and local variables.\nIs class necessary?\nHelp me in this.","AnswerCount":4,"Available Count":3,"Score":1.0,"is_accepted":false,"ViewCount":2284,"Q_Id":438149,"Users Score":10,"Answer":"No, of course class is not a must. As Python is a scripting language, you can simply code your scripts without defining your own classes.\nClasses are useful if you implement a more complex program which needs a structured approach and OOP benfits (encapsulation, polimorphism) help you in doing it.","Q_Score":0,"Tags":"python,class,scripting","A_Id":438171,"CreationDate":"2009-01-13T06:42:00.000","Title":"Help needed--Is class necessary in Python 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":1,"System Administration and DevOps":0,"Web Development":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},{"Question":"Is there any reason to prefer unicode(somestring, 'utf8') as opposed to somestring.decode('utf8')?\nMy only thought is that .decode() is a bound method so python may be able to resolve it more efficiently, but correct me if I'm wrong.","AnswerCount":2,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":30226,"Q_Id":440320,"Users Score":23,"Answer":"I'd prefer 'something'.decode(...) since the unicode type is no longer there in Python 3.0, while text = b'binarydata'.decode(encoding) is still valid.","Q_Score":27,"Tags":"python,unicode,utf-8","A_Id":440461,"CreationDate":"2009-01-13T19:06:00.000","Title":"unicode() vs. str.decode() for a utf8 encoded byte string (python 2.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":0,"Web Development":0},{"Question":"Just want to know what's the common way to react on events in python. There are several ways in other languages like callback functions, delegates, listener-structures and so on. \nIs there a common way? Which default language concepts or additional modules are there and which can you recommend?","AnswerCount":8,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":23479,"Q_Id":443885,"Users Score":0,"Answer":"Personally, I've only seen callbacks used. However, I haven't seen that much event driven python code so YMMV.","Q_Score":25,"Tags":"python,events,delegates,callback","A_Id":443934,"CreationDate":"2009-01-14T17:20:00.000","Title":"Python: Callbacks, Delegates, ... ? What is common?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Just want to know what's the common way to react on events in python. There are several ways in other languages like callback functions, delegates, listener-structures and so on. \nIs there a common way? Which default language concepts or additional modules are there and which can you recommend?","AnswerCount":8,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":23479,"Q_Id":443885,"Users Score":0,"Answer":"I have seen listeners and callbacks used. But AFAIK there is no Python way. They should be equally feasible if the application in question is suitable.","Q_Score":25,"Tags":"python,events,delegates,callback","A_Id":444003,"CreationDate":"2009-01-14T17:20:00.000","Title":"Python: Callbacks, Delegates, ... ? What is common?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have scanned 'the Google' and have not found the definitive answer on whether the Iron* languages (any or all) will end up with Attribute support..\nAnyone?\nThanks - Jon","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":316,"Q_Id":443996,"Users Score":0,"Answer":"We're looking at attribute support again for a .NET interop-focused release in the near future. Keep an eye on ironruby-core@rubyforge.org for an updates.","Q_Score":1,"Tags":"ironpython,ironruby","A_Id":592844,"CreationDate":"2009-01-14T17:49:00.000","Title":"Has anyone tracked down whether IronPython or IronRuby will support Attributes?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"What makes Python stand out for use in web development? What are some examples of highly successful uses of Python on the web?","AnswerCount":12,"Available Count":5,"Score":0.0,"is_accepted":false,"ViewCount":15173,"Q_Id":452305,"Users Score":0,"Answer":"Dynamic languages are in general good for web apps because the speed of development. Python in particular has two advantages over most of them:\n\n\"batteries included\" means lots of available libraries\nDjango. For me this is the only reason why i use Python instead of Lua (which i like a lot more).","Q_Score":10,"Tags":"python,programming-languages","A_Id":452352,"CreationDate":"2009-01-16T22:38:00.000","Title":"What are the benefits of using Python for web programming?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"What makes Python stand out for use in web development? What are some examples of highly successful uses of Python on the web?","AnswerCount":12,"Available Count":5,"Score":0.0166651236,"is_accepted":false,"ViewCount":15173,"Q_Id":452305,"Users Score":1,"Answer":"GNU Mailman is another project written in python that is widely successful.","Q_Score":10,"Tags":"python,programming-languages","A_Id":452356,"CreationDate":"2009-01-16T22:38:00.000","Title":"What are the benefits of using Python for web programming?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"What makes Python stand out for use in web development? What are some examples of highly successful uses of Python on the web?","AnswerCount":12,"Available Count":5,"Score":0.0,"is_accepted":false,"ViewCount":15173,"Q_Id":452305,"Users Score":0,"Answer":"Besides the frameworks...\n\nPython's pervasive support for Unicode should make i18n much smoother.\nA sane namespace system makes debugging much nicer, because it's typically easier to find where things are defined.\nPython's inability to function as a standalone templating language should discourage the mixture of HTML with model code\nGreat standard library","Q_Score":10,"Tags":"python,programming-languages","A_Id":452384,"CreationDate":"2009-01-16T22:38:00.000","Title":"What are the benefits of using Python for web programming?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"What makes Python stand out for use in web development? What are some examples of highly successful uses of Python on the web?","AnswerCount":12,"Available Count":5,"Score":0.0,"is_accepted":false,"ViewCount":15173,"Q_Id":452305,"Users Score":0,"Answer":"Other examples of Python sites are Reddit and YouTube.","Q_Score":10,"Tags":"python,programming-languages","A_Id":452392,"CreationDate":"2009-01-16T22:38:00.000","Title":"What are the benefits of using Python for web programming?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"What makes Python stand out for use in web development? What are some examples of highly successful uses of Python on the web?","AnswerCount":12,"Available Count":5,"Score":0.0166651236,"is_accepted":false,"ViewCount":15173,"Q_Id":452305,"Users Score":1,"Answer":"As many have pointed out, Django is a great reason to use Python...so in order to figure out why Python is great for web development, the best bet is to look at why it is a good language to build a framework like Django.\nIMHO Python combines the cleanest, or at least one of the cleanest, metaprogramming models of any language with a very pure object orientation. This not only makes it possible to write extremely general abstractions that are easy to use, but also allows the abstractions to combine relatively cleanly with others. This is harder to do in languages that take a code-generation based approach to metaprogramming (e.g. Ruby).","Q_Score":10,"Tags":"python,programming-languages","A_Id":452600,"CreationDate":"2009-01-16T22:38:00.000","Title":"What are the benefits of using Python for web programming?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm new to web services and as an introduction I'm playing around with the Twitter API using the Twisted framework in python. I've read up on the different formats they offer, but it's still not clear to me which one I should use in my fairly simple project.\nSpecifically the practical difference between using JSON or XML is something I'd like guidance on. All I'm doing is requesting the public timeline and caching it locally.\nThanks.","AnswerCount":3,"Available Count":2,"Score":0.2605204458,"is_accepted":false,"ViewCount":8204,"Q_Id":453158,"Users Score":4,"Answer":"RSS and Atom are XML formats.\nJSON is a string which can be evaluated as Javascript code.","Q_Score":6,"Tags":"python,xml,json,twitter,twisted","A_Id":453160,"CreationDate":"2009-01-17T11:19:00.000","Title":"What is the practical difference between xml, json, rss and atom when interfacing with 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},{"Question":"I'm new to web services and as an introduction I'm playing around with the Twitter API using the Twisted framework in python. I've read up on the different formats they offer, but it's still not clear to me which one I should use in my fairly simple project.\nSpecifically the practical difference between using JSON or XML is something I'd like guidance on. All I'm doing is requesting the public timeline and caching it locally.\nThanks.","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":8204,"Q_Id":453158,"Users Score":1,"Answer":"I would say the amount of data being sent over the wire is one factor. XML data stream will be bigger than JSON for the same data. But you can use whatever you know more\/have more experience. \nI would recommend JSON, as it's more \"pythonic\" than XML.","Q_Score":6,"Tags":"python,xml,json,twitter,twisted","A_Id":453164,"CreationDate":"2009-01-17T11:19:00.000","Title":"What is the practical difference between xml, json, rss and atom when interfacing with 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},{"Question":"I have a Python class full of static methods. What are the advantages and disadvantages of packaging these in a class rather than raw functions?","AnswerCount":7,"Available Count":5,"Score":1.2,"is_accepted":true,"ViewCount":6805,"Q_Id":456001,"Users Score":35,"Answer":"There are none. This is what modules are for: grouping related functions. Using a class full of static methods makes me cringe from Javaitis. The only time I would use a static function is if the function is an integral part of the class. (In fact, I'd probably want to use a class method anyway.)","Q_Score":20,"Tags":"python,class,static-methods","A_Id":456008,"CreationDate":"2009-01-18T22:09:00.000","Title":"Is there any advantage in using a Python 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},{"Question":"I have a Python class full of static methods. What are the advantages and disadvantages of packaging these in a class rather than raw functions?","AnswerCount":7,"Available Count":5,"Score":0.057080742,"is_accepted":false,"ViewCount":6805,"Q_Id":456001,"Users Score":2,"Answer":"Classes are only useful when you have a set of functionality than interacts with a set of data (instance properties) that needs to be persisted between function calls and referenced in a discrete fashion.\nIf your class contains nothing other than static methods, then your class is just syntactic cruft, and straight functions are much clearer and all that you need.","Q_Score":20,"Tags":"python,class,static-methods","A_Id":456081,"CreationDate":"2009-01-18T22:09:00.000","Title":"Is there any advantage in using a Python 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},{"Question":"I have a Python class full of static methods. What are the advantages and disadvantages of packaging these in a class rather than raw functions?","AnswerCount":7,"Available Count":5,"Score":0.0,"is_accepted":false,"ViewCount":6805,"Q_Id":456001,"Users Score":0,"Answer":"I agree with Benjamin. Rather than having a bunch of static methods, you should probably have a bunch of functions. And if you want to organize them, you should think about using modules rather than classes. However, if you want to refactor your code to be OO, that's another matter.","Q_Score":20,"Tags":"python,class,static-methods","A_Id":456013,"CreationDate":"2009-01-18T22:09:00.000","Title":"Is there any advantage in using a Python 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},{"Question":"I have a Python class full of static methods. What are the advantages and disadvantages of packaging these in a class rather than raw functions?","AnswerCount":7,"Available Count":5,"Score":0.0285636566,"is_accepted":false,"ViewCount":6805,"Q_Id":456001,"Users Score":1,"Answer":"Not only are there no advantages, but it makes things slower than using a module full of methods. There's much less need for static methods in python than there is for them in java or c#, they are used in very special cases.","Q_Score":20,"Tags":"python,class,static-methods","A_Id":456016,"CreationDate":"2009-01-18T22:09:00.000","Title":"Is there any advantage in using a Python 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},{"Question":"I have a Python class full of static methods. What are the advantages and disadvantages of packaging these in a class rather than raw functions?","AnswerCount":7,"Available Count":5,"Score":0.0,"is_accepted":false,"ViewCount":6805,"Q_Id":456001,"Users Score":0,"Answer":"Depends on the nature of the functions. If they're not strongly unrelated (minimal amount of calls between them) and they don't have any state then yes I'd say dump them into a module. However, you could be shooting yourself in the foot if you ever need to modify the behavior as you're throwing inheritance out the window. So my answer is maybe, and be sure you look at your particular scenario rather then always assuming a module is the best way to collect a set of methods.","Q_Score":20,"Tags":"python,class,static-methods","A_Id":456222,"CreationDate":"2009-01-18T22:09:00.000","Title":"Is there any advantage in using a Python 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},{"Question":"I found the bottleneck in my python code, played around with psycho etc. Then decided to write a c\/c++ extension for performance.\nWith the help of swig you almost don't need to care about arguments etc. Everything works fine.\nNow my question: swig creates a quite large py-file which does a lot of 'checkings' and 'PySwigObject' before calling the actual .pyd or .so code.\nDoes anyone of you have any experience whether there is some more performance to gain if you hand-write this file or let swig do it.","AnswerCount":10,"Available Count":3,"Score":1.0,"is_accepted":false,"ViewCount":32045,"Q_Id":456884,"Users Score":8,"Answer":"An observation: Based on the benchmarking conducted by the pybindgen developers, there is no significant difference between boost.python and swig. I haven't done my own benchmarking to verify how much of this depends on the proper use of the boost.python functionality. \nNote also that there may be a reason that pybindgen seems to be in general quite a bit faster than swig and boost.python: it may not produce as versatile a binding as the other two. For instance, exception propagation, call argument type checking, etc. I haven't had a chance to use pybindgen yet but I intend to. \nBoost is in general quite big package to install, and last I saw you can't just install boost python you pretty much need the whole Boost library. As others have mentioned compilation will be slow due to heavy use of template programming, which also means typically rather cryptic error messages at compile time. \nSummary: given how easy SWIG is to install and use, that it generates decent binding that is robust and versatile, and that one interface file allows your C++ DLL to be available from several other languages like LUA, C#, and Java, I would favor it over boost.python. But unless you really need multi-language support I would take a close look at PyBindGen because of its purported speed, and pay close attention to robustness and versatility of binding it generates.","Q_Score":70,"Tags":"python,c++,c,swig,cython","A_Id":3167276,"CreationDate":"2009-01-19T08:32:00.000","Title":"Extending python - to swig, not to swig or Cython","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},{"Question":"I found the bottleneck in my python code, played around with psycho etc. Then decided to write a c\/c++ extension for performance.\nWith the help of swig you almost don't need to care about arguments etc. Everything works fine.\nNow my question: swig creates a quite large py-file which does a lot of 'checkings' and 'PySwigObject' before calling the actual .pyd or .so code.\nDoes anyone of you have any experience whether there is some more performance to gain if you hand-write this file or let swig do it.","AnswerCount":10,"Available Count":3,"Score":1.0,"is_accepted":false,"ViewCount":32045,"Q_Id":456884,"Users Score":6,"Answer":"There be dragons here. Don't swig, don't boost. For any complicated project the code you have to fill in yourself to make them work becomes unmanageable quickly. If it's a plain C API to your library (no classes), you can just use ctypes. It will be easy and painless, and you won't have to spend hours trawling through the documentation for these labyrinthine wrapper projects trying to find the one tiny note about the feature you need.","Q_Score":70,"Tags":"python,c++,c,swig,cython","A_Id":461364,"CreationDate":"2009-01-19T08:32:00.000","Title":"Extending python - to swig, not to swig or Cython","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},{"Question":"I found the bottleneck in my python code, played around with psycho etc. Then decided to write a c\/c++ extension for performance.\nWith the help of swig you almost don't need to care about arguments etc. Everything works fine.\nNow my question: swig creates a quite large py-file which does a lot of 'checkings' and 'PySwigObject' before calling the actual .pyd or .so code.\nDoes anyone of you have any experience whether there is some more performance to gain if you hand-write this file or let swig do it.","AnswerCount":10,"Available Count":3,"Score":0.0599281035,"is_accepted":false,"ViewCount":32045,"Q_Id":456884,"Users Score":3,"Answer":"If its not a big extension, boost::python might also be an option, it executes faster than swig, because you control what's happening, but it'll take longer to dev.\nAnyways swig's overhead is acceptable if the amount of work within a single call is large enough. For example if you issue is that you have some medium sized logic block you want to move to C\/C++, but that block is called within a tight-loop, frequently, you might have to avoid swig, but I can't really think of any real-world examples except for scripted graphics shaders.","Q_Score":70,"Tags":"python,c++,c,swig,cython","A_Id":456894,"CreationDate":"2009-01-19T08:32:00.000","Title":"Extending python - to swig, not to swig or Cython","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},{"Question":"Please tell me C++\/Java code which utilize memory more than 70% .\nFor Example we have 3 Virtual machine and in memory resources we want to test the\nmemory utilization as per memory resources allocated by user.","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":352,"Q_Id":456926,"Users Score":0,"Answer":"I want to test the Memory utilization but after executing the code i am unable to test the same.\nAs i am new to this so help me more on this.\nLet we have 3 Virtual machine V1,V2,V3\nFor V1 - Set shared resource as High\nFor V2 - Set shared resources as Normal \nFor V3 - Set shared resources as Normal \nSo it means total is 2 GB then V1 get 1 GB and V2,V3 gets 512 MB each . So i want to test using programming if some one changes the Shared or reservation or Limit then how it works.","Q_Score":1,"Tags":"java,c++,python,c","A_Id":460265,"CreationDate":"2009-01-19T08:52:00.000","Title":"Code to utilize memory more than 70%","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"Please tell me C++\/Java code which utilize memory more than 70% .\nFor Example we have 3 Virtual machine and in memory resources we want to test the\nmemory utilization as per memory resources allocated by user.","AnswerCount":3,"Available Count":2,"Score":0.2605204458,"is_accepted":false,"ViewCount":352,"Q_Id":456926,"Users Score":4,"Answer":"Which memory? On a 64 bit platform, a 64 bit process can use far more than 4GB. You'd be filling swap for hours before you hit those limits.\nIf you want to test \"70% of physical RAM\", you might discover that you cannot allocate 70% of the 32 bits address space. A significant amount is already claimed by the OS.","Q_Score":1,"Tags":"java,c++,python,c","A_Id":456948,"CreationDate":"2009-01-19T08:52:00.000","Title":"Code to utilize memory more than 70%","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I wrote an application server (using python & twisted) and I want to start writing some tests. But I do not want to use Twisted's Trial due to time constraints and not having time to play with it now. So here is what I have in mind: write a small test client that connects to the app server and makes the necessary requests (the communication protocol is some in-house XML), store in a static way the received XML and then write some tests on those static data using unitest.\nMy question is: Is this a correct approach and if yes, what kind of tests are covered with this approach?\nAlso, using this method has several disadvantages, like: not being able to access the database layer in order to build\/rebuild the schema, when will the test client going to connect to the server: per each unit test or before running the test suite?","AnswerCount":4,"Available Count":3,"Score":0.049958375,"is_accepted":false,"ViewCount":1357,"Q_Id":464543,"Users Score":1,"Answer":"I think you chose the wrong direction. It's true that the Trial docs is very light. But Trial is base on unittest and only add some stuff to deal with the reactor loop and the asynchronous calls (it's not easy to write tests that deal with deffers). All your tests that are not including deffer\/asynchronous call will be exactly like normal unittest.\nThe Trial command is a test runner (a bit like nose), so you don't have to write test suites for your tests. You will save time with it. On top of that, the Trial command can output profiling and coverage information. Just do Trial -h for more info.\nBut in any way the first thing you should ask yourself is which kind of tests do you need the most, unit tests, integration tests or system tests (black-box). It's possible to do all with Trial but it's not necessary allways the best fit.","Q_Score":3,"Tags":"python,unit-testing,twisted","A_Id":465422,"CreationDate":"2009-01-21T09:15:00.000","Title":"unit testing for an application 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":1,"Web Development":1},{"Question":"I wrote an application server (using python & twisted) and I want to start writing some tests. But I do not want to use Twisted's Trial due to time constraints and not having time to play with it now. So here is what I have in mind: write a small test client that connects to the app server and makes the necessary requests (the communication protocol is some in-house XML), store in a static way the received XML and then write some tests on those static data using unitest.\nMy question is: Is this a correct approach and if yes, what kind of tests are covered with this approach?\nAlso, using this method has several disadvantages, like: not being able to access the database layer in order to build\/rebuild the schema, when will the test client going to connect to the server: per each unit test or before running the test suite?","AnswerCount":4,"Available Count":3,"Score":1.2,"is_accepted":true,"ViewCount":1357,"Q_Id":464543,"Users Score":1,"Answer":"\"My question is: Is this a correct approach?\"\nIt's what you chose. You made a lot of excuses, so I'm assuming that your pretty well fixed on this course. It's not the best, but you've already listed all your reasons for doing it (and then asked follow-up questions on this specific course of action). \"correct\" doesn't enter into it anymore, so there's no answer to this question.\n\"what kind of tests are covered with this approach?\"\nThey call it \"black-box\" testing. The application server is a black box that has a few inputs and outputs, and you can't test any of it's internals. It's considered one acceptable form of testing because it tests the bottom-line external interfaces for acceptable behavior.\nIf you have problems, it turns out to be useless for doing diagnostic work. You'll find that you need to also to white-box testing on the internal structures. \n\"not being able to access the database layer in order to build\/rebuild the schema,\" \nWhy not? This is Python. Write a separate tool that imports that layer and does database builds.\n\"when will the test client going to connect to the server: per each unit test or before running the test suite?\"\nDepends on the intent of the test. Depends on your use cases. What happens in the \"real world\" with your actual intended clients?\nYou'll want to test client-like behavior, making connections the way clients make connections.\nAlso, you'll want to test abnormal behavior, like clients dropping connections or doing things out of order, or unconnected.","Q_Score":3,"Tags":"python,unit-testing,twisted","A_Id":464870,"CreationDate":"2009-01-21T09:15:00.000","Title":"unit testing for an application 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":1,"Web Development":1},{"Question":"I wrote an application server (using python & twisted) and I want to start writing some tests. But I do not want to use Twisted's Trial due to time constraints and not having time to play with it now. So here is what I have in mind: write a small test client that connects to the app server and makes the necessary requests (the communication protocol is some in-house XML), store in a static way the received XML and then write some tests on those static data using unitest.\nMy question is: Is this a correct approach and if yes, what kind of tests are covered with this approach?\nAlso, using this method has several disadvantages, like: not being able to access the database layer in order to build\/rebuild the schema, when will the test client going to connect to the server: per each unit test or before running the test suite?","AnswerCount":4,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":1357,"Q_Id":464543,"Users Score":0,"Answer":"haven't used twisted before, and the twisted\/trial documentation isn't stellar from what I just saw, but it'll likely take you 2-3 days to implement correctly the test system you describe above. Now, like I said I have no idea about Trial, but I GUESS you could probably get it working in 1-2 days, since you already have a Twisted application. Now if Trial gives you more coverage in less time, I'd go with Trial.\nBut remember this is just an answer from a very cursory look at the docs","Q_Score":3,"Tags":"python,unit-testing,twisted","A_Id":464596,"CreationDate":"2009-01-21T09:15:00.000","Title":"unit testing for an application 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":1,"Web Development":1},{"Question":"I'm curious about how .NET will affect Python and Ruby applications. \nWill applications written in IronPython\/IronRuby be so specific to the .NET environment, that they will essentially become platform specific? \nIf they don't use any of the .NET features, then what is the advantage of IronPython\/IronRuby over their non .NET counterparts?","AnswerCount":7,"Available Count":6,"Score":0.0285636566,"is_accepted":false,"ViewCount":501,"Q_Id":466897,"Users Score":1,"Answer":"IronPython\/IronRuby are built to work on the .net virtual machine, so they are as you say essentially platform specific. \nApparently they are compatible with Python and Ruby as long as you don't use any of the .net framework in your programs.","Q_Score":5,"Tags":".net,python,ruby,ironpython,ironruby","A_Id":466930,"CreationDate":"2009-01-21T20:43:00.000","Title":"How will Python and Ruby applications be affected by .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":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm curious about how .NET will affect Python and Ruby applications. \nWill applications written in IronPython\/IronRuby be so specific to the .NET environment, that they will essentially become platform specific? \nIf they don't use any of the .NET features, then what is the advantage of IronPython\/IronRuby over their non .NET counterparts?","AnswerCount":7,"Available Count":6,"Score":0.0,"is_accepted":false,"ViewCount":501,"Q_Id":466897,"Users Score":0,"Answer":"You answer your first question with the second one, if you don't use anything from .Net only the original libs provided by the implementation of the language, you could interpret your *.py or *.rb file with another implementation and it should work.\nThe advantage would be if your a .Net shop you usually take care of having the right framework installed on client machine etc... well if you want python or ruby code, you now need to support another \"framework\" need to distribute install, take care of version problem etc... So there 2 advantages, using .Net framework power inside another language + keep the distribution\/maintenance as simple as possible.","Q_Score":5,"Tags":".net,python,ruby,ironpython,ironruby","A_Id":467031,"CreationDate":"2009-01-21T20:43:00.000","Title":"How will Python and Ruby applications be affected by .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":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm curious about how .NET will affect Python and Ruby applications. \nWill applications written in IronPython\/IronRuby be so specific to the .NET environment, that they will essentially become platform specific? \nIf they don't use any of the .NET features, then what is the advantage of IronPython\/IronRuby over their non .NET counterparts?","AnswerCount":7,"Available Count":6,"Score":0.0,"is_accepted":false,"ViewCount":501,"Q_Id":466897,"Users Score":0,"Answer":"It would be cool to run Rails\/Django under IIS rather then Apache\/Mongrel type solutions","Q_Score":5,"Tags":".net,python,ruby,ironpython,ironruby","A_Id":467067,"CreationDate":"2009-01-21T20:43:00.000","Title":"How will Python and Ruby applications be affected by .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":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm curious about how .NET will affect Python and Ruby applications. \nWill applications written in IronPython\/IronRuby be so specific to the .NET environment, that they will essentially become platform specific? \nIf they don't use any of the .NET features, then what is the advantage of IronPython\/IronRuby over their non .NET counterparts?","AnswerCount":7,"Available Count":6,"Score":0.0285636566,"is_accepted":false,"ViewCount":501,"Q_Id":466897,"Users Score":1,"Answer":"If you create a library or framework, people can use it on .NET with their .NET code. That's pretty cool for them, and for you!\nWhen developing an application, if you use .NET's facilities with abandon then you lose \"cross-platformity\", which is not always an issue.\nIf you wrap these uses with an internal API, you can replace the .NET implementations later with pure-Python, wrapped C (for CPython), or Java (for Jython) later.","Q_Score":5,"Tags":".net,python,ruby,ironpython,ironruby","A_Id":467145,"CreationDate":"2009-01-21T20:43:00.000","Title":"How will Python and Ruby applications be affected by .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":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm curious about how .NET will affect Python and Ruby applications. \nWill applications written in IronPython\/IronRuby be so specific to the .NET environment, that they will essentially become platform specific? \nIf they don't use any of the .NET features, then what is the advantage of IronPython\/IronRuby over their non .NET counterparts?","AnswerCount":7,"Available Count":6,"Score":0.0285636566,"is_accepted":false,"ViewCount":501,"Q_Id":466897,"Users Score":1,"Answer":"According to the Mono page, IronPython is compatible with Mono's implementation of the .Net runtime, so executables should work both on Windows and Linux.","Q_Score":5,"Tags":".net,python,ruby,ironpython,ironruby","A_Id":467385,"CreationDate":"2009-01-21T20:43:00.000","Title":"How will Python and Ruby applications be affected by .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":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm curious about how .NET will affect Python and Ruby applications. \nWill applications written in IronPython\/IronRuby be so specific to the .NET environment, that they will essentially become platform specific? \nIf they don't use any of the .NET features, then what is the advantage of IronPython\/IronRuby over their non .NET counterparts?","AnswerCount":7,"Available Count":6,"Score":0.057080742,"is_accepted":false,"ViewCount":501,"Q_Id":466897,"Users Score":2,"Answer":"Will applications written in IronPython\/IronRuby be so specific to the .NET environment, that they will essentially become platform specific?\n\nIronRuby currently ships with most of the core ruby standard library, and support for ruby gems.\nThis means that it will support pretty much any native ruby app that doesn't rely on C extensions.\nThe flipside is that it will be possible to write native ruby apps in IronRuby that don't rely on the CLR, and those will be portable to MRI. \nWhether or not people choose to create or use extensions for their apps using the CLR is the same question as to whether people create or use C extensions for MRI - one is no more portable than the other.\nThere is a side-question of \"because it is so much easier to create IronRuby extensions in C# than it is to create CRuby extensions in C, will people create extensions where they should be sticking to native ruby code?\", but that's entirely subjective.\nOn the whole though, I think anything that makes creating extensions easier is a big win.\n\n\nIf they don't use any of the .NET features, then what is the advantage of IronPython\/IronRuby over their non .NET counterparts?\n\n\nPerformance: IronRuby is already faster for the most part than MRI 1.8, and isn't far off MRI 1.9, and things will only improve in future. I think python is similar in this respect.\nDeployment: As people have mentioned, running a native ruby cross-platform rails app inside IIS is an attractive proposition to some windows-based developers, as it lets them better integrate with existing servers\/management infrastructure\/etc\nStability: While MRI 1.9 is much better than 1.8 was, I don't think anyone could disagree that CLR has a much better garbage collector and base runtime than C ruby does.","Q_Score":5,"Tags":".net,python,ruby,ironpython,ironruby","A_Id":1285474,"CreationDate":"2009-01-21T20:43:00.000","Title":"How will Python and Ruby applications be affected by .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":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"We are ready in our company to move everything to Python instead of C#, we are a consulting company and we usually write small projects in C# we don't do huge projects and our work is more based on complex mathematical models not complex software structures. So we believe IronPython is a good platform for us because it provides standard GUI functionality on windows and access to all of .Net libraries. \nI know Ironpython studio is not complete, and in fact I had a hard time adding my references but I was wondering if someone could list some of the pros and cons of this migration for us, considering Python code is easier to read by our clients and we usually deliver a proof-of-concept prototype instead of a full-functional code, our clients usually go ahead and implement the application themselves","AnswerCount":3,"Available Count":2,"Score":1.0,"is_accepted":false,"ViewCount":5128,"Q_Id":471712,"Users Score":7,"Answer":"The way you describe things, it sounds like you're company is switching to Python simple for the sake of Python. Is there some specific reason you want to use Python? Is a more dynamic language necessary? Is the functional programming going to help you at all? If you've got a perfectly good working set of tools in C#, why bother switching?\nIf you're set on switching, you may want to consider starting with standard Python unless you're specifically tied to the .NET libraries. You can write cross platform GUIs using a number of different frameworks like wxPython, pyQt, etc. That said, Visual Studio has a far superior GUI designer to just about any of the tools out there for creating Python windowed layouts.","Q_Score":16,"Tags":"python,ironpython,ironpython-studio","A_Id":471725,"CreationDate":"2009-01-23T02:49:00.000","Title":"Pros and cons of IronPython and IronPython 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":0},{"Question":"We are ready in our company to move everything to Python instead of C#, we are a consulting company and we usually write small projects in C# we don't do huge projects and our work is more based on complex mathematical models not complex software structures. So we believe IronPython is a good platform for us because it provides standard GUI functionality on windows and access to all of .Net libraries. \nI know Ironpython studio is not complete, and in fact I had a hard time adding my references but I was wondering if someone could list some of the pros and cons of this migration for us, considering Python code is easier to read by our clients and we usually deliver a proof-of-concept prototype instead of a full-functional code, our clients usually go ahead and implement the application themselves","AnswerCount":3,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":5128,"Q_Id":471712,"Users Score":18,"Answer":"My company, Resolver Systems, develops what is probably the biggest application written in IronPython yet. (It's called Resolver One, and it's a Pythonic spreadsheet). We are also hosting the Ironclad project (to run CPython extensions under IronPython) and that is going well (we plan to release a beta of Resolver One & numpy soon).\nThe reason we chose IronPython was the .NET integration - our clients want 100% integration on Windows and the easiest way to do that right now is .NET. \nWe design our GUI (without behaviour) in Visual Studio, compile it into a DLL and subclass it from IronPython to add behaviour.\nWe have found that IronPython is faster at some cases and slower at some others. However, the IronPython team is very responsive, whenever we report a regression they fix it and usually backport it to the bugfix release. If you worry about performance, you can always implement a critical part in C# (we haven't had to do that yet).\nIf you have experience with C#, then IronPython will be natural for you, and easier than C#, especially for prototypes.\nRegarding IronPython studio, we don't use it. Each of us has his editor of choice (TextPad, Emacs, Vim & Wing), and everything works fine.","Q_Score":16,"Tags":"python,ironpython,ironpython-studio","A_Id":472355,"CreationDate":"2009-01-23T02:49:00.000","Title":"Pros and cons of IronPython and IronPython 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":0},{"Question":"If there is truly a 'best' way, what is the best way to ship a python app and ensure people can't (easily) reverse engineer your algorithms\/security\/work in general?\nIf there isn't a 'best' way, what are the different options available?\nBackground:\nI love coding in Python and would love to release more apps with it. One thing that I wonder about is the possibility of people circumventing any licensing code I put in, or being able to just rip off my entire source base. I've heard of Py2Exe and similar applications, but I'm curious if there are 'preferred' ways of doing it, or if this problem is just a fact of life.","AnswerCount":5,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":12980,"Q_Id":475216,"Users Score":13,"Answer":"Security through obscurity never works. If you must use a proprietary license, enforce it through the law, not half-baked obfuscation attempts.\nIf you're worried about them learning your security (e.g. cryptography) algorithm, the same applies. Real, useful, security algorithms (like AES) are secure even though the algorithm is fully known.","Q_Score":8,"Tags":"python,security,reverse-engineering","A_Id":475246,"CreationDate":"2009-01-24T00:40:00.000","Title":"Python Applications: Can You Secure Your Code Somehow?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"If there is truly a 'best' way, what is the best way to ship a python app and ensure people can't (easily) reverse engineer your algorithms\/security\/work in general?\nIf there isn't a 'best' way, what are the different options available?\nBackground:\nI love coding in Python and would love to release more apps with it. One thing that I wonder about is the possibility of people circumventing any licensing code I put in, or being able to just rip off my entire source base. I've heard of Py2Exe and similar applications, but I'm curious if there are 'preferred' ways of doing it, or if this problem is just a fact of life.","AnswerCount":5,"Available Count":2,"Score":1.0,"is_accepted":false,"ViewCount":12980,"Q_Id":475216,"Users Score":8,"Answer":"Even if you use a compiled language like C# or Java, people can perform reverse engineering if they are motivated and technically competent. Obfuscation is not a reliable protection against this.\nYou can add prohibition against reverse-engineering to your end-user license agreement for your software. Most proprietary companies do this. But that doesn't prevent violation, it only gives you legal recourse.\nThe best solution is to offer products and services in which the user's access to read your code does not harm your ability to sell your product or service. Base your business on service provided, or subscription to periodic updates to data, rather than the code itself.\nExample: Slashdot actually makes their code for their website available. Does this harm their ability to run their website? No.\nAnother remedy is to set your price point such that the effort to pirate your code is more costly than simply buying legitimate licenses to use your product. Joel Spolsky has made a recommendation to this effects in his articles and podcasts.","Q_Score":8,"Tags":"python,security,reverse-engineering","A_Id":475394,"CreationDate":"2009-01-24T00:40:00.000","Title":"Python Applications: Can You Secure Your Code Somehow?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I will participate a modeling competition, which spends three days.\nI need a language which is fast and designed for modeling, such as to 2D\/3D models.\nI have considered these languages:\n\nPython\nSage\n\nWhich languages would you use?","AnswerCount":3,"Available Count":2,"Score":-0.0665680765,"is_accepted":false,"ViewCount":185,"Q_Id":477335,"Users Score":-1,"Answer":"I would use C++, since it spends three days I would have time to write C++ code, and it's a lot faster then python, which would be my choice if it were a one day competition. So I would probably use C++ with OpenGL and SDL for the models. The simulations would I first write in C++, and if I had time at the end I would try to implement them in a shader if it were possible.","Q_Score":0,"Tags":"python,sage","A_Id":477372,"CreationDate":"2009-01-25T07:40:00.000","Title":"Most suitable language(s) for simulations in modeling?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I will participate a modeling competition, which spends three days.\nI need a language which is fast and designed for modeling, such as to 2D\/3D models.\nI have considered these languages:\n\nPython\nSage\n\nWhich languages would you use?","AnswerCount":3,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":185,"Q_Id":477335,"Users Score":4,"Answer":"You should use the language that you know best and that has good-enough tools for the task at hand. Depending on when the competition is you may have no time to learn a new language\/environment.","Q_Score":0,"Tags":"python,sage","A_Id":477384,"CreationDate":"2009-01-25T07:40:00.000","Title":"Most suitable language(s) for simulations in modeling?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I just configured Eclipse with PyDev latest version, but when I import external modules, neither code completion nor syntax highlighting works. How do I enable it?\nKomodo Edit does a better synax highlighting, apparently. - But Ctrl+R doesnt run the program. \nI prefer a SciTE kind of editor with similar highlighting and fonts (aesthetics) and F5 working but with display of folder and files dynamically like Komodo Edit and a better code completion and vi emulation. Suggestions, please.\nIf I want to buy a Py IDE, Komodo or Wingware, which is better?-- Wrt syntax highlighting and code completion","AnswerCount":11,"Available Count":10,"Score":0.0,"is_accepted":false,"ViewCount":31316,"Q_Id":491053,"Users Score":0,"Answer":"Between komodo and wingide i would go for wing. The license is not that expensive and the fact that it is commercial gives you a bigger probability of more updates and bug fixes. If you, like me, prefer a free solution, then stick with pydev. At least until aptana closes the free door :)","Q_Score":18,"Tags":"python,ide","A_Id":495362,"CreationDate":"2009-01-29T09:50:00.000","Title":"No code completion and syntax highlighting in Pydev","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},{"Question":"I just configured Eclipse with PyDev latest version, but when I import external modules, neither code completion nor syntax highlighting works. How do I enable it?\nKomodo Edit does a better synax highlighting, apparently. - But Ctrl+R doesnt run the program. \nI prefer a SciTE kind of editor with similar highlighting and fonts (aesthetics) and F5 working but with display of folder and files dynamically like Komodo Edit and a better code completion and vi emulation. Suggestions, please.\nIf I want to buy a Py IDE, Komodo or Wingware, which is better?-- Wrt syntax highlighting and code completion","AnswerCount":11,"Available Count":10,"Score":0.0363476168,"is_accepted":false,"ViewCount":31316,"Q_Id":491053,"Users Score":2,"Answer":"Check to see if the 'P' icon is appearing for your items and in the top of your editor after opening it. If it's not appearing, it may be that there's a problem with the file association, so, go to window > preferences > general > editors > file associations and make sure that the .py files are associated with the Python Editor (note that because of an eclipse bug, if it seems correct, you may have to remove the association and add it again)","Q_Score":18,"Tags":"python,ide","A_Id":1399741,"CreationDate":"2009-01-29T09:50:00.000","Title":"No code completion and syntax highlighting in Pydev","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},{"Question":"I just configured Eclipse with PyDev latest version, but when I import external modules, neither code completion nor syntax highlighting works. How do I enable it?\nKomodo Edit does a better synax highlighting, apparently. - But Ctrl+R doesnt run the program. \nI prefer a SciTE kind of editor with similar highlighting and fonts (aesthetics) and F5 working but with display of folder and files dynamically like Komodo Edit and a better code completion and vi emulation. Suggestions, please.\nIf I want to buy a Py IDE, Komodo or Wingware, which is better?-- Wrt syntax highlighting and code completion","AnswerCount":11,"Available Count":10,"Score":0.0181798149,"is_accepted":false,"ViewCount":31316,"Q_Id":491053,"Users Score":1,"Answer":"It sounds like you have to specify the location of the Python interpreter. Do this under Preferences > Pydev > Interpreter - Python. Create a new interpreter and point it to the Python interpreter executable.","Q_Score":18,"Tags":"python,ide","A_Id":4665424,"CreationDate":"2009-01-29T09:50:00.000","Title":"No code completion and syntax highlighting in Pydev","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},{"Question":"I just configured Eclipse with PyDev latest version, but when I import external modules, neither code completion nor syntax highlighting works. How do I enable it?\nKomodo Edit does a better synax highlighting, apparently. - But Ctrl+R doesnt run the program. \nI prefer a SciTE kind of editor with similar highlighting and fonts (aesthetics) and F5 working but with display of folder and files dynamically like Komodo Edit and a better code completion and vi emulation. Suggestions, please.\nIf I want to buy a Py IDE, Komodo or Wingware, which is better?-- Wrt syntax highlighting and code completion","AnswerCount":11,"Available Count":10,"Score":0.0906594778,"is_accepted":false,"ViewCount":31316,"Q_Id":491053,"Users Score":5,"Answer":"Make sure you use 'Open With' as 'Python Editor' by right clicking on the file - It worked for me","Q_Score":18,"Tags":"python,ide","A_Id":17847161,"CreationDate":"2009-01-29T09:50:00.000","Title":"No code completion and syntax highlighting in Pydev","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},{"Question":"I just configured Eclipse with PyDev latest version, but when I import external modules, neither code completion nor syntax highlighting works. How do I enable it?\nKomodo Edit does a better synax highlighting, apparently. - But Ctrl+R doesnt run the program. \nI prefer a SciTE kind of editor with similar highlighting and fonts (aesthetics) and F5 working but with display of folder and files dynamically like Komodo Edit and a better code completion and vi emulation. Suggestions, please.\nIf I want to buy a Py IDE, Komodo or Wingware, which is better?-- Wrt syntax highlighting and code completion","AnswerCount":11,"Available Count":10,"Score":0.0,"is_accepted":false,"ViewCount":31316,"Q_Id":491053,"Users Score":0,"Answer":"Check your Theme configuration. Python highlighting uses Theme Colors","Q_Score":18,"Tags":"python,ide","A_Id":18933901,"CreationDate":"2009-01-29T09:50:00.000","Title":"No code completion and syntax highlighting in Pydev","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},{"Question":"I just configured Eclipse with PyDev latest version, but when I import external modules, neither code completion nor syntax highlighting works. How do I enable it?\nKomodo Edit does a better synax highlighting, apparently. - But Ctrl+R doesnt run the program. \nI prefer a SciTE kind of editor with similar highlighting and fonts (aesthetics) and F5 working but with display of folder and files dynamically like Komodo Edit and a better code completion and vi emulation. Suggestions, please.\nIf I want to buy a Py IDE, Komodo or Wingware, which is better?-- Wrt syntax highlighting and code completion","AnswerCount":11,"Available Count":10,"Score":0.0,"is_accepted":false,"ViewCount":31316,"Q_Id":491053,"Users Score":0,"Answer":"In case anyone else makes the embarrassing mistake that I did: be sure your source code file actually ends with \".py\". Even if its in a Python project, PyDev won't guess without the extension.","Q_Score":18,"Tags":"python,ide","A_Id":19301447,"CreationDate":"2009-01-29T09:50:00.000","Title":"No code completion and syntax highlighting in Pydev","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},{"Question":"I just configured Eclipse with PyDev latest version, but when I import external modules, neither code completion nor syntax highlighting works. How do I enable it?\nKomodo Edit does a better synax highlighting, apparently. - But Ctrl+R doesnt run the program. \nI prefer a SciTE kind of editor with similar highlighting and fonts (aesthetics) and F5 working but with display of folder and files dynamically like Komodo Edit and a better code completion and vi emulation. Suggestions, please.\nIf I want to buy a Py IDE, Komodo or Wingware, which is better?-- Wrt syntax highlighting and code completion","AnswerCount":11,"Available Count":10,"Score":0.0,"is_accepted":false,"ViewCount":31316,"Q_Id":491053,"Users Score":0,"Answer":"When syntax highlighting was not working for me using PyDev, I discovered that there were somehow two 'Python Editor' associations defined for .py files in my installation of Eclipse\/PyDev. From the Eclipse Main Menu, go to Window > Preferences > General > Editors > FileAssociations to see the file extension <-> editor mapping. I set a different one as default for .py files at the bottom of the dialog, and got syntax highlighting working again.","Q_Score":18,"Tags":"python,ide","A_Id":35208736,"CreationDate":"2009-01-29T09:50:00.000","Title":"No code completion and syntax highlighting in Pydev","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},{"Question":"I just configured Eclipse with PyDev latest version, but when I import external modules, neither code completion nor syntax highlighting works. How do I enable it?\nKomodo Edit does a better synax highlighting, apparently. - But Ctrl+R doesnt run the program. \nI prefer a SciTE kind of editor with similar highlighting and fonts (aesthetics) and F5 working but with display of folder and files dynamically like Komodo Edit and a better code completion and vi emulation. Suggestions, please.\nIf I want to buy a Py IDE, Komodo or Wingware, which is better?-- Wrt syntax highlighting and code completion","AnswerCount":11,"Available Count":10,"Score":0.0,"is_accepted":false,"ViewCount":31316,"Q_Id":491053,"Users Score":0,"Answer":"Well, I tried the Wing Professional and I think its really the best Py IDE out there.","Q_Score":18,"Tags":"python,ide","A_Id":495297,"CreationDate":"2009-01-29T09:50:00.000","Title":"No code completion and syntax highlighting in Pydev","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},{"Question":"I just configured Eclipse with PyDev latest version, but when I import external modules, neither code completion nor syntax highlighting works. How do I enable it?\nKomodo Edit does a better synax highlighting, apparently. - But Ctrl+R doesnt run the program. \nI prefer a SciTE kind of editor with similar highlighting and fonts (aesthetics) and F5 working but with display of folder and files dynamically like Komodo Edit and a better code completion and vi emulation. Suggestions, please.\nIf I want to buy a Py IDE, Komodo or Wingware, which is better?-- Wrt syntax highlighting and code completion","AnswerCount":11,"Available Count":10,"Score":1.0,"is_accepted":false,"ViewCount":31316,"Q_Id":491053,"Users Score":13,"Answer":"The typical reason that code completion doesn't work under PyDev is that the libraries aren't in the PYTHONPATH. If you go into the Project Properties, and setup PyDev PYTHONPATH preferences to include the places where the code you are trying to complete lives, it will work just fine...\nProject > Properties > PyDev-PYTHONPAH > click 'Add source folder'","Q_Score":18,"Tags":"python,ide","A_Id":1836524,"CreationDate":"2009-01-29T09:50:00.000","Title":"No code completion and syntax highlighting in Pydev","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},{"Question":"I just configured Eclipse with PyDev latest version, but when I import external modules, neither code completion nor syntax highlighting works. How do I enable it?\nKomodo Edit does a better synax highlighting, apparently. - But Ctrl+R doesnt run the program. \nI prefer a SciTE kind of editor with similar highlighting and fonts (aesthetics) and F5 working but with display of folder and files dynamically like Komodo Edit and a better code completion and vi emulation. Suggestions, please.\nIf I want to buy a Py IDE, Komodo or Wingware, which is better?-- Wrt syntax highlighting and code completion","AnswerCount":11,"Available Count":10,"Score":1.2,"is_accepted":true,"ViewCount":31316,"Q_Id":491053,"Users Score":23,"Answer":"To enable code completion, go to Window > Preferences > Pydev > Editor > Code Completion, and check the 'Use Code Completion?' box, as well as the other boxes for what you want to complete on. It seems to take a second to load, the first time it has to complete something.\nSyntax coloring should just work by default. Right-click on the file in the package explorer, go to 'Open With', and make sure you're opening it with the Python Editor, and not the regular Text Editor.\nI don't know exactly what you mean by importing external modules. I have my source in a separate directory structure on disk; my PyDev projects contain folders linked to those. Code completion works for that, as well as other modules like 'os'. If you're having troubles, are the modules added to the PyDev's Python search path (not necessarily the same as the regular one)?\nI took a brief look at Komodo and Wingware a while back, so I can't answer the second part of your question. But ended up going with PyDev. I'm not a big fan of Eclipse, but PyDev works reasonably well for me.","Q_Score":18,"Tags":"python,ide","A_Id":492073,"CreationDate":"2009-01-29T09:50:00.000","Title":"No code completion and syntax highlighting in Pydev","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},{"Question":"I want to have some work done on the Network front, pinging numerous computers on a LAN and retrieving data about the response time. Which would be the most useful and productive to work with: Perl or Python?","AnswerCount":9,"Available Count":3,"Score":0.022218565,"is_accepted":false,"ViewCount":7896,"Q_Id":491380,"Users Score":1,"Answer":"Right now I've experimented the approach of creating some simple unit test for network services using various TAP libraries (mainly bash+netcat+curl and perl). The advantage is that you wrote a single script that you can use for both unit and network testing.\nThe display is dove via TAP::Harness::HTML.","Q_Score":3,"Tags":"python,perl,networking,scripting-language","A_Id":4275651,"CreationDate":"2009-01-29T12:22:00.000","Title":"Should I use Perl or Python for network monitoring?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I want to have some work done on the Network front, pinging numerous computers on a LAN and retrieving data about the response time. Which would be the most useful and productive to work with: Perl or Python?","AnswerCount":9,"Available Count":3,"Score":0.022218565,"is_accepted":false,"ViewCount":7896,"Q_Id":491380,"Users Score":1,"Answer":"Whichever you know better or are more comfortable using. They both can do the job and do it well, so it is your preference.","Q_Score":3,"Tags":"python,perl,networking,scripting-language","A_Id":492708,"CreationDate":"2009-01-29T12:22:00.000","Title":"Should I use Perl or Python for network monitoring?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I want to have some work done on the Network front, pinging numerous computers on a LAN and retrieving data about the response time. Which would be the most useful and productive to work with: Perl or Python?","AnswerCount":9,"Available Count":3,"Score":-0.022218565,"is_accepted":false,"ViewCount":7896,"Q_Id":491380,"Users Score":-1,"Answer":"I'd say that if you need something quick and dirty that's up and running by this afternoon, then perl is probably the better language.\nHowever for developing solid application that's easy to maintain and extend and that you can build on over time, I'd go with python.\nThis is of course assuming you know both languages more or less equally well.","Q_Score":3,"Tags":"python,perl,networking,scripting-language","A_Id":491625,"CreationDate":"2009-01-29T12:22:00.000","Title":"Should I use Perl or Python for network monitoring?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"My primary language right now is D, and I'm in the process of learning Python because it's required for a course I'm taking. While I understand why dynamic languages would be a breath of fresh air for people programming in static languages without type inference or templates (IMHO templates are to a large extent compile-time duck typing), I'm curious what the benefits are of dynamic languages even when you have those. \nThe bottom line is that, if I'm going to learn Python, I want to learn it in a way that really changes my thinking about programming, rather than just writing D in Python. I have not used dynamic languages since I was a fairly novice programmer and unable to appreciate the flexibility they supposedly offer, and want to learn to take full advantage of them now. What can be done easily\/elegantly in a dynamically typed, interpreted language that's awkward or impossible in a static language, even with templates, polymorphism, static type inference, and maybe runtime reflection?","AnswerCount":13,"Available Count":7,"Score":0.0,"is_accepted":false,"ViewCount":1456,"Q_Id":493973,"Users Score":0,"Answer":"I find dynamic languages like Perl and to a lesser extent Python allow me to write quick and dirty scripts for things I need to do. The run cycle is much shorter in dynamic languages and often less code needs to be written then in a statically typed language which increases my productivity. This unfortunately comes at the cost of maintainability but that is a fault of the way I write programs in dynamic languages not in the languages them selves.","Q_Score":8,"Tags":"python,programming-languages,language-design,dynamic-languages,duck-typing","A_Id":494118,"CreationDate":"2009-01-29T23:42:00.000","Title":"Uses for Dynamic 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},{"Question":"My primary language right now is D, and I'm in the process of learning Python because it's required for a course I'm taking. While I understand why dynamic languages would be a breath of fresh air for people programming in static languages without type inference or templates (IMHO templates are to a large extent compile-time duck typing), I'm curious what the benefits are of dynamic languages even when you have those. \nThe bottom line is that, if I'm going to learn Python, I want to learn it in a way that really changes my thinking about programming, rather than just writing D in Python. I have not used dynamic languages since I was a fairly novice programmer and unable to appreciate the flexibility they supposedly offer, and want to learn to take full advantage of them now. What can be done easily\/elegantly in a dynamically typed, interpreted language that's awkward or impossible in a static language, even with templates, polymorphism, static type inference, and maybe runtime reflection?","AnswerCount":13,"Available Count":7,"Score":0.0153834017,"is_accepted":false,"ViewCount":1456,"Q_Id":493973,"Users Score":1,"Answer":"The point is that in a dynamic language you can implement the same functionality much quicker than in a statically typed one. Therefore the productivity is typically much higher.\nThings like templates or polymorphism in principle give you lots of flexibility, but you have to write a large amount of code to make it work. In a dynamic language this flexibility almost comes for free.\nSo I think you look at the difference in the wrong way, productivity really is the main point here (just like garbage collection improves productivity, but otherwise does not really allow you to do new things).","Q_Score":8,"Tags":"python,programming-languages,language-design,dynamic-languages,duck-typing","A_Id":495293,"CreationDate":"2009-01-29T23:42:00.000","Title":"Uses for Dynamic 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},{"Question":"My primary language right now is D, and I'm in the process of learning Python because it's required for a course I'm taking. While I understand why dynamic languages would be a breath of fresh air for people programming in static languages without type inference or templates (IMHO templates are to a large extent compile-time duck typing), I'm curious what the benefits are of dynamic languages even when you have those. \nThe bottom line is that, if I'm going to learn Python, I want to learn it in a way that really changes my thinking about programming, rather than just writing D in Python. I have not used dynamic languages since I was a fairly novice programmer and unable to appreciate the flexibility they supposedly offer, and want to learn to take full advantage of them now. What can be done easily\/elegantly in a dynamically typed, interpreted language that's awkward or impossible in a static language, even with templates, polymorphism, static type inference, and maybe runtime reflection?","AnswerCount":13,"Available Count":7,"Score":0.0153834017,"is_accepted":false,"ViewCount":1456,"Q_Id":493973,"Users Score":1,"Answer":"One big advantage of dynamic typing when using objects is that you don't need to use class hierarchies anymore when you want several classes to have the same interface - that's more or less what is called duck typing. Bad inheritance is very difficult to fix afterwards - this makes refactoring often harder than it is in a language like python.","Q_Score":8,"Tags":"python,programming-languages,language-design,dynamic-languages,duck-typing","A_Id":494423,"CreationDate":"2009-01-29T23:42:00.000","Title":"Uses for Dynamic 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},{"Question":"My primary language right now is D, and I'm in the process of learning Python because it's required for a course I'm taking. While I understand why dynamic languages would be a breath of fresh air for people programming in static languages without type inference or templates (IMHO templates are to a large extent compile-time duck typing), I'm curious what the benefits are of dynamic languages even when you have those. \nThe bottom line is that, if I'm going to learn Python, I want to learn it in a way that really changes my thinking about programming, rather than just writing D in Python. I have not used dynamic languages since I was a fairly novice programmer and unable to appreciate the flexibility they supposedly offer, and want to learn to take full advantage of them now. What can be done easily\/elegantly in a dynamically typed, interpreted language that's awkward or impossible in a static language, even with templates, polymorphism, static type inference, and maybe runtime reflection?","AnswerCount":13,"Available Count":7,"Score":-0.0307595242,"is_accepted":false,"ViewCount":1456,"Q_Id":493973,"Users Score":-2,"Answer":"Compiled languages tend to be used when efficiency and type safety are the priorities. Otherwise I can't think of any reason why anyone wouldn't be using ruby :)","Q_Score":8,"Tags":"python,programming-languages,language-design,dynamic-languages,duck-typing","A_Id":494121,"CreationDate":"2009-01-29T23:42:00.000","Title":"Uses for Dynamic 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},{"Question":"My primary language right now is D, and I'm in the process of learning Python because it's required for a course I'm taking. While I understand why dynamic languages would be a breath of fresh air for people programming in static languages without type inference or templates (IMHO templates are to a large extent compile-time duck typing), I'm curious what the benefits are of dynamic languages even when you have those. \nThe bottom line is that, if I'm going to learn Python, I want to learn it in a way that really changes my thinking about programming, rather than just writing D in Python. I have not used dynamic languages since I was a fairly novice programmer and unable to appreciate the flexibility they supposedly offer, and want to learn to take full advantage of them now. What can be done easily\/elegantly in a dynamically typed, interpreted language that's awkward or impossible in a static language, even with templates, polymorphism, static type inference, and maybe runtime reflection?","AnswerCount":13,"Available Count":7,"Score":0.0153834017,"is_accepted":false,"ViewCount":1456,"Q_Id":493973,"Users Score":1,"Answer":"In dynamic languages you can use values in ways that you know are correct. In a statically typed language you can only use values in ways the compiler knows are correct. You need all of the things you mentioned to regain flexibility that's taken away by the type system (I'm not bashing static type systems, the flexibility is often taken away for good reasons). This is a lot of complexity that you don't have to deal with in a dynamic language if you want to use values in ways the language designer didn't anticipate (for example, putting values of different types in a hash table).\nSo it's not that you can't do these things in a statically typed language (if you have runtime reflection), it's just more complicated.","Q_Score":8,"Tags":"python,programming-languages,language-design,dynamic-languages,duck-typing","A_Id":494009,"CreationDate":"2009-01-29T23:42:00.000","Title":"Uses for Dynamic 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},{"Question":"My primary language right now is D, and I'm in the process of learning Python because it's required for a course I'm taking. While I understand why dynamic languages would be a breath of fresh air for people programming in static languages without type inference or templates (IMHO templates are to a large extent compile-time duck typing), I'm curious what the benefits are of dynamic languages even when you have those. \nThe bottom line is that, if I'm going to learn Python, I want to learn it in a way that really changes my thinking about programming, rather than just writing D in Python. I have not used dynamic languages since I was a fairly novice programmer and unable to appreciate the flexibility they supposedly offer, and want to learn to take full advantage of them now. What can be done easily\/elegantly in a dynamically typed, interpreted language that's awkward or impossible in a static language, even with templates, polymorphism, static type inference, and maybe runtime reflection?","AnswerCount":13,"Available Count":7,"Score":0.0,"is_accepted":false,"ViewCount":1456,"Q_Id":493973,"Users Score":0,"Answer":"With a dynamic language it's much easier to have a command line interpreter so you can test things on the command line and don't have to worry about a compile step to see if they work.","Q_Score":8,"Tags":"python,programming-languages,language-design,dynamic-languages,duck-typing","A_Id":493993,"CreationDate":"2009-01-29T23:42:00.000","Title":"Uses for Dynamic 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},{"Question":"My primary language right now is D, and I'm in the process of learning Python because it's required for a course I'm taking. While I understand why dynamic languages would be a breath of fresh air for people programming in static languages without type inference or templates (IMHO templates are to a large extent compile-time duck typing), I'm curious what the benefits are of dynamic languages even when you have those. \nThe bottom line is that, if I'm going to learn Python, I want to learn it in a way that really changes my thinking about programming, rather than just writing D in Python. I have not used dynamic languages since I was a fairly novice programmer and unable to appreciate the flexibility they supposedly offer, and want to learn to take full advantage of them now. What can be done easily\/elegantly in a dynamically typed, interpreted language that's awkward or impossible in a static language, even with templates, polymorphism, static type inference, and maybe runtime reflection?","AnswerCount":13,"Available Count":7,"Score":1.2,"is_accepted":true,"ViewCount":1456,"Q_Id":493973,"Users Score":15,"Answer":"In theory, there's nothing that dynamic languages can do and static languages can't. Smart people put a lot of work into making very good dynamic languages, leading to a perception at the moment that dynamic languages are ahead while static ones need to catch up.\nIn time, this will swing the other way. Already various static languages have:\n\nGenerics, which make static types less stupid by letting it select the right type when objects are passed around, saving the programmer from having to cast it themselves\nType inference, which saves having to waste time on writing the stuff that should be obvious\nClosures, which among many other things help to separate mechanism from intention, letting you pull together complicated algorithms from mostly existing ingredients.\nImplicit conversions, which lets you simulate \"monkey patching\" without the risks it usually involves.\nCode loading and easy programmatic access to the compiler, so users and third parties can script your program. Use with caution!\nSyntaxes that are more conducive to the creation of Domain Specific Languages within them.\n\n...and no doubt more to come. The dynamic movement has spawned some interesting developments in static language design, and we all benefit from the competition. I only hope more of these features make it to the mainstream.\nThere's one place where I don't see the dominant dynamic language being replaced, and that's Javascript in the browser. There's just too much of an existing market to replace, so the emphasis seems to be towards making Javascript itself better instead.","Q_Score":8,"Tags":"python,programming-languages,language-design,dynamic-languages,duck-typing","A_Id":494055,"CreationDate":"2009-01-29T23:42:00.000","Title":"Uses for Dynamic 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},{"Question":"I waste a lot of time between Vim and Python. I find it too slow to manually copy-paste from Python to Vim and vice versa. A good broken example is:\n\n%!python for i in xrange(25); print 6*i \\n \n\nHow can you do such tweaks direcly in Vim? [Solved]\n[Clarification] I need things to Vim, like printing sequences, arithmetics... - things I cannot do in Vim.\n[?] Can someone elaborate this point:\n\"your script can read from stdin to operate directly on the lines given (., %, ...).\" \n[Further Clarification]\nIf I want to print 'Hello' to lines 4,5, 6 and 7, what is wrong:\n\n:4-7!python -c \"print 'hello'\"\n\nThe dot . modifies the current line. Can I print on multiple lines 7, 32 and 99:\n\n:7,32,99!python -c \"print 'hello'\"\n\nClearly not working. How?","AnswerCount":12,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":20950,"Q_Id":501585,"Users Score":0,"Answer":"If I want to print 'Hello' to lines 4,5, 6 and 7, what is wrong:\n\nIf you want to do something in randomly chosen places throughout your file, you're better of recording keystrokes and replaying them. Go to the first line you want to change, and hit qz to starting recording into register z. Do whatever edits you want for that line and hit q again when you're finished. Go to the next line you want to change and press @z to replay the macro.","Q_Score":52,"Tags":"python,vim","A_Id":501812,"CreationDate":"2009-02-01T21:10:00.000","Title":"How can you use Python in Vim?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've got a number of scripts that use common definitions. How do I split them in multiple files? Furthermore, the application can not be installed in any way in my scenario; it must be possible to have an arbitrary number of versions concurrently running and it must work without superuser rights. Solutions I've come up with are:\n\nDuplicate code in every\nscript. Messy, and probably the worst\nscheme.\nPut all scripts and common\ncode in a single directory, and\nuse from . import to load them.\nThe downside of this approach is that\nI'd like to put my libraries in other\ndirectory than the applications.\nPut common\ncode in its own directory, write a __init__.py that imports all submodules and finally use from . import to load them.\nKeeps code organized, but it's a little bit of overhead to maintain __init__.py and qualify names.\nAdd the library directory to\nsys.path and\nimport. I tend to\nthis, but I'm not sure whether\nfiddling with sys.path\nis nice code.\nLoad using\nexecfile\n(exec in Python 3).\nCombines the advantages of the\nprevious two approaches: Only one\nline per module needed, and I can use\na dedicated. On the other hand, this\nevades the python module concept and\npolutes the global namespace.\nWrite and install a module using\ndistutils. This\ninstalls the library for all python\nscripts and needs superuser rights\nand impacts other applications and is hence not applicable in my case.\n\nWhat is the best method?","AnswerCount":5,"Available Count":2,"Score":0.1586485043,"is_accepted":false,"ViewCount":3665,"Q_Id":501945,"Users Score":4,"Answer":"You can set the PYTHONPATH environment variable to the directory where your library files are located. This adds that path to the library search path and you can use a normal import to import them.","Q_Score":6,"Tags":"python","A_Id":501958,"CreationDate":"2009-02-02T00:59:00.000","Title":"How to modularize a Python 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":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've got a number of scripts that use common definitions. How do I split them in multiple files? Furthermore, the application can not be installed in any way in my scenario; it must be possible to have an arbitrary number of versions concurrently running and it must work without superuser rights. Solutions I've come up with are:\n\nDuplicate code in every\nscript. Messy, and probably the worst\nscheme.\nPut all scripts and common\ncode in a single directory, and\nuse from . import to load them.\nThe downside of this approach is that\nI'd like to put my libraries in other\ndirectory than the applications.\nPut common\ncode in its own directory, write a __init__.py that imports all submodules and finally use from . import to load them.\nKeeps code organized, but it's a little bit of overhead to maintain __init__.py and qualify names.\nAdd the library directory to\nsys.path and\nimport. I tend to\nthis, but I'm not sure whether\nfiddling with sys.path\nis nice code.\nLoad using\nexecfile\n(exec in Python 3).\nCombines the advantages of the\nprevious two approaches: Only one\nline per module needed, and I can use\na dedicated. On the other hand, this\nevades the python module concept and\npolutes the global namespace.\nWrite and install a module using\ndistutils. This\ninstalls the library for all python\nscripts and needs superuser rights\nand impacts other applications and is hence not applicable in my case.\n\nWhat is the best method?","AnswerCount":5,"Available Count":2,"Score":0.0399786803,"is_accepted":false,"ViewCount":3665,"Q_Id":501945,"Users Score":1,"Answer":"I've used the third approach (add the directories to sys.path) for more than one project, and I think it's a valid approach.","Q_Score":6,"Tags":"python","A_Id":501966,"CreationDate":"2009-02-02T00:59:00.000","Title":"How to modularize a Python 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":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using postfix in my production server which will receive all the emails related to mydomain.com In this context, I want to forward only emails related to few users to different email addresses. By which I mean, lets say I am a super user(superuser@mydomain.com). I want to forward all my emails(all mails with to:superuser@mydomain.com) to my personal email id: superuser@gmail.com. So I think I would some programming logic is needed here. So I want to write a custom python script which should read the postfix email inbox and forward all new emails depending on the said criteria. Can I do this? I heard about .forward file in the postfix arena. Can I use that to achieve the same(by totally bypassing pythonic solution)?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":2899,"Q_Id":507376,"Users Score":-1,"Answer":"Procmail is the solution for mail filtering. You can call python scripts from your .procmailrc if you need more scripting.","Q_Score":0,"Tags":"python,email,smtp,postfix-mta,mailing","A_Id":507398,"CreationDate":"2009-02-03T14:54:00.000","Title":"How do I read\/retrieve emails received by local postfix, through 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},{"Question":"I have a C extension module for Python and I want to make it available to Rubyists.\nThe source has a number of C modules, with only one being Python-dependent. The rest depend only on each other and the standard library. I can build it with python setup.py build in the usual way.\nI've been experimenting with adding Ruby support using newgem and I can build a version of the extension with rake gem. However, the combined source has an ugly directory layout (mixing Gem-style and Setuptools-style structures) and the build process is a kludge.\nI can't just keep all the sources in the same directory because mkmf automatically picks up the Python-dependent module and tries to build that, and users shouldn't have to install Python to compile a module that won't be used. My current hack is for extconf.rb to copy the Python-independent source-files into the same directory as the Ruby-dependent extension module.\nIs there a saner way to make the code available to both languages? Should I just duplicate the Python-independent code in a separate Gem? Should I release the independent code as a separate lib built with autotools? Is there a version of mkmf that can skip the unwanted module?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":734,"Q_Id":511412,"Users Score":5,"Answer":"One way to solve it is to create three different projects:\n\nThe library itself, independent on python & ruby\nPython bindings\nRuby bindings\n\nThat's probably the cleanest solution, albeit it requires a bit more work when doing releases, but it has the advantage that you can release a new version of the Ruby bindings without having to ship a new library\/python bindings version.","Q_Score":8,"Tags":"python,ruby,setuptools,newgem","A_Id":511871,"CreationDate":"2009-02-04T13:42:00.000","Title":"Combined Python & Ruby extension module","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},{"Question":"My hosting service does not currently run\/allow svn, git, cvs on their server. I would really like to be able to 'sync' my current source on my development machine with my production server. \nI am looking for a pure php\/python\/ruby version control system (not just a client for a version control system) that does not require any services running on the server machine, something that could use the http interface to upload\/download and sync files - basically offering a back end into my 'live' site for version control.\nAdditionally, I would think that such a system would be easy to develop an 'online' ide for, so that I could develop directly on the production server. (issues of testing aside of course)\nDoes anyone know if such a system exists?\n==Edit==\nReally, I want a wiki front end for a version control \/ development system - Basically look like a wiki and edit development files so that I could easily make and roll back changes via the web. I doubt this exists, but it would be easy to extend an existing php port of svn...","AnswerCount":8,"Available Count":6,"Score":0.0,"is_accepted":false,"ViewCount":1960,"Q_Id":513173,"Users Score":0,"Answer":"Why dont you want a client..? A simple client that you can run on your production machine which then syncs to your repository running on another server somewhere.\nSVN is available over HTTP so writing a client that is able to sync your code is really easy in python or php.","Q_Score":2,"Tags":"php,python,version-control,web-applications","A_Id":513899,"CreationDate":"2009-02-04T20:34:00.000","Title":"pure web based versioning 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},{"Question":"My hosting service does not currently run\/allow svn, git, cvs on their server. I would really like to be able to 'sync' my current source on my development machine with my production server. \nI am looking for a pure php\/python\/ruby version control system (not just a client for a version control system) that does not require any services running on the server machine, something that could use the http interface to upload\/download and sync files - basically offering a back end into my 'live' site for version control.\nAdditionally, I would think that such a system would be easy to develop an 'online' ide for, so that I could develop directly on the production server. (issues of testing aside of course)\nDoes anyone know if such a system exists?\n==Edit==\nReally, I want a wiki front end for a version control \/ development system - Basically look like a wiki and edit development files so that I could easily make and roll back changes via the web. I doubt this exists, but it would be easy to extend an existing php port of svn...","AnswerCount":8,"Available Count":6,"Score":0.024994793,"is_accepted":false,"ViewCount":1960,"Q_Id":513173,"Users Score":1,"Answer":"I think it's actually a pretty good idea, but don't believe such a versioning system exists (yet) so hopefully you'll go ahead and make one.\nI don't think adapting an existing solution is going to be easy, but it's probably worth looking into because if you use an existing solution you'll have all the client support done, and most of the versioning difficulties taken care of.\nStarting from scratch is not going to be trivial.\n-Adam","Q_Score":2,"Tags":"php,python,version-control,web-applications","A_Id":513366,"CreationDate":"2009-02-04T20:34:00.000","Title":"pure web based versioning 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},{"Question":"My hosting service does not currently run\/allow svn, git, cvs on their server. I would really like to be able to 'sync' my current source on my development machine with my production server. \nI am looking for a pure php\/python\/ruby version control system (not just a client for a version control system) that does not require any services running on the server machine, something that could use the http interface to upload\/download and sync files - basically offering a back end into my 'live' site for version control.\nAdditionally, I would think that such a system would be easy to develop an 'online' ide for, so that I could develop directly on the production server. (issues of testing aside of course)\nDoes anyone know if such a system exists?\n==Edit==\nReally, I want a wiki front end for a version control \/ development system - Basically look like a wiki and edit development files so that I could easily make and roll back changes via the web. I doubt this exists, but it would be easy to extend an existing php port of svn...","AnswerCount":8,"Available Count":6,"Score":1.0,"is_accepted":false,"ViewCount":1960,"Q_Id":513173,"Users Score":7,"Answer":"Get a better hosting service. Seriously. Even if you found something that worked in PHP\/Ruby\/Perl\/Whatever, it would still be a sub-par solution. It most likely wouldn't integrate with any IDE you have, and wouldn't have a good tool set available for working with it. It would be really clunky to do correctly.\nThe other option is to get a free SVN host, or host SVN on your own machine, and then just push updates from your SVN host to your web site via ftp.","Q_Score":2,"Tags":"php,python,version-control,web-applications","A_Id":513231,"CreationDate":"2009-02-04T20:34:00.000","Title":"pure web based versioning 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},{"Question":"My hosting service does not currently run\/allow svn, git, cvs on their server. I would really like to be able to 'sync' my current source on my development machine with my production server. \nI am looking for a pure php\/python\/ruby version control system (not just a client for a version control system) that does not require any services running on the server machine, something that could use the http interface to upload\/download and sync files - basically offering a back end into my 'live' site for version control.\nAdditionally, I would think that such a system would be easy to develop an 'online' ide for, so that I could develop directly on the production server. (issues of testing aside of course)\nDoes anyone know if such a system exists?\n==Edit==\nReally, I want a wiki front end for a version control \/ development system - Basically look like a wiki and edit development files so that I could easily make and roll back changes via the web. I doubt this exists, but it would be easy to extend an existing php port of svn...","AnswerCount":8,"Available Count":6,"Score":0.0,"is_accepted":false,"ViewCount":1960,"Q_Id":513173,"Users Score":0,"Answer":"you could try the reverse way\n\nuse e.g. a free online svn\/git Service to version control the sources on your dev machine\nuse usual ways to update the \"production\" machine aka site, like FTP","Q_Score":2,"Tags":"php,python,version-control,web-applications","A_Id":513253,"CreationDate":"2009-02-04T20:34:00.000","Title":"pure web based versioning 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},{"Question":"My hosting service does not currently run\/allow svn, git, cvs on their server. I would really like to be able to 'sync' my current source on my development machine with my production server. \nI am looking for a pure php\/python\/ruby version control system (not just a client for a version control system) that does not require any services running on the server machine, something that could use the http interface to upload\/download and sync files - basically offering a back end into my 'live' site for version control.\nAdditionally, I would think that such a system would be easy to develop an 'online' ide for, so that I could develop directly on the production server. (issues of testing aside of course)\nDoes anyone know if such a system exists?\n==Edit==\nReally, I want a wiki front end for a version control \/ development system - Basically look like a wiki and edit development files so that I could easily make and roll back changes via the web. I doubt this exists, but it would be easy to extend an existing php port of svn...","AnswerCount":8,"Available Count":6,"Score":0.024994793,"is_accepted":false,"ViewCount":1960,"Q_Id":513173,"Users Score":1,"Answer":"Use Bazaar:\n\nLightweight. No dedicated server with Bazaar installed is needed, just FTP access to a web server. A smart server is available for those requiring additional performance or security but it is not required in many cases - Bazaar 1.x over plain http performs well.","Q_Score":2,"Tags":"php,python,version-control,web-applications","A_Id":515956,"CreationDate":"2009-02-04T20:34:00.000","Title":"pure web based versioning 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},{"Question":"My hosting service does not currently run\/allow svn, git, cvs on their server. I would really like to be able to 'sync' my current source on my development machine with my production server. \nI am looking for a pure php\/python\/ruby version control system (not just a client for a version control system) that does not require any services running on the server machine, something that could use the http interface to upload\/download and sync files - basically offering a back end into my 'live' site for version control.\nAdditionally, I would think that such a system would be easy to develop an 'online' ide for, so that I could develop directly on the production server. (issues of testing aside of course)\nDoes anyone know if such a system exists?\n==Edit==\nReally, I want a wiki front end for a version control \/ development system - Basically look like a wiki and edit development files so that I could easily make and roll back changes via the web. I doubt this exists, but it would be easy to extend an existing php port of svn...","AnswerCount":8,"Available Count":6,"Score":0.049958375,"is_accepted":false,"ViewCount":1960,"Q_Id":513173,"Users Score":2,"Answer":"Don't host your repository on your web server. Deploy from your server to the ftp\/sftp - whatever.","Q_Score":2,"Tags":"php,python,version-control,web-applications","A_Id":513322,"CreationDate":"2009-02-04T20:34:00.000","Title":"pure web based versioning 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},{"Question":"We are running a large project with several different languages: Java, Python, PHP, SQL and Perl. \nUntil now people have been working in their own private repositories, but now we want to merge the entire project in a single repository. The question now is: how should the directory structure look? Should we have separate directories for each language, or should we separate it by component\/project? How well does python\/perl\/java cope with a common directory layout?","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":1166,"Q_Id":516798,"Users Score":2,"Answer":"I think the best thing to do would be to ensure that your various modules don't depend upon being in the same directory (i.e. separate by component). A lot of people seem to be deathly afraid of this idea, but a good set of build scripts should be able to automate away any pain.\nThe end goal would be to make it easy to install the infrastructure, and then really easy to work on a single component once the environment is setup.\n(It's important to note that I come from the Perl and CL worlds, where we install \"modules\" into some global location, like ~\/perl or ~\/.sbcl, rather than including each module with each project, like Java people do. You'd think this would be a maintenance problem, but it ends up not being one. With a script that updates each module from your git repository (or CPAN) on a regular basis, it is really the best way.)\nEdit: one more thing:\nProjects always have external dependencies. My projects need Postgres and a working Linux install. It would be insane to bundle this with the app code in version control -- but a script to get everything setup on a fresh workstation is very helpful. \nI guess what I'm trying to say, in a roundabout way perhaps, is that I don't think you should treat your internal modules differently from external modules.","Q_Score":5,"Tags":"java,python,sql,directory","A_Id":518493,"CreationDate":"2009-02-05T16:57:00.000","Title":"Mixed language source directory 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":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have downloaded the Pyscripter and learning Python. But I have no Idea if it has any job value , especially in India. I am learning Python as a Hobby. But it would be comforting to know if Python programmers are in demand in India.","AnswerCount":8,"Available Count":2,"Score":0.024994793,"is_accepted":false,"ViewCount":5951,"Q_Id":520210,"Users Score":1,"Answer":"It's juste one example but I know it is widely used in large scientific institutions with high tech machinery where non-programmers (typically physicists) need quick prototypes or tools to cover their data collection\/processing needs. The easy-to access scripting language aspect clearly plays its role here. So I don't know about building a career out of that only but I'd definitely say that knowing Python is a very valuable asset on your resume, it'll strengthen your \"smell of usefulness\".","Q_Score":8,"Tags":"python","A_Id":520369,"CreationDate":"2009-02-06T13:08:00.000","Title":"Where is Python used? I read about it a lot on Reddit","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have downloaded the Pyscripter and learning Python. But I have no Idea if it has any job value , especially in India. I am learning Python as a Hobby. But it would be comforting to know if Python programmers are in demand in India.","AnswerCount":8,"Available Count":2,"Score":0.024994793,"is_accepted":false,"ViewCount":5951,"Q_Id":520210,"Users Score":1,"Answer":"In 10 years of web development I've had 1 client have me write an email parsing app with it. Not that it doesn't get used, but I've seen Ruby\/php\/.net way more often in the wild.\nEdit:\nFrom the other posts if you plan on working at Google, it sounds like the language to learn - LOL!","Q_Score":8,"Tags":"python","A_Id":520257,"CreationDate":"2009-02-06T13:08:00.000","Title":"Where is Python used? I read about it a lot on Reddit","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":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},{"Question":"What's the simplest way to do a find and replace for a given input string, say abc, and replace with another string, say XYZ in file \/tmp\/file.txt?\nI am writting an app and using IronPython to execute commands through SSH \u2014 but I don't know Unix that well and don't know what to look for.\nI have heard that Bash, apart from being a command line interface, can be a very powerful scripting language. So, if this is true, I assume you can perform actions like these.\nCan I do it with bash, and what's the simplest (one line) script to achieve my goal?","AnswerCount":17,"Available Count":2,"Score":0.0117641631,"is_accepted":false,"ViewCount":811095,"Q_Id":525592,"Users Score":1,"Answer":"For MAC users in case you don't read the comments :)\nAs mentioned by @Austin, if you get the Invalid command code error\nFor the in-place replacements BSD sed requires a file extension after the -i flag to save to a backup file with given extension.\nsed -i '.bak' 's\/find\/replace' \/file.txt\nYou can use '' empty string if you want to skip backup.\nsed -i '' 's\/find\/replace' \/file.txt\nAll merit to @Austin","Q_Score":687,"Tags":"bash,replace,scripting,ironpython","A_Id":70116740,"CreationDate":"2009-02-08T11:57:00.000","Title":"Find and Replace Inside a Text File from a Bash 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},{"Question":"What's the simplest way to do a find and replace for a given input string, say abc, and replace with another string, say XYZ in file \/tmp\/file.txt?\nI am writting an app and using IronPython to execute commands through SSH \u2014 but I don't know Unix that well and don't know what to look for.\nI have heard that Bash, apart from being a command line interface, can be a very powerful scripting language. So, if this is true, I assume you can perform actions like these.\nCan I do it with bash, and what's the simplest (one line) script to achieve my goal?","AnswerCount":17,"Available Count":2,"Score":0.0235250705,"is_accepted":false,"ViewCount":811095,"Q_Id":525592,"Users Score":2,"Answer":"Simplest way to replace multiple text in a file using sed command\nCommand -\nsed -i 's#a\/b\/c#D\/E#g;s#\/x\/y\/z#D:\/X#g;' filename\nIn the above command s#a\/b\/c#D\/E#g where I am replacing a\/b\/c with D\/E and then after the ; we again doing the same thing","Q_Score":687,"Tags":"bash,replace,scripting,ironpython","A_Id":68204228,"CreationDate":"2009-02-08T11:57:00.000","Title":"Find and Replace Inside a Text File from a Bash 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},{"Question":"I'm working on a regression-testing tool that will validate a very large number of Excel spreadsheets. At the moment I control them via COM from a Python script using the latest version of the pywin32 product. Unfortunately COM seems to have a number of annoying drawbacks:\nFor example, the slightest upset seems to be able to break the connection to the COM-Server, once severed there seems to be no safe way to re-connect to the Excel application. There's absolutely no safety built into the COM Application object.\nThe Excel COM interface will not allow me to safely remote-control two seperate instances of the Excel application operating on the same workbook file, even if they are read-only.\nAlso when something does go wrong I seldom get any useful error-messages... at best I can except a numerical error-code or a barely useful message such as \"An Exception has occurred\". It's almost impossible to know why something went wrong.\nFinally, COM lacks the ability to control some of the most fundamental aspects of Excel? For example there's no way to do a guaranteed close of just the Excel process that a COM client is connected to. You cannot even use COM to find Excel's PID.\nSo what if I were to completely abandon COM? Is there an alternative way to control Excel? \nAll I want to do is run macros, open and close workbooks and read and write cell-ranges? Perhaps some .NET experts know a trick or two which have not yet bubbled into the Python community? What about you office-hackers? Could there be a better way to get at Excel's innards than COM?","AnswerCount":5,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":5983,"Q_Id":528817,"Users Score":7,"Answer":"There is no way that completely bypasses COM. You can use VSTO (Visual Studio Tools for Office), which has nice .NET wrappers on the COM objects, but it is still COM underneath.","Q_Score":1,"Tags":"python,.net,excel,com","A_Id":528833,"CreationDate":"2009-02-09T16:21:00.000","Title":"Is there a better way (besides COM) to remote-control Excel?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I'm writing a Python program with a lot of file access. It's running surprisingly slowly, so I used cProfile to find out what was taking the time.\nIt seems there's a lot of time spent in what Python is reporting as \"{built-in method acquire}\". I have no idea what this method is. What is it, and how can I speed up my program?","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":2567,"Q_Id":530127,"Users Score":0,"Answer":"you want to look for cpu used, not for \"total time used\" from within that method--that might help. Sorry I don't use python but that's how it is for me in ruby :)\n-r","Q_Score":7,"Tags":"python,optimization,profiling,performance","A_Id":1267504,"CreationDate":"2009-02-09T21:41:00.000","Title":"What is Python's \"built-in method acquire\"? How can I speed it up?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm writing a Python program with a lot of file access. It's running surprisingly slowly, so I used cProfile to find out what was taking the time.\nIt seems there's a lot of time spent in what Python is reporting as \"{built-in method acquire}\". I have no idea what this method is. What is it, and how can I speed up my program?","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":2567,"Q_Id":530127,"Users Score":0,"Answer":"Using threads for IO is a bad idea. Threading won't make your program wait faster. You can achieve better results by using asynchronous I\/O and an event loop; Post more information about your program, and why you are using threads.","Q_Score":7,"Tags":"python,optimization,profiling,performance","A_Id":530233,"CreationDate":"2009-02-09T21:41:00.000","Title":"What is Python's \"built-in method acquire\"? How can I speed it up?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I switched from NAnt to using Python to write build automation scripts. I am curious if whether any build frameworks worth using that are similar to Make, Ant, and NAnt, but, instead, are Python-based. For example, Ruby has Rake. What about Python?","AnswerCount":5,"Available Count":1,"Score":0.0798297691,"is_accepted":false,"ViewCount":2630,"Q_Id":542289,"Users Score":2,"Answer":"My Rapid Throughts:\nSCons is quite mature and oriented also to other languages (es C++)\nWaf is very simlar to ant\/maven, so you will prefer it if you are used to ant\/maven\nPaver is very pythonic oriented, and seems a good option if you do not know how to start.","Q_Score":16,"Tags":"python,build-process,build-automation","A_Id":3838805,"CreationDate":"2009-02-12T16:59:00.000","Title":"Are there any good build frameworks written 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},{"Question":"Imagine that you need to develop and schedule an application\/script to do the following:-\n\nReference one or more .net assemblies\nQuery the API, get some objects\nfor each object call another method in the API\n\nWhat would you use?\nIn the past I have created small console applications that do the above, but it seems a bit clumsy and overkill.\nI imagine something like PowerShell or IronPython might be a better fit.\nAny recommendations?","AnswerCount":5,"Available Count":4,"Score":0.0,"is_accepted":false,"ViewCount":373,"Q_Id":549344,"Users Score":0,"Answer":"Out of frustration with PowerShell I did look into IronPython. I think this is a good alternative to powershell, especially if you are a programmer. Even if you are an IT person, I think Windows command shell + IronPython is a good combination that will accomplish what you need in the .NET era (like what command shell + vbscript was fine for in the COM era).","Q_Score":6,"Tags":".net,powershell,scripting,automation,ironpython","A_Id":549602,"CreationDate":"2009-02-14T16:41:00.000","Title":"What is the best technology to use for automating a task using .net libraries?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Imagine that you need to develop and schedule an application\/script to do the following:-\n\nReference one or more .net assemblies\nQuery the API, get some objects\nfor each object call another method in the API\n\nWhat would you use?\nIn the past I have created small console applications that do the above, but it seems a bit clumsy and overkill.\nI imagine something like PowerShell or IronPython might be a better fit.\nAny recommendations?","AnswerCount":5,"Available Count":4,"Score":1.2,"is_accepted":true,"ViewCount":373,"Q_Id":549344,"Users Score":2,"Answer":"IronPython.\nI trialled using both Powershell and IronPython for the above task and came to the conclusion that IronPython was the best fit (for me).\nTo be fair either Powershell or any DLR based language such as IronPython or IronRuby would suit the task and would be less overhead than looking after trivial console applications.\nIf all you are doing is consuming a .net library and doing some scripting then IronPython edges Powershell. If you want to utilise some sort of shell-type functionality or use existing CMDLETS then Powershell is a better choice. \nIronPython, being a implementation of python, brings all the advantages of python for scripting such as being easy to learn, easy to read and quick to develop in.","Q_Score":6,"Tags":".net,powershell,scripting,automation,ironpython","A_Id":564698,"CreationDate":"2009-02-14T16:41:00.000","Title":"What is the best technology to use for automating a task using .net libraries?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Imagine that you need to develop and schedule an application\/script to do the following:-\n\nReference one or more .net assemblies\nQuery the API, get some objects\nfor each object call another method in the API\n\nWhat would you use?\nIn the past I have created small console applications that do the above, but it seems a bit clumsy and overkill.\nI imagine something like PowerShell or IronPython might be a better fit.\nAny recommendations?","AnswerCount":5,"Available Count":4,"Score":0.0798297691,"is_accepted":false,"ViewCount":373,"Q_Id":549344,"Users Score":2,"Answer":"The problem with application drivers is that they constantly break. Applications are constantly changing their external surface and this wreaks havoc on drivers. Therefore you constantly need to updated parts of the drivers. I find a non-compiled dynamic language is ideal for this as you can quickly make an update and kick off a task. \nPowershell is a great technology for this. It is an amazingly flexible and really easy to pick up. It is a mix of compiled and dynamic code. So the more algorithm heavy portions of your driver can be any compiled language and the more fragile and frequently updated pieces can be script. They integrate seamlessly. \nI'm an avid Powershell user and really don't have much experience with IronPython (hence my choice). IronPython could also have these features though so if you're more comfortable with that language it's where you should go.","Q_Score":6,"Tags":".net,powershell,scripting,automation,ironpython","A_Id":549356,"CreationDate":"2009-02-14T16:41:00.000","Title":"What is the best technology to use for automating a task using .net libraries?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Imagine that you need to develop and schedule an application\/script to do the following:-\n\nReference one or more .net assemblies\nQuery the API, get some objects\nfor each object call another method in the API\n\nWhat would you use?\nIn the past I have created small console applications that do the above, but it seems a bit clumsy and overkill.\nI imagine something like PowerShell or IronPython might be a better fit.\nAny recommendations?","AnswerCount":5,"Available Count":4,"Score":0.1194272985,"is_accepted":false,"ViewCount":373,"Q_Id":549344,"Users Score":3,"Answer":"One of the advantages of PowerShell is that they've done a lot of work in the background to make things fit together easily, doing implicit type conversions etc to make the output of one program usable as the input to another. And since everything passes objects, you don't have to write text munging code to cobble things together.\nI do prefer Python, however, when I'm writing a large amount of original code rather than relying heavily on libraries and gluing together components.","Q_Score":6,"Tags":".net,powershell,scripting,automation,ironpython","A_Id":549404,"CreationDate":"2009-02-14T16:41:00.000","Title":"What is the best technology to use for automating a task using .net libraries?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am working on C++ since last 4-5 years . Recently I have bought iphone and macbook and want do do some programming for iphone.\nSo I have started reading one book about Objective-C. I have also learn that we can program with Ruby and Python on MAC.\nSo my question is which one to study? Which language you guys see the FUTURE???\nCan we program with these languages on other platforms? Or are these only limited on MAC?\nI am just a beginner in objective-C.Need some expert thoughts which way to go.\nAC","AnswerCount":12,"Available Count":10,"Score":1.0,"is_accepted":false,"ViewCount":15650,"Q_Id":550474,"Users Score":10,"Answer":"If you want to program for iphone then you should use objective-C. The entire iphone API is based on objective-C, and you have the benefits of using interface builder and IDE support from Xcode.","Q_Score":7,"Tags":"python,objective-c,ruby,programming-languages","A_Id":550496,"CreationDate":"2009-02-15T07:28:00.000","Title":"Study Objective-C , 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":0},{"Question":"I am working on C++ since last 4-5 years . Recently I have bought iphone and macbook and want do do some programming for iphone.\nSo I have started reading one book about Objective-C. I have also learn that we can program with Ruby and Python on MAC.\nSo my question is which one to study? Which language you guys see the FUTURE???\nCan we program with these languages on other platforms? Or are these only limited on MAC?\nI am just a beginner in objective-C.Need some expert thoughts which way to go.\nAC","AnswerCount":12,"Available Count":10,"Score":0.0333209931,"is_accepted":false,"ViewCount":15650,"Q_Id":550474,"Users Score":2,"Answer":"I have written small games, interpreters, and tons of awessome stuff in Ruby. I Wouldn't recommend It to write intensive AI programs for instance, but It's fun to learn and powerful for most applications. Even when I do most of my work in C++ Ruby is my favorite language for subjective reasons.\nObjective C as most people said Is a must in iPhone development, and fun if You're enthusiastic about learning languages.\nI haven't tried Python, but I hear nothing but good things about It, and PyGames Is quite popular.\nI would learn the three ( well...I would skip objective C unless You're curious about getting into iPhone development), the most languages you know, the best professional You will be. As a good professor of mine always said..It's not about being the master in just one language, It's about knowing the pros and cons of each one to choose the right one according to the particular problem You want to solve.\nCheers !","Q_Score":7,"Tags":"python,objective-c,ruby,programming-languages","A_Id":1331003,"CreationDate":"2009-02-15T07:28:00.000","Title":"Study Objective-C , 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":0},{"Question":"I am working on C++ since last 4-5 years . Recently I have bought iphone and macbook and want do do some programming for iphone.\nSo I have started reading one book about Objective-C. I have also learn that we can program with Ruby and Python on MAC.\nSo my question is which one to study? Which language you guys see the FUTURE???\nCan we program with these languages on other platforms? Or are these only limited on MAC?\nI am just a beginner in objective-C.Need some expert thoughts which way to go.\nAC","AnswerCount":12,"Available Count":10,"Score":0.0333209931,"is_accepted":false,"ViewCount":15650,"Q_Id":550474,"Users Score":2,"Answer":"Just my two cents...As I'm sure you're aware, Apple and others in the respective communities are doing a lot of work with Ruby and Python, for both Mac and iPhone development. Objective-C will pretty much get you into Apple arenas only these days (though maybe that's not a bad thing;) However, if you are only going to learn one language in the foreseeable future, think about where you will be using it, and what for. Ruby and Python will get you a lot further if you are looking beyond solely Mac desktop and iPhone.","Q_Score":7,"Tags":"python,objective-c,ruby,programming-languages","A_Id":552528,"CreationDate":"2009-02-15T07:28:00.000","Title":"Study Objective-C , 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":0},{"Question":"I am working on C++ since last 4-5 years . Recently I have bought iphone and macbook and want do do some programming for iphone.\nSo I have started reading one book about Objective-C. I have also learn that we can program with Ruby and Python on MAC.\nSo my question is which one to study? Which language you guys see the FUTURE???\nCan we program with these languages on other platforms? Or are these only limited on MAC?\nI am just a beginner in objective-C.Need some expert thoughts which way to go.\nAC","AnswerCount":12,"Available Count":10,"Score":1.0,"is_accepted":false,"ViewCount":15650,"Q_Id":550474,"Users Score":7,"Answer":"Objective-C is the only way to program an iPhone if you want to produce native programs that can be sold in the App Store.\nSome of the more advanced concepts in Objective-C are now being added to languages like C# (eg: extension methods in C# v3.0). Learning to think in Objective-C will be useful, the OO model you learn will be applicable to most other languages and environments as an addition to your C++ experience.\nRuby's object model is closer to that of Objective-C than is Python so I suggest also learning Ruby but not until you have your Objective-C skills down solidly. \nNote that you can use Objective-C++ and use C++ for all but your GUI code by having .mm suffixes on your files - this works on both iPhone and Mac. Given your C++ experience, that help you be productive.\nIf you want to program iPhone, don't bother learning the new Objective-C 2.0 memory management but you can still use the Properties model (iPhone effectively has a subset of the Objective-C 2.0 runtime).","Q_Score":7,"Tags":"python,objective-c,ruby,programming-languages","A_Id":550516,"CreationDate":"2009-02-15T07:28:00.000","Title":"Study Objective-C , 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":0},{"Question":"I am working on C++ since last 4-5 years . Recently I have bought iphone and macbook and want do do some programming for iphone.\nSo I have started reading one book about Objective-C. I have also learn that we can program with Ruby and Python on MAC.\nSo my question is which one to study? Which language you guys see the FUTURE???\nCan we program with these languages on other platforms? Or are these only limited on MAC?\nI am just a beginner in objective-C.Need some expert thoughts which way to go.\nAC","AnswerCount":12,"Available Count":10,"Score":0.0333209931,"is_accepted":false,"ViewCount":15650,"Q_Id":550474,"Users Score":2,"Answer":"Ruby. With Ruby you will be able to do both web development (Rails\/Sinatra\/etc.) and very soon program on the MAC\/Iphone platform with the Macruby project. Why not get the best of both worlds?\nTommy","Q_Score":7,"Tags":"python,objective-c,ruby,programming-languages","A_Id":550980,"CreationDate":"2009-02-15T07:28:00.000","Title":"Study Objective-C , 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":0},{"Question":"I am working on C++ since last 4-5 years . Recently I have bought iphone and macbook and want do do some programming for iphone.\nSo I have started reading one book about Objective-C. I have also learn that we can program with Ruby and Python on MAC.\nSo my question is which one to study? Which language you guys see the FUTURE???\nCan we program with these languages on other platforms? Or are these only limited on MAC?\nI am just a beginner in objective-C.Need some expert thoughts which way to go.\nAC","AnswerCount":12,"Available Count":10,"Score":0.0333209931,"is_accepted":false,"ViewCount":15650,"Q_Id":550474,"Users Score":2,"Answer":"To program on Mac OS X, you really do need a good foundation in Objective-C. The vast majority of documentation will assume Objective-C. Even if you choose to program some applications in some other language, you will be better off having a good understanding of it.","Q_Score":7,"Tags":"python,objective-c,ruby,programming-languages","A_Id":550540,"CreationDate":"2009-02-15T07:28:00.000","Title":"Study Objective-C , 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":0},{"Question":"I am working on C++ since last 4-5 years . Recently I have bought iphone and macbook and want do do some programming for iphone.\nSo I have started reading one book about Objective-C. I have also learn that we can program with Ruby and Python on MAC.\nSo my question is which one to study? Which language you guys see the FUTURE???\nCan we program with these languages on other platforms? Or are these only limited on MAC?\nI am just a beginner in objective-C.Need some expert thoughts which way to go.\nAC","AnswerCount":12,"Available Count":10,"Score":0.0333209931,"is_accepted":false,"ViewCount":15650,"Q_Id":550474,"Users Score":2,"Answer":"If you program with Objective-C, your main goal should be writing Cocoa applications on the Mac. Beyond that, it has little use. Ruby and Python are useful scripting languages, and there are also bridges to write Cocoa applications.\nIf you want to write apps on the Mac, I would start with Objective-C. There is more support available.\nIn terms of the future, it seems like a lot of people are jumping on the Ruby bandwagon at the moment. Good luck.","Q_Score":7,"Tags":"python,objective-c,ruby,programming-languages","A_Id":550499,"CreationDate":"2009-02-15T07:28:00.000","Title":"Study Objective-C , 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":0},{"Question":"I am working on C++ since last 4-5 years . Recently I have bought iphone and macbook and want do do some programming for iphone.\nSo I have started reading one book about Objective-C. I have also learn that we can program with Ruby and Python on MAC.\nSo my question is which one to study? Which language you guys see the FUTURE???\nCan we program with these languages on other platforms? Or are these only limited on MAC?\nI am just a beginner in objective-C.Need some expert thoughts which way to go.\nAC","AnswerCount":12,"Available Count":10,"Score":1.0,"is_accepted":false,"ViewCount":15650,"Q_Id":550474,"Users Score":7,"Answer":"Which language you guys see the FUTURE???\nFuture of what? iPhone development? Objective-C. \nWeb Services? Python\/Ruby in parallel for a while. At least until people start trying to do maintenance on large Ruby applications and get frustrated with it's opacity.\nReal-time game engine development? Embedded applications? Future of what?\n\"Can we program with these languages on other platforms? Or are these only limited on MAC?\"\nRuby and Python: Yes. These are designed to run on any platform that supports C.\nObjective-C: Yes. It's open source, it's in the GCC, it should work almost anywhere. \nLearning a new language is not a zero-sum game. You can learn more than one language; learning Objective-C now does not prevent you from learning Python or Ruby in the future.","Q_Score":7,"Tags":"python,objective-c,ruby,programming-languages","A_Id":550829,"CreationDate":"2009-02-15T07:28:00.000","Title":"Study Objective-C , 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":0},{"Question":"I am working on C++ since last 4-5 years . Recently I have bought iphone and macbook and want do do some programming for iphone.\nSo I have started reading one book about Objective-C. I have also learn that we can program with Ruby and Python on MAC.\nSo my question is which one to study? Which language you guys see the FUTURE???\nCan we program with these languages on other platforms? Or are these only limited on MAC?\nI am just a beginner in objective-C.Need some expert thoughts which way to go.\nAC","AnswerCount":12,"Available Count":10,"Score":0.0665680765,"is_accepted":false,"ViewCount":15650,"Q_Id":550474,"Users Score":4,"Answer":"As a Perlite, I'm just going to point out that OS X has Perl as well as Python or Ruby.\nAs far as Perl\/Python\/Ruby goes, programs are almost completely cross-platform. It is fairly easy to run a Perl\/Python\/Ruby program on any platform and it works more or less the same. There may be some minor differences, but they're not major.\nObjective-C, while not strictly confined to OS X, is only really used in OpenStep-based environments, which generally means OS X and the iPhone. The only Objective-C compiler I know of is gcc, and I imagine you can write Objective-C on Linux, but I don't know if Windows support is very good (if it exists).\nAs for which is the language of the \"future\", all 3 (or 4) languages will be used very widely in the future. No one can really predict this kind of thing, and none of the languages are really going to die off (unless Apple switches to a new language as a \"standard\" for making Mac programs), so you'll be pretty safe with any of them.\nMy advice: try them all out and see which one you think most suits your style, and learn that one.","Q_Score":7,"Tags":"python,objective-c,ruby,programming-languages","A_Id":550485,"CreationDate":"2009-02-15T07:28:00.000","Title":"Study Objective-C , 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":0},{"Question":"I am working on C++ since last 4-5 years . Recently I have bought iphone and macbook and want do do some programming for iphone.\nSo I have started reading one book about Objective-C. I have also learn that we can program with Ruby and Python on MAC.\nSo my question is which one to study? Which language you guys see the FUTURE???\nCan we program with these languages on other platforms? Or are these only limited on MAC?\nI am just a beginner in objective-C.Need some expert thoughts which way to go.\nAC","AnswerCount":12,"Available Count":10,"Score":0.0166651236,"is_accepted":false,"ViewCount":15650,"Q_Id":550474,"Users Score":1,"Answer":"Objective-C is only Mac\/iPhone, and I recommend you to learn if you want to develop applications for Mac\/iPhone.\nPython is everything and it's future, but python more preferable for web development. Python is Google :) Python is web, games, science, graphics, desktop, etc. Also it's very good choice if you are C\/C++ developer.\nNot sure if i can recommend you to learn Ruby...","Q_Score":7,"Tags":"python,objective-c,ruby,programming-languages","A_Id":550868,"CreationDate":"2009-02-15T07:28:00.000","Title":"Study Objective-C , 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":0},{"Question":"Several processes with the same name are running on host. What is the cross-platform way to get PIDs of those processes by name using python or jython?\n\nI want something like pidof but in python. (I don't have pidof anyway.)\nI can't parse \/proc because it might be unavailable (on HP-UX).\nI do not want to run os.popen('ps') and parse the output because I think it is ugly (field sequence may be different in different OS).\nTarget platforms are Solaris, HP-UX, and maybe others.","AnswerCount":9,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":78794,"Q_Id":550653,"Users Score":0,"Answer":"There isn't, I'm afraid. Processes are uniquely identified by pid not by name. If you really must find a pid by name, then you will have use something like you have suggested, but it won't be portable and probably will not work in all cases.\nIf you only have to find the pids for a certain application and you have control over this application, then I'd suggest changing this app to store its pid in files in some location where your script can find it.","Q_Score":58,"Tags":"python,cross-platform,jython,hp-ux","A_Id":557021,"CreationDate":"2009-02-15T10:23:00.000","Title":"Cross-platform way to get PIDs by process name 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},{"Question":"Several processes with the same name are running on host. What is the cross-platform way to get PIDs of those processes by name using python or jython?\n\nI want something like pidof but in python. (I don't have pidof anyway.)\nI can't parse \/proc because it might be unavailable (on HP-UX).\nI do not want to run os.popen('ps') and parse the output because I think it is ugly (field sequence may be different in different OS).\nTarget platforms are Solaris, HP-UX, and maybe others.","AnswerCount":9,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":78794,"Q_Id":550653,"Users Score":0,"Answer":"For jython, if Java 5 is used, then you can get the Java process id as following:\nfrom java.lang.management import *\npid = ManagementFactory.getRuntimeMXBean().getName()","Q_Score":58,"Tags":"python,cross-platform,jython,hp-ux","A_Id":727024,"CreationDate":"2009-02-15T10:23:00.000","Title":"Cross-platform way to get PIDs by process name 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},{"Question":"Several processes with the same name are running on host. What is the cross-platform way to get PIDs of those processes by name using python or jython?\n\nI want something like pidof but in python. (I don't have pidof anyway.)\nI can't parse \/proc because it might be unavailable (on HP-UX).\nI do not want to run os.popen('ps') and parse the output because I think it is ugly (field sequence may be different in different OS).\nTarget platforms are Solaris, HP-UX, and maybe others.","AnswerCount":9,"Available Count":3,"Score":0.022218565,"is_accepted":false,"ViewCount":78794,"Q_Id":550653,"Users Score":1,"Answer":"I don't think you will be able to find a purely python-based, portable solution without using \/proc or command line utilities, at least not in python itself. Parsing os.system is not ugly - someone has to deal with the multiple platforms, be it you or someone else. Implementing it for the OS you are interested in should be fairly easy, honestly.","Q_Score":58,"Tags":"python,cross-platform,jython,hp-ux","A_Id":550672,"CreationDate":"2009-02-15T10:23:00.000","Title":"Cross-platform way to get PIDs by process name 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},{"Question":"I'm thinking about using Python as an embedded scripting language in a hobby project written in C++. I would not like to depend on separately installed Python distribution. Python documentation seems to be quite clear about general usage, but I couldn't find a clear answer to this.\nIs it feasible to deploy a Python interpreter + standard library with my application? Would some other language like Lua, Javascript (Spidermonkey), Ruby, etc. be better for this use?\nHere's the criteria I'm weighing the different languages against:\n\nNo\/Few dependencies on externally installed packages\nStandard library with good feature set\nNice language :)\nDoesn't result in a huge install package\n\nedit: \nI guess the question should be: \nHow do I deploy my own python library + standard library with the installer of my program, so that it doesn't matter whether the platform already has python installed or not?\nedit2: \nOne more clarification. I don't need info about specifics of linking C and Python code.","AnswerCount":4,"Available Count":1,"Score":0.2449186624,"is_accepted":false,"ViewCount":4914,"Q_Id":551227,"Users Score":5,"Answer":"To extend the answer by gimel, there is nothing to stop you from shipping python.dll, using it, and setting a correct PYTHONPATH in order to use your own installation of the python standard library. They are just libraries and files, and your install process can just deal with them as such.","Q_Score":18,"Tags":"c++,python,deployment,scripting-language,embedded-language","A_Id":551332,"CreationDate":"2009-02-15T17:12:00.000","Title":"Deploying application with Python or another embedded scripting 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},{"Question":"I'm a C# .NET developer and I work on mostly ASP.NET projects.\nI want to learn a new programming language,\n\nto improve my programming skills by experiencing a new language, \nto see something different then microsoft environment,\nand maybe to think in a different way.\n\nI focus on two languages for my goal. Python and Ruby.\n\nWhich one do you offer for me ? \nPros and cons of them on each other?\nIs it worth learning them ?\n\nEDIT : Sorry I editted my post but not inform here, \nRuby on Rails replaced with Ruby.","AnswerCount":8,"Available Count":5,"Score":1.2,"is_accepted":true,"ViewCount":1835,"Q_Id":551465,"Users Score":16,"Answer":"Both languages are powerful and fun. Either would be a useful addition to your tool box.\nPython has a larger community and probably more mature documentation and libraries. Its object-orientation is a little inconsistent and feels (to me, IMHO) like something that was bolted on to the language. You can alter class behaviour at runtime (monkey-patching) but not for the precompiled classes and it's generally frowned-upon.\nRuby might be a little more different to your current experience: it has some flavour of Smalltalk (method-calling is more correctly message-sending for example). Its object-orientation is built-in from scratch, all classes are open to modification and it's an accepted - if slightly scary - practise. The community is smaller, the libraries less mature and documentation coverage is less.\nBoth languages will have some level of broken backward compatibility in their next majopr releases, both have .Net implementations (IronPython is production, IronRuby getting there). Both have web frameworks that reflect their strengths (search SO for the Django\/Rails debate).\nIf I'd never seen Ruby, I'd be very happy working in Python, and have done so without suffering when necessary. I always found myself wishing I could do the work in Ruby. But that's my opinion, YMMV.\nEdit: Come to think of it, and even though it pains me, if you're seeking to leverage your knowledge of the .Net framework, you might be best off looking at IronPython, as it's more mature than the Ruby equivalent.","Q_Score":12,"Tags":"python,ruby-on-rails,ruby,comparison","A_Id":552734,"CreationDate":"2009-02-15T19:45:00.000","Title":"Python or Ruby for a .NET developer?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I'm a C# .NET developer and I work on mostly ASP.NET projects.\nI want to learn a new programming language,\n\nto improve my programming skills by experiencing a new language, \nto see something different then microsoft environment,\nand maybe to think in a different way.\n\nI focus on two languages for my goal. Python and Ruby.\n\nWhich one do you offer for me ? \nPros and cons of them on each other?\nIs it worth learning them ?\n\nEDIT : Sorry I editted my post but not inform here, \nRuby on Rails replaced with Ruby.","AnswerCount":8,"Available Count":5,"Score":1.0,"is_accepted":false,"ViewCount":1835,"Q_Id":551465,"Users Score":6,"Answer":"First... good for you for wanting to broaden your knowledge! Second, you are comparing a language (Python) with a web framework (Ruby on Rails).\nI think your best option is to try a few different frameworks in both Python and Ruby, do the same fairly simple task in each, and only then pick which one you'd like to learn more about. Rails is nice for Ruby, but it's not the only one out there. For Python I like Pylons and Django.\nPros and cons: Ruby is a little cleaner, language-wise, than Python. Python has a much larger set of modules.\nIs it worth learning? Yes, to both Python and Ruby.","Q_Score":12,"Tags":"python,ruby-on-rails,ruby,comparison","A_Id":551484,"CreationDate":"2009-02-15T19:45:00.000","Title":"Python or Ruby for a .NET developer?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I'm a C# .NET developer and I work on mostly ASP.NET projects.\nI want to learn a new programming language,\n\nto improve my programming skills by experiencing a new language, \nto see something different then microsoft environment,\nand maybe to think in a different way.\n\nI focus on two languages for my goal. Python and Ruby.\n\nWhich one do you offer for me ? \nPros and cons of them on each other?\nIs it worth learning them ?\n\nEDIT : Sorry I editted my post but not inform here, \nRuby on Rails replaced with Ruby.","AnswerCount":8,"Available Count":5,"Score":0.049958375,"is_accepted":false,"ViewCount":1835,"Q_Id":551465,"Users Score":2,"Answer":"Rule of thumb - Python if you like strict rules and Ruby if you hate them. \nAnother one: if you adore JavaScript - Ruby is your choice :)","Q_Score":12,"Tags":"python,ruby-on-rails,ruby,comparison","A_Id":552177,"CreationDate":"2009-02-15T19:45:00.000","Title":"Python or Ruby for a .NET developer?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I'm a C# .NET developer and I work on mostly ASP.NET projects.\nI want to learn a new programming language,\n\nto improve my programming skills by experiencing a new language, \nto see something different then microsoft environment,\nand maybe to think in a different way.\n\nI focus on two languages for my goal. Python and Ruby.\n\nWhich one do you offer for me ? \nPros and cons of them on each other?\nIs it worth learning them ?\n\nEDIT : Sorry I editted my post but not inform here, \nRuby on Rails replaced with Ruby.","AnswerCount":8,"Available Count":5,"Score":0.049958375,"is_accepted":false,"ViewCount":1835,"Q_Id":551465,"Users Score":2,"Answer":"What? No mention of IronPython?\nIronPython is the flagship language of the DLR. It allows you to use all the familiar .NET libraries, but through Python.\nI would definitely try Python and IronPython. You'll learn a lot and might even sneak it into your current projects (you can embed an IronPython engine in a .NET application).","Q_Score":12,"Tags":"python,ruby-on-rails,ruby,comparison","A_Id":555166,"CreationDate":"2009-02-15T19:45:00.000","Title":"Python or Ruby for a .NET developer?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I'm a C# .NET developer and I work on mostly ASP.NET projects.\nI want to learn a new programming language,\n\nto improve my programming skills by experiencing a new language, \nto see something different then microsoft environment,\nand maybe to think in a different way.\n\nI focus on two languages for my goal. Python and Ruby.\n\nWhich one do you offer for me ? \nPros and cons of them on each other?\nIs it worth learning them ?\n\nEDIT : Sorry I editted my post but not inform here, \nRuby on Rails replaced with Ruby.","AnswerCount":8,"Available Count":5,"Score":0.0,"is_accepted":false,"ViewCount":1835,"Q_Id":551465,"Users Score":0,"Answer":"I'd get in on Ruby. Seems to have a larger (or at least more active) community, the pace of new projects & continued development is second-to-none, and the learning resources seem to outnumber & outpace those of Python. I could be wrong, but these are my impressions.","Q_Score":12,"Tags":"python,ruby-on-rails,ruby,comparison","A_Id":552126,"CreationDate":"2009-02-15T19:45:00.000","Title":"Python or Ruby for a .NET developer?","Data Science and Machine Learning":0,"Database and SQL":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},{"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},{"Question":"For C++, Java, or Python, what are some good game + free game engines that are easy to pick up?\nAny type of game engine is okay. I just want to get started somewhere by looking into different game engines and their capabilities.","AnswerCount":14,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":10754,"Q_Id":564469,"Users Score":0,"Answer":"There is a RPG engine called VERGE if you're interested. Never tried it but I heard good things from it. \nI think it's in C++.","Q_Score":9,"Tags":"java,c++,python","A_Id":1949983,"CreationDate":"2009-02-19T09:05:00.000","Title":"What is a good & free game engine?","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},{"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},{"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},{"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},{"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},{"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},{"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},{"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},{"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},{"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},{"Question":"Do you know of any tool that could assist me in obfuscating python code?","AnswerCount":7,"Available Count":2,"Score":1.0,"is_accepted":false,"ViewCount":39050,"Q_Id":576963,"Users Score":15,"Answer":"Your problem space is underspecified. Is this for a command-line app? Is this code supposed to be used as a library?\nIn addition to the two other answers, you could embed the code into a binary. When it starts, decode the code and eval the string. This works for a shared library extension as well. You could also do that with byte code, I think, but it wouldn't be as simple as calling Py_EvalCode.\npy2exe or freeze are other solution, which convert the code into an executable. It just includes the code in the binary, and doesn't do any sort of serious obsfucation, but it's still harder than opening a .py file.\nYou could write the code in Cython, which is similar to Python and writes Python extension files in C, for use as a .so. That's perhaps the hardest of these to reverse engineer and still give you a high-level language for develoment.\nThey are all hackable, as are all solutions. How hard to you want it to be?","Q_Score":39,"Tags":"python,obfuscation","A_Id":577161,"CreationDate":"2009-02-23T09:08:00.000","Title":"Python Code Obfuscation","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Do you know of any tool that could assist me in obfuscating python code?","AnswerCount":7,"Available Count":2,"Score":0.1418931938,"is_accepted":false,"ViewCount":39050,"Q_Id":576963,"Users Score":5,"Answer":"In many situations you can ship byte-compiled .pyc files instead of the .py source files. This gives you some level of obfuscation. As the pyobfuscate README suggests, this has limitations. But you may be able to combine the two approaches.","Q_Score":39,"Tags":"python,obfuscation","A_Id":577067,"CreationDate":"2009-02-23T09:08:00.000","Title":"Python Code Obfuscation","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"My teacher told me that if I wanted to get the best grade in our programming class, I should code a Simple Source Code Converter. \nPython to Ruby (the simplest he said) \nNow my question to you: how hard is it to code a simple source code converter for python to ruby. (It should convert file controlling, Control Statements, etc.) \nDo you have any tips for me?\nWhich language should I use to code the converter (C#, Python or Ruby)?","AnswerCount":8,"Available Count":6,"Score":0.0,"is_accepted":false,"ViewCount":4019,"Q_Id":579524,"Users Score":0,"Answer":"The hardest part would be preserving semantics.\nLike how do you deal with metaclass assignments, or function decorators, or yield-based generators when going to Ruby? I have no Ruby experience so I don't know what is directly supported.","Q_Score":5,"Tags":"python,ruby,converter","A_Id":579627,"CreationDate":"2009-02-23T21:48:00.000","Title":"How do I code a source code converter from python to 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":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"My teacher told me that if I wanted to get the best grade in our programming class, I should code a Simple Source Code Converter. \nPython to Ruby (the simplest he said) \nNow my question to you: how hard is it to code a simple source code converter for python to ruby. (It should convert file controlling, Control Statements, etc.) \nDo you have any tips for me?\nWhich language should I use to code the converter (C#, Python or Ruby)?","AnswerCount":8,"Available Count":6,"Score":0.0,"is_accepted":false,"ViewCount":4019,"Q_Id":579524,"Users Score":0,"Answer":"As simple as coming up with enough clever regexps that convert the syntax correctly.\nRuby and python's syntax is close enough for this to be not very hard.\nYou might need to do abit of extra work to rewrite stuff that you have in python that doesn't exist in ruby like listing comprehension for instance.","Q_Score":5,"Tags":"python,ruby,converter","A_Id":579540,"CreationDate":"2009-02-23T21:48:00.000","Title":"How do I code a source code converter from python to 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":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"My teacher told me that if I wanted to get the best grade in our programming class, I should code a Simple Source Code Converter. \nPython to Ruby (the simplest he said) \nNow my question to you: how hard is it to code a simple source code converter for python to ruby. (It should convert file controlling, Control Statements, etc.) \nDo you have any tips for me?\nWhich language should I use to code the converter (C#, Python or Ruby)?","AnswerCount":8,"Available Count":6,"Score":1.0,"is_accepted":false,"ViewCount":4019,"Q_Id":579524,"Users Score":13,"Answer":"I think your teacher is fibbing - this is pretty hard. It is equivalent to writing a compiler\/interpreter. I don't know how much time you have available for this project, but you are typically looking at several man-years of work.","Q_Score":5,"Tags":"python,ruby,converter","A_Id":579549,"CreationDate":"2009-02-23T21:48:00.000","Title":"How do I code a source code converter from python to 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":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"My teacher told me that if I wanted to get the best grade in our programming class, I should code a Simple Source Code Converter. \nPython to Ruby (the simplest he said) \nNow my question to you: how hard is it to code a simple source code converter for python to ruby. (It should convert file controlling, Control Statements, etc.) \nDo you have any tips for me?\nWhich language should I use to code the converter (C#, Python or Ruby)?","AnswerCount":8,"Available Count":6,"Score":0.0,"is_accepted":false,"ViewCount":4019,"Q_Id":579524,"Users Score":0,"Answer":"It sounds like your teacher is a bit of a practical joker!","Q_Score":5,"Tags":"python,ruby,converter","A_Id":579595,"CreationDate":"2009-02-23T21:48:00.000","Title":"How do I code a source code converter from python to 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":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"My teacher told me that if I wanted to get the best grade in our programming class, I should code a Simple Source Code Converter. \nPython to Ruby (the simplest he said) \nNow my question to you: how hard is it to code a simple source code converter for python to ruby. (It should convert file controlling, Control Statements, etc.) \nDo you have any tips for me?\nWhich language should I use to code the converter (C#, Python or Ruby)?","AnswerCount":8,"Available Count":6,"Score":0.0,"is_accepted":false,"ViewCount":4019,"Q_Id":579524,"Users Score":0,"Answer":"the language should not matter. pick the one you are most comfortable with strings in. \ntips wise i would use a dictionary\/look-up array for the keywords. The hardest part will be dealing with the white space in python","Q_Score":5,"Tags":"python,ruby,converter","A_Id":579546,"CreationDate":"2009-02-23T21:48:00.000","Title":"How do I code a source code converter from python to 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":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"My teacher told me that if I wanted to get the best grade in our programming class, I should code a Simple Source Code Converter. \nPython to Ruby (the simplest he said) \nNow my question to you: how hard is it to code a simple source code converter for python to ruby. (It should convert file controlling, Control Statements, etc.) \nDo you have any tips for me?\nWhich language should I use to code the converter (C#, Python or Ruby)?","AnswerCount":8,"Available Count":6,"Score":0.0,"is_accepted":false,"ViewCount":4019,"Q_Id":579524,"Users Score":0,"Answer":"First simple may mean that it does not take care of all the valid semantics of Python, but only a subset of this.\nThe first thing I would get would be a copy of the dragon book, which you can find in any university library. The second thing I would do would be to get a copy of the syntax and semantics of Python.","Q_Score":5,"Tags":"python,ruby,converter","A_Id":579543,"CreationDate":"2009-02-23T21:48:00.000","Title":"How do I code a source code converter from python to 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":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a tool which I have written in python and generally should be run as a daemon. What are the best practices for packaging this tool for distribution, particularly how should settings files and the daemon executable\/script be handled?\nRelatedly are there any common tools for setting up the daemon for running on boot as appropriate for the given platform (i.e. init scripts on linux, services on windows, launchd on os x)?","AnswerCount":10,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":16678,"Q_Id":588749,"Users Score":0,"Answer":"correct me if wrong, but I believe the question is how to DEPLOY the daemon. Set your app to install via pip and then make the entry_point a cli(daemon()). Then create an init script that simply runs $app_name &","Q_Score":24,"Tags":"python,packaging,setuptools,distutils","A_Id":40901455,"CreationDate":"2009-02-26T01:32:00.000","Title":"Python Daemon Packaging 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":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have a tool which I have written in python and generally should be run as a daemon. What are the best practices for packaging this tool for distribution, particularly how should settings files and the daemon executable\/script be handled?\nRelatedly are there any common tools for setting up the daemon for running on boot as appropriate for the given platform (i.e. init scripts on linux, services on windows, launchd on os x)?","AnswerCount":10,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":16678,"Q_Id":588749,"Users Score":0,"Answer":"On Linux systems, the system's package manager (Portage for Gentoo, Aptitude for Ubuntu\/Debian, yum for Fedora, etc.) usually takes care of installing the program including placing init scripts in the right places. If you want to distribute your program for Linux, you might want to look into bundling it up into the proper format for various distributions' package managers.\nThis advice is obviously irrelevant on systems which don't have package managers (Windows, and Mac I think).","Q_Score":24,"Tags":"python,packaging,setuptools,distutils","A_Id":588835,"CreationDate":"2009-02-26T01:32:00.000","Title":"Python Daemon Packaging 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":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am going to be building a Pylons-based web application. For this purpose, I'd like to build a minimal Linux platform, upon which I would then install the necessary packages such as Python and Pylons, and other necessary dependencies. The other reason to keep it minimal is because this machine will be virtual, probably over KVM, and will eventually be replicated in some cloud environment.\nWhat would you use to do this? I am thinking of using Fedora 10's AOS iso, but would love to understand all my options.","AnswerCount":7,"Available Count":4,"Score":0.0285636566,"is_accepted":false,"ViewCount":602,"Q_Id":589115,"Users Score":1,"Answer":"If you want to be able to remove all the cruft but still be using a \u2018mainstream\u2019 distro rather than one cut down to aim at tiny devices, look at Slackware. You can happily remove stuff as low-level as sysvinit, cron and so on, without collapsing into dependency hell. And nothing in it relies on Perl or Python, so you can easily remove them (and install whichever version of Python your app prefers to use).","Q_Score":2,"Tags":"python,linux,pylons","A_Id":590001,"CreationDate":"2009-02-26T04:33:00.000","Title":"Miminal Linux For a Pylons Web 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},{"Question":"I am going to be building a Pylons-based web application. For this purpose, I'd like to build a minimal Linux platform, upon which I would then install the necessary packages such as Python and Pylons, and other necessary dependencies. The other reason to keep it minimal is because this machine will be virtual, probably over KVM, and will eventually be replicated in some cloud environment.\nWhat would you use to do this? I am thinking of using Fedora 10's AOS iso, but would love to understand all my options.","AnswerCount":7,"Available Count":4,"Score":0.0285636566,"is_accepted":false,"ViewCount":602,"Q_Id":589115,"Users Score":1,"Answer":"For this purpose, I'd like to build a minimal Linux platform...\n\nSo Why not try to use ArchLinux www.archlinux.org?\nAlso you can use virtualenv with Pylons in it.","Q_Score":2,"Tags":"python,linux,pylons","A_Id":895583,"CreationDate":"2009-02-26T04:33:00.000","Title":"Miminal Linux For a Pylons Web 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},{"Question":"I am going to be building a Pylons-based web application. For this purpose, I'd like to build a minimal Linux platform, upon which I would then install the necessary packages such as Python and Pylons, and other necessary dependencies. The other reason to keep it minimal is because this machine will be virtual, probably over KVM, and will eventually be replicated in some cloud environment.\nWhat would you use to do this? I am thinking of using Fedora 10's AOS iso, but would love to understand all my options.","AnswerCount":7,"Available Count":4,"Score":0.0,"is_accepted":false,"ViewCount":602,"Q_Id":589115,"Users Score":0,"Answer":"debootstrap is your friend.","Q_Score":2,"Tags":"python,linux,pylons","A_Id":589638,"CreationDate":"2009-02-26T04:33:00.000","Title":"Miminal Linux For a Pylons Web 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},{"Question":"I am going to be building a Pylons-based web application. For this purpose, I'd like to build a minimal Linux platform, upon which I would then install the necessary packages such as Python and Pylons, and other necessary dependencies. The other reason to keep it minimal is because this machine will be virtual, probably over KVM, and will eventually be replicated in some cloud environment.\nWhat would you use to do this? I am thinking of using Fedora 10's AOS iso, but would love to understand all my options.","AnswerCount":7,"Available Count":4,"Score":0.0,"is_accepted":false,"ViewCount":602,"Q_Id":589115,"Users Score":0,"Answer":"Damn Small Linux? Slax?","Q_Score":2,"Tags":"python,linux,pylons","A_Id":589645,"CreationDate":"2009-02-26T04:33:00.000","Title":"Miminal Linux For a Pylons Web 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},{"Question":"I'm trying to find resources on video and voice chat operability in Python... Does anybody know of some good resources or sample projects?\nAny help would really be appreciated!","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":3199,"Q_Id":590053,"Users Score":0,"Answer":"Basically a farsight lib which has xmpp-jingle that can accomodate video and voice chat is commonly used,for python itz farsight.py: try it.....!","Q_Score":3,"Tags":"python,audio,chat,voice","A_Id":6936316,"CreationDate":"2009-02-26T10:56:00.000","Title":"Video and Voice chat operability 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},{"Question":"I do a lot of Python quick simulation stuff and I'm constantly saving (:w) and then running (:!!). Is there a way to combine these actions?\nMaybe a \"save and run\" command.","AnswerCount":12,"Available Count":1,"Score":0.0831409664,"is_accepted":false,"ViewCount":19544,"Q_Id":601039,"Users Score":5,"Answer":"Command combination seems to work through the | character, so perhaps something like aliasing :w|!your-command-here to a distinct key combination.","Q_Score":52,"Tags":"python,vim","A_Id":601053,"CreationDate":"2009-03-02T01:54:00.000","Title":"Save and run at the same time in Vim","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"i'm looking for a C++ replacement of the Python PubSub Library in which i don't have to connect a signal with a slot or so, but instead can register for a special Kind of messages, without knowing the object which can send it.","AnswerCount":3,"Available Count":1,"Score":0.1325487884,"is_accepted":false,"ViewCount":1723,"Q_Id":605629,"Users Score":2,"Answer":"Perhaps you misunderstand what signals and slots are. With signals and slots you don't have to know who sends signals. Your \"client\" class just declares slots, and an outside manager can connect signals to them.\nI recommend you to check out Qt. It's an amazing cross-platform library with much more than just GUI support. It has a convenient and efficient implementation of signals and slots which you can use.\nThese days it's also licensed with LGPL (in addition to GPL and commercial), so you can use it for practically any purpose.\nRe your clarification comment, why not raise an exception for the error? The parent can notify the GUI, or alternatively the GUI can register for a signal the parent emits. This way the parent also doesn't have to know about the GUI.","Q_Score":1,"Tags":"c++,python,observer-pattern,publish-subscribe","A_Id":607627,"CreationDate":"2009-03-03T09:02:00.000","Title":"Python's PubSub\/observer Pattern for 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":0,"Web Development":0},{"Question":"I'm hosting IronPython in a c#-based WebService to be able to provide custom extension scripts. However, I'm finding that memory usage sharply increases when I do simple load testing by executing the webservice repeatedly in a loop.\nIronPython-1.1 implemented IDisposable on its objects so that you can dispose of them when they are done. The new IronPython-2 engine based on the DLR has no such concept.\nFrom what I understood, everytime you execute a script in the ScriptEngine a new assembly is injected in the appdomain and can't be unloaded.\nIs there any way around this?","AnswerCount":3,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":1344,"Q_Id":610128,"Users Score":0,"Answer":"Turns out, after aspnet_wp goes to about 500mb, the garbage collector kicks in and cleans out the mess. The memory usage then drops to about 20mb and steadily starts increasing again during load testing.\nSo there's no memory 'leak' as such.","Q_Score":2,"Tags":"performance,ironpython","A_Id":613533,"CreationDate":"2009-03-04T11:11:00.000","Title":"IronPython memory usage","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},{"Question":"I'm hosting IronPython in a c#-based WebService to be able to provide custom extension scripts. However, I'm finding that memory usage sharply increases when I do simple load testing by executing the webservice repeatedly in a loop.\nIronPython-1.1 implemented IDisposable on its objects so that you can dispose of them when they are done. The new IronPython-2 engine based on the DLR has no such concept.\nFrom what I understood, everytime you execute a script in the ScriptEngine a new assembly is injected in the appdomain and can't be unloaded.\nIs there any way around this?","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":1344,"Q_Id":610128,"Users Score":1,"Answer":"You could try creating a new AppDomain every time you run one of your IronPython scripts. Although assebmlies cannot be unloaded from memory you can unload an AppDomain and this will allow you to get the injected assembly out of memory.","Q_Score":2,"Tags":"performance,ironpython","A_Id":611623,"CreationDate":"2009-03-04T11:11:00.000","Title":"IronPython memory usage","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},{"Question":"I`m currently studying C++ and want to learn another language.\nFor work I use C# + ASP (just started learning it, actually), but I want something \"less Microsoft\" and powerful.\nI have heard Python is a popular and powerful language, not so complicated as C++. But many people mentioned it was hard for them to get back to C++\/Java from Python because they started thinking in it, get used to absence of memory management, etc.\nWhat do you recommend?","AnswerCount":17,"Available Count":17,"Score":0.0,"is_accepted":false,"ViewCount":9495,"Q_Id":615100,"Users Score":0,"Answer":"Try LISP instead (or afterwards, it's your call). You are at least partially right, though. using Python for a while makes you not want to go back to a statically typed and compiled language. It's just sooo much more comfortable not to have to please the compiler like ALL THE TIME ;). And yet another aspect is the readability of python code, which is awesome.","Q_Score":8,"Tags":"c++,python","A_Id":615254,"CreationDate":"2009-03-05T14:52:00.000","Title":"Should I learn Python after 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},{"Question":"I`m currently studying C++ and want to learn another language.\nFor work I use C# + ASP (just started learning it, actually), but I want something \"less Microsoft\" and powerful.\nI have heard Python is a popular and powerful language, not so complicated as C++. But many people mentioned it was hard for them to get back to C++\/Java from Python because they started thinking in it, get used to absence of memory management, etc.\nWhat do you recommend?","AnswerCount":17,"Available Count":17,"Score":0.0235250705,"is_accepted":false,"ViewCount":9495,"Q_Id":615100,"Users Score":2,"Answer":"I don't think that \"Python makes you lazy\" (nice title, anyway!).\nOn the contrary, in programming as in life, knowing more than one language is important; I think you'll find python amusing and sufficiently different from C++ or C# so that the languages will not get mixed in your head...","Q_Score":8,"Tags":"c++,python","A_Id":615121,"CreationDate":"2009-03-05T14:52:00.000","Title":"Should I learn Python after 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},{"Question":"I`m currently studying C++ and want to learn another language.\nFor work I use C# + ASP (just started learning it, actually), but I want something \"less Microsoft\" and powerful.\nI have heard Python is a popular and powerful language, not so complicated as C++. But many people mentioned it was hard for them to get back to C++\/Java from Python because they started thinking in it, get used to absence of memory management, etc.\nWhat do you recommend?","AnswerCount":17,"Available Count":17,"Score":0.0117641631,"is_accepted":false,"ViewCount":9495,"Q_Id":615100,"Users Score":1,"Answer":"Learning more languages can only make you a better developer, regardless of their approach. Besides, your experience with C++ (or, at least C) will come in handy for writing high-performance parts of your applications using Python's C API, which lets \"raw\" C and C++ code intermingle nicely with the pure Python stuff.\nI still write code in Objective-C (1.0... before memory management) and Python on a daily basis. The variety is actually fun, rather than confusing; keeps things from being boring.","Q_Score":8,"Tags":"c++,python","A_Id":615129,"CreationDate":"2009-03-05T14:52:00.000","Title":"Should I learn Python after 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},{"Question":"I`m currently studying C++ and want to learn another language.\nFor work I use C# + ASP (just started learning it, actually), but I want something \"less Microsoft\" and powerful.\nI have heard Python is a popular and powerful language, not so complicated as C++. But many people mentioned it was hard for them to get back to C++\/Java from Python because they started thinking in it, get used to absence of memory management, etc.\nWhat do you recommend?","AnswerCount":17,"Available Count":17,"Score":0.0235250705,"is_accepted":false,"ViewCount":9495,"Q_Id":615100,"Users Score":2,"Answer":"Python is complementary to C++ and easy to integrate with C++. (As evidence of this claim, the C++ gurus from Boost use Python.)\nAnd as you said, Python gives you a way to get a perspective outside the Microsoft orbit. But even there, if you need to integrate Python with MS tools, there's IronPython.","Q_Score":8,"Tags":"c++,python","A_Id":615163,"CreationDate":"2009-03-05T14:52:00.000","Title":"Should I learn Python after 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},{"Question":"I`m currently studying C++ and want to learn another language.\nFor work I use C# + ASP (just started learning it, actually), but I want something \"less Microsoft\" and powerful.\nI have heard Python is a popular and powerful language, not so complicated as C++. But many people mentioned it was hard for them to get back to C++\/Java from Python because they started thinking in it, get used to absence of memory management, etc.\nWhat do you recommend?","AnswerCount":17,"Available Count":17,"Score":0.0,"is_accepted":false,"ViewCount":9495,"Q_Id":615100,"Users Score":0,"Answer":"You could learn a new programming language, like python, and use it to do all the tasks you'd normally perform in your 'core' languages; or you could take a language (like python, or perl) and use it to complement your core language.\nYou could learn VBScript and use it to write scripts that glue your code and others together. If you want something less Microsoft, then python, perl or bash scripting would be a good idea - not just to learn how to code in the new, but also how to do things differently from the usual 'code an app' way.","Q_Score":8,"Tags":"c++,python","A_Id":615155,"CreationDate":"2009-03-05T14:52:00.000","Title":"Should I learn Python after 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},{"Question":"I`m currently studying C++ and want to learn another language.\nFor work I use C# + ASP (just started learning it, actually), but I want something \"less Microsoft\" and powerful.\nI have heard Python is a popular and powerful language, not so complicated as C++. But many people mentioned it was hard for them to get back to C++\/Java from Python because they started thinking in it, get used to absence of memory management, etc.\nWhat do you recommend?","AnswerCount":17,"Available Count":17,"Score":0.0470241165,"is_accepted":false,"ViewCount":9495,"Q_Id":615100,"Users Score":4,"Answer":"Many would argue that you would benefit from learning Python before C++. \n\nThe syntax hurdles are much, much lower;\nDebugging is much more friendly\nThere are a plethora of libraries---batteries included, you know. It's easy to \nexperiment with web scraping, XML, etc. in Python. Again, the barriers to entry\nin C++ are much higher.\n\nIt's still good to learn C\/C++, because of its close connection to the machine. But a new programmer can learn an awful lot from exploring in Python.","Q_Score":8,"Tags":"c++,python","A_Id":615152,"CreationDate":"2009-03-05T14:52:00.000","Title":"Should I learn Python after 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},{"Question":"I`m currently studying C++ and want to learn another language.\nFor work I use C# + ASP (just started learning it, actually), but I want something \"less Microsoft\" and powerful.\nI have heard Python is a popular and powerful language, not so complicated as C++. But many people mentioned it was hard for them to get back to C++\/Java from Python because they started thinking in it, get used to absence of memory management, etc.\nWhat do you recommend?","AnswerCount":17,"Available Count":17,"Score":0.0117641631,"is_accepted":false,"ViewCount":9495,"Q_Id":615100,"Users Score":1,"Answer":"It is up to what exactly is the kind of applications you want to program, for example for Websites that need access to databases I would go for Ruby( and Ruby on Rails framework ) , for financial applications or applications that need a lot of parallel processing I would go for a funcional programming language like Haskell, oCaml or the new F#, these last 3 wil make you a better programer even if you don't programm a lot in them , by the way c# has been lately in the latest versions adding more and more funcional programming features. I would learn Python for a security and exploits kinds of applications.","Q_Score":8,"Tags":"c++,python","A_Id":615150,"CreationDate":"2009-03-05T14:52:00.000","Title":"Should I learn Python after 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},{"Question":"I`m currently studying C++ and want to learn another language.\nFor work I use C# + ASP (just started learning it, actually), but I want something \"less Microsoft\" and powerful.\nI have heard Python is a popular and powerful language, not so complicated as C++. But many people mentioned it was hard for them to get back to C++\/Java from Python because they started thinking in it, get used to absence of memory management, etc.\nWhat do you recommend?","AnswerCount":17,"Available Count":17,"Score":0.0470241165,"is_accepted":false,"ViewCount":9495,"Q_Id":615100,"Users Score":4,"Answer":"Well, I've learnt Python after C\/C++, Java and C#. Python is a great language, and its simplicity and consistency have improved the way I code. It has also helped me think more clearly about the algorithms underlying my code. I could go on about the benifits it brought me, instead I'll summarize the reason to learn it ->\n\nLearning a new lanuage doesn't take away, it adds to your programming skill and keeps you sharp by teaching you to shift between the frames of mind that each language requires.\n\nSo go out there and learn Python. Your code will improve(TM).\nP.S.\n1.You'll lose C++ (or any other language) skills, if you neglect their upkeep and maintainance. Thats entirely up to you.\n2.Programmer (intelligent) laziness is a virtue.","Q_Score":8,"Tags":"c++,python","A_Id":615148,"CreationDate":"2009-03-05T14:52:00.000","Title":"Should I learn Python after 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},{"Question":"I`m currently studying C++ and want to learn another language.\nFor work I use C# + ASP (just started learning it, actually), but I want something \"less Microsoft\" and powerful.\nI have heard Python is a popular and powerful language, not so complicated as C++. But many people mentioned it was hard for them to get back to C++\/Java from Python because they started thinking in it, get used to absence of memory management, etc.\nWhat do you recommend?","AnswerCount":17,"Available Count":17,"Score":0.0,"is_accepted":false,"ViewCount":9495,"Q_Id":615100,"Users Score":0,"Answer":"I learned, in order:\n\nBASIC\nPascal\nAda\n(A little bit of Haskell)\nJava\nPython\nC++\nC#\n\nI don't feel Python inhibited my ability to learn or use C++. I am glad though that I learned pointers in Pascal before encountering reference types in Java, Python and C#, because I feel it gave me a good basis to understand the idea of the differences between \"value types\" and \"reference types\". I think for me the most important of those languages are Python, Haskell and C++. All of them complement each other, and although there are times I'm working in one and wish I had a feature from another, on the whole I think I benefit greatly from a deeper understanding of things like type systems, object orientation and metaprogramming by seeing the different ways these languages approach these things.","Q_Score":8,"Tags":"c++,python","A_Id":615248,"CreationDate":"2009-03-05T14:52:00.000","Title":"Should I learn Python after 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},{"Question":"I`m currently studying C++ and want to learn another language.\nFor work I use C# + ASP (just started learning it, actually), but I want something \"less Microsoft\" and powerful.\nI have heard Python is a popular and powerful language, not so complicated as C++. But many people mentioned it was hard for them to get back to C++\/Java from Python because they started thinking in it, get used to absence of memory management, etc.\nWhat do you recommend?","AnswerCount":17,"Available Count":17,"Score":0.0117641631,"is_accepted":false,"ViewCount":9495,"Q_Id":615100,"Users Score":1,"Answer":"I learned C\/C++, Java, Python & C# in that order.\nThe two I actually invariably end up using are C++ & Python; I find the niche Java & C# occupy between them to be too narrow to feel the need to use them much (at least for the stuff I do).\nI also think I didn't really \"get\" C++ functors and boost::bind until I'd been exposed to Python.","Q_Score":8,"Tags":"c++,python","A_Id":618870,"CreationDate":"2009-03-05T14:52:00.000","Title":"Should I learn Python after 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},{"Question":"I`m currently studying C++ and want to learn another language.\nFor work I use C# + ASP (just started learning it, actually), but I want something \"less Microsoft\" and powerful.\nI have heard Python is a popular and powerful language, not so complicated as C++. But many people mentioned it was hard for them to get back to C++\/Java from Python because they started thinking in it, get used to absence of memory management, etc.\nWhat do you recommend?","AnswerCount":17,"Available Count":17,"Score":0.0117641631,"is_accepted":false,"ViewCount":9495,"Q_Id":615100,"Users Score":1,"Answer":"Flex your brain and improve your skill set. Give a functional language a whirl.","Q_Score":8,"Tags":"c++,python","A_Id":615138,"CreationDate":"2009-03-05T14:52:00.000","Title":"Should I learn Python after 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},{"Question":"I`m currently studying C++ and want to learn another language.\nFor work I use C# + ASP (just started learning it, actually), but I want something \"less Microsoft\" and powerful.\nI have heard Python is a popular and powerful language, not so complicated as C++. But many people mentioned it was hard for them to get back to C++\/Java from Python because they started thinking in it, get used to absence of memory management, etc.\nWhat do you recommend?","AnswerCount":17,"Available Count":17,"Score":0.0,"is_accepted":false,"ViewCount":9495,"Q_Id":615100,"Users Score":0,"Answer":"It is true. After learning python, everything else will seem like too much effort for the same amount of real work being done. You'll get used to the clean, small syntax and the freedom of GC. You will enjoy working in list comps, generators, etc. You'll start to think in python and C++ and Java will be like building a ship in a bottle one twiggy little stick at a time.\nBut since it's that much easier, doesn't it tempt you to try it all the more?","Q_Score":8,"Tags":"c++,python","A_Id":617254,"CreationDate":"2009-03-05T14:52:00.000","Title":"Should I learn Python after 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},{"Question":"I`m currently studying C++ and want to learn another language.\nFor work I use C# + ASP (just started learning it, actually), but I want something \"less Microsoft\" and powerful.\nI have heard Python is a popular and powerful language, not so complicated as C++. But many people mentioned it was hard for them to get back to C++\/Java from Python because they started thinking in it, get used to absence of memory management, etc.\nWhat do you recommend?","AnswerCount":17,"Available Count":17,"Score":0.0,"is_accepted":false,"ViewCount":9495,"Q_Id":615100,"Users Score":0,"Answer":"I think it is always good to know several programming languages. I've learned c++ at school and I've used it a lot in the past years because it is really a standard in the industry. I've learned python by my own and I am using it to make a lot of nice tools that would be too long to write in c++. \nPython has just a very positive influence on my c++ skills. It gives another way to think.","Q_Score":8,"Tags":"c++,python","A_Id":949801,"CreationDate":"2009-03-05T14:52:00.000","Title":"Should I learn Python after 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},{"Question":"I`m currently studying C++ and want to learn another language.\nFor work I use C# + ASP (just started learning it, actually), but I want something \"less Microsoft\" and powerful.\nI have heard Python is a popular and powerful language, not so complicated as C++. But many people mentioned it was hard for them to get back to C++\/Java from Python because they started thinking in it, get used to absence of memory management, etc.\nWhat do you recommend?","AnswerCount":17,"Available Count":17,"Score":1.2,"is_accepted":true,"ViewCount":9495,"Q_Id":615100,"Users Score":30,"Answer":"There's no right or wrong answer, really. But I think you'll benefit more from learning Python. Given the similarities between C# and C++, you'll learn a different way of thinking from Python. The more ways you learn to think about a problem, the better it makes you as a programmer, regardless of the language.","Q_Score":8,"Tags":"c++,python","A_Id":615128,"CreationDate":"2009-03-05T14:52:00.000","Title":"Should I learn Python after 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},{"Question":"I`m currently studying C++ and want to learn another language.\nFor work I use C# + ASP (just started learning it, actually), but I want something \"less Microsoft\" and powerful.\nI have heard Python is a popular and powerful language, not so complicated as C++. But many people mentioned it was hard for them to get back to C++\/Java from Python because they started thinking in it, get used to absence of memory management, etc.\nWhat do you recommend?","AnswerCount":17,"Available Count":17,"Score":1.0,"is_accepted":false,"ViewCount":9495,"Q_Id":615100,"Users Score":9,"Answer":"The benefit of going from a more static language to a dynamic language is to change your programming paradigm -- it's not a matter of becoming \"lazy\" so much as realizing new ways of accomplishing things, which will make you better in any language.","Q_Score":8,"Tags":"c++,python","A_Id":615118,"CreationDate":"2009-03-05T14:52:00.000","Title":"Should I learn Python after 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},{"Question":"I`m currently studying C++ and want to learn another language.\nFor work I use C# + ASP (just started learning it, actually), but I want something \"less Microsoft\" and powerful.\nI have heard Python is a popular and powerful language, not so complicated as C++. But many people mentioned it was hard for them to get back to C++\/Java from Python because they started thinking in it, get used to absence of memory management, etc.\nWhat do you recommend?","AnswerCount":17,"Available Count":17,"Score":0.0117641631,"is_accepted":false,"ViewCount":9495,"Q_Id":615100,"Users Score":1,"Answer":"Many languages are quite similar to others, but to move between imperitave and functional \/ dynamic and static \/ Object and Procedural languages you do need to train yourself to think within the constraints of the language you are using. Since most projects are at least a few weeks, this is generally not a problem after the first few days.\nYou will find it more difficult to switch away from a language+environment you enjoy in your after-hours \/ hobby development.\n\nC, Macro Assembler => basically the same - difference is mainly libraries\nC++, Java, C#, Delphi => basically the same paradigm - you learn quickly how to leverage the features of the specific language and adopt concepts from one syntax to another. It's basically the same way of thinking, the biggest exception is how you think of memory manangement.\nPython - good language, strategically a better choice than ruby, although there are other aspects of ruby that can be argued to be superior. What make python a good choice is the presence of a formal language body which keeps python environments on different platforms very compatible to one another.\n\nIf you are interested, read this http:\/\/cmdematos.com\/?p=120 on making a strategic language choice.","Q_Score":8,"Tags":"c++,python","A_Id":1235385,"CreationDate":"2009-03-05T14:52:00.000","Title":"Should I learn Python after 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},{"Question":"I`m currently studying C++ and want to learn another language.\nFor work I use C# + ASP (just started learning it, actually), but I want something \"less Microsoft\" and powerful.\nI have heard Python is a popular and powerful language, not so complicated as C++. But many people mentioned it was hard for them to get back to C++\/Java from Python because they started thinking in it, get used to absence of memory management, etc.\nWhat do you recommend?","AnswerCount":17,"Available Count":17,"Score":0.0,"is_accepted":false,"ViewCount":9495,"Q_Id":615100,"Users Score":0,"Answer":"From a utility perspective, it is good to learn one of the more dynamic languages like Python (or Ruby or Perl) too. Not only do they stretch your mind, but they are superior for certain kinds of tasks. If you want to manipulate text, for example, C++ is a lot harder to use than Python. It gives you another arrow in your quiver to use when appropriate.","Q_Score":8,"Tags":"c++,python","A_Id":615218,"CreationDate":"2009-03-05T14:52:00.000","Title":"Should I learn Python after 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},{"Question":"I want to get all the messages from my gmail inbox, but I am facing 2 problems.\n\nIt does not get all the emails, (as per the count in stat function)\nThe order of emails it get is random.\n\nI am unsure if its the problem with poplib or gmail pop server.\nWhat am I missing here?","AnswerCount":4,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":1096,"Q_Id":617892,"Users Score":2,"Answer":"You can also try imaplib module since GMail also provides access to email via IMAP protocol.","Q_Score":1,"Tags":"python,python-2.5,poplib","A_Id":628130,"CreationDate":"2009-03-06T06:55:00.000","Title":"Poplib not working correctly?","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},{"Question":"From what I have seen and read on blogs, PyPy is a very ambitious project. What are some advantages it will bring to the table over its siblings (CPython, Jython, and IronPython)? Is it speed, cross-platform compatibility (including mobile platforms), the ability to use c-extensions without the GIL, or is this more of a technical exercise on what can be done?","AnswerCount":4,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":3214,"Q_Id":619437,"Users Score":0,"Answer":"cross-platform compatibility\n\nYes","Q_Score":28,"Tags":"python,interpreter,pypy","A_Id":619480,"CreationDate":"2009-03-06T16:25:00.000","Title":"What does PyPy have to offer over CPython, Jython, and 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},{"Question":"From what I have seen and read on blogs, PyPy is a very ambitious project. What are some advantages it will bring to the table over its siblings (CPython, Jython, and IronPython)? Is it speed, cross-platform compatibility (including mobile platforms), the ability to use c-extensions without the GIL, or is this more of a technical exercise on what can be done?","AnswerCount":4,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":3214,"Q_Id":619437,"Users Score":38,"Answer":"PyPy is really two projects:\n\nAn interpreter compiler toolchain allowing you to write interpreters in RPython (a static subset of Python) and have cross-platform interpreters compiled standalone, for the JVM, for .NET (etc)\nAn implementation of Python in RPython\n\nThese two projects allow for many things.\n\nMaintaining Python in Python is much easier than maintaining it in C\nFrom a single codebase you can generate Python interpreters that run on the JVM, .NET and standalone - rather than having multiple slightly incompatible implementations\nPart of the compiler toolchain includes an experimental JIT generator (now in its fifth incarnation and starting to work really well) - the goal is for a JITed PyPy to run much faster than CPython\nIt is much easier to experiment with fundamental language features - like removing the GIL, better garbage collection, integrating stackless and so on\n\nSo there are really a lot of reasons for PyPy to be exciting, and it is finally starting to live up to all its promises.","Q_Score":28,"Tags":"python,interpreter,pypy","A_Id":619544,"CreationDate":"2009-03-06T16:25:00.000","Title":"What does PyPy have to offer over CPython, Jython, and 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},{"Question":"I need to download emails from the gmail inbox only using poplib.Unfortunately I do not see any option to select Inbox alone, and poplib gives me emails from sent items too.\nHow do I select emails only from inbox?\nI dont want to use any gmail specific libraries.","AnswerCount":3,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":2392,"Q_Id":625148,"Users Score":4,"Answer":"POP3 has no concept of 'folders'. If gmail is showing you both 'sent' as well as 'received' mail, then you really don't have any option but to receive all that email.\nPerhaps you would be better off using IMAP4 instead of POP3. Python has libraries that will work with gmail's IMAP4 server.","Q_Score":2,"Tags":"python,gmail,pop3,poplib","A_Id":625175,"CreationDate":"2009-03-09T05:49:00.000","Title":"Select mails from inbox alone via poplib","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},{"Question":"I have a program in C that communicates via UDP with another program (in Java) and then does process manipulation (start\/stop) based on the UDP pkt exchange.\nNow this C program has been legacy and I want to convert it to Python - do you think Python will be a good choice for the tasks mentioned?","AnswerCount":7,"Available Count":6,"Score":0.0285636566,"is_accepted":false,"ViewCount":381,"Q_Id":632730,"Users Score":1,"Answer":"If I was faced with a similar situation I'd ask myself a couple of questions:\n\nIs there anything more important I could be working on?\nDoes Python bring anything to the table that is currently handled poorly by the current application?\nWill this allow me to add functionality that was previously too difficult to implement?\nIs this going to disrupt service in any way?\n\nIf I can't answer those satisfactorily, then I'd put off the rewrite.","Q_Score":2,"Tags":"python,c","A_Id":632844,"CreationDate":"2009-03-10T23:47:00.000","Title":"What is the feasibility of porting a legacy C program 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":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have a program in C that communicates via UDP with another program (in Java) and then does process manipulation (start\/stop) based on the UDP pkt exchange.\nNow this C program has been legacy and I want to convert it to Python - do you think Python will be a good choice for the tasks mentioned?","AnswerCount":7,"Available Count":6,"Score":0.0,"is_accepted":false,"ViewCount":381,"Q_Id":632730,"Users Score":0,"Answer":"If this is an embedded program, then it might be a problem to port it since Python programs typically rely on the Python runtime and library, and those are fairly large. Especially when compared to a C program doing a well-defined task. Of course, it's likely you've already considered that aspect, but I wanted to mention it in the context of the question anyway, since I feel it's an important aspect when doing this type of comparison.","Q_Score":2,"Tags":"python,c","A_Id":634093,"CreationDate":"2009-03-10T23:47:00.000","Title":"What is the feasibility of porting a legacy C program 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":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have a program in C that communicates via UDP with another program (in Java) and then does process manipulation (start\/stop) based on the UDP pkt exchange.\nNow this C program has been legacy and I want to convert it to Python - do you think Python will be a good choice for the tasks mentioned?","AnswerCount":7,"Available Count":6,"Score":0.0285636566,"is_accepted":false,"ViewCount":381,"Q_Id":632730,"Users Score":1,"Answer":"Assuming that you have control over the environment which this application will run, and that the performance of interpreted language (python) compared to a compiled one (C) can be ignored, I believe Python is a great choice for this.","Q_Score":2,"Tags":"python,c","A_Id":632740,"CreationDate":"2009-03-10T23:47:00.000","Title":"What is the feasibility of porting a legacy C program 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":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have a program in C that communicates via UDP with another program (in Java) and then does process manipulation (start\/stop) based on the UDP pkt exchange.\nNow this C program has been legacy and I want to convert it to Python - do you think Python will be a good choice for the tasks mentioned?","AnswerCount":7,"Available Count":6,"Score":0.1137907297,"is_accepted":false,"ViewCount":381,"Q_Id":632730,"Users Score":4,"Answer":"I'd say that if:\n\nYour C code contains no platform specific requirements\nYou are sure speed is not going to be an issue going from C to python\nYou have a desire to not compile anymore\nYou would like to try utilise exception handling\nYou want to dabble in OO\nYou might choose to run on many platforms without porting\nYou are curious about dynamic typing\nYou want memory handled for you\nYou know or want to learn python\n\nThen sure, why not. \nThere doesn't seem to be any technical reason you shouldn't use python here, so it's a preference in this case.","Q_Score":2,"Tags":"python,c","A_Id":632788,"CreationDate":"2009-03-10T23:47:00.000","Title":"What is the feasibility of porting a legacy C program 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":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have a program in C that communicates via UDP with another program (in Java) and then does process manipulation (start\/stop) based on the UDP pkt exchange.\nNow this C program has been legacy and I want to convert it to Python - do you think Python will be a good choice for the tasks mentioned?","AnswerCount":7,"Available Count":6,"Score":0.057080742,"is_accepted":false,"ViewCount":381,"Q_Id":632730,"Users Score":2,"Answer":"Remember as well, you can leave parts of your program in C, turn them into Python modules and build python code around them - you don't need to re-write everything up-front.","Q_Score":2,"Tags":"python,c","A_Id":632925,"CreationDate":"2009-03-10T23:47:00.000","Title":"What is the feasibility of porting a legacy C program 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":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have a program in C that communicates via UDP with another program (in Java) and then does process manipulation (start\/stop) based on the UDP pkt exchange.\nNow this C program has been legacy and I want to convert it to Python - do you think Python will be a good choice for the tasks mentioned?","AnswerCount":7,"Available Count":6,"Score":0.0285636566,"is_accepted":false,"ViewCount":381,"Q_Id":632730,"Users Score":1,"Answer":"Yes, I think Python is a good choice, if all your platforms support it. Since this is a network program, I'm assuming the network is your runtime bottleneck? That's likely to still be the case in Python. If you really do need to speed it up, you can include your long-since-debugged, speedy C as Python modules.","Q_Score":2,"Tags":"python,c","A_Id":632935,"CreationDate":"2009-03-10T23:47:00.000","Title":"What is the feasibility of porting a legacy C program 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":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"What is out there on conventions and tools for documenting python source code?","AnswerCount":5,"Available Count":1,"Score":0.0399786803,"is_accepted":false,"ViewCount":15370,"Q_Id":635419,"Users Score":1,"Answer":"using doxypy filter with doxygen is a good thing also","Q_Score":21,"Tags":"python,documentation,documentation-generation","A_Id":22247361,"CreationDate":"2009-03-11T16:54:00.000","Title":"code documentation 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},{"Question":"I'd like to have your opinion about writing web apps in PHP vs. a long-running process using tools such as Django or Turbogears for Python.\nAs far as I know:\n- In PHP, pages are fetched from the hard-disk every time (although I assume the OS keeps files in RAM for a while after they've been accessed)\n- Pages are recompiled into opcode every time (although tools from eg. Zend can keep a compiled version in RAM)\n- Fetching pages every time means reading global and session data every time, and re-opening connections to the DB\nSo, I guess PHP makes sense on a shared server (multiple sites sharing the same host) to run apps with moderate use, while a long-running process offers higher performance with apps that run on a dedicated server and are under heavy use?\nThanks for any feedback.","AnswerCount":5,"Available Count":3,"Score":0.0399786803,"is_accepted":false,"ViewCount":1789,"Q_Id":639409,"Users Score":1,"Answer":"PHP is fine for either use in my opinion, the performance overheads are rarely noticed. It's usually other processes which will delay the program. It's easy to cache PHP programs with something like eAccelerator.","Q_Score":5,"Tags":"php,python","A_Id":639435,"CreationDate":"2009-03-12T16:22:00.000","Title":"PHP vs. long-running process (Python, Java, etc.)?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I'd like to have your opinion about writing web apps in PHP vs. a long-running process using tools such as Django or Turbogears for Python.\nAs far as I know:\n- In PHP, pages are fetched from the hard-disk every time (although I assume the OS keeps files in RAM for a while after they've been accessed)\n- Pages are recompiled into opcode every time (although tools from eg. Zend can keep a compiled version in RAM)\n- Fetching pages every time means reading global and session data every time, and re-opening connections to the DB\nSo, I guess PHP makes sense on a shared server (multiple sites sharing the same host) to run apps with moderate use, while a long-running process offers higher performance with apps that run on a dedicated server and are under heavy use?\nThanks for any feedback.","AnswerCount":5,"Available Count":3,"Score":0.1194272985,"is_accepted":false,"ViewCount":1789,"Q_Id":639409,"Users Score":3,"Answer":"After you apply memcache, opcode caching, and connection pooling, the only real difference between PHP and other options is that PHP is short-lived, processed based, while other options are, typically, long-lived multithreaded based.\nThe advantage PHP has is that its dirt simple to write scripts. You don't have to worry about memory management (its always released at the end of the request), and you don't have to worry about concurrency very much.\nThe major disadvantage, I can see anyways, is that some more advanced (sometimes crazier?) things are harder: pre-computing results, warming caches, reusing existing data, request prioritizing, and asynchronous programming. I'm sure people can think of many more.\nMost of the time, though, those disadvantages aren't a big deal. You can scale by adding more machines and using more caching. The average web developer doesn't need to worry about concurrency control or memory management, so taking the minuscule hit from removing them isn't a big deal.","Q_Score":5,"Tags":"php,python","A_Id":639537,"CreationDate":"2009-03-12T16:22:00.000","Title":"PHP vs. long-running process (Python, Java, etc.)?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I'd like to have your opinion about writing web apps in PHP vs. a long-running process using tools such as Django or Turbogears for Python.\nAs far as I know:\n- In PHP, pages are fetched from the hard-disk every time (although I assume the OS keeps files in RAM for a while after they've been accessed)\n- Pages are recompiled into opcode every time (although tools from eg. Zend can keep a compiled version in RAM)\n- Fetching pages every time means reading global and session data every time, and re-opening connections to the DB\nSo, I guess PHP makes sense on a shared server (multiple sites sharing the same host) to run apps with moderate use, while a long-running process offers higher performance with apps that run on a dedicated server and are under heavy use?\nThanks for any feedback.","AnswerCount":5,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":1789,"Q_Id":639409,"Users Score":0,"Answer":"As many others have noted, PHP nor Django are going to be your bottlenecks. Hitting the hard disk for the bytecode on PHP is irrelevant for a heavily trafficked site because caching will take over at that point. The same is true for Django.\nModel\/View and user experience design will have order of magnitude benefits to performance over the language itself.","Q_Score":5,"Tags":"php,python","A_Id":640138,"CreationDate":"2009-03-12T16:22:00.000","Title":"PHP vs. long-running process (Python, Java, etc.)?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I would like to auto-fill a paragraph to 80 characters (or some other fixed width) in Eclipse. Is this possible via a keyboard command like in Emacs? Or is there maybe a plugin (I did not find anything on google)?\nEdit: I am not sure if this is relevant, but I need this for docstrings in Python code (using the PyDev plugin).","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":1354,"Q_Id":643422,"Users Score":2,"Answer":"Highlight the text, then press Ctrl-Shift-F, or open the context menu and select Source \/ Format.","Q_Score":2,"Tags":"python,eclipse,formatting,word-wrap","A_Id":643439,"CreationDate":"2009-03-13T16:05:00.000","Title":"How can I auto-fill a paragraph 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":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a Python module with nothing but regular global functions. I need to call it from another business-domain scripting environment that can only call out to C DLLs. Is there anyway to build my Python modules so that to other code it can be called like a standard C function that's exported from a DLL? This is for a Windows environment. I'm aware of IronPython, but as far as I know it can only build .NET Assemblies, which are not callable as C DLL functions.","AnswerCount":3,"Available Count":1,"Score":0.1325487884,"is_accepted":false,"ViewCount":310,"Q_Id":645892,"Users Score":2,"Answer":"Py2exe can generate COM dlls from python code, by compiling and embedding python code + interpreter. It does not, AFAIK, support regular DLLs yet. For that, see dirkgently's answer about embedding python yourself.","Q_Score":7,"Tags":"python","A_Id":645935,"CreationDate":"2009-03-14T13:11:00.000","Title":"Is there a way to build a C-like DLL from a 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},{"Question":"I am new to Satchmo -- picked it up because I needed payment processing for site subscriptions and physical product.\nMy site will have two classes of users: paid subscribers and free users. Both can order a \nphysical product. Paid subscribers get an automatic discount on all orders.\nI don't see a configuration for this in the admin. (Discount looks like it would apply to all users. If I'm missing something here, let me know.)\nSo what's the best place to automatically override the price depending on the user class? The displayed price should show up, say, 10% less for subscribers everywhere in the site, not just at the checkout.\nThanks.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":312,"Q_Id":647257,"Users Score":2,"Answer":"Checkout the tiered pricing module","Q_Score":1,"Tags":"python,django,satchmo","A_Id":1198670,"CreationDate":"2009-03-15T03:46:00.000","Title":"Provide discount to preferred customer with 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":1},{"Question":"One of Python's strongest points is the ease of writing C and C++ extensions to speed up processor intensive parts of the code. Can these extensions avoid the Global Interpreter Lock or are they also restricted by the GIL? If not, then this \"ease of extension\" is even more of a killer feature than I previously realized. I suspect the answer is not a simple yes-or-no but I am not sure, so I am asking the question here on StackOverflow.","AnswerCount":4,"Available Count":1,"Score":0.049958375,"is_accepted":false,"ViewCount":7350,"Q_Id":651048,"Users Score":1,"Answer":"Check out Cython, it has similar syntax to Python but with a few constructs like \"cdef\", fast numpy access functions, and a \"with nogil\" statement (which does what it says).","Q_Score":28,"Tags":"c++,python,c,multithreading","A_Id":733143,"CreationDate":"2009-03-16T16:00:00.000","Title":"Concurrency: Are Python extensions written in C\/C++ affected by the Global Interpreter Lock?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I need advice and how to got about setting up a simple service for my users. I would like to add a new feature where users can send and receive emails from their gmail account. I have seen this done several times and I know its possible.\nThere use to be a project for \"Libgmailer\" at sourceforge but I think it was abandoned. Is anyone aware of anything similar?\nI have found that Gmail has a Python API but my site is making use of PHP.\nI really need ideas on how to best go about this!\nThanks all for any input","AnswerCount":3,"Available Count":3,"Score":1.2,"is_accepted":true,"ViewCount":498,"Q_Id":656180,"Users Score":6,"Answer":"any library\/source that works with imap or pop will work.","Q_Score":1,"Tags":"php,python,email,gmail","A_Id":656198,"CreationDate":"2009-03-17T21:51:00.000","Title":"Implementation: How to retrieve and send emails for different Gmail accounts?","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},{"Question":"I need advice and how to got about setting up a simple service for my users. I would like to add a new feature where users can send and receive emails from their gmail account. I have seen this done several times and I know its possible.\nThere use to be a project for \"Libgmailer\" at sourceforge but I think it was abandoned. Is anyone aware of anything similar?\nI have found that Gmail has a Python API but my site is making use of PHP.\nI really need ideas on how to best go about this!\nThanks all for any input","AnswerCount":3,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":498,"Q_Id":656180,"Users Score":0,"Answer":"Just a thought, Gmail supports POP\/IMAP access. Could you do it using those protocols? It would mean asking your users to go into their gmail and enable it though.","Q_Score":1,"Tags":"php,python,email,gmail","A_Id":656205,"CreationDate":"2009-03-17T21:51:00.000","Title":"Implementation: How to retrieve and send emails for different Gmail accounts?","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},{"Question":"I need advice and how to got about setting up a simple service for my users. I would like to add a new feature where users can send and receive emails from their gmail account. I have seen this done several times and I know its possible.\nThere use to be a project for \"Libgmailer\" at sourceforge but I think it was abandoned. Is anyone aware of anything similar?\nI have found that Gmail has a Python API but my site is making use of PHP.\nI really need ideas on how to best go about this!\nThanks all for any input","AnswerCount":3,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":498,"Q_Id":656180,"Users Score":0,"Answer":"Well if Google didn't come up with anything personally I'd see if I could reverse engineer the Python API by implementing it and watching it with a packet sniffer. My guess is it's just accessing some web service which should be pretty easy to mimic regardless of the language you're using.","Q_Score":1,"Tags":"php,python,email,gmail","A_Id":656194,"CreationDate":"2009-03-17T21:51:00.000","Title":"Implementation: How to retrieve and send emails for different Gmail accounts?","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},{"Question":"I've been playing with PyWinAuto today and having fun automating all sorts GUI tests. I was wondering if it is still state of the art or if there might be something else (also free) which does windows rich client automation better.","AnswerCount":4,"Available Count":2,"Score":0.1488850336,"is_accepted":false,"ViewCount":6625,"Q_Id":656779,"Users Score":3,"Answer":"I am going the same way, bit by bit and I have to say that python + pywinauto is good stuff!","Q_Score":10,"Tags":"python,pywinauto","A_Id":6291256,"CreationDate":"2009-03-18T02:34:00.000","Title":"PyWinAuto still useful?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I've been playing with PyWinAuto today and having fun automating all sorts GUI tests. I was wondering if it is still state of the art or if there might be something else (also free) which does windows rich client automation better.","AnswerCount":4,"Available Count":2,"Score":1.0,"is_accepted":false,"ViewCount":6625,"Q_Id":656779,"Users Score":8,"Answer":"I used to do test automation on our projects with AutoIt but switched over to pywinauto 3 months ago and have been very happy with that decision. There are some rough edges, but I've been able to fill them in with my own supplementary test functions. In addition I find that coding tests and support code in Python is much easier and more manageable compared to AutoIt. With Python I have way more powerful options for logging, debugging, documentation, process management and test configuration. For me it was absolutely the right way to go.","Q_Score":10,"Tags":"python,pywinauto","A_Id":1653008,"CreationDate":"2009-03-18T02:34:00.000","Title":"PyWinAuto still useful?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"Is there a way of knowing which modules are available to import from inside a package?","AnswerCount":4,"Available Count":2,"Score":-0.0996679946,"is_accepted":false,"ViewCount":284,"Q_Id":657868,"Users Score":-2,"Answer":"import fred\nprint dir(fred)","Q_Score":2,"Tags":"python,import","A_Id":657927,"CreationDate":"2009-03-18T11:30:00.000","Title":"How do I find the modules that are available for import from within a 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},{"Question":"Is there a way of knowing which modules are available to import from inside a package?","AnswerCount":4,"Available Count":2,"Score":-0.049958375,"is_accepted":false,"ViewCount":284,"Q_Id":657868,"Users Score":-1,"Answer":"You have the source.\nLook at the files inside the package directory. Those modules are available for you to import.","Q_Score":2,"Tags":"python,import","A_Id":658158,"CreationDate":"2009-03-18T11:30:00.000","Title":"How do I find the modules that are available for import from within a 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},{"Question":"I am stuck with a fairly complex Python module that does not return useful error codes (it actually fails disturbingly silently). However, the underlying C library it calls sets errno.\nNormally errno comes in over OSError attributes, but since I don't have an exception, I can't get at it.\nUsing ctypes, libc.errno doesn't work because errno is a macro in GNU libc. Python 2.6 has some affordances but Debian still uses Python 2.5. Inserting a C module into my pure Python program just to read errno disgusts me.\nIs there some way to access errno? A Linux-only solution is fine, since the library being wrapped is Linux-only. I also don't have to worry about threads, as I'm only running one thread during the time in which this can fail.","AnswerCount":6,"Available Count":1,"Score":0.0333209931,"is_accepted":false,"ViewCount":10955,"Q_Id":661017,"Users Score":1,"Answer":"ctypes actually gives a standard way to access python's c implementation, which is using errno. I haven't tested this on anything other than my (linux) system, but this should be very portable:\nctypes.c_int.in_dll(ctypes.pythonapi,\"errno\")\nwhich returns a c_int containing the current value.","Q_Score":25,"Tags":"python,linux,python-2.5,errno","A_Id":6170629,"CreationDate":"2009-03-19T04:00:00.000","Title":"Access to errno 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},{"Question":"Is there a simple way of testing if the generator has no items, like peek, hasNext, isEmpty, something along those lines?","AnswerCount":24,"Available Count":3,"Score":1.2,"is_accepted":true,"ViewCount":101926,"Q_Id":661603,"Users Score":66,"Answer":"The simple answer to your question: no, there is no simple way. There are a whole lot of work-arounds.\nThere really shouldn't be a simple way, because of what generators are: a way to output a sequence of values without holding the sequence in memory. So there's no backward traversal.\nYou could write a has_next function or maybe even slap it on to a generator as a method with a fancy decorator if you wanted to.","Q_Score":206,"Tags":"python,generator","A_Id":662925,"CreationDate":"2009-03-19T09:51:00.000","Title":"How do I know if a generator is empty from the 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":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Is there a simple way of testing if the generator has no items, like peek, hasNext, isEmpty, something along those lines?","AnswerCount":24,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":101926,"Q_Id":661603,"Users Score":0,"Answer":"There's a very simple solution: if next(generator,-1) == -1 then the generator is empty!","Q_Score":206,"Tags":"python,generator","A_Id":64162865,"CreationDate":"2009-03-19T09:51:00.000","Title":"How do I know if a generator is empty from the 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":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Is there a simple way of testing if the generator has no items, like peek, hasNext, isEmpty, something along those lines?","AnswerCount":24,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":101926,"Q_Id":661603,"Users Score":0,"Answer":"bool(generator) will return the correct result","Q_Score":206,"Tags":"python,generator","A_Id":70471281,"CreationDate":"2009-03-19T09:51:00.000","Title":"How do I know if a generator is empty from the 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":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I could use some pseudo-code, or better, Python. I am trying to implement a rate-limiting queue for a Python IRC bot, and it partially works, but if someone triggers less messages than the limit (e.g., rate limit is 5 messages per 8 seconds, and the person triggers only 4), and the next trigger is over the 8 seconds (e.g., 16 seconds later), the bot sends the message, but the queue becomes full and the bot waits 8 seconds, even though it's not needed since the 8 second period has lapsed.","AnswerCount":10,"Available Count":1,"Score":0.0599281035,"is_accepted":false,"ViewCount":108156,"Q_Id":667508,"Users Score":3,"Answer":"One solution is to attach a timestamp to each queue item and to discard the item after 8 seconds have passed. You can perform this check each time the queue is added to.\nThis only works if you limit the queue size to 5 and discard any additions whilst the queue is full.","Q_Score":173,"Tags":"python,algorithm,message-queue","A_Id":667528,"CreationDate":"2009-03-20T19:02:00.000","Title":"What's a good rate limiting algorithm?","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},{"Question":"I'm a somewhat advanced C++\/Java Developer who recently became interested in Python and I enjoy its dynamic typing and efficient coding style very much. I currently use it on my small programming needs like solving programming riddles and scripting, but I'm curious if anyone out there has successfully used Python in an enterprise-quality project? (Preferably using modern programming concepts such as OOP and some type of Design Pattern)\nIf so, would you please explain why you chose Python (specifically) and give us some of the lessons you learned from this project? (Feel free to compare the use of Python in the project vs Java or etc)","AnswerCount":2,"Available Count":2,"Score":0.2913126125,"is_accepted":false,"ViewCount":1839,"Q_Id":672781,"Users Score":3,"Answer":"I've been using Python as distributed computing framework in one of the worlds largest banks. \nIt was chosen because:\n\nIt had to be extremely fast for developing and deploying new functionalities;\nIt had to be easily integrable with C and C++; \nSome parts of the code were to be written by people whose area of expertise was mathematical modeling, not software development.","Q_Score":7,"Tags":"java,python,design-patterns,programming-languages,dynamic-typing","A_Id":672806,"CreationDate":"2009-03-23T09:59:00.000","Title":"Python Programming - Rules\/Advice for developing enterprise-level software 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},{"Question":"I'm a somewhat advanced C++\/Java Developer who recently became interested in Python and I enjoy its dynamic typing and efficient coding style very much. I currently use it on my small programming needs like solving programming riddles and scripting, but I'm curious if anyone out there has successfully used Python in an enterprise-quality project? (Preferably using modern programming concepts such as OOP and some type of Design Pattern)\nIf so, would you please explain why you chose Python (specifically) and give us some of the lessons you learned from this project? (Feel free to compare the use of Python in the project vs Java or etc)","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":1839,"Q_Id":672781,"Users Score":17,"Answer":"I'm using Python for developing a complex insurance underwriting application.\nOur application software essentially repackages our actuarial model in a form that companies can subscribe to it. This business is based on our actuaries and their deep thinking. We're not packaging a clever algorithm that's relatively fixed. We're renting our actuarial brains to customers via a web service.\n\nThe actuaries must be free to make changes as they gain deeper insight into the various factors that lead to claims.\n\nStatic languages (Java, C++, C#) lead to early lock-in to a data model.\nPython allows us to have a very flexible data model. They're free to add, change or delete factors or information sources without a lot of development cost and complexity. Duck typing allows us to introduce new pieces without a lot rework.\n\nOur software is a service (not a package) so we have an endless integration problem.\n\nStatic languages need complex mapping components. Often some kind of configurable, XML-driven mapping from customer messages to our ever-changing internal structures.\nPython allows us to have the mappings as a simple Python class definition that we simply tweak, test and put into production. There are no limitations on this module -- it's first-class Python code.\n\nWe have to do extensive, long-running proof-of-concept. These involve numerous \"what-if\" scenarios with different data feeds and customized features.\n\nStatic languages require a lot of careful planning and thinking to create yet another demo, yet another mapping from yet another customer-supplied file to the current version of our actuarial models.\nPython requires much less planning. Duck typing (and Django) let us knock out a demo without very much pain. The data mappings are simple python class definitions; our actuarial models are in a fairly constant state of flux.\n\nOur business model is subject to a certain amount of negotiation. We have rather complex contracts with information providers; these don't change as often as the actuarial model, but changes here require customization.\n\nStatic languages bind in assumptions about the contracts, and require fairly complex designs (or workarounds) to handle the brain-farts of the business folks negotiating the deals.\nIn Python, we use an extensive test suite and do a lot of refactoring as the various contract terms and conditions trickle down to us. \n\nEvery week we get a question like \"Can we handle a provision like X?\" Our standard answer is \"Absolutely.\" Followed by an hour of refactoring to be sure we could handle it if the deal was struck in that form.\nWe're mostly a RESTful web service. Django does a lot of this out of the box. We had to write some extensions because our security model is a bit more strict than the one provided by Django. \n\nStatic languages don't have to ship source. Don't like the security model? Pay the vendor $$$.\nDynamic languages must ship as source. In our case, we spend time reading the source of Django carefully to make sure that our security model fits cleanly with the rest of Django. We don't need HIPAA compliance, but we're building it in anyway. \n\nWe use web services from information providers. urllib2 does this for us nicely. We can prototype an interface rapidly. \n\nWith a static language, you have API's, you write, you run, and you hope it worked. The development cycle is Edit, Compile, Build, Run, Crash, Look at Logs; and this is just to spike the interface and be sure we have the protocol, credentials and configuration right.\nWe exercise the interface in interactive Python. Since we're executing it interactively, we can examine the responses immediately. The development cycle is reduced to Run, Edit. We can spike a web services API in an afternoon.","Q_Score":7,"Tags":"java,python,design-patterns,programming-languages,dynamic-typing","A_Id":672975,"CreationDate":"2009-03-23T09:59:00.000","Title":"Python Programming - Rules\/Advice for developing enterprise-level software 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},{"Question":"I want to enable a user on a website to upload an image, and write some text over it. Also, they should be able to crop\/scale\/move the image and text. For that stuff, I can do it in jQuery.\nAfter they've made the image the way they want it, is there a way i can take a screenshot of that image (using PiL) and save it on the server?\nWhat is the best\/proper way to do this?","AnswerCount":4,"Available Count":2,"Score":0.049958375,"is_accepted":false,"ViewCount":1584,"Q_Id":673725,"Users Score":1,"Answer":"I assume you got Python on the server side.\nThe best way imo is to somehow 'get' all the editing parameters from the client, then re-render it using PIL.\nUpdate: How I will do it\nOn the server side, you need an url to handle posts. \nOn the client side, (after each edit, )send a post to that url, with the editing parameters.\nI think there is not an easy solution to this.\nMaybe if you don't use PIL to render the final image, but only remember the parameters, each view from clients can render itself?","Q_Score":1,"Tags":"jquery,python,css,xhtml,python-imaging-library","A_Id":673958,"CreationDate":"2009-03-23T15:00:00.000","Title":"Using PiL to take a screenshot of HTML\/CSS","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I want to enable a user on a website to upload an image, and write some text over it. Also, they should be able to crop\/scale\/move the image and text. For that stuff, I can do it in jQuery.\nAfter they've made the image the way they want it, is there a way i can take a screenshot of that image (using PiL) and save it on the server?\nWhat is the best\/proper way to do this?","AnswerCount":4,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":1584,"Q_Id":673725,"Users Score":0,"Answer":"Well, even if others are trying to discourage you from doing this, it would probably not be that hard.\nOn the client-side, you, you define a div that is floated\/resizable over the image, with transparency, that can be scaled for the crop.\nMove, I assume it applies only to the text, so you dynamically create draggable spans on the client side, still easy.\nScale, I have no Idea of a simple UI to do it.\nWhen you want to update your Image, you serialize your data (position of your cropping div and position of your text spans \/ scaling, relative to the position to the image.) Then, using json or anything similar you'd like, you transfer the data to the server. \nThen, on the server, using python\/PIL, you reproduce the transformations that you have serialized.","Q_Score":1,"Tags":"jquery,python,css,xhtml,python-imaging-library","A_Id":674283,"CreationDate":"2009-03-23T15:00:00.000","Title":"Using PiL to take a screenshot of HTML\/CSS","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I'm trying to use gstreamer 0.10 from Python to simultaneously display a v4l2 video source and record it to xvid-in-avi. Over a long period of time the computer would be fast enough to do this but if another program uses the disk it drops frames. That's bad enough, but on playback there are bursts of movement in the video where frames were dropped instead of displaying the frames we were able to encode at a lower framerate.\nThe pipeline is v4l2src ! capsfilter ! tee ! queue ! xvidenc ! avimux ! filesink and the tee also sinks to a queue ! xvimagesink sync=false. I've tried adding videorate in front of xvidenc but that seems to make things worse.\nI've considered spooling the uncompressed video to disk in this pipeline and encoding it in a background thread. What else could I do to solve this problem? Is xvidenc or avimux doing the wrong thing with dropped frames? Could I dramatically increase the size of the queue preceding my encoder?","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":3103,"Q_Id":677641,"Users Score":5,"Answer":"tee will block if either output blocks, so it's probably your bottleneck. I suggest to write the stream that takes longer to encode to disk and encode from there.","Q_Score":4,"Tags":"python,linux,gstreamer","A_Id":677681,"CreationDate":"2009-03-24T14:28:00.000","Title":"How can I record live video with gstreamer without dropping frames?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to use gstreamer 0.10 from Python to simultaneously display a v4l2 video source and record it to xvid-in-avi. Over a long period of time the computer would be fast enough to do this but if another program uses the disk it drops frames. That's bad enough, but on playback there are bursts of movement in the video where frames were dropped instead of displaying the frames we were able to encode at a lower framerate.\nThe pipeline is v4l2src ! capsfilter ! tee ! queue ! xvidenc ! avimux ! filesink and the tee also sinks to a queue ! xvimagesink sync=false. I've tried adding videorate in front of xvidenc but that seems to make things worse.\nI've considered spooling the uncompressed video to disk in this pipeline and encoding it in a background thread. What else could I do to solve this problem? Is xvidenc or avimux doing the wrong thing with dropped frames? Could I dramatically increase the size of the queue preceding my encoder?","AnswerCount":2,"Available Count":2,"Score":0.1973753202,"is_accepted":false,"ViewCount":3103,"Q_Id":677641,"Users Score":2,"Answer":"and you need to write xvimagesink, not xvimagesync","Q_Score":4,"Tags":"python,linux,gstreamer","A_Id":2237878,"CreationDate":"2009-03-24T14:28:00.000","Title":"How can I record live video with gstreamer without dropping frames?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Are there any alternatives to Python for .NET or IronPython for accessing .NET CLR? Both of these seem to have downsides in that Python for .NET is not under active development (as far as I can tell) and you lose some features available in CPython if you use IronPython. So are there any alternatives?","AnswerCount":4,"Available Count":2,"Score":0.049958375,"is_accepted":false,"ViewCount":3386,"Q_Id":681853,"Users Score":1,"Answer":"As far as I know you are not going to get anything more actively developed than IronPython .\nIronPython is currently one of the .NET 5 being developed by the language team (C#, VB.NET, F#, IronPython and IronRuby) so I doubt that there's another open source .NET Python project that's gone anywhere near as far.","Q_Score":3,"Tags":".net,python,clr,ironpython","A_Id":681875,"CreationDate":"2009-03-25T14:33:00.000","Title":"Any alternatives to IronPython, Python for .NET for accessing CLR 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":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Are there any alternatives to Python for .NET or IronPython for accessing .NET CLR? Both of these seem to have downsides in that Python for .NET is not under active development (as far as I can tell) and you lose some features available in CPython if you use IronPython. So are there any alternatives?","AnswerCount":4,"Available Count":2,"Score":0.1973753202,"is_accepted":false,"ViewCount":3386,"Q_Id":681853,"Users Score":4,"Answer":"Apart from Python for .NET (which works pretty well for me), the only other solution I'm aware of is exposing the .NET libraries via COM interop, so you can use them via the pywin32 extensions. \n(I don't know much about .NET com interop yet, so hopefully someone else can provide further explanation on that.)","Q_Score":3,"Tags":".net,python,clr,ironpython","A_Id":682313,"CreationDate":"2009-03-25T14:33:00.000","Title":"Any alternatives to IronPython, Python for .NET for accessing CLR 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":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've mainly been doing C# development for the past few years but recently started to do a bit of Python (not Iron Python). But I'm not sure if I've made the mental leap to Python...I kind of feel I'm trying to do things as I would in C#.\nAny advice on how I can fully take advantage of Python?\nOr any tips\\tricks, things to learn more about, things to watch out for?","AnswerCount":10,"Available Count":2,"Score":0.0399786803,"is_accepted":false,"ViewCount":12232,"Q_Id":683273,"Users Score":2,"Answer":"I'm pretty much in your shoes too, still using C# for most of my work, but using Python more and more for other projects.\n@e-satis probably knows Python inside-out and all his advice is top-notch. From my point of view what made the biggest difference to me was the following:\nGet back into functional. not necessarily spaghetti code, but learning that not everything has to be in an object, nor should it be.\nThe interpreter. It's like the immediate window except 10^10 better. Because of how Python works you don't need all the baggage and crap C# makes you put in before you can run things; you can just whack in a few lines and see how things work.\nI've normally got an IDLE instance up where I just throw around snippets as I'm working out how the various bits in the language works while I'm editing my files... e.g. busy working out how to do a map call on a list, but I'm not 100% on the lambda I should use... whack in a few lines into IDLE, see how it works and what it does.\nAnd finally, loving into the verbosity of Python, and I don't mean that in the long winded meaning of verbosity, but as e-satis pointed out, using verbs like \"in\", \"is\", \"for\", etc.\nIf you did a lot of reflection work in C# you'll feel like crying when you see how simple the same stuff is in Python.\nGood luck with it.","Q_Score":74,"Tags":"c#,python","A_Id":687099,"CreationDate":"2009-03-25T20:18:00.000","Title":"Advice for C# programmer writing 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},{"Question":"I've mainly been doing C# development for the past few years but recently started to do a bit of Python (not Iron Python). But I'm not sure if I've made the mental leap to Python...I kind of feel I'm trying to do things as I would in C#.\nAny advice on how I can fully take advantage of Python?\nOr any tips\\tricks, things to learn more about, things to watch out for?","AnswerCount":10,"Available Count":2,"Score":1.0,"is_accepted":false,"ViewCount":12232,"Q_Id":683273,"Users Score":16,"Answer":"Refrain from using classes. Use dictionaries, sets, list and tuples.\nSetters and getters are forbidden.\nDon't have exception handlers unless you really need to - let it crash in style.\nPylint can be your friend for more pythonish coding style.\nWhen you're ready - check out list comprehensions, generators and lambda functions.","Q_Score":74,"Tags":"c#,python","A_Id":683362,"CreationDate":"2009-03-25T20:18:00.000","Title":"Advice for C# programmer writing 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},{"Question":"I'm programming a game in Python, where all IO activities are done by an IO object (in the hope that it will be easy to swap that object out for another which implements a different user interface). Nearly all the other objects in the game need to access the IO system at some point (e.g. printing a message, updating the position of the player, showing a special effect caused by an in-game action), so my question is this:\nDoes it make sense for a reference to the IO object to be available globally?\nThe alternative is passing a reference to the IO object into the __init__() of every object that needs to use it. I understand that this is good from a testing point of view, but is this worth the resulting \"function signature pollution\"?\nThanks.","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":250,"Q_Id":687703,"Users Score":0,"Answer":"Nope.\nVariables are too specific to be passed around in the global namespace. Hide them inside static functions\/classes instead that can do magic things to them at run time (or call other ones entirely).\nConsider what happens if the IO can periodically change state or if it needs to block for a while (like many sockets do). \nConsider what happens if the same block of code is included multiple times. Does the variable instance get duplicated as well?\nConsider what happens if you want to have a version 2 of the same variable. What if you want to change its interface? Do you have to modify all the code that references it?\nDoes it really make sense to infect all the code that uses the variable with knowledge of all the ways it can go bad?","Q_Score":5,"Tags":"python,io,global-variables","A_Id":687855,"CreationDate":"2009-03-26T21:52:00.000","Title":"Python game programming: is my IO object a legitimate candidate for being a global 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},{"Question":"I'm programming a game in Python, where all IO activities are done by an IO object (in the hope that it will be easy to swap that object out for another which implements a different user interface). Nearly all the other objects in the game need to access the IO system at some point (e.g. printing a message, updating the position of the player, showing a special effect caused by an in-game action), so my question is this:\nDoes it make sense for a reference to the IO object to be available globally?\nThe alternative is passing a reference to the IO object into the __init__() of every object that needs to use it. I understand that this is good from a testing point of view, but is this worth the resulting \"function signature pollution\"?\nThanks.","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":250,"Q_Id":687703,"Users Score":1,"Answer":"Yes, I think so.\nAnother possibility would be to create a module loggerModule that has functions like print() and write(), but this would only marginally be better.","Q_Score":5,"Tags":"python,io,global-variables","A_Id":687782,"CreationDate":"2009-03-26T21:52:00.000","Title":"Python game programming: is my IO object a legitimate candidate for being a global 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},{"Question":"How to make sure that code is still working after refactoring ( i.e, after variable name change)?\nIn static language, if a class is renamed but other referring class is not, then I will get a compilation error. \nBut in dynamic language there is no such safety net, and your code can break during refactoring if you are not careful enough. You can use unit test, but when you are using mocks it's pretty hard to know the name changes and as a consequence, it may not help.\nHow to solve this problem?","AnswerCount":4,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":403,"Q_Id":688740,"Users Score":17,"Answer":"Before you start refactoring you should create tests that will be able to test what you're going to change - if you say unit tests will not be enought, or they will be hard to create, then by all means create higher level tests possibly even excersising the whole of your product. \nIf you have code coverage tools for your language use them to measure the quality of the tests that you've created - after it's reached a reasonably high value and if the tests are kept up to date and extended you'll be able to do anything with your code very efficiently and be rather sure things are not going in the wrong direction.","Q_Score":7,"Tags":"php,python,dynamic-languages","A_Id":688756,"CreationDate":"2009-03-27T06:36:00.000","Title":"How to Make sure the code is still working after refactoring ( Dynamic 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},{"Question":"How to make sure that code is still working after refactoring ( i.e, after variable name change)?\nIn static language, if a class is renamed but other referring class is not, then I will get a compilation error. \nBut in dynamic language there is no such safety net, and your code can break during refactoring if you are not careful enough. You can use unit test, but when you are using mocks it's pretty hard to know the name changes and as a consequence, it may not help.\nHow to solve this problem?","AnswerCount":4,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":403,"Q_Id":688740,"Users Score":0,"Answer":"1) For Python use PyUnit for PHP phpunit.\n2) TDD approach is good but also making tests after writing code is acceptable.\n3) Also use refactoring tools that are available for Your IDE they do only safe refactorings.\nIn Python You have rope (this is library but have plugins for most IDEs).\n4) Good books are:\n'Test-Driven Development by example' Best\n'Expert Python Programing' Tarek Ziade (explain both TDD and refactoring)\ngoogle tdd and database to find a good book about TDD approach for developing databases.\nAdd info for mocks you are using. AFAIK mocks are needed only when database or network is involved. But normally unit test should cover small pice of code (one class only) sometimes two classes so no mockup needed !!","Q_Score":7,"Tags":"php,python,dynamic-languages","A_Id":1813232,"CreationDate":"2009-03-27T06:36:00.000","Title":"How to Make sure the code is still working after refactoring ( Dynamic 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},{"Question":"I'm on Fedora Core 6 (64 bit)\nafter \"yum install libjpeg-devel\" I have downloaded and built PIL. It gives the message:\n--- JPEG support ok\nLooks like JPEG built okay, but when running selftest.py:\nIOError: decoder jpeg not available\nWhy would it appear to have built correctly, but fail the selftest?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":2349,"Q_Id":689560,"Users Score":1,"Answer":"Turns out this gets solved by completely removing the installed versions of PIL and starting the build again from scratch.","Q_Score":3,"Tags":"python,jpeg,python-imaging-library,fedora,libjpeg","A_Id":689629,"CreationDate":"2009-03-27T12:19:00.000","Title":"Building Python PIL for JPEG looks okay, but fails the selftest","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have been asked to quote a project where they want to see sent email using POP. I am pretty sure this is not possible, but I thought if it was.\nSo is it possible given a users POP email server details to access their sent mail?\nIf so any examples in Python or fetchmail?","AnswerCount":4,"Available Count":4,"Score":0.1488850336,"is_accepted":false,"ViewCount":3820,"Q_Id":690527,"Users Score":3,"Answer":"Pop doesn't support sent email. Pop is an inbox only, Sent mail will be stored in IMAP, Exchange or other proprietary system.","Q_Score":0,"Tags":"python,email,pop3,fetchmail","A_Id":690536,"CreationDate":"2009-03-27T16:45:00.000","Title":"Is it possible to Access a Users Sent Email over POP?","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},{"Question":"I have been asked to quote a project where they want to see sent email using POP. I am pretty sure this is not possible, but I thought if it was.\nSo is it possible given a users POP email server details to access their sent mail?\nIf so any examples in Python or fetchmail?","AnswerCount":4,"Available Count":4,"Score":0.049958375,"is_accepted":false,"ViewCount":3820,"Q_Id":690527,"Users Score":1,"Answer":"The smtp (mail sending) server could forward a copy of all sent mail back to the sender, they could then access this over pop.","Q_Score":0,"Tags":"python,email,pop3,fetchmail","A_Id":690541,"CreationDate":"2009-03-27T16:45:00.000","Title":"Is it possible to Access a Users Sent Email over POP?","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},{"Question":"I have been asked to quote a project where they want to see sent email using POP. I am pretty sure this is not possible, but I thought if it was.\nSo is it possible given a users POP email server details to access their sent mail?\nIf so any examples in Python or fetchmail?","AnswerCount":4,"Available Count":4,"Score":1.2,"is_accepted":true,"ViewCount":3820,"Q_Id":690527,"Users Score":5,"Answer":"POP3 only handles receiving email; sent mail is sent via SMTP in these situations, and may be sent via a different ISP to the receiver (say, when you host your own email server, but use your current ISP to send). As such, this isn't directly possible.\nIMAP could do it, as this offers server side email folders as well as having the server handle the interface to both send and receive SMTP traffic","Q_Score":0,"Tags":"python,email,pop3,fetchmail","A_Id":690542,"CreationDate":"2009-03-27T16:45:00.000","Title":"Is it possible to Access a Users Sent Email over POP?","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},{"Question":"I have been asked to quote a project where they want to see sent email using POP. I am pretty sure this is not possible, but I thought if it was.\nSo is it possible given a users POP email server details to access their sent mail?\nIf so any examples in Python or fetchmail?","AnswerCount":4,"Available Count":4,"Score":0.049958375,"is_accepted":false,"ViewCount":3820,"Q_Id":690527,"Users Score":1,"Answer":"Emails are not sent using POP, but collected from a server using POP. They are sent using SMTP, and they don't hang around on the server once they're gone.\nYou might want to look into IMAP?","Q_Score":0,"Tags":"python,email,pop3,fetchmail","A_Id":690540,"CreationDate":"2009-03-27T16:45:00.000","Title":"Is it possible to Access a Users Sent Email over POP?","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},{"Question":"I'm going to build a turn-key solution for a vertical market, and would like to offer both options: software as a service, and give them the opportunity to host the application on their own. In other words, I'm aiming to have similar deployment options as Joel's FogBugz.\nI'm a Python programmer, and I could fly over the project with Django. There are several reasons I prefer PHP though:\n1) Django installation, and configuration assumes you have access to a shell (my target is not the programmer type). Although I could offer installation service, but not on their servers.\n2) Django runs only on some specific hosts that must take special care to enable it. Installing mod_python\/mod_wsgi, and most likely the minority of my potential clients would have root access, or even a cpanel.\n3) Using PHP would mean I could run it on their existing server. I would have no need to move them to a Django-enabled server, and no downtime for their emails, while the DNS updates.\nOn the other hand, I have very little experience with PHP. Smarty as a templating language looks nice, and works similarly to Django templates. It doesn't offer template inheritance though, except in a very hackish way in which I wish not to use as it could break the application if the designer messes them up. What do you think? Thanks in advance!","AnswerCount":3,"Available Count":3,"Score":0.2605204458,"is_accepted":false,"ViewCount":6522,"Q_Id":690856,"Users Score":4,"Answer":"Deployment is clearly a problem for all non-PHP based web apps, but I think things are getting better with the DreamHost\/Engineyard type ISP's who provide Ruby\/Python etc. out of the box. It also looks like there's going to be a lot of discussion at PyCon this week about ways to fix deployment problems. The growth in popularity of Django, Turbogears, and Pylons is driving demand for better deployment solutions.\nThat said, if your target market are people hosting on the very low end $12 a year type ISP's then I don't think you have much choice other than PHP.\nFinally, one thing I disagree with you is running PHP and Django on the same server. I'm running a few PHP apps on my server with Apache and dozens of Django sites with mod_wsgi in daemon mode. Running it that way means the Python interpreter doesn't use up ram in the Apache workers and vice versa, the PHP interpreter isn't contaminating my mod_wsgi daemons :)","Q_Score":8,"Tags":"php,python,django,codeigniter","A_Id":691231,"CreationDate":"2009-03-27T18:05:00.000","Title":"Django or CodeIgniter for Turn-Key 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},{"Question":"I'm going to build a turn-key solution for a vertical market, and would like to offer both options: software as a service, and give them the opportunity to host the application on their own. In other words, I'm aiming to have similar deployment options as Joel's FogBugz.\nI'm a Python programmer, and I could fly over the project with Django. There are several reasons I prefer PHP though:\n1) Django installation, and configuration assumes you have access to a shell (my target is not the programmer type). Although I could offer installation service, but not on their servers.\n2) Django runs only on some specific hosts that must take special care to enable it. Installing mod_python\/mod_wsgi, and most likely the minority of my potential clients would have root access, or even a cpanel.\n3) Using PHP would mean I could run it on their existing server. I would have no need to move them to a Django-enabled server, and no downtime for their emails, while the DNS updates.\nOn the other hand, I have very little experience with PHP. Smarty as a templating language looks nice, and works similarly to Django templates. It doesn't offer template inheritance though, except in a very hackish way in which I wish not to use as it could break the application if the designer messes them up. What do you think? Thanks in advance!","AnswerCount":3,"Available Count":3,"Score":0.1973753202,"is_accepted":false,"ViewCount":6522,"Q_Id":690856,"Users Score":3,"Answer":"If you want your application to be mainstream then your almost forced to go with PHP. Going from Django to PHP is alot easier than going from PHP to Django. You know the standards, you just need to learn the PHP syntax and functions.\nI would definitely use a PHP framework. Symfony and akelos are very similar to Rails (close to Django). On the other than theres Code Igniter which does what it should - organise your code.","Q_Score":8,"Tags":"php,python,django,codeigniter","A_Id":691549,"CreationDate":"2009-03-27T18:05:00.000","Title":"Django or CodeIgniter for Turn-Key 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},{"Question":"I'm going to build a turn-key solution for a vertical market, and would like to offer both options: software as a service, and give them the opportunity to host the application on their own. In other words, I'm aiming to have similar deployment options as Joel's FogBugz.\nI'm a Python programmer, and I could fly over the project with Django. There are several reasons I prefer PHP though:\n1) Django installation, and configuration assumes you have access to a shell (my target is not the programmer type). Although I could offer installation service, but not on their servers.\n2) Django runs only on some specific hosts that must take special care to enable it. Installing mod_python\/mod_wsgi, and most likely the minority of my potential clients would have root access, or even a cpanel.\n3) Using PHP would mean I could run it on their existing server. I would have no need to move them to a Django-enabled server, and no downtime for their emails, while the DNS updates.\nOn the other hand, I have very little experience with PHP. Smarty as a templating language looks nice, and works similarly to Django templates. It doesn't offer template inheritance though, except in a very hackish way in which I wish not to use as it could break the application if the designer messes them up. What do you think? Thanks in advance!","AnswerCount":3,"Available Count":3,"Score":0.1325487884,"is_accepted":false,"ViewCount":6522,"Q_Id":690856,"Users Score":2,"Answer":"Based on your own conclusions, I would go with CodeIgniter. It seems like there would be a ton of work helping your customers install your web app, and I assume you don't want that.\nBuild a simple-to-install web app so that you can concentrate your efforts on making it better and selling it, instead of working extra as a sysadmin or writing extensive installation tutorials.\n(With that said, FogBugz wasn't easy to install on our Linux server, even though it is written in PHP. It took me and my colleague (both programmers!) more than a full work day to install. So I think there will always be problems with installation of self-hosted web apps.)","Q_Score":8,"Tags":"php,python,django,codeigniter","A_Id":692907,"CreationDate":"2009-03-27T18:05:00.000","Title":"Django or CodeIgniter for Turn-Key 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},{"Question":"Lets say I have projects x and y in brother directories: projects\/x and projects\/y.\nThere are some utility funcs common to both projects in myutils.py and some db stuff in mydbstuff.py, etc.\nThose are minor common goodies, so I don't want to create a single package for them. \nQuestions arise about the whereabouts of such files, possible changes to PYTHONPATH, proper way to import, etc. \nWhat is the 'pythonic way' to use such files?","AnswerCount":5,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":426,"Q_Id":696792,"Users Score":0,"Answer":"I agree with 'create a package'.\nIf you cannot do that, how about using symbolic links\/junctions (ln -s on Linux, linkd on Windows)?","Q_Score":5,"Tags":"python","A_Id":697052,"CreationDate":"2009-03-30T11:12:00.000","Title":"What is the pythonic way to share common files in multiple 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},{"Question":"Lets say I have projects x and y in brother directories: projects\/x and projects\/y.\nThere are some utility funcs common to both projects in myutils.py and some db stuff in mydbstuff.py, etc.\nThose are minor common goodies, so I don't want to create a single package for them. \nQuestions arise about the whereabouts of such files, possible changes to PYTHONPATH, proper way to import, etc. \nWhat is the 'pythonic way' to use such files?","AnswerCount":5,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":426,"Q_Id":696792,"Users Score":9,"Answer":"The pythonic way is to create a single extra package for them.\nWhy don't you want to create a package? You can distribute this package with both projects, and the effect would be the same.\nYou'll never do it right for all instalation scenarios and platforms if you do it by mangling with PYTHONPATH and custom imports.\nJust create another package and be done in no time.","Q_Score":5,"Tags":"python","A_Id":696825,"CreationDate":"2009-03-30T11:12:00.000","Title":"What is the pythonic way to share common files in multiple 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},{"Question":"Given a class C in Python, how can I determine which file the class was defined in? I need something that can work from either the class C, or from an instance off C.\nThe reason I am doing this, is because I am generally a fan off putting files that belong together in the same folder. I want to create a class that uses a Django template to render itself as HTML. The base implementation should infer the filename for the template based on the filename that the class is defined in.\nSay I put a class LocationArtifact in the file \"base\/artifacts.py\", then I want the default behaviour to be that the template name is \"base\/LocationArtifact.html\".","AnswerCount":3,"Available Count":1,"Score":0.3215127375,"is_accepted":false,"ViewCount":56627,"Q_Id":697320,"Users Score":5,"Answer":"This is the wrong approach for Django and really forcing things.\nThe typical Django app pattern is:\n\n\/project\n\n\/appname\n\nmodels.py\nviews.py\n\/templates\n\nindex.html\netc.","Q_Score":121,"Tags":"python,class,introspection","A_Id":697405,"CreationDate":"2009-03-30T13:58:00.000","Title":"How do I get the filepath for a class 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},{"Question":"Has anyone ever tried that?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":4155,"Q_Id":697594,"Users Score":1,"Answer":"What kind of integration are you talking about?\nIf you want to call some BIRT API the I gues it could be done from Jython as Jython can call any Java API.\nIf you don't need to call the BIRT API then you can just get the birt reports with http requests from the BIRT report server (a tomcat application).","Q_Score":3,"Tags":"java,python,reporting,birt","A_Id":716222,"CreationDate":"2009-03-30T15:05:00.000","Title":"How to integrate BIRT 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},{"Question":"I hit this issue about two years ago when I first implemented our SWIG bindings. As soon as we exposed a large amount of code we got to the point where SWIG would output C++ files so large the compiler could not handle them. The only way I could get around the issue was to split up the interfaces into multiple modules and to compile them separately.\nThis has several downsides:\n\u2022 Each module must know about dependencies in other modules. I have a script to generate the interface files which handles this side of things, but it adds extra complexity.\n\u2022 Each additional module increases the time that the dynamic linker requires to load in the code. I have added an init.py file that imports all the submodules, so that the fact that the code is split up is transparent to the user, but what is always visible is the long load times.\nI'm currently reviewing our build scripts \/ build process and I wanted to see if I could find a solution to this issue that was better than what I have now. Ideally, I'd have one shared library containing all the wrapper code. \nDoes anyone know how I can acheive this with SWIG? I've seen some custom code written in Ruby for a specific project, where the output is post-processed to make this possible, but when I looked at the feasibility for Python wrappers it does not look so easy.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2117,"Q_Id":697749,"Users Score":0,"Answer":"If split properly, the modules don't necessarily need to have the same dependencies as the others - just what's necessary to do compilation. If you break things up appropriately, you can have libraries without cyclic dependencies. The issue with using multiple libraries is that by default, SWIG declares its runtime code statically, and as a result, as problems passing objects from one module to another. You need to enable a shared version of the SWIG runtime code.\nFrom the documentation (SWIG web page documentation link is broken):\n\nThe runtime functions are private to\n each SWIG-generated module. That is,\n the runtime functions are declared\n with \"static\" linkage and are visible\n only to the wrapper functions defined\n in that module. The only problem with\n this approach is that when more than\n one SWIG module is used in the same\n application, those modules often need\n to share type information. This is\n especially true for C++ programs where\n SWIG must collect and share\n information about inheritance\n relationships that cross module\n boundaries.\n\nCheck out that section in your downloaded documentation (section 16.2 The SWIG runtime code), and it'll give you details on how to enable this so that objects can be properly handled when passed from one module to the other.\nFWIW, I've not worked with Python SWIG, but have done Tcl SWIG.","Q_Score":9,"Tags":"c++,python,swig","A_Id":698089,"CreationDate":"2009-03-30T15:40:00.000","Title":"Is it possible to split a SWIG module for compilation, but rejoin it when linking?","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},{"Question":"I know it's kinda subjective but, if you were to put yourself in my shoes which would you invest the time in learning?\nI want to write a web app which deals securely with relatively modest amounts of peoples private data, a few thousand records of a few Kb each but stuff that needs to be kept safe, addresses, phone numbers etc. I've done several web projects in PHP\/MYSQL and have decided, handy though it is I really don't like PHP and don't want to do another large project in it...\nAs such I figure I'd best learn something new and so I am considering 2 options (although I'll happily entertain others if you have suggestions). I'm having terrible trouble deciding though. They both look quite involved so rather than just jump in and potentially waste days getting up to speed enough on both of them to make an informed choice I thought I'd come here and canvas some opinion.\nSo the two options I'm considering are...\nOne of the PYTHON Web frameworks - TurboGears seems well regarded?\nAdvantage: Of all the languages I ever tried Python is by far and away my favorite. There's loads of frameworks to choose from and I have done quite a lot of non web python coding over the last few years. \nDisadvantage: There's loads to choose from so it's hard to pick! Need to run single server process? or mod_python? which I don't like the sound of. What I do like is the notion of process separation and compartmentalization, i.e. if one users account is compromised it gives an attacker no leverage against the rest of the system. I'm not clear to what extent a python solution would handle that.\nWriting it as a SEASIDE app Which I guess runs on a squeak app server?\nAdv: From what I've heard it would permit good compartmentalization of users as each would have their own little private VM independent of all the systems other users which sounds wonderful from a security, scaling and redundancy standpoint.\nDis: I've not done any Smalltalk since Uni 15 years back and I never dug too deep into it then. I don't see much entry level help for seaside or that many projects using it. I suspect setting a server up to run it is hard for the same reason i.e. not because it's inherently hard but just cause there will be less help online and a presumption you are already rather au fait with Sqeak\/Smalltalk.\nSo, what do people think? Would I be able to efficiently get the kind of strong separation and compartmentalization I'm after with a Python framework? Is Seaside as good as I think in terms of insulating users from each other? Might I be better off, security wise, sticking to the languages I'm most familiar with so I don't make any n00b mistakes or will Seaside be worth worth scaling the learning curve and prove more secure, comprehensible and maintainable in the long run? At the end of the day it's not a life or death decision and I can always bail if I start with one and then hate it so pls nobody get all holy language war and start flaming anyone! ;-)\nCheers for any replies this gets,\nRoger :)","AnswerCount":9,"Available Count":3,"Score":1.2,"is_accepted":true,"ViewCount":2399,"Q_Id":697866,"Users Score":10,"Answer":"Disclaimer: I really don't like PHP, Python is nice, but doesn't come close to Smalltalk in my book. But I am a biased Smalltalker. Some answers about Seaside\/Squeak:\nQ: Which I guess runs on a squeak app server?\nSeaside runs in several different Smalltalks (VW, Gemstone, Squeak etc). The term \"app server\" is not really used in Smalltalk country. :)\nQ: From what I've heard it would permit good compartmentalization of users as each would have their own little private VM independent of all the systems other users which sounds wonderful from a security, scaling and redundancy standpoint.\nYes, each user has its own WASession and all UI components the user sees are instances living on the server side in that session. So sharing of state between sessions is something you must do explicitly, typically through a db.\nQ: I've not done any Smalltalk since Uni 15 years back and I never dug too deep into it then. I don't see much entry level help for seaside or that many projects using it.\nSmalltalk is easy to get going with and there is a whole free online book on Seaside.\nQ: I suspect setting a server up to run it is hard for the same reason i.e. not because it's inherently hard but just cause there will be less help online and a presumption you are already rather au fait with Sqeak\/Smalltalk.\nNo, not hard. :) In fact, quite trivial. Tons of help - Seaside ml, IRC on freenode, etc.\nQ: Is Seaside as good as I think in terms of insulating users from each other?\nI would say so.\nQ: Might I be better off, security wise, sticking to the languages I'm most familiar with so I don't make any n00b mistakes or will Seaside be worth worth scaling the learning curve and prove more secure, comprehensible and maintainable in the long run?\nThe killer argument in favor of Seaside IMHO is the true component model. It really, really makes it wonderful for complex UIs and maintenance. If you are afraid of learning \"something different\" (but then you wouldn't even consider it in the first place I guess) then I would warn you. But if you are not afraid then you will probably love it.\nAlso - Squeak (or VW) is a truly awesome development environment - debugging live Seaside sessions, changing code in the debugger and resuming etc etc. It rocks.","Q_Score":9,"Tags":"python,frameworks,seaside","A_Id":698677,"CreationDate":"2009-03-30T16:11:00.000","Title":"Dilemma: Should I learn Seaside or a Python 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},{"Question":"I know it's kinda subjective but, if you were to put yourself in my shoes which would you invest the time in learning?\nI want to write a web app which deals securely with relatively modest amounts of peoples private data, a few thousand records of a few Kb each but stuff that needs to be kept safe, addresses, phone numbers etc. I've done several web projects in PHP\/MYSQL and have decided, handy though it is I really don't like PHP and don't want to do another large project in it...\nAs such I figure I'd best learn something new and so I am considering 2 options (although I'll happily entertain others if you have suggestions). I'm having terrible trouble deciding though. They both look quite involved so rather than just jump in and potentially waste days getting up to speed enough on both of them to make an informed choice I thought I'd come here and canvas some opinion.\nSo the two options I'm considering are...\nOne of the PYTHON Web frameworks - TurboGears seems well regarded?\nAdvantage: Of all the languages I ever tried Python is by far and away my favorite. There's loads of frameworks to choose from and I have done quite a lot of non web python coding over the last few years. \nDisadvantage: There's loads to choose from so it's hard to pick! Need to run single server process? or mod_python? which I don't like the sound of. What I do like is the notion of process separation and compartmentalization, i.e. if one users account is compromised it gives an attacker no leverage against the rest of the system. I'm not clear to what extent a python solution would handle that.\nWriting it as a SEASIDE app Which I guess runs on a squeak app server?\nAdv: From what I've heard it would permit good compartmentalization of users as each would have their own little private VM independent of all the systems other users which sounds wonderful from a security, scaling and redundancy standpoint.\nDis: I've not done any Smalltalk since Uni 15 years back and I never dug too deep into it then. I don't see much entry level help for seaside or that many projects using it. I suspect setting a server up to run it is hard for the same reason i.e. not because it's inherently hard but just cause there will be less help online and a presumption you are already rather au fait with Sqeak\/Smalltalk.\nSo, what do people think? Would I be able to efficiently get the kind of strong separation and compartmentalization I'm after with a Python framework? Is Seaside as good as I think in terms of insulating users from each other? Might I be better off, security wise, sticking to the languages I'm most familiar with so I don't make any n00b mistakes or will Seaside be worth worth scaling the learning curve and prove more secure, comprehensible and maintainable in the long run? At the end of the day it's not a life or death decision and I can always bail if I start with one and then hate it so pls nobody get all holy language war and start flaming anyone! ;-)\nCheers for any replies this gets,\nRoger :)","AnswerCount":9,"Available Count":3,"Score":1.0,"is_accepted":false,"ViewCount":2399,"Q_Id":697866,"Users Score":6,"Answer":"I've been getting into seaside myself but in many ways it is very hard to get started, which has nothing to do with the smalltalk which can be picked up extremely quickly. The challenge is that you are really protected from writing html directly. \nI find in most frameworks when you get stuck on how to do something there is always a work around of solving it by using the template. You may later discover that this solution causes problems with clarity down the road and there is in fact a better solutions built into the framework but you were able to move on from that problem until you learned the right way to do it.\nSeaside doesn't have templates so you don't get that crutch. No problems have permanently stumped me but some have taken me longer to solve than I would have liked. The flip side of this is you end up learning the seaside methodology much quicker because you can't cheat.\nIf you decide to go the seaside route don't be afraid to post to the seaside mailing list at squeakfoundation.org. I found it intimidating at first because you don't see a lot of beginner questions there due to the low traffic but people are willing to help beginners there.\nAlso there are a handful of seaside developers who monitor stackoverflow regularly. Good luck.","Q_Score":9,"Tags":"python,frameworks,seaside","A_Id":698940,"CreationDate":"2009-03-30T16:11:00.000","Title":"Dilemma: Should I learn Seaside or a Python 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},{"Question":"I know it's kinda subjective but, if you were to put yourself in my shoes which would you invest the time in learning?\nI want to write a web app which deals securely with relatively modest amounts of peoples private data, a few thousand records of a few Kb each but stuff that needs to be kept safe, addresses, phone numbers etc. I've done several web projects in PHP\/MYSQL and have decided, handy though it is I really don't like PHP and don't want to do another large project in it...\nAs such I figure I'd best learn something new and so I am considering 2 options (although I'll happily entertain others if you have suggestions). I'm having terrible trouble deciding though. They both look quite involved so rather than just jump in and potentially waste days getting up to speed enough on both of them to make an informed choice I thought I'd come here and canvas some opinion.\nSo the two options I'm considering are...\nOne of the PYTHON Web frameworks - TurboGears seems well regarded?\nAdvantage: Of all the languages I ever tried Python is by far and away my favorite. There's loads of frameworks to choose from and I have done quite a lot of non web python coding over the last few years. \nDisadvantage: There's loads to choose from so it's hard to pick! Need to run single server process? or mod_python? which I don't like the sound of. What I do like is the notion of process separation and compartmentalization, i.e. if one users account is compromised it gives an attacker no leverage against the rest of the system. I'm not clear to what extent a python solution would handle that.\nWriting it as a SEASIDE app Which I guess runs on a squeak app server?\nAdv: From what I've heard it would permit good compartmentalization of users as each would have their own little private VM independent of all the systems other users which sounds wonderful from a security, scaling and redundancy standpoint.\nDis: I've not done any Smalltalk since Uni 15 years back and I never dug too deep into it then. I don't see much entry level help for seaside or that many projects using it. I suspect setting a server up to run it is hard for the same reason i.e. not because it's inherently hard but just cause there will be less help online and a presumption you are already rather au fait with Sqeak\/Smalltalk.\nSo, what do people think? Would I be able to efficiently get the kind of strong separation and compartmentalization I'm after with a Python framework? Is Seaside as good as I think in terms of insulating users from each other? Might I be better off, security wise, sticking to the languages I'm most familiar with so I don't make any n00b mistakes or will Seaside be worth worth scaling the learning curve and prove more secure, comprehensible and maintainable in the long run? At the end of the day it's not a life or death decision and I can always bail if I start with one and then hate it so pls nobody get all holy language war and start flaming anyone! ;-)\nCheers for any replies this gets,\nRoger :)","AnswerCount":9,"Available Count":3,"Score":0.022218565,"is_accepted":false,"ViewCount":2399,"Q_Id":697866,"Users Score":1,"Answer":"I think you've pretty much summed up the pros and cons. Seaside isn't that hard to set up (I've installed it twice for various projects) but using it will definitely affect how you work--in addition to re-learning the language you'll probably have to adjust lots of assumptions about your work flow. \nIt also depends on two other factors\n\nIf other people will eventually be maintaining it, you'll have better luck finding python programmers\nIf you are doing a highly stateful site, Seaside is going to beat the pants off any other framework I've seen.","Q_Score":9,"Tags":"python,frameworks,seaside","A_Id":697934,"CreationDate":"2009-03-30T16:11:00.000","Title":"Dilemma: Should I learn Seaside or a Python 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},{"Question":"I have a binary named A that generates output when called. If I call it from a Bash shell, most of the output is suppressed by A > \/dev\/null. All of the output is suppressed by A &> \/dev\/null\nI have a python script named B that needs to call A. I want to be able to generate output from B, while suppressing all the output from A.\nFrom within B, I've tried os.system('A'), os.system('A > \/dev\/null'), and os.system('A &> \/dev\/null'), os.execvp('...'), etc. but none of those suppress all the output from A.\nI could run B &> \/dev\/null, but that suppresses all of B's output too and I don't want that.\nAnyone have suggestions?","AnswerCount":9,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":42935,"Q_Id":699325,"Users Score":12,"Answer":"If your search engine lead you to this old question (like me), be aware that using PIPE may lead to deadlocks.\nIndeed, because pipes are buffered, you can write a certain number of bytes in a pipe, even if no one read it. However the size of buffer is finite. And consequently if your program A has an output larger than the buffer, A will be blocked on writing, while the calling program B awaits the termination of A. But not, in this particular case... see comments below.\nStill, I recommend using Devin Jeanpierre and DNS' solution.","Q_Score":45,"Tags":"python,redirect","A_Id":2728111,"CreationDate":"2009-03-30T22:39:00.000","Title":"Suppress output in Python calls to executables","Data Science and Machine Learning":0,"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},{"Question":"I have binary files no larger than 20Mb in size that have a header section and then a data section containing sequences of uchars. I have Numpy, SciPy, etc. and each library has different ways of loading in the data. Any suggestions for the most efficient methods I should use?","AnswerCount":4,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":450,"Q_Id":703262,"Users Score":0,"Answer":"I found that array.fromfile is the fastest methods for homogeneous data.","Q_Score":6,"Tags":"python,input,binaryfiles","A_Id":703588,"CreationDate":"2009-03-31T22:03:00.000","Title":"Most efficient way of loading formatted binary files in 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},{"Question":"I'm using the json module in Python 2.6 to load and decode JSON files. However I'm currently getting slower than expected performance. I'm using a test case which is 6MB in size and json.loads() is taking 20 seconds.\nI thought the json module had some native code to speed up the decoding?\nHow do I check if this is being used?\nAs a comparison, I downloaded and installed the python-cjson module, and cjson.decode() is taking 1 second for the same test case.\nI'd rather use the JSON module provided with Python 2.6 so that users of my code aren't required to install additional modules.\n(I'm developing on Mac OS X, but I getting a similar result on Windows XP.)","AnswerCount":7,"Available Count":1,"Score":0.0285636566,"is_accepted":false,"ViewCount":37359,"Q_Id":706101,"Users Score":1,"Answer":"Even though _json is available, I've noticed json decoding is very slow on CPython 2.6.6. I haven't compared with other implementations, but I've switched to string manipulation when inside performance-critical loops.","Q_Score":45,"Tags":"python,json,python-2.6","A_Id":5541345,"CreationDate":"2009-04-01T15:39:00.000","Title":"Python 2.6 JSON decoding 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},{"Question":"I've tried to find a comprehensive guide on whether it is best to use import module or from module import. I've just started with Python and I'm trying to start off with best practices in mind.\nBasically, I was hoping if anyone could share their experiences, what preferences other developers have and what's the best way to avoid any gotchas down the road?","AnswerCount":21,"Available Count":6,"Score":1.0,"is_accepted":false,"ViewCount":216208,"Q_Id":710551,"Users Score":43,"Answer":"Both ways are supported for a reason: there are times when one is more appropriate than the other.\n\nimport module: nice when you are using many bits from the module. drawback is that you'll need to qualify each reference with the module name.\nfrom module import ...: nice that imported items are usable directly without module name prefix. The drawback is that you must list each thing you use, and that it's not clear in code where something came from.\n\nWhich to use depends on which makes the code clear and readable, and has more than a little to do with personal preference. I lean toward import module generally because in the code it's very clear where an object or function came from. I use from module import ... when I'm using some object\/function a lot in the code.","Q_Score":535,"Tags":"python,python-import","A_Id":710598,"CreationDate":"2009-04-02T16:40:00.000","Title":"Use 'import module' or 'from module import'?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've tried to find a comprehensive guide on whether it is best to use import module or from module import. I've just started with Python and I'm trying to start off with best practices in mind.\nBasically, I was hoping if anyone could share their experiences, what preferences other developers have and what's the best way to avoid any gotchas down the road?","AnswerCount":21,"Available Count":6,"Score":0.0380768203,"is_accepted":false,"ViewCount":216208,"Q_Id":710551,"Users Score":4,"Answer":"To add to what people have said about from x import *: besides making it more difficult to tell where names came from, this throws off code checkers like Pylint. They will report those names as undefined variables.","Q_Score":535,"Tags":"python,python-import","A_Id":710831,"CreationDate":"2009-04-02T16:40:00.000","Title":"Use 'import module' or 'from module import'?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've tried to find a comprehensive guide on whether it is best to use import module or from module import. I've just started with Python and I'm trying to start off with best practices in mind.\nBasically, I was hoping if anyone could share their experiences, what preferences other developers have and what's the best way to avoid any gotchas down the road?","AnswerCount":21,"Available Count":6,"Score":0.0,"is_accepted":false,"ViewCount":216208,"Q_Id":710551,"Users Score":0,"Answer":"Import Module - You don't need additional efforts to fetch another thing from module. It has disadvantages such as redundant typing \nModule Import From - Less typing &More control over which items of a module can be accessed.To use a new item from the module you have to update your import statement.","Q_Score":535,"Tags":"python,python-import","A_Id":34892472,"CreationDate":"2009-04-02T16:40:00.000","Title":"Use 'import module' or 'from module import'?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've tried to find a comprehensive guide on whether it is best to use import module or from module import. I've just started with Python and I'm trying to start off with best practices in mind.\nBasically, I was hoping if anyone could share their experiences, what preferences other developers have and what's the best way to avoid any gotchas down the road?","AnswerCount":21,"Available Count":6,"Score":0.0095235216,"is_accepted":false,"ViewCount":216208,"Q_Id":710551,"Users Score":1,"Answer":"since many people answered here but i am just trying my best :)\n\nimport module is best when you don't know which item you have to import from module. In this way it may be difficult to debug when problem raises because\nyou don't know which item have problem.\n\nform module import is best when you know which item you require to import and also helpful in more controlling using importing specific item according to your need. Using this way debugging may be easy because you know which item you imported.","Q_Score":535,"Tags":"python,python-import","A_Id":62796069,"CreationDate":"2009-04-02T16:40:00.000","Title":"Use 'import module' or 'from module import'?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've tried to find a comprehensive guide on whether it is best to use import module or from module import. I've just started with Python and I'm trying to start off with best practices in mind.\nBasically, I was hoping if anyone could share their experiences, what preferences other developers have and what's the best way to avoid any gotchas down the road?","AnswerCount":21,"Available Count":6,"Score":0.0285636566,"is_accepted":false,"ViewCount":216208,"Q_Id":710551,"Users Score":3,"Answer":"My own answer to this depends mostly on first, how many different modules I'll be using. If i'm only going to use one or two, I'll often use from ... import since it makes for fewer keystrokes in the rest of the file, but if I'm going to make use of many different modules, I prefer just import because that means that each module reference is self-documenting. I can see where each symbol comes from without having to hunt around.\nUsuaully I prefer the self documenting style of plain import and only change to from.. import when the number of times I have to type the module name grows above 10 to 20, even if there's only one module being imported.","Q_Score":535,"Tags":"python,python-import","A_Id":710861,"CreationDate":"2009-04-02T16:40:00.000","Title":"Use 'import module' or 'from module import'?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've tried to find a comprehensive guide on whether it is best to use import module or from module import. I've just started with Python and I'm trying to start off with best practices in mind.\nBasically, I was hoping if anyone could share their experiences, what preferences other developers have and what's the best way to avoid any gotchas down the road?","AnswerCount":21,"Available Count":6,"Score":1.2,"is_accepted":true,"ViewCount":216208,"Q_Id":710551,"Users Score":575,"Answer":"The difference between import module and from module import foo is mainly subjective. Pick the one you like best and be consistent in your use of it. Here are some points to help you decide.\nimport module\n\nPros:\n\nLess maintenance of your import statements. Don't need to add any additional imports to start using another item from the module\n\nCons:\n\nTyping module.foo in your code can be tedious and redundant (tedium can be minimized by using import module as mo then typing mo.foo)\n\n\nfrom module import foo\n\nPros:\n\nLess typing to use foo\nMore control over which items of a module can be accessed\n\nCons:\n\nTo use a new item from the module you have to update your import statement\nYou lose context about foo. For example, it's less clear what ceil() does compared to math.ceil()\n\n\nEither method is acceptable, but don't use from module import *. \nFor any reasonable large set of code, if you import * you will likely be cementing it into the module, unable to be removed. This is because it is difficult to determine what items used in the code are coming from 'module', making it easy to get to the point where you think you don't use the import any more but it's extremely difficult to be sure.","Q_Score":535,"Tags":"python,python-import","A_Id":710603,"CreationDate":"2009-04-02T16:40:00.000","Title":"Use 'import module' or 'from module import'?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Many third-party Python modules have an attribute which holds the version information for the module (usually something like module.VERSION or module.__version__), however some do not.\nParticular examples of such modules are libxslt and libxml2.\nI need to check that the correct version of these modules are being used at runtime. Is there a way to do this?\nA potential solution wold be to read in the source at runtime, hash it, and then compare it to the hash of the known version, but that's nasty. \nIs there a better solutions?","AnswerCount":7,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":83866,"Q_Id":710609,"Users Score":8,"Answer":"I'd stay away from hashing. The version of libxslt being used might contain some type of patch that doesn't effect your use of it. \nAs an alternative, I'd like to suggest that you don't check at run time (don't know if that's a hard requirement or not). For the python stuff I write that has external dependencies (3rd party libraries), I write a script that users can run to check their python install to see if the appropriate versions of modules are installed. \nFor the modules that don't have a defined 'version' attribute, you can inspect the interfaces it contains (classes and methods) and see if they match the interface they expect. Then in the actual code that you're working on, assume that the 3rd party modules have the interface you expect.","Q_Score":136,"Tags":"python,module,version","A_Id":710653,"CreationDate":"2009-04-02T16:53:00.000","Title":"Checking a Python module version at runtime","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Many third-party Python modules have an attribute which holds the version information for the module (usually something like module.VERSION or module.__version__), however some do not.\nParticular examples of such modules are libxslt and libxml2.\nI need to check that the correct version of these modules are being used at runtime. Is there a way to do this?\nA potential solution wold be to read in the source at runtime, hash it, and then compare it to the hash of the known version, but that's nasty. \nIs there a better solutions?","AnswerCount":7,"Available Count":2,"Score":1.0,"is_accepted":false,"ViewCount":83866,"Q_Id":710609,"Users Score":6,"Answer":"Some ideas:\n\nTry checking for functions that exist or don't exist in your needed versions.\nIf there are no function differences, inspect function arguments and signatures.\nIf you can't figure it out from function signatures, set up some stub calls at import time and check their behavior.","Q_Score":136,"Tags":"python,module,version","A_Id":710642,"CreationDate":"2009-04-02T16:53:00.000","Title":"Checking a Python module version at runtime","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I use nosetests to run my unittests and it works well. I want to get a list of all the tests nostests finds without actually running them. Is there a way to do that?","AnswerCount":3,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":9288,"Q_Id":712020,"Users Score":3,"Answer":"There will be soon: a new --collect switch that produces this behavior was demo'd at PyCon last week. It should be on the trunk \"soon\" and will be in the 0.11 release.\nThe http:\/\/groups.google.com\/group\/nose-users list is a great resource for nose questions.","Q_Score":42,"Tags":"python,unit-testing,nose,nosetests","A_Id":716408,"CreationDate":"2009-04-02T23:27:00.000","Title":"List all Tests Found by Nosetest","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"There is cgi.escape but that appears to be implemented in pure python. It seems like most frameworks like Django also just run some regular expressions. This is something we do a lot, so it would be good to have it be as fast as possible.\nMaybe C implementations wouldn't be much faster than a series of regexes for this?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":961,"Q_Id":712113,"Users Score":0,"Answer":"See lxml, which is based on libxml2. While it's primarily a XML library, HTML support is available.","Q_Score":0,"Tags":"python,escaping,python-module","A_Id":712154,"CreationDate":"2009-04-03T00:14:00.000","Title":"Is there a good python module that does HTML encoding\/escaping 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":0,"Web Development":1},{"Question":"I have a web application and I would like to enable real time SMS notifications to the users of the applications. \nNote: I currently cannot use the Twitter API because I live in West Africa, and Twitter doesn't send SMS to my country.\nAlso email2sms is not an option because the mobile operators don't allow that in my country.","AnswerCount":7,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":2976,"Q_Id":716946,"Users Score":0,"Answer":"I don't have any knowledge in this area. But I think you'll have to talk to the mobile operators, and see if they have any API for sending SMS messages. \nYou'll probably have to pay them, or have some scheme for customers to pay them. Alternatively there might be some 3rd party that implements this functionality.","Q_Score":1,"Tags":"python,sms,notifications","A_Id":716953,"CreationDate":"2009-04-04T11:47:00.000","Title":"How do I enable SMS notifications in my web apps?","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},{"Question":"I have a web application and I would like to enable real time SMS notifications to the users of the applications. \nNote: I currently cannot use the Twitter API because I live in West Africa, and Twitter doesn't send SMS to my country.\nAlso email2sms is not an option because the mobile operators don't allow that in my country.","AnswerCount":7,"Available Count":2,"Score":0.057080742,"is_accepted":false,"ViewCount":2976,"Q_Id":716946,"Users Score":2,"Answer":"The easiest way to accomplish this is by using a third party API. Some I know that work well are:\n\nrestSms.me\nTwilio.com\nClicatell.com\n\nI have used all of them and they easiest\/cheapest one to implement was restSms.me\nHope that helps.","Q_Score":1,"Tags":"python,sms,notifications","A_Id":5414483,"CreationDate":"2009-04-04T11:47:00.000","Title":"How do I enable SMS notifications in my web apps?","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},{"Question":"The authentication system for an application we're using right now uses a two-way hash that's basically little more than a glorified caesar cypher. Without going into too much detail about what's going on with it, I'd like to replace it with a more secure encryption algorithm (and it needs to be done server-side). Unfortunately, it needs to be two-way and the algorithms in hashlib are all one-way.\nWhat are some good encryption libraries that will include algorithms for this kind of thing?","AnswerCount":3,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":3449,"Q_Id":721436,"Users Score":8,"Answer":"If it's two-way, it's not really a \"hash\". It's encryption (and from the sounds of things this is really more of a 'salt' or 'cypher', not real encryption.) A hash is one-way by definition. So rather than something like MD5 or SHA1 you need to look for something more like PGP.\nSecondly, can you explain the reasoning behind the 2-way requirement? That's not generally considered good practice for authentication systems any more.","Q_Score":5,"Tags":"python,encryption","A_Id":721444,"CreationDate":"2009-04-06T13:27:00.000","Title":"What's a good two-way encryption library implemented 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},{"Question":"I'm not sure if this is even possible since this might be handled in hardware, but I need to send some Ethernet frames with errors in them. I'd like to be able to create runts, jabber, misalignment, and bad FCS errors. I'm working in Python.","AnswerCount":4,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":12680,"Q_Id":723635,"Users Score":9,"Answer":"It can be handled in hardware, but isn't always -- and even if it is, you can turn that off; see the ethtool offload parameters.\nWith regard to getting full control over the frames you create -- look into PF_PACKET (for one approach) or the tap driver (for another).\nHere's an article on using PF_PACKET to send hand-crafted frames from Python.","Q_Score":9,"Tags":"python,networking,automated-tests,ethernet","A_Id":724009,"CreationDate":"2009-04-06T23:30:00.000","Title":"How do you send an Ethernet frame with a corrupt FCS?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"Is there any way to generate words based on characters and checking if a domain exists with this word (ping)?\nWhat I want to do is to generate words based on some characters, example \"abcdefgh\", and then ping generatedword.com to check if it exists.","AnswerCount":3,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":382,"Q_Id":735743,"Users Score":3,"Answer":"Just because a site fails a ping doesn't mean the domain is available. The domain could be reserved but not pointing anywhere, or the machine may not respond to pings, or it may just be down.","Q_Score":0,"Tags":"python,ping","A_Id":735801,"CreationDate":"2009-04-09T20:03:00.000","Title":"Looping through chars, generating words and checking if domain exists","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I need to measure the performance of a hard disk using python. What is the best\/fastest\/shortest\/easiest approach to do it? It doesn't have to be overly accurate, just a ballpark value.\nMy actual goal is to write a small utility which will adjust the postgres settings to the best configuration for the given hardware.\nMy naive approach would be to write some files and measure the time how long it would take. I would try it for several block sizes, and then I would try to access some random positions within a large file. Any other ideas?","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":179,"Q_Id":757816,"Users Score":2,"Answer":"I would think your best bet would be using an external tool, Bonnie++ for example, and parse the program output. Even if you're not that concerned with precision there's no reason to reinvent the wheel. Why rewrite what's already there?","Q_Score":1,"Tags":"python,performance,postgresql","A_Id":758057,"CreationDate":"2009-04-16T20:00:00.000","Title":"Whats the easiest and fastest way to measure HD performance 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},{"Question":"I have a python process (Pylons webapp) that is constantly using 10-30% of CPU. I'll improve\/tune logging to get some insight of what's going on, but until then, are there any tools\/techniques that allow to see what python process is doing, how many and how busy threads it has etc?\nUpdate:\n\nconfigured access log which shows that there are no requests going on, webapp is just idling \nno point to plug in paste.profile in middleware chain since there are no requests, activity must be happening either in webapp's worker threads or paster web server\nrunning paster like this: \"python -m cProfile -o outfile \/usr\/bin\/paster serve dev.ini\" and inspecting results shows that most time is spent in \"posix.waitpid\". Paster runs webapp in subprocess, subprocess activity is not picked up by profiler\nlooking into ;hacking PasteScript \"serve\" command so that subprocesses would get profiled\n\nAnother update:\nAfter much tinkering, sticking profiler in various places and getting familiar with PasteScript insides, I discovered that the constant CPU load goes away if application is started without \"--reload\" parameter (this flag tells paster to restart itself if code changes, handy in development), which is fine in production environment.","AnswerCount":2,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":3282,"Q_Id":760039,"Users Score":6,"Answer":"As you noted, in --reload mode, Paste sweeps the filesystem every second to see if any of the files loaded have changed. If they have, then Paste reloads the process. You can also manually tell Paste to monitor non-Python code modules for changes if desired.\nYou can change the reload interval with the --reload-interval option, this will reduce the CPU usage when using --reload as it will sweep less often.","Q_Score":6,"Tags":"python,multithreading,debugging,monitoring,pylons","A_Id":784432,"CreationDate":"2009-04-17T11:17:00.000","Title":"Investigating python process to see what's eating CPU","Data Science and Machine Learning":0,"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},{"Question":"I'm trying to find a way to mark a USB flash device in a way that I can programmaticly test for without mounting it or changing the label. \nAre there any properties I can modify about a device that will not cause it to behave\/look differently to the user?\nRunning Ubuntu Jaunty.","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":104,"Q_Id":760310,"Users Score":0,"Answer":"Changing the VID\/PID might make your device non-usable without custom drivers. HAL isn't supposed to auto-mount your flash drives for you. \nThat being said, you could always sneak something into the boot sector and\/or the beginning part of the drive. There are a lot of spare bytes in there that can be used for custom purposes - both nefarious and otherwise.","Q_Score":1,"Tags":"python,hardware,mount,dbus,hal","A_Id":760814,"CreationDate":"2009-04-17T12:58:00.000","Title":"How to mark a device in a way that can be retrived by HAL but does not require mounting or changing the label","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I'm trying to find a way to mark a USB flash device in a way that I can programmaticly test for without mounting it or changing the label. \nAre there any properties I can modify about a device that will not cause it to behave\/look differently to the user?\nRunning Ubuntu Jaunty.","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":104,"Q_Id":760310,"Users Score":1,"Answer":"You cannot modify this property, but the tuple (vendor_id, product_id, serial_number) is unique to each device, so you can use this as mark that is already there. \nYou can enumerate the devices on the USB bus using lsusb or usblib.","Q_Score":1,"Tags":"python,hardware,mount,dbus,hal","A_Id":760744,"CreationDate":"2009-04-17T12:58:00.000","Title":"How to mark a device in a way that can be retrived by HAL but does not require mounting or changing the label","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"Is it possible to import modules based on location? \n(eg. do all modules i import have to be in \/usr\/lib64\/python2.5\/ or a similar dir?)\nI'd like to import a module that's local to the current script.","AnswerCount":7,"Available Count":2,"Score":0.0855049882,"is_accepted":false,"ViewCount":462,"Q_Id":762111,"Users Score":3,"Answer":"python will import from the current directory by default.\nsys.path is the variable that controls where python searches for imports.","Q_Score":3,"Tags":"python,import","A_Id":762122,"CreationDate":"2009-04-17T20:37:00.000","Title":"Importing 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},{"Question":"Is it possible to import modules based on location? \n(eg. do all modules i import have to be in \/usr\/lib64\/python2.5\/ or a similar dir?)\nI'd like to import a module that's local to the current script.","AnswerCount":7,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":462,"Q_Id":762111,"Users Score":0,"Answer":"It searches in .\/lib by default.","Q_Score":3,"Tags":"python,import","A_Id":762142,"CreationDate":"2009-04-17T20:37:00.000","Title":"Importing 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},{"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},{"Question":"I need to send email in delbian linux. How to send? I run my server on 256 MB linux box and I heard postfix and sendmail is overkill.\nRecently I came across the ssmtp, that seems to be an executable, needs to be executed as a process and called through python using os modules.\nalternatively, python already provides smtplib which is working fine with me.\nWhat is the advantage of using ssmtp over python's smtplib?","AnswerCount":3,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":4757,"Q_Id":764778,"Users Score":5,"Answer":"In a Python program, there is no advantage.\nThe only purpose of ssmtp is to wrap the SMTP protocol in the sendmail API. That is, it provides a program \/usr\/sbin\/sendmail that accepts the same options, arguments, and inputs as the full-blown sendmail (though most of the options do nothing); but behind the scenes, instead of processing the email itself, it sends the message to an SMTP server. This is for systems that need to have a sendmail program present, perhaps because they don't understand SMTP - for example, I think older versions of PHP had this requirement, and even in recent versions it might still be easier to configure PHP to use the so-called sendmail interface (i.e. the program sendmail) than to use SMTP directly. (I haven't used PHP in a little while, I'm not sure about the current status) \nHowever, in Python the situation is reversed: you have a builtin library that makes it easy to use SMTP directly, whereas using sendmail requires you to invoke the subprocess module which is somewhat clunky and also very dependent on things that are not part of Python. So basically there is no reason not to use smtplib.","Q_Score":3,"Tags":"python,smtplib,ssmtp","A_Id":765044,"CreationDate":"2009-04-19T03:24:00.000","Title":"how to send mail in python ssmtp vs smtplib","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I need to send email in delbian linux. How to send? I run my server on 256 MB linux box and I heard postfix and sendmail is overkill.\nRecently I came across the ssmtp, that seems to be an executable, needs to be executed as a process and called through python using os modules.\nalternatively, python already provides smtplib which is working fine with me.\nWhat is the advantage of using ssmtp over python's smtplib?","AnswerCount":3,"Available Count":2,"Score":0.1325487884,"is_accepted":false,"ViewCount":4757,"Q_Id":764778,"Users Score":2,"Answer":"Additionally, postfix is very easy to install in \"satellite\" mode, where all it does is queue and deliver email for you. Way easier than implementing your own email queue. Most decent package management systems will let you configure it this way.","Q_Score":3,"Tags":"python,smtplib,ssmtp","A_Id":766413,"CreationDate":"2009-04-19T03:24:00.000","Title":"how to send mail in python ssmtp vs smtplib","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"Can you elaborate on the current state of \"blocks\" (in the Ruby sense) in Python?\nWhat are the language constructs that exist in Python? How do they compare to other languages (like Ruby, Smalltalk, [insert more])? Or does Python lack such constructs?\nI have so far understood the lambda thing; it is only one-line, but maybe it comes close. What about \"decorators\" and yield in this context?\nI am also using old Python versions in some projects. Which constructs were introduced in which Python version (2.5, 2.6, etc.) or are planned in future versions?\nCan you link interesting articles on the subject that explain this stuff for Python and also comparing to other languages and could be interesting for someone who wants to extend basic Python knowledge?","AnswerCount":4,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":4121,"Q_Id":767519,"Users Score":0,"Answer":"The def is equivalent of an assignment statement which only binds the function object to the object reference variable.\nThe object reference variable can then be used to call the function object to execute.","Q_Score":10,"Tags":"python,ruby,lambda","A_Id":768265,"CreationDate":"2009-04-20T09:14:00.000","Title":"Blocks of code 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},{"Question":"I need to create ZIP archives on demand, using either Python zipfile module or unix command line utilities. \nResources to be zipped are often > 1GB and not necessarily compression-friendly.\nHow do I efficiently estimate its creation time \/ size?","AnswerCount":4,"Available Count":2,"Score":0.1488850336,"is_accepted":false,"ViewCount":3583,"Q_Id":767684,"Users Score":3,"Answer":"I suggest you measure the average time it takes to produce a zip of a certain size. Then you calculate the estimate from that measure. However I think the estimate will be very rough in any case if you don't know how well the data compresses. If the data you want to compress had a very similar \"profile\" each time you could probably make better predictions.","Q_Score":7,"Tags":"python,zip,time-estimation","A_Id":767701,"CreationDate":"2009-04-20T10:23:00.000","Title":"Estimating zip size\/creation 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},{"Question":"I need to create ZIP archives on demand, using either Python zipfile module or unix command line utilities. \nResources to be zipped are often > 1GB and not necessarily compression-friendly.\nHow do I efficiently estimate its creation time \/ size?","AnswerCount":4,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":3583,"Q_Id":767684,"Users Score":16,"Answer":"Extract a bunch of small parts from the big file. Maybe 64 chunks of 64k each. Randomly selected.\nConcatenate the data, compress it, measure the time and the compression ratio. Since you've randomly selected parts of the file chances are that you have compressed a representative subset of the data.\nNow all you have to do is to estimate the time for the whole file based on the time of your test-data.","Q_Score":7,"Tags":"python,zip,time-estimation","A_Id":767704,"CreationDate":"2009-04-20T10:23:00.000","Title":"Estimating zip size\/creation 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},{"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},{"Question":"I've set up a few web servers in my day, but I'm not sure how they work internally. I'm setting up a new environment for myself and I'm interested in configuring my lighttpd server to support both PHP and Python. Is this possible?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":3056,"Q_Id":771341,"Users Score":1,"Answer":"You can also enable Lighty to use .pl, .py and .php as 'cgi' by enabling mod_cgi and setting it up. The default configs are on the Lighty website. However, this will have the benefits and problems of running an independent cgi process. If you are only experiencing light traffic, performance shouldn't be an issue.","Q_Score":3,"Tags":"php,python,lighttpd,configure","A_Id":771528,"CreationDate":"2009-04-21T06:49:00.000","Title":"Python + PHP + Lighttpd?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"Since python2.6, it's now easier to extract data from a password protected zip. But how to create a password protected zipfile in pure python ?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1457,"Q_Id":772814,"Users Score":3,"Answer":"I've looked for this in the past and been unsuccessful. (I'd love to see a solution get posted!)\nOne option is a commercial package from chilkatsoft that will do this, but at $150. Makes sense if you are doing a commercial app, but tough to swallow otherwise.\nI wound up calling out to the system for my solution, a while ago. Unfortunately, this locks it to a platform.","Q_Score":3,"Tags":"python,zip","A_Id":772842,"CreationDate":"2009-04-21T14:20:00.000","Title":"How to create a password protected zipfile 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},{"Question":"Hi I have a small comment shoutbox type cgi process running on a server and currently when someone leaves a comment I simply format that comment into html i.e\n

$title<\/p>\n

$comment<\/p>\nand store in a flat file.\nWould it be faster and acceptably low in LOC to reimplement the storage in xml or json, in a simple spec of my own or stick with the simple html route?. \nI don't want to use relational database for this.","AnswerCount":3,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":331,"Q_Id":777090,"Users Score":3,"Answer":"If a flat file is fast enough, then go with that, since it's very simple and accessible. Storing as XML and JSON but still using a flat file probably is very comparable in performance.\nYou might want to consider (ignore this if you just left it out of your question) sanitizing\/filtering the text, so that users can't break your HTML by e.g. entering \"<\/p>\" in the comment text.","Q_Score":1,"Tags":"python,xml,json","A_Id":777119,"CreationDate":"2009-04-22T12:56:00.000","Title":"fastest way to store comment data 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},{"Question":"The struct.pack() function allows converting integers of up to 64 bit to byte strings. What's the most efficient way to pack an even larger integer? I'd rather not add a dependency on non-standard modules like PyCrypto (which provides num_to_bytes()).","AnswerCount":7,"Available Count":1,"Score":0.057080742,"is_accepted":false,"ViewCount":4223,"Q_Id":777525,"Users Score":2,"Answer":"I take it you mean you only want to use as many bytes as you need to represent the number? e.g. if the number is:\n\n255 or less you'd use only 1 byte\n65535 or less 2 bytes\n16777215 or less 3 bytes\netc etc\n\nOn the Psion PDA they'd usually have some of packing scheme in which you read the first byte, detect if it has the highest bit set and then read another byte if it has. That way you'd just keep reading bytes until you read the \"full\" number. That system works quite well if most of the numbers you are dealing with are fairly small, as you'll normally only use one or two bytes per number.\nThe alternative is to have one (or more) bytes representing the number of total bytes used, but at that point it's basically a string in Python anyway. i.e. it's a string of base-256 digits.","Q_Score":14,"Tags":"python,byte","A_Id":777746,"CreationDate":"2009-04-22T14:36:00.000","Title":"Efficient arbitrary-sized integer packing 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},{"Question":"Other than basic python syntax, what other key areas should I learn to get a website live?\nIs there a web.config in the python world?\nWhich libraries handle things like authentication? or is that all done manually via session cookies and database tables?\nAre there any web specific libraries?\nEdit: sorry!\nI am well versed in asp.net, I want to branch out and learn Python, hence this question (sorry, terrible start to this question I know).","AnswerCount":5,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":177,"Q_Id":777924,"Users Score":0,"Answer":"Oh, golly.\nLook, this is gonna be real hard to answer because, read as you wrote it, you're missing a lot of steps. Like, you need a web server, a design, some HTML, and so on.\nAre you building from the ground up? Asking about Python makes me suspect you may be using something like Zope.","Q_Score":0,"Tags":"python","A_Id":777952,"CreationDate":"2009-04-22T15:46:00.000","Title":"Other than basic python syntax, what other key areas should I learn to get a website live?","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},{"Question":"Is there an easy-to-use python module that'd do english or finnish text validation?\nIt'd be ok if I could just check the words exist in user-defined dictionary and possibly checking that the grammar is somewhat okay.\nI am planning to implement a fancy validation for a directory contents I did while ago back. This involves some simple stuff like checking that the config scripts won't crash and does it all well. It's all quite easy otherwise.\nFor the validator I should just be able to input whole files or strings of unicode text.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":152,"Q_Id":783189,"Users Score":2,"Answer":"I'm not sure what you're trying to do, but if you're looking for something that can say 'this is valid English' or 'this is valid Finnish', then you're looking at a class of problems that is quite likely unsolvable.\nIf not, then use a dictionary and\/or letter frequencies and Bayesian analysis to determine whether or not given text is English-like or Finnish-like. If you're trying to auto-detect a language, this is likely the best route, although you'll run into problems with mixed-language text.","Q_Score":0,"Tags":"python","A_Id":783207,"CreationDate":"2009-04-23T19:27:00.000","Title":"English and\/or Finnish text validation","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"G'day folks. I'm trying to introduce Ruby at work, and a few people are interested. However, I've been asked to present the benefits of Ruby over Python and PHP.\nI've broken this down into 2 parts:\n1) show Python and Ruby's advantages over PHP;\n2) show Ruby's advantages over Python.\nThe first is easy. I'll explain things like:\n\nEverything's an object.\nPython and Ruby are easier to read and write.\n\nFor the second, I'm thinking of:\n\nRuby has many conveniences, which makes it easier to read and write. Eg: Optional brackets, and being able to open built-ins, allows for things like 2.days.from_now\nRSpec is miles ahead of Python's TDD and BDD frameworks.\nGitHub and RubyForge are fantastic resources for finding, releasing, and collaborating on software.\n\nDo you have any suggestions? I'm all ears!","AnswerCount":11,"Available Count":9,"Score":0.0906594778,"is_accepted":false,"ViewCount":1888,"Q_Id":784584,"Users Score":5,"Answer":"Devil's advocate maybe...\n\n\nEverything's an object.\n\n\nThis is a feature of Ruby, but it is not self-explanatory as to why this is a benefit. You would need to pre-prepare an argument for why that is a benefit. When convincing somebody of something's superiority, always think in terms of showing the benefits, not the features.\n\n\nPython and Ruby are easier to read and write.\n\n\nThis is a very big claim to make, and I would not be comfortable making such a claim without a substantial amount of credible objective third party evidence supporting this. If not, and I suspect such a claim really couldn't be backed up, I would play it safe and avoid making such a claim. Making a claim this substantial, but only backing it up with personal opinion or anecdotal evidence would not be a good idea.\n\n\nRuby has many conveniences, which\n makes it easier to read and write. Eg:\n Optional brackets, and being able to\n open built-ins, allows for things like\n 2.days.from_now\n\n\nAgain, you will need to think benefits, not features. It may be true that it has optional brackets, but you cannot just mention a feature, you have to explain its benefit - why that feature is a better idea than any other approach. Personally I am not sure that 'optional' syntax is ever a good idea, and would need a fair bit of evidence to convince me that it was.\n\n\nGitHub and RubyForge are fantastic resources for finding,\n releasing, and collaborating on\n software.\n\n\nThat's good. There are also similar resources for languages other than Ruby - again, you will need to not only mention the existence of these but explain how they are better than the alternatives.\nGood luck.","Q_Score":2,"Tags":"python,ruby","A_Id":784667,"CreationDate":"2009-04-24T05:02:00.000","Title":"Convincing others of Ruby over Python and 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":1},{"Question":"G'day folks. I'm trying to introduce Ruby at work, and a few people are interested. However, I've been asked to present the benefits of Ruby over Python and PHP.\nI've broken this down into 2 parts:\n1) show Python and Ruby's advantages over PHP;\n2) show Ruby's advantages over Python.\nThe first is easy. I'll explain things like:\n\nEverything's an object.\nPython and Ruby are easier to read and write.\n\nFor the second, I'm thinking of:\n\nRuby has many conveniences, which makes it easier to read and write. Eg: Optional brackets, and being able to open built-ins, allows for things like 2.days.from_now\nRSpec is miles ahead of Python's TDD and BDD frameworks.\nGitHub and RubyForge are fantastic resources for finding, releasing, and collaborating on software.\n\nDo you have any suggestions? I'm all ears!","AnswerCount":11,"Available Count":9,"Score":0.0,"is_accepted":false,"ViewCount":1888,"Q_Id":784584,"Users Score":0,"Answer":"All 3 languages have their place. As with any programming task you must pick the language best suited for the task. Python has list comprehensions, php is much better when embedding and generating html. Ruby is a great language too. One of the things I have found myself using in ruby a few times is the 'a'...'zzzzz' to generate all possible strings of size 1 - 5. They all have their advantages and are all better than the others at particular tasks.","Q_Score":2,"Tags":"python,ruby","A_Id":784633,"CreationDate":"2009-04-24T05:02:00.000","Title":"Convincing others of Ruby over Python and 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":1},{"Question":"G'day folks. I'm trying to introduce Ruby at work, and a few people are interested. However, I've been asked to present the benefits of Ruby over Python and PHP.\nI've broken this down into 2 parts:\n1) show Python and Ruby's advantages over PHP;\n2) show Ruby's advantages over Python.\nThe first is easy. I'll explain things like:\n\nEverything's an object.\nPython and Ruby are easier to read and write.\n\nFor the second, I'm thinking of:\n\nRuby has many conveniences, which makes it easier to read and write. Eg: Optional brackets, and being able to open built-ins, allows for things like 2.days.from_now\nRSpec is miles ahead of Python's TDD and BDD frameworks.\nGitHub and RubyForge are fantastic resources for finding, releasing, and collaborating on software.\n\nDo you have any suggestions? I'm all ears!","AnswerCount":11,"Available Count":9,"Score":0.0,"is_accepted":false,"ViewCount":1888,"Q_Id":784584,"Users Score":0,"Answer":"If you are inclined towards a language or a software then you will tend to see only the goodies compared to others. If you want to do real comparison then comapre pros and cons and see if Ruby is clear winner in terms of what you want to achieve with that language in your company. If you do this and your company see benefits of Ruby then surely they will use.","Q_Score":2,"Tags":"python,ruby","A_Id":784656,"CreationDate":"2009-04-24T05:02:00.000","Title":"Convincing others of Ruby over Python and 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":1},{"Question":"G'day folks. I'm trying to introduce Ruby at work, and a few people are interested. However, I've been asked to present the benefits of Ruby over Python and PHP.\nI've broken this down into 2 parts:\n1) show Python and Ruby's advantages over PHP;\n2) show Ruby's advantages over Python.\nThe first is easy. I'll explain things like:\n\nEverything's an object.\nPython and Ruby are easier to read and write.\n\nFor the second, I'm thinking of:\n\nRuby has many conveniences, which makes it easier to read and write. Eg: Optional brackets, and being able to open built-ins, allows for things like 2.days.from_now\nRSpec is miles ahead of Python's TDD and BDD frameworks.\nGitHub and RubyForge are fantastic resources for finding, releasing, and collaborating on software.\n\nDo you have any suggestions? I'm all ears!","AnswerCount":11,"Available Count":9,"Score":0.0,"is_accepted":false,"ViewCount":1888,"Q_Id":784584,"Users Score":0,"Answer":"This kind of post gives Ruby programmers a bad name. Ruby is Beethoven, Python is Bach. If you prefer one style to the other, fine, but don't try to argue the superiority of one over the other.","Q_Score":2,"Tags":"python,ruby","A_Id":1227135,"CreationDate":"2009-04-24T05:02:00.000","Title":"Convincing others of Ruby over Python and 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":1},{"Question":"G'day folks. I'm trying to introduce Ruby at work, and a few people are interested. However, I've been asked to present the benefits of Ruby over Python and PHP.\nI've broken this down into 2 parts:\n1) show Python and Ruby's advantages over PHP;\n2) show Ruby's advantages over Python.\nThe first is easy. I'll explain things like:\n\nEverything's an object.\nPython and Ruby are easier to read and write.\n\nFor the second, I'm thinking of:\n\nRuby has many conveniences, which makes it easier to read and write. Eg: Optional brackets, and being able to open built-ins, allows for things like 2.days.from_now\nRSpec is miles ahead of Python's TDD and BDD frameworks.\nGitHub and RubyForge are fantastic resources for finding, releasing, and collaborating on software.\n\nDo you have any suggestions? I'm all ears!","AnswerCount":11,"Available Count":9,"Score":0.0181798149,"is_accepted":false,"ViewCount":1888,"Q_Id":784584,"Users Score":1,"Answer":"Actually no one ever conviced me (at least directly), to use one programming language or another. \nI used to have a certain need for clearness (if you might call it that way) and some other criteria, a language and its ecosystem should meet. And you definitively will end up using some stdlib, and third-party resources, so you might want to look into them as well (and use them as arguments).\nI am a fan of both, ruby and python (and these languages conviced me both by their design, their constant progress and their communities). The general notion of a scripting language makes them equally appealing. I found gem to be one of the slowest software I ever used. And personally, I think pythons stdlib is better organized than rubys. But I like Ruby Mixins, they are elegant and safe a lot of time.\nIn short: You could point your colleagues interest to some current hot spots, where coding is just hard, then show some alternatives in ruby. Rake is a great tool as well, demonstrate it ... Just be rationally passionate about it .. The rest will come ..","Q_Score":2,"Tags":"python,ruby","A_Id":785273,"CreationDate":"2009-04-24T05:02:00.000","Title":"Convincing others of Ruby over Python and 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":1},{"Question":"G'day folks. I'm trying to introduce Ruby at work, and a few people are interested. However, I've been asked to present the benefits of Ruby over Python and PHP.\nI've broken this down into 2 parts:\n1) show Python and Ruby's advantages over PHP;\n2) show Ruby's advantages over Python.\nThe first is easy. I'll explain things like:\n\nEverything's an object.\nPython and Ruby are easier to read and write.\n\nFor the second, I'm thinking of:\n\nRuby has many conveniences, which makes it easier to read and write. Eg: Optional brackets, and being able to open built-ins, allows for things like 2.days.from_now\nRSpec is miles ahead of Python's TDD and BDD frameworks.\nGitHub and RubyForge are fantastic resources for finding, releasing, and collaborating on software.\n\nDo you have any suggestions? I'm all ears!","AnswerCount":11,"Available Count":9,"Score":0.0363476168,"is_accepted":false,"ViewCount":1888,"Q_Id":784584,"Users Score":2,"Answer":"You're going to have a tough sell over python. GitHub is written in Ruby, not for ruby per se, by the way.\nFor python one has BitBucket (even though I do prefer git), as well as pypi.\nCorrect me if I'm wrong, but it sounds like you haven't looked at python code all that much. (I've written buckets of both python and Ruby by the way) I find it much more readable, especially when you're working on code that's not your own.\nAnyways, not really answering your question, and don't really want to contribute more to the flame war.","Q_Score":2,"Tags":"python,ruby","A_Id":785262,"CreationDate":"2009-04-24T05:02:00.000","Title":"Convincing others of Ruby over Python and 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":1},{"Question":"G'day folks. I'm trying to introduce Ruby at work, and a few people are interested. However, I've been asked to present the benefits of Ruby over Python and PHP.\nI've broken this down into 2 parts:\n1) show Python and Ruby's advantages over PHP;\n2) show Ruby's advantages over Python.\nThe first is easy. I'll explain things like:\n\nEverything's an object.\nPython and Ruby are easier to read and write.\n\nFor the second, I'm thinking of:\n\nRuby has many conveniences, which makes it easier to read and write. Eg: Optional brackets, and being able to open built-ins, allows for things like 2.days.from_now\nRSpec is miles ahead of Python's TDD and BDD frameworks.\nGitHub and RubyForge are fantastic resources for finding, releasing, and collaborating on software.\n\nDo you have any suggestions? I'm all ears!","AnswerCount":11,"Available Count":9,"Score":0.0906594778,"is_accepted":false,"ViewCount":1888,"Q_Id":784584,"Users Score":5,"Answer":"If you really want to show Ruby is better (assuming it is for your application!), why not try writing a small app from scratch in front of them? It doesn't have to be big, but something relavent to what you'll eventually be using it for is a good idea.\nWrite the app in all three languages including any configuration for the server (I'm assuming you're writing a web app here using DJango \/ Rails \/ PHP right?) and show how much faster you are, how much cleaner the code is etc. ...assuming it is ;-)\nYou can finish up by asking them what they'd like to add to it and then try adding that feature if it's a small change. Nothing like a bit of audience participation - people like applauding themselves. If you get them involved they're more likely to accept the winner.\nFor the record, I've tried all three and would agree that both Ruby and Python seem to result in cleaner code. I'd go for Python over Ruby though - there was something clunky about the syntax of Ruby when I tried it that I just didn't experience with Python.","Q_Score":2,"Tags":"python,ruby","A_Id":785060,"CreationDate":"2009-04-24T05:02:00.000","Title":"Convincing others of Ruby over Python and 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":1},{"Question":"G'day folks. I'm trying to introduce Ruby at work, and a few people are interested. However, I've been asked to present the benefits of Ruby over Python and PHP.\nI've broken this down into 2 parts:\n1) show Python and Ruby's advantages over PHP;\n2) show Ruby's advantages over Python.\nThe first is easy. I'll explain things like:\n\nEverything's an object.\nPython and Ruby are easier to read and write.\n\nFor the second, I'm thinking of:\n\nRuby has many conveniences, which makes it easier to read and write. Eg: Optional brackets, and being able to open built-ins, allows for things like 2.days.from_now\nRSpec is miles ahead of Python's TDD and BDD frameworks.\nGitHub and RubyForge are fantastic resources for finding, releasing, and collaborating on software.\n\nDo you have any suggestions? I'm all ears!","AnswerCount":11,"Available Count":9,"Score":1.0,"is_accepted":false,"ViewCount":1888,"Q_Id":784584,"Users Score":29,"Answer":"If your goal is to show why language X is better than language Y, you're stuck in subjective-land where there are no right answers.\nNo, Ruby is not better than PHP or Python. It might be more suited for a given purpose, and for that you can give specific examples. PHP is a poor choice for writing an SMTP server; Ruby and Python will serve you better (in fact, in Python it can be done in just a few lines, can't speak for Ruby though). On the other hand, PHP is better suited than Ruby for writing a one-off, short backend for an email submission form. The code is short, easy to maintain, quick to write, etc.\nPHP has an absolutely huge developer base, making programmers easy to find, which comes in handy if you ever want to out-source any aspect of the development chain. On the other hand, it's also terrifically easy to write horrible code in PHP, and there is more than enough of that going around.\nPython has a much larger user base than Ruby, and indeed is the primary language that RedHat uses for developing system tools. So if you're on a RedHat derived server (and statistically, chances are pretty good that you are if you're using Linux) then Python is guaranteed to be already in-place and working properly, etc.\nIn short, weigh the benefits, make a decision, but don't assume that people will agree with you; after all it's just an opinion.\n\nEdit\nIt just occurred to me that I failed to state the whole point: you shouldn't be trying to convince other people that they should use Ruby over Python\/PHP. Instead you should be trying to determine whether you should use Ruby over Python\/PHP. \nYou can't go fact-finding like this having already determined what the answer will be -- that's not helpful. Instead you should be gathering information on the benefits and drawbacks of each language and weighing that against the requirements of your company. Once you come to a conclusion, you'll already have a preponderance of evidence showing it was the correct one.","Q_Score":2,"Tags":"python,ruby","A_Id":784626,"CreationDate":"2009-04-24T05:02:00.000","Title":"Convincing others of Ruby over Python and 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":1},{"Question":"G'day folks. I'm trying to introduce Ruby at work, and a few people are interested. However, I've been asked to present the benefits of Ruby over Python and PHP.\nI've broken this down into 2 parts:\n1) show Python and Ruby's advantages over PHP;\n2) show Ruby's advantages over Python.\nThe first is easy. I'll explain things like:\n\nEverything's an object.\nPython and Ruby are easier to read and write.\n\nFor the second, I'm thinking of:\n\nRuby has many conveniences, which makes it easier to read and write. Eg: Optional brackets, and being able to open built-ins, allows for things like 2.days.from_now\nRSpec is miles ahead of Python's TDD and BDD frameworks.\nGitHub and RubyForge are fantastic resources for finding, releasing, and collaborating on software.\n\nDo you have any suggestions? I'm all ears!","AnswerCount":11,"Available Count":9,"Score":1.0,"is_accepted":false,"ViewCount":1888,"Q_Id":784584,"Users Score":12,"Answer":"Hmm, as an active programmer in all three languages I simply can't agree with the sentiment that either is better than the other. Sure, Python and Ruby are more object-oriented, but that's not a requirement to be better, it's only a convenience. You can't beat the community of PHP and the legacy (for good and for bad) of code, nor ignore the direction PHP is taking for the future, the mass of support, the distributed servers ready for it, and so on.\nIf you want to focus on syntax, then all three have their strong and weak points. If you want to talk about back-end technology, then as all three are moving active open-source projects, there really is no winner.\nExcept, you, the programmer, who can mix and choose what best suits you. Remember that even if you think Ruby is the best thing since NAND gates it doesn't mean others follow. And remember also that we're all different; some people actually like Java and .Net, just like others love LISP. We're all different, and I doubt any of the Ruby\/Python\/PHP contenders are any better than the other. Sorry.","Q_Score":2,"Tags":"python,ruby","A_Id":784621,"CreationDate":"2009-04-24T05:02:00.000","Title":"Convincing others of Ruby over Python and 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":1},{"Question":"Is there a way to generically retrieve process stats using Perl or Python? We could keep it Linux specific.\nThere are a few problems: I won't know the PID ahead of time, but I can run the process in question from the script itself. For example, I'd have no problem doing:\n.\/myscript.pl some\/process\/I\/want\/to\/get\/stats\/for\nBasically, I'd like to, at the very least, get the memory consumption of the process, but the more information I can get the better (like run time of the process, average CPU usage of the process, etc.)\nThanks.","AnswerCount":3,"Available Count":2,"Score":0.1325487884,"is_accepted":false,"ViewCount":4760,"Q_Id":785810,"Users Score":2,"Answer":"If you are fork()ing the child, you will know it's PID.\nFrom within the parent you can then parse the files in \/proc\/ just keep writing on a TXT the current timestamp in some time interval, depending on your needs (here each half hour was perfect).\nIf the timestamp on the TXT is outdated relatively to the current one when you check, then there was a problem on the program and it should be restarted or what you prefer to do.","Q_Score":121,"Tags":"python,process,daemon","A_Id":66500807,"CreationDate":"2009-04-25T06:59:00.000","Title":"Check to see if python script is running","Data Science and Machine Learning":0,"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},{"Question":"I am using Python as a plug-in scripting language for an existing C++ application. I am able to embed the python interpreter as stated in the Python documentation. Everything works successfully with the initialization and de-initialization of the interpreter. I am, however, having trouble loading modules because I have not been able to zip up the standard library in to a zip file (normally PythonXX.zip, corresponding to the version number of the python dll). \nWhat is the simplest way to zip up all of the standard library after optimized bytecode compiling? I'm looking for a simple script or command to do so for me, as I really don't want to do this by hand. \nAny ideas? \nThanks!","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":845,"Q_Id":789598,"Users Score":2,"Answer":"It shouldn't be too difficult to write a script for that. Check out the zipfile.PyZipFile class and it's writepy method.","Q_Score":3,"Tags":"c++,python,distribution,embedded-language","A_Id":789669,"CreationDate":"2009-04-25T19:48:00.000","Title":"What is the easiest way to build Python26.zip for embedded 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":1,"System Administration and DevOps":0,"Web Development":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},{"Question":"(I'm sure this is a FAQ, but also hard to google)\nWhy does Python use abs(x) instead of x.abs?\nAs far as I see everything abs() does besides calling x.__abs__ could just as well be implemented in object.abs()\nIs it historical, because there hasn't always been a root class?","AnswerCount":4,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":635,"Q_Id":789718,"Users Score":0,"Answer":"Python is a language that supports object oriented coding, but it deliberately isn't a pure OO language. As you correctly mention, Python classes, even user defined ones, haven't always derived from a single base class.\nFunctions are the basic unit of functionality in Python, so it makes sense for the core operations (random sample: str, dir, print, hash) to look like functions.","Q_Score":4,"Tags":"python,oop","A_Id":789746,"CreationDate":"2009-04-25T21:02:00.000","Title":"Why builtin functions instead of root class methods?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"(I'm sure this is a FAQ, but also hard to google)\nWhy does Python use abs(x) instead of x.abs?\nAs far as I see everything abs() does besides calling x.__abs__ could just as well be implemented in object.abs()\nIs it historical, because there hasn't always been a root class?","AnswerCount":4,"Available Count":2,"Score":0.049958375,"is_accepted":false,"ViewCount":635,"Q_Id":789718,"Users Score":1,"Answer":"I think you are looking a typical example where a language designer decides that readability and terseness trump purist constructs.","Q_Score":4,"Tags":"python,oop","A_Id":789724,"CreationDate":"2009-04-25T21:02:00.000","Title":"Why builtin functions instead of root class methods?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Do locales contain information about preferred units for temperature, lengths, etc. on Unix\/Linux? Is it possible to access these properties from Python? I checked out the \"locales\" module, but didn't find anything suitable.\nI'd like my application to automatically convert values into the most suitable unit.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":355,"Q_Id":789953,"Users Score":0,"Answer":"For what it's worth, KDE offers a choice of \"Metric\" or \"Imperial\" as the standard unit system, so I would presume that it's possible to access that information through Python somehow. Gnome might have a similar setting, I'm not sure... but I don't think there's any equivalent for a generic UNIX\/Linux system.\nThe most recent version of SciPy (0.7) includes a module for unit handling, and you can use that to do your conversions if necessary.","Q_Score":1,"Tags":"python,localization","A_Id":790078,"CreationDate":"2009-04-25T23:49:00.000","Title":"Locales and temperature\/length 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":1,"Web Development":0},{"Question":"Currently I'm using a Windows batch file to build my software. It does things like running MSBuild, copying files, creating a ZIP file, running some tests, including the subversion revision number, etc.\nBut the problem is, batch files are evil. So I would like to change to something better. I was planning to recreate my build script in Python. Is that a smart choice? What about all those build systems, like Ant, SCons, Maven, Rake, etc. Would using any of those be a better choice?\nNote: I'm not planning to replace my Visual Studio solution\/project files. I only want to script everything else that's required to create a release of my software.\nEdit: I have good reasons to move away from batch, that's not what my question is about. I would like to know (for example) what SCons gives me, over a normal Python script.","AnswerCount":12,"Available Count":6,"Score":1.0,"is_accepted":false,"ViewCount":9281,"Q_Id":792629,"Users Score":7,"Answer":"As you're mentioning Python and SCons, I'd say go for SCons. It is Python after all. And yes, any of the above would be a better choice than hand-rolled build scripts.","Q_Score":18,"Tags":"python,build-process,build-automation","A_Id":792646,"CreationDate":"2009-04-27T08:19:00.000","Title":"Is Python the right hammer for this nail? (build 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},{"Question":"Currently I'm using a Windows batch file to build my software. It does things like running MSBuild, copying files, creating a ZIP file, running some tests, including the subversion revision number, etc.\nBut the problem is, batch files are evil. So I would like to change to something better. I was planning to recreate my build script in Python. Is that a smart choice? What about all those build systems, like Ant, SCons, Maven, Rake, etc. Would using any of those be a better choice?\nNote: I'm not planning to replace my Visual Studio solution\/project files. I only want to script everything else that's required to create a release of my software.\nEdit: I have good reasons to move away from batch, that's not what my question is about. I would like to know (for example) what SCons gives me, over a normal Python script.","AnswerCount":12,"Available Count":6,"Score":0.0665680765,"is_accepted":false,"ViewCount":9281,"Q_Id":792629,"Users Score":4,"Answer":"I've seen python scripts used for building releases elsewhere so it can't be bad. Actually, I've personally used perl scripts to automate release building. I guess any scripting language could easily automate that procedure. If it's gonna be easy to do (and probably better than batch scripts), why not try it?","Q_Score":18,"Tags":"python,build-process,build-automation","A_Id":792636,"CreationDate":"2009-04-27T08:19:00.000","Title":"Is Python the right hammer for this nail? (build 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},{"Question":"Currently I'm using a Windows batch file to build my software. It does things like running MSBuild, copying files, creating a ZIP file, running some tests, including the subversion revision number, etc.\nBut the problem is, batch files are evil. So I would like to change to something better. I was planning to recreate my build script in Python. Is that a smart choice? What about all those build systems, like Ant, SCons, Maven, Rake, etc. Would using any of those be a better choice?\nNote: I'm not planning to replace my Visual Studio solution\/project files. I only want to script everything else that's required to create a release of my software.\nEdit: I have good reasons to move away from batch, that's not what my question is about. I would like to know (for example) what SCons gives me, over a normal Python script.","AnswerCount":12,"Available Count":6,"Score":1.0,"is_accepted":false,"ViewCount":9281,"Q_Id":792629,"Users Score":9,"Answer":"Batch files aren't evil - they've actually come quite a long way from the brain-dead days of command.com. The command language can be pretty expressive nowadays, it just requires a bit of effort on your part to learn it.\nUnless there's an actual problem with your build script that you can't fix (and, if that's the case, that's the question you should be asking rather than some wishy-washy \"What's the best replacement?\" :-), my approach would be to stick with what you've got.\nA vague feeling of evilness would not be reason for me to waste effort 'fixing' something that isn't broken. And it would be wasted effort unless there's a clear advantage to changing (\"less evil\" is not something I'd consider a clear advantage).","Q_Score":18,"Tags":"python,build-process,build-automation","A_Id":792663,"CreationDate":"2009-04-27T08:19:00.000","Title":"Is Python the right hammer for this nail? (build 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},{"Question":"Currently I'm using a Windows batch file to build my software. It does things like running MSBuild, copying files, creating a ZIP file, running some tests, including the subversion revision number, etc.\nBut the problem is, batch files are evil. So I would like to change to something better. I was planning to recreate my build script in Python. Is that a smart choice? What about all those build systems, like Ant, SCons, Maven, Rake, etc. Would using any of those be a better choice?\nNote: I'm not planning to replace my Visual Studio solution\/project files. I only want to script everything else that's required to create a release of my software.\nEdit: I have good reasons to move away from batch, that's not what my question is about. I would like to know (for example) what SCons gives me, over a normal Python script.","AnswerCount":12,"Available Count":6,"Score":0.0166651236,"is_accepted":false,"ViewCount":9281,"Q_Id":792629,"Users Score":1,"Answer":"You can create custom makefiles for Microsoft nmake tool which you already have installed. Using a tool like that (SCons, Maven, etc. fall into the same category) gives you much more than regular scripts. \nThe main benefit is that dependencies between files are tracked and also the timestamps of changes. For example, you can make your .zip file depend on some other files, so .zip only gets repacked if some of those files have changed in the meantime. Just like with source code and its compiled form.","Q_Score":18,"Tags":"python,build-process,build-automation","A_Id":792676,"CreationDate":"2009-04-27T08:19:00.000","Title":"Is Python the right hammer for this nail? (build 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},{"Question":"Currently I'm using a Windows batch file to build my software. It does things like running MSBuild, copying files, creating a ZIP file, running some tests, including the subversion revision number, etc.\nBut the problem is, batch files are evil. So I would like to change to something better. I was planning to recreate my build script in Python. Is that a smart choice? What about all those build systems, like Ant, SCons, Maven, Rake, etc. Would using any of those be a better choice?\nNote: I'm not planning to replace my Visual Studio solution\/project files. I only want to script everything else that's required to create a release of my software.\nEdit: I have good reasons to move away from batch, that's not what my question is about. I would like to know (for example) what SCons gives me, over a normal Python script.","AnswerCount":12,"Available Count":6,"Score":0.049958375,"is_accepted":false,"ViewCount":9281,"Q_Id":792629,"Users Score":3,"Answer":"Why should you use python? If your build script isn't broke don't fix it. If your having issues updating it to deal with new aditions to the project then you may want to look at rewriting it. I wouldn't use Python though tools like NANT or MSBuild do the job. I don't see the point in using a general purpis programming language to do something that tools have already been written to do unless you have a lot of obscure requirements existing tools can't deal with. Second what happens if you get hit by a bus or win the lotto? If you are determined to script everything I'd use powershell or some other Microsoft specific technology since your already wedded to Microsoft. If you leave will there be enough Python programmers to maintain the build scripts?","Q_Score":18,"Tags":"python,build-process,build-automation","A_Id":793354,"CreationDate":"2009-04-27T08:19:00.000","Title":"Is Python the right hammer for this nail? (build 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},{"Question":"Currently I'm using a Windows batch file to build my software. It does things like running MSBuild, copying files, creating a ZIP file, running some tests, including the subversion revision number, etc.\nBut the problem is, batch files are evil. So I would like to change to something better. I was planning to recreate my build script in Python. Is that a smart choice? What about all those build systems, like Ant, SCons, Maven, Rake, etc. Would using any of those be a better choice?\nNote: I'm not planning to replace my Visual Studio solution\/project files. I only want to script everything else that's required to create a release of my software.\nEdit: I have good reasons to move away from batch, that's not what my question is about. I would like to know (for example) what SCons gives me, over a normal Python script.","AnswerCount":12,"Available Count":6,"Score":0.0166651236,"is_accepted":false,"ViewCount":9281,"Q_Id":792629,"Users Score":1,"Answer":"Python is very portable. SCons is field tested and reliable. Given what you know (from what you explained), why even ask the question?\nIf your maintaining something, its not just about getting it to build, its also about explaining to the user why it can NOT build, which saves you a ton of very frustrating questions while helping users to help themselves.\nI can not think of a modern, production operating system that lacks Python, unless you get into the embedded \/ research arena.\nSo, I'm answering to say, you answered your own question :)","Q_Score":18,"Tags":"python,build-process,build-automation","A_Id":792680,"CreationDate":"2009-04-27T08:19:00.000","Title":"Is Python the right hammer for this nail? (build 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},{"Question":"Can anyone point to serious comparison of Python runtime footprint versus Java?\nThanks,\n Avraham","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":5256,"Q_Id":795241,"Users Score":1,"Answer":"I can't compare memory footprint because it really depends on classes what you load\/use. But what I can tell you that Python (IronPython 2.7 in particular) has real memory leak problems. Especially with third party well used ones like Financial.\nWhen Java application\/server runs without issues with rare cases which could be identified with common tools Python grows in memory constantly. \nMemory dumps shows that Python itself as well as most of packages don't pay attention for common classes like String and keep them in different parts of the execution modules. It is hard and unwise to go through all these sources and fix all leaks.\nI was trying a lot to fix the issues but finally gave in and simply restart application when it reaches some memory threshold.","Q_Score":7,"Tags":"java,python,footprint,memory-footprint","A_Id":35581985,"CreationDate":"2009-04-27T20:49:00.000","Title":"python versus java runtime footprint","Data Science and Machine Learning":0,"Database and SQL":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},{"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},{"Question":"I tried to learn shell(bash) scripting few times but was driven away by the syntax. Then I found Python and was able to do most of the things a shell script can do in Python. I am now not sure whether I should invest my time in learning shell scripting anymore. So I want to ask:\nWhat are strengths of shell scripting that make it an indispensable tool as compared to Python?\nI am not a system administration by profession, but I am interested in setting up Linux systems for home users, hence I think learning shell scripting can become necessary.","AnswerCount":8,"Available Count":8,"Score":1.0,"is_accepted":false,"ViewCount":63953,"Q_Id":796319,"Users Score":17,"Answer":"There's nothing you can do with shell scripts that you can't do with python. \nThe big advantage of shell scripts is that you use the same commands as you do when you use the shell, so if you're a heavy shell user, shell scripting will at some point become a very quick and easy way to automate your shell work.\nI also find it easier to deal with pipes of data in shell scripts than in python, though it's absolutely doable from python.\nAnd, finally, you don't have to fire up an additional interpeter to run the shell scripts, giving you a very small, but sometimes maybe noticeable speed and memory usage advantage.\nBut then again, Python scripts are a lot more maintainable, I'm trying to migrate from big ugly shell scripts to Python scripts for that very reason. It's also easier to do exception handling and QA with Python.","Q_Score":109,"Tags":"python,shell","A_Id":796344,"CreationDate":"2009-04-28T05:16:00.000","Title":"Strengths of Shell Scripting compared 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":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I tried to learn shell(bash) scripting few times but was driven away by the syntax. Then I found Python and was able to do most of the things a shell script can do in Python. I am now not sure whether I should invest my time in learning shell scripting anymore. So I want to ask:\nWhat are strengths of shell scripting that make it an indispensable tool as compared to Python?\nI am not a system administration by profession, but I am interested in setting up Linux systems for home users, hence I think learning shell scripting can become necessary.","AnswerCount":8,"Available Count":8,"Score":1.0,"is_accepted":false,"ViewCount":63953,"Q_Id":796319,"Users Score":9,"Answer":"I agree with most of the previous answers. I consider shell commands most suited to do filesystem-oriented tasks (copy and move files, grep, etc). Shell is better, in my opinion, if you have to read and write to file, since a single >>file.txt redirection appends to file instantly, instead of needing, say, file=open('file.txt','a'); file.write(), etc.\nCurrently, for my personal use, I mix both, creating a python script and calling os.system('command') or os.popen('command') every time some action is easier in shell than in python.","Q_Score":109,"Tags":"python,shell","A_Id":4980553,"CreationDate":"2009-04-28T05:16:00.000","Title":"Strengths of Shell Scripting compared 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":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I tried to learn shell(bash) scripting few times but was driven away by the syntax. Then I found Python and was able to do most of the things a shell script can do in Python. I am now not sure whether I should invest my time in learning shell scripting anymore. So I want to ask:\nWhat are strengths of shell scripting that make it an indispensable tool as compared to Python?\nI am not a system administration by profession, but I am interested in setting up Linux systems for home users, hence I think learning shell scripting can become necessary.","AnswerCount":8,"Available Count":8,"Score":0.1243530018,"is_accepted":false,"ViewCount":63953,"Q_Id":796319,"Users Score":5,"Answer":"Another thing to consider when choosing shell scripts of Python is the Python version that will be running on the target machines. RHEL5 (to name one) is going to be around for a long time. RHEL5 is stuck with Python 2.4. There are a lot of nice libraries that depend on functionality added to Python post-2.4.","Q_Score":109,"Tags":"python,shell","A_Id":9188834,"CreationDate":"2009-04-28T05:16:00.000","Title":"Strengths of Shell Scripting compared 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":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I tried to learn shell(bash) scripting few times but was driven away by the syntax. Then I found Python and was able to do most of the things a shell script can do in Python. I am now not sure whether I should invest my time in learning shell scripting anymore. So I want to ask:\nWhat are strengths of shell scripting that make it an indispensable tool as compared to Python?\nI am not a system administration by profession, but I am interested in setting up Linux systems for home users, hence I think learning shell scripting can become necessary.","AnswerCount":8,"Available Count":8,"Score":1.0,"is_accepted":false,"ViewCount":63953,"Q_Id":796319,"Users Score":36,"Answer":"The shell makes common and simple actions really simple, at the expense of making more complex things much much more complex.\nTypically, a small shell script will be shorter and simpler than the corresponding python program, but the python program will tend to gracefully accept modifications, whereas the shell script will tend to get less and less maintainable as code is added.\nThis has the consequence that for optimal day-to-day productivity you need shell-scripting, but you should use it mostly for throwaway scripts, and use python everywhere else.","Q_Score":109,"Tags":"python,shell","A_Id":814425,"CreationDate":"2009-04-28T05:16:00.000","Title":"Strengths of Shell Scripting compared 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":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I tried to learn shell(bash) scripting few times but was driven away by the syntax. Then I found Python and was able to do most of the things a shell script can do in Python. I am now not sure whether I should invest my time in learning shell scripting anymore. So I want to ask:\nWhat are strengths of shell scripting that make it an indispensable tool as compared to Python?\nI am not a system administration by profession, but I am interested in setting up Linux systems for home users, hence I think learning shell scripting can become necessary.","AnswerCount":8,"Available Count":8,"Score":1.0,"is_accepted":false,"ViewCount":63953,"Q_Id":796319,"Users Score":58,"Answer":"\"What are strengths of shell scripting that make it an indispensable tool as compared to Python?\"\nThe shell is not indispensable. Why do you think there are so many? bash, tcsh, csh, sh, etc., etc., \nPython is a shell. Not the one you'd use for running all commands, but for scripting, it's ideal.\nPython is a more-or-less standard part of all Linux distro's.\nThe more traditional shells do too many things.\n\nThey have a handy user interface for running commands. This includes one-line commands where the shell searches your PATH, forks and execs the requested program. It also includes pipelines, sequences and concurrent programs (using ;, | and &) as well as some redirection (using > and <).\nThey have a crummy little programming-language-like capability for running scripts. This language is rather hard to use and extremely inefficient. Most statements in this language require forking one or more additional processes, wasting time and memory.\n\nRunning programs from the shell, redirecting stderr to a log file and that kind of thing is good. Do that in the shell.\nAlmost everything else can be done more efficiently and more clearly as a Python script.\nYou need both. However, you should never write a script with if-statements or loops in a traditional shell language.","Q_Score":109,"Tags":"python,shell","A_Id":797341,"CreationDate":"2009-04-28T05:16:00.000","Title":"Strengths of Shell Scripting compared 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":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I tried to learn shell(bash) scripting few times but was driven away by the syntax. Then I found Python and was able to do most of the things a shell script can do in Python. I am now not sure whether I should invest my time in learning shell scripting anymore. So I want to ask:\nWhat are strengths of shell scripting that make it an indispensable tool as compared to Python?\nI am not a system administration by profession, but I am interested in setting up Linux systems for home users, hence I think learning shell scripting can become necessary.","AnswerCount":8,"Available Count":8,"Score":1.0,"is_accepted":false,"ViewCount":63953,"Q_Id":796319,"Users Score":7,"Answer":"The shell is available everywhere. If you stick to a relatively basic set of portable functionality, your scripts can run on cell phones, wireless routers, DVRs, netbooks, workstations, big iron servers, and the like. Python is not necessarily included out of the box on lots of systems, and depending on the environment it may be hard to get it installed.\nLearning some shell scripting can also help you learn some command line tricks, since the command line is, well, the shell. It's also good for taking some fairly long and complicated command line, and converting that into a more general script after you realize you'll need it some more.\nThe shell also has some pretty powerful features; pipelines are a really interesting control construct that is native only to the shell, as far as I know.","Q_Score":109,"Tags":"python,shell","A_Id":796348,"CreationDate":"2009-04-28T05:16:00.000","Title":"Strengths of Shell Scripting compared 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":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I tried to learn shell(bash) scripting few times but was driven away by the syntax. Then I found Python and was able to do most of the things a shell script can do in Python. I am now not sure whether I should invest my time in learning shell scripting anymore. So I want to ask:\nWhat are strengths of shell scripting that make it an indispensable tool as compared to Python?\nI am not a system administration by profession, but I am interested in setting up Linux systems for home users, hence I think learning shell scripting can become necessary.","AnswerCount":8,"Available Count":8,"Score":1.0,"is_accepted":false,"ViewCount":63953,"Q_Id":796319,"Users Score":11,"Answer":"one doesn't have to learn shell scripting, as all the previous answers indicate; but learning is never a bad thing. it's really a question of personal priorities. it's very hard for someone else to tell you what is and isn't worth your time.\nmost programmers find that learning new languages gets incrementally easier each time. (the same is largely true of natural languages too.) and the earlier you start, the better.\nplus: having learned a language enables you to extravagantly diss its limitations from a position of complete knowledge and familiarity. this probably won't get you laid, but might earn you a beer from your peers!","Q_Score":109,"Tags":"python,shell","A_Id":3074616,"CreationDate":"2009-04-28T05:16:00.000","Title":"Strengths of Shell Scripting compared 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":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I tried to learn shell(bash) scripting few times but was driven away by the syntax. Then I found Python and was able to do most of the things a shell script can do in Python. I am now not sure whether I should invest my time in learning shell scripting anymore. So I want to ask:\nWhat are strengths of shell scripting that make it an indispensable tool as compared to Python?\nI am not a system administration by profession, but I am interested in setting up Linux systems for home users, hence I think learning shell scripting can become necessary.","AnswerCount":8,"Available Count":8,"Score":1.2,"is_accepted":true,"ViewCount":63953,"Q_Id":796319,"Users Score":95,"Answer":"Shell scripting has simpler notations for I\/O redirection.\nIt is simpler to create pipelines out of existing programs in shell.\nShell scripting reuses entire programs.\nShell is universally available (on anything like Unix) - Python is not necessarily installed.\n\n'Tis true that you can do everything in Python that you can do in shell; 'tis also true that there are things that are easy in Python that are hard in shell (just as there are things that are easy in shell but hard in Python). Knowing both will be best in the long term.","Q_Score":109,"Tags":"python,shell","A_Id":796343,"CreationDate":"2009-04-28T05:16:00.000","Title":"Strengths of Shell Scripting compared 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":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I'm hacking some support for DomainKeys and DKIM into an open source email marketing program, which uses a python script to send the actual emails via SMTP. I decided to go the quick and dirty route, and just write a perl script that accepts an email message from STDIN, signs it, then returns it signed.\nWhat I would like to do, is from the python script, pipe the email text that's in a string to the perl script, and store the result in another variable, so I can send the email signed. I'm not exactly a python guru, however, and I can't seem to find a good way to do this. I'm pretty sure I can use something like os.system for this, but piping a variable to the perl script is something that seems to elude me.\nIn short: How can I pipe a variable from a python script, to a perl script, and store the result in Python?\nEDIT: I forgot to include that the system I'm working with only has python v2.3","AnswerCount":6,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":13888,"Q_Id":798413,"Users Score":2,"Answer":"I'm sure there's a reason you're going down the route you've chosen, but why not just do the signing in Python?\nHow are you signing it? Maybe we could provide some assitance in writing a python implementation?","Q_Score":6,"Tags":"python,perl,domainkeys,dkim","A_Id":798508,"CreationDate":"2009-04-28T14:58:00.000","Title":"How to call a Perl script from Python, piping input to 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":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am looking for RAD like environment for PHP and\/or Python free or not does not matter.\nIt should have a visual environment where one can use a point and click interface so that it is possible to select objects with mouse and move them around.\nI have looked at Delphi4PHP. The RAD part is fantastic, but I don't like the framework on which it is based VCL4PHP (vcl4php.sourceforge.net) is crappy. Just to deploy a simple Hello world application we will have to deploy 40MB of that framework. That is just stupid.....\nI looked at Eclipse but it is only a code IDE. Does not have a visual way of designing a page\/window. Did I miss any plugin that supports this feature?\nI was suggested to give NetBeans IDE a close look so I also looked that up, but did not find what I wanted.\nI have also looked up following but none of these are true RAD:\n\nNuSphere PHPEd\nVS PHP for Visual Studio \nPHP Designer (not a designer by any means just a plain old IDE)\n\nI have not been able to find any descent Python RAD tool also.\nI have looked up Yes Software's Code Charge Studio (www.yessoftware.com) but it cannot be used to develop complicated applications like say for example an Accounting System or an Inventory Management App, etc.. It is useful but for very simple apps. Making changes to Visual part (referred as components by this people) is a nightmare. Finally it does not support Python.","AnswerCount":14,"Available Count":5,"Score":-1.0,"is_accepted":false,"ViewCount":3848,"Q_Id":801090,"Users Score":-5,"Answer":"The good news is that you won't miss it as soon as you familiarize yourself with a way of work when the responsibilities are shared.\nThink it over: really the programmer is the right person to assemble the user interface? I think not even in case of a desktop application.\nProgrammer should write good code, separated display logic, and let all the presentation things to \n\ninformation architects\nuser interface\/experience specialists\nhere comes you, to write the code\ngraphic designers\nsitebuilders\n\nThe -not so bad- news is that, there is no such tool for PHP and Python.","Q_Score":6,"Tags":"php,python,vcl4php","A_Id":801196,"CreationDate":"2009-04-29T06:17:00.000","Title":"Looking for a PHP and\/or Python RAD","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I am looking for RAD like environment for PHP and\/or Python free or not does not matter.\nIt should have a visual environment where one can use a point and click interface so that it is possible to select objects with mouse and move them around.\nI have looked at Delphi4PHP. The RAD part is fantastic, but I don't like the framework on which it is based VCL4PHP (vcl4php.sourceforge.net) is crappy. Just to deploy a simple Hello world application we will have to deploy 40MB of that framework. That is just stupid.....\nI looked at Eclipse but it is only a code IDE. Does not have a visual way of designing a page\/window. Did I miss any plugin that supports this feature?\nI was suggested to give NetBeans IDE a close look so I also looked that up, but did not find what I wanted.\nI have also looked up following but none of these are true RAD:\n\nNuSphere PHPEd\nVS PHP for Visual Studio \nPHP Designer (not a designer by any means just a plain old IDE)\n\nI have not been able to find any descent Python RAD tool also.\nI have looked up Yes Software's Code Charge Studio (www.yessoftware.com) but it cannot be used to develop complicated applications like say for example an Accounting System or an Inventory Management App, etc.. It is useful but for very simple apps. Making changes to Visual part (referred as components by this people) is a nightmare. Finally it does not support Python.","AnswerCount":14,"Available Count":5,"Score":0.0285636566,"is_accepted":false,"ViewCount":3848,"Q_Id":801090,"Users Score":2,"Answer":"I just remenbered some more tools that might be useful to you, besides WebDev:\n\nPHPMaker\nWaveMaker\n\nFor Python I'm gonna try the DialogBlocks later this evening.","Q_Score":6,"Tags":"php,python,vcl4php","A_Id":801278,"CreationDate":"2009-04-29T06:17:00.000","Title":"Looking for a PHP and\/or Python RAD","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I am looking for RAD like environment for PHP and\/or Python free or not does not matter.\nIt should have a visual environment where one can use a point and click interface so that it is possible to select objects with mouse and move them around.\nI have looked at Delphi4PHP. The RAD part is fantastic, but I don't like the framework on which it is based VCL4PHP (vcl4php.sourceforge.net) is crappy. Just to deploy a simple Hello world application we will have to deploy 40MB of that framework. That is just stupid.....\nI looked at Eclipse but it is only a code IDE. Does not have a visual way of designing a page\/window. Did I miss any plugin that supports this feature?\nI was suggested to give NetBeans IDE a close look so I also looked that up, but did not find what I wanted.\nI have also looked up following but none of these are true RAD:\n\nNuSphere PHPEd\nVS PHP for Visual Studio \nPHP Designer (not a designer by any means just a plain old IDE)\n\nI have not been able to find any descent Python RAD tool also.\nI have looked up Yes Software's Code Charge Studio (www.yessoftware.com) but it cannot be used to develop complicated applications like say for example an Accounting System or an Inventory Management App, etc.. It is useful but for very simple apps. Making changes to Visual part (referred as components by this people) is a nightmare. Finally it does not support Python.","AnswerCount":14,"Available Count":5,"Score":0.0,"is_accepted":false,"ViewCount":3848,"Q_Id":801090,"Users Score":0,"Answer":"Let me elaborate on CodeCharge Studio. I think you still can consider this system. \nPersonally, I've been using it to develop very complex high-load data-base driven CRM applications, with 4.x version it even generates AJAX-based code and autocomplete, ajax-form submittion are piece of cake.\nWith CCS you will need sometimes some tuning, but the tricks are pretty much typical. So, CodeCharge Studio is still a choice for complex applications too.","Q_Score":6,"Tags":"php,python,vcl4php","A_Id":1256441,"CreationDate":"2009-04-29T06:17:00.000","Title":"Looking for a PHP and\/or Python RAD","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I am looking for RAD like environment for PHP and\/or Python free or not does not matter.\nIt should have a visual environment where one can use a point and click interface so that it is possible to select objects with mouse and move them around.\nI have looked at Delphi4PHP. The RAD part is fantastic, but I don't like the framework on which it is based VCL4PHP (vcl4php.sourceforge.net) is crappy. Just to deploy a simple Hello world application we will have to deploy 40MB of that framework. That is just stupid.....\nI looked at Eclipse but it is only a code IDE. Does not have a visual way of designing a page\/window. Did I miss any plugin that supports this feature?\nI was suggested to give NetBeans IDE a close look so I also looked that up, but did not find what I wanted.\nI have also looked up following but none of these are true RAD:\n\nNuSphere PHPEd\nVS PHP for Visual Studio \nPHP Designer (not a designer by any means just a plain old IDE)\n\nI have not been able to find any descent Python RAD tool also.\nI have looked up Yes Software's Code Charge Studio (www.yessoftware.com) but it cannot be used to develop complicated applications like say for example an Accounting System or an Inventory Management App, etc.. It is useful but for very simple apps. Making changes to Visual part (referred as components by this people) is a nightmare. Finally it does not support Python.","AnswerCount":14,"Available Count":5,"Score":0.0142847425,"is_accepted":false,"ViewCount":3848,"Q_Id":801090,"Users Score":1,"Answer":"I don't think Yogi is a PITA. He is discerning and this is very helpful. Since none of these tools quite hit the mark for him when one does it will be the right one and then all of us will benefit from his studied decision.","Q_Score":6,"Tags":"php,python,vcl4php","A_Id":4500774,"CreationDate":"2009-04-29T06:17:00.000","Title":"Looking for a PHP and\/or Python RAD","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I am looking for RAD like environment for PHP and\/or Python free or not does not matter.\nIt should have a visual environment where one can use a point and click interface so that it is possible to select objects with mouse and move them around.\nI have looked at Delphi4PHP. The RAD part is fantastic, but I don't like the framework on which it is based VCL4PHP (vcl4php.sourceforge.net) is crappy. Just to deploy a simple Hello world application we will have to deploy 40MB of that framework. That is just stupid.....\nI looked at Eclipse but it is only a code IDE. Does not have a visual way of designing a page\/window. Did I miss any plugin that supports this feature?\nI was suggested to give NetBeans IDE a close look so I also looked that up, but did not find what I wanted.\nI have also looked up following but none of these are true RAD:\n\nNuSphere PHPEd\nVS PHP for Visual Studio \nPHP Designer (not a designer by any means just a plain old IDE)\n\nI have not been able to find any descent Python RAD tool also.\nI have looked up Yes Software's Code Charge Studio (www.yessoftware.com) but it cannot be used to develop complicated applications like say for example an Accounting System or an Inventory Management App, etc.. It is useful but for very simple apps. Making changes to Visual part (referred as components by this people) is a nightmare. Finally it does not support Python.","AnswerCount":14,"Available Count":5,"Score":0.0142847425,"is_accepted":false,"ViewCount":3848,"Q_Id":801090,"Users Score":1,"Answer":"Delphi4PHP is the only I know of, back in the old days I also used Macromedia (now Adobe) Dreamweaver to generate some code, and if you set up a live site it kinda acts like a RAD IDE. Kinda.\nFor Python, I asked a similar question a couple of hours ago, I'm also interested in knowing such tool.","Q_Score":6,"Tags":"php,python,vcl4php","A_Id":801096,"CreationDate":"2009-04-29T06:17:00.000","Title":"Looking for a PHP and\/or Python RAD","Data Science and Machine Learning":0,"Database and SQL":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},{"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},{"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},{"Question":"I have one script in Perl and the other in Python. I need to get the results of Perl in Python and then give the final report. The results from Perl can be scalar variable, hash variable, or an array.\nPlease let me know as soon as possible regarding this.","AnswerCount":3,"Available Count":1,"Score":0.1325487884,"is_accepted":false,"ViewCount":1453,"Q_Id":805160,"Users Score":2,"Answer":"You could serialize the results to some sort of a string format, print this to standard output in the Perl script. Then, from python call the perl script and redirect the results of stdout to a variable in python.","Q_Score":1,"Tags":"python,perl","A_Id":805185,"CreationDate":"2009-04-30T02:39:00.000","Title":"How can I get the results of a Perl script 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},{"Question":"What are the ups and downs of using FastCGI C++ vs. PHP\/Python\/Perl to do the same job. \nAny performance or design pitfalls or using one over the other? Even your opinions are welcome. (Tell me why one or the other rocks, or one or the other sucks).","AnswerCount":16,"Available Count":10,"Score":1.0,"is_accepted":false,"ViewCount":16655,"Q_Id":805957,"Users Score":12,"Answer":"Using C++ is likely to result in a radically faster application than PHP, Perl or Python and somewhat faster than C# or Java - unless it spends most of its time waiting for the DB, in which case there won't be a difference. This is actually the most common case.\nOn the other hand, due to the reasons benhoyt mentioned, developing a web app in C++ will take longer and will be harder to maintain. Furthermore, it's far more likely to contain serious security holes (nowadys everyone worries most about SQL injection and XSS - but if they were writing their webapps in C++ it would be buffer overflows and it would be their entire networks getting p0wned rather than just the data).\nAnd that's why almost nobody writes web apps in C++ these days.","Q_Score":24,"Tags":"php,c++,python,perl,fastcgi","A_Id":806037,"CreationDate":"2009-04-30T08:43:00.000","Title":"FastCGI C++ vs. A Script Language (PHP\/Python\/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":0,"Web Development":0},{"Question":"What are the ups and downs of using FastCGI C++ vs. PHP\/Python\/Perl to do the same job. \nAny performance or design pitfalls or using one over the other? Even your opinions are welcome. (Tell me why one or the other rocks, or one or the other sucks).","AnswerCount":16,"Available Count":10,"Score":1.2,"is_accepted":true,"ViewCount":16655,"Q_Id":805957,"Users Score":23,"Answer":"Several years ago, I more or less learned web app programming on the job. C was the main language I knew, so I wrote the (fairly large-scale) web app in C. Bad mistake. C's string handling and memory management is tedious, and together with my lack of experience in web apps, it quickly became a hard-to-maintain project.\nC++ would be significantly better, mainly because std::string is much nicer than char*.\nHowever, now I'd use Python every time (though PHP is not a terrible choice, and perhaps easier to get started with). Python's string handling is awesome, and it handles Unicode seamlessly. Python has much better web tools and frameworks than C++, and its regex handling and standard libraries (urllib, email, etc) work very well. And you don't have to worry about memory management.\nI'd probably only use C or C++ for a web app if I was severely RAM-constrained (like on an embedded micro) or if I worked at Google and was coding a search engine that was going to have to respond to thousands of queries per second.","Q_Score":24,"Tags":"php,c++,python,perl,fastcgi","A_Id":806004,"CreationDate":"2009-04-30T08:43:00.000","Title":"FastCGI C++ vs. A Script Language (PHP\/Python\/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":0,"Web Development":0},{"Question":"What are the ups and downs of using FastCGI C++ vs. PHP\/Python\/Perl to do the same job. \nAny performance or design pitfalls or using one over the other? Even your opinions are welcome. (Tell me why one or the other rocks, or one or the other sucks).","AnswerCount":16,"Available Count":10,"Score":1.0,"is_accepted":false,"ViewCount":16655,"Q_Id":805957,"Users Score":6,"Answer":"If you want to be able to implement web services in an existing running process (e.g. daemon), which is written in C\/C++. It makes sense to make that process implement the FastCGI protocol for that interface. Get Apache to deal with HTTP (2-way SSL etc) to the outside world and field requests through FastCGI through a socket. If you do this in PHP, you have to get PHP to talk to your process, which means maintaining PHP code as well as your process.","Q_Score":24,"Tags":"php,c++,python,perl,fastcgi","A_Id":806257,"CreationDate":"2009-04-30T08:43:00.000","Title":"FastCGI C++ vs. A Script Language (PHP\/Python\/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":0,"Web Development":0},{"Question":"What are the ups and downs of using FastCGI C++ vs. PHP\/Python\/Perl to do the same job. \nAny performance or design pitfalls or using one over the other? Even your opinions are welcome. (Tell me why one or the other rocks, or one or the other sucks).","AnswerCount":16,"Available Count":10,"Score":0.024994793,"is_accepted":false,"ViewCount":16655,"Q_Id":805957,"Users Score":2,"Answer":"You can use FastCGI with PHP\/Python\/Ruby\/Perl to get runtime performance that should be enough until your site grows really big. And even then, you can make architectural improvements (database tuning, caching etc) to scale even more without abandoning scripting languages. Some pretty large sites are done in PHP\/Python\/Ruby\/Perl.\nThe big gain you get by using high-level languages is programmer performance. And that is what you should worry about first. It will be more important to respond quickly to feature demands from users, than to trim some milliseconds off the page response time.","Q_Score":24,"Tags":"php,c++,python,perl,fastcgi","A_Id":806042,"CreationDate":"2009-04-30T08:43:00.000","Title":"FastCGI C++ vs. A Script Language (PHP\/Python\/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":0,"Web Development":0},{"Question":"What are the ups and downs of using FastCGI C++ vs. PHP\/Python\/Perl to do the same job. \nAny performance or design pitfalls or using one over the other? Even your opinions are welcome. (Tell me why one or the other rocks, or one or the other sucks).","AnswerCount":16,"Available Count":10,"Score":0.0374824318,"is_accepted":false,"ViewCount":16655,"Q_Id":805957,"Users Score":3,"Answer":"There is a middle ground here. Python (and I believe Perl and Ruby) allow you to call functions from C. 99 times out of 100, you won't need to. But it's nice to know that the option is there if you need it.\nUsually for webapps, the speed of the programming language simply isn't an issue. In the time it takes to execute a single database query, a processor can execute a few billion instructions. It's about the same for sending and receiving http data.","Q_Score":24,"Tags":"php,c++,python,perl,fastcgi","A_Id":806988,"CreationDate":"2009-04-30T08:43:00.000","Title":"FastCGI C++ vs. A Script Language (PHP\/Python\/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":0,"Web Development":0},{"Question":"What are the ups and downs of using FastCGI C++ vs. PHP\/Python\/Perl to do the same job. \nAny performance or design pitfalls or using one over the other? Even your opinions are welcome. (Tell me why one or the other rocks, or one or the other sucks).","AnswerCount":16,"Available Count":10,"Score":1.0,"is_accepted":false,"ViewCount":16655,"Q_Id":805957,"Users Score":7,"Answer":"The question is \"where's the value created?\"\nIf you think the value is created in Memory management, careful class design and getting the nightly build to work, then use C++. You'll get to spend lots of time writing a lot of code to do important things like deleting objects that are no longer referenced.\nIf you think the value is in deploying applications that people can use, then use Python with the Django framework. The Django tutorial shows you that within about 20 minutes you can have an application up and running. It's production-ready, and you could focus on important things:\n\nThe model. Just write the model in Python, and the ORM layer handles all of the database interaction for you. No SQL. No manual mapping. \nThe presentation. Just design your pages in HTML with a few {{}} \"fill in a value here\" and a few {% for thing in object_list %} constructs and your pages are ready to go. No string manipulation. \nThe view functions. Write simple Python functions to encapsulate the processing part of your site. Not validation (those are in forms), not presentation (that was in the templates), not the underlying model (that was in the model classes), but a little bit of authorization checking, query processing and response formulation. Since Python has a rich set of collection classes, this code winds up being very short and to the point.\nOther stuff. URL mappings are Python regexes. Forms are matched to your model; you can subclass the defaults to add customized input validation and processing.\nWonderful unit testing framework for low-level model features as well as end-to-end operations.\n\nNo memory management, no scrupulous class design with abstracts and interfaces. No worrying about how to optimize string manipulation. No nightly build. Just create the stuff of real value.","Q_Score":24,"Tags":"php,c++,python,perl,fastcgi","A_Id":806293,"CreationDate":"2009-04-30T08:43:00.000","Title":"FastCGI C++ vs. A Script Language (PHP\/Python\/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":0,"Web Development":0},{"Question":"What are the ups and downs of using FastCGI C++ vs. PHP\/Python\/Perl to do the same job. \nAny performance or design pitfalls or using one over the other? Even your opinions are welcome. (Tell me why one or the other rocks, or one or the other sucks).","AnswerCount":16,"Available Count":10,"Score":0.024994793,"is_accepted":false,"ViewCount":16655,"Q_Id":805957,"Users Score":2,"Answer":"Well... You will save memory and CPU power with C\/C++ vs Python\/Perl\/Ruby\/Java\/.NET. If the resources saved by using C\/C++ represents a large fraction of the total resources available (a FastCGI running on the embedded board of a robot), then yeah, C\/C++. Else, why bother ?","Q_Score":24,"Tags":"php,c++,python,perl,fastcgi","A_Id":1470204,"CreationDate":"2009-04-30T08:43:00.000","Title":"FastCGI C++ vs. A Script Language (PHP\/Python\/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":0,"Web Development":0},{"Question":"What are the ups and downs of using FastCGI C++ vs. PHP\/Python\/Perl to do the same job. \nAny performance or design pitfalls or using one over the other? Even your opinions are welcome. (Tell me why one or the other rocks, or one or the other sucks).","AnswerCount":16,"Available Count":10,"Score":0.012499349,"is_accepted":false,"ViewCount":16655,"Q_Id":805957,"Users Score":1,"Answer":"C++ is a strongly typed language...i.e. you can declare ints, floats, etc....generally you can program more efficiently than you can with weakly typed languages. Facebook reported a 50% improvement when switching from PHP to C++. I would consider scripting languages to be prototyping languages...when you want production level efficiency use a compiled language.","Q_Score":24,"Tags":"php,c++,python,perl,fastcgi","A_Id":9231448,"CreationDate":"2009-04-30T08:43:00.000","Title":"FastCGI C++ vs. A Script Language (PHP\/Python\/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":0,"Web Development":0},{"Question":"What are the ups and downs of using FastCGI C++ vs. PHP\/Python\/Perl to do the same job. \nAny performance or design pitfalls or using one over the other? Even your opinions are welcome. (Tell me why one or the other rocks, or one or the other sucks).","AnswerCount":16,"Available Count":10,"Score":0.0,"is_accepted":false,"ViewCount":16655,"Q_Id":805957,"Users Score":0,"Answer":"My every search through Google indicates C\/C++ gives best performance for web apps that need functionality such as searching for information in web pages or getting information from a database.","Q_Score":24,"Tags":"php,c++,python,perl,fastcgi","A_Id":9242626,"CreationDate":"2009-04-30T08:43:00.000","Title":"FastCGI C++ vs. A Script Language (PHP\/Python\/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":0,"Web Development":0},{"Question":"What are the ups and downs of using FastCGI C++ vs. PHP\/Python\/Perl to do the same job. \nAny performance or design pitfalls or using one over the other? Even your opinions are welcome. (Tell me why one or the other rocks, or one or the other sucks).","AnswerCount":16,"Available Count":10,"Score":0.012499349,"is_accepted":false,"ViewCount":16655,"Q_Id":805957,"Users Score":1,"Answer":"Too bad there are no benchmarks of C\/C++ vs Perl CGI.\nWithout FastCGI I think C\/C++ would be a lot faster, with FastCGI possibly it'll be faster (but maybe a little less - all the initialization part is executed once).\nAgain this is very application dependent, so some sort of benchmarks for different dynamic web pages should be provided.\nPersonally I think that if your company has resources it should\/could invest in C\/C++ (given that they have to find proper ones...), otherwise is better to stick to a scripting language.\nNaturally if you want to deploy fast applications you should use C\/C++.\nAt the end of the day the compiled language is faster. But probably finding good C\/C++ devs is hard nowdays?\nCheers,","Q_Score":24,"Tags":"php,c++,python,perl,fastcgi","A_Id":1321663,"CreationDate":"2009-04-30T08:43:00.000","Title":"FastCGI C++ vs. A Script Language (PHP\/Python\/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":0,"Web Development":0},{"Question":"I have a lot of python unit tests for a project and it's getting to the point where it takes a long time to run them. I don't want to add more because I know they're going to make things slower. How do people solve this problem? Is there any easy way to distribute the test execution over a cluster?","AnswerCount":5,"Available Count":4,"Score":1.2,"is_accepted":true,"ViewCount":1201,"Q_Id":809564,"Users Score":5,"Answer":"You can't frequently run all your tests, because they're too slow. This is an inevitable consequence of your project getting bigger, and won't go away. Sure, you may be able to run the tests in parallel and get a nice speedup, but the problem will just come back later, and it'll never be as it was when your project was small.\nFor productivity, you need to be able to code, and run relevant unit tests and get results within a few seconds. If you have a hierarchy of tests, you can do this effectively: run the tests for the module you're working on frequently, the tests for the component you're working on occasionally, and the project-wide tests infrequently (perhaps before you're thinking of checking it in). You may have integration tests, or full system tests which you may run overnight: this strategy is an extension of that idea.\nAll you need to do to set this up is to organize your code and tests to support the hierarchy.","Q_Score":4,"Tags":"python,unit-testing","A_Id":814552,"CreationDate":"2009-04-30T23:25:00.000","Title":"distributed\/faster 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":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a lot of python unit tests for a project and it's getting to the point where it takes a long time to run them. I don't want to add more because I know they're going to make things slower. How do people solve this problem? Is there any easy way to distribute the test execution over a cluster?","AnswerCount":5,"Available Count":4,"Score":0.1194272985,"is_accepted":false,"ViewCount":1201,"Q_Id":809564,"Users Score":3,"Answer":"See py.test, which has the ability to pass unit tests off to a group of machines, or Nose, which (as of trunk, not the currently released version) supports running tests in parallel with the multiprocessing module.","Q_Score":4,"Tags":"python,unit-testing","A_Id":811222,"CreationDate":"2009-04-30T23:25:00.000","Title":"distributed\/faster 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":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a lot of python unit tests for a project and it's getting to the point where it takes a long time to run them. I don't want to add more because I know they're going to make things slower. How do people solve this problem? Is there any easy way to distribute the test execution over a cluster?","AnswerCount":5,"Available Count":4,"Score":0.0399786803,"is_accepted":false,"ViewCount":1201,"Q_Id":809564,"Users Score":1,"Answer":"While coding, only run the tests of the class that You have just changed, not all the tests in the whole project.\nStill, it is a good practice to run all tests before You commit Your code (but the Continuous Integration server can do it for You).","Q_Score":4,"Tags":"python,unit-testing","A_Id":810002,"CreationDate":"2009-04-30T23:25:00.000","Title":"distributed\/faster 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":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a lot of python unit tests for a project and it's getting to the point where it takes a long time to run them. I don't want to add more because I know they're going to make things slower. How do people solve this problem? Is there any easy way to distribute the test execution over a cluster?","AnswerCount":5,"Available Count":4,"Score":0.0798297691,"is_accepted":false,"ViewCount":1201,"Q_Id":809564,"Users Score":2,"Answer":"Profile them to see what really is slow. You may be able to solve this problem with out distribution. If the tests are truly unit tests then I see not many problems with running the tests across multiple execution engines.","Q_Score":4,"Tags":"python,unit-testing","A_Id":809629,"CreationDate":"2009-04-30T23:25:00.000","Title":"distributed\/faster 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":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm interested in learning python to have access to a more agile language for writing tests in my .NET projects. \nIs IronPython mature enough for these purposes yet? I'm content with writing tests in C#, but find dynamic languages like ruby and python very attractive. Would it be better to forgo IronPython while learning, and stick to the official version 3 distribution? \nI'd be interested to hear from anyone that has had success writing tests for a .net project in ironruby or ironpython.\nEdit: reworked my question to address the real issue about using dynamic languages for TDD in .NET - the version issue isn't as important. Apologies for the poorly worded question.","AnswerCount":4,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":314,"Q_Id":809737,"Users Score":0,"Answer":"What I've found however, is that IronPython to the best of my knowledge appears to be based on Python v2, while many of the learning resources available on the web are focused on Python v3.\n\nI don't know what resources you've been looking at, but the majority of them are for v2.","Q_Score":1,"Tags":".net,tdd,ironpython","A_Id":809754,"CreationDate":"2009-05-01T00:32:00.000","Title":"Learning Python on Windows for TDD","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":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":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},{"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},{"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},{"Question":"It seems that Python 2.6.1 doesn't compile bz2 library by default from source.\nI don't have lib-dynload\/bz2.so\nWhat's the quickest way to add it (without installing Python from scratch)?\nOS is Linux 2.4.32-grsec+f6b+gr217+nfs+a32+fuse23+tg+++opt+c8+gr2b-v6.194 #1 SMP Tue Jun 6 15:52:09 PDT 2006 i686 GNU\/Linux\nIIRC I used only --prefix flag.","AnswerCount":4,"Available Count":3,"Score":1.0,"is_accepted":false,"ViewCount":40171,"Q_Id":812781,"Users Score":28,"Answer":"Use your vendor's package management to add the package that contains the development files for bz2. It's usually a package called \"libbz2-dev\". E.g. on Ubuntu\nsudo apt-get install libbz2-dev","Q_Score":28,"Tags":"python,c,compiler-construction","A_Id":813744,"CreationDate":"2009-05-01T19:03:00.000","Title":"Python's bz2 module not compiled by default","Data Science and Machine Learning":0,"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},{"Question":"It seems that Python 2.6.1 doesn't compile bz2 library by default from source.\nI don't have lib-dynload\/bz2.so\nWhat's the quickest way to add it (without installing Python from scratch)?\nOS is Linux 2.4.32-grsec+f6b+gr217+nfs+a32+fuse23+tg+++opt+c8+gr2b-v6.194 #1 SMP Tue Jun 6 15:52:09 PDT 2006 i686 GNU\/Linux\nIIRC I used only --prefix flag.","AnswerCount":4,"Available Count":3,"Score":1.2,"is_accepted":true,"ViewCount":40171,"Q_Id":812781,"Users Score":33,"Answer":"You need libbz2.so (the general purpose libbz2 library) properly installed first, for Python to be able to build its own interface to it. That would typically be from a package in your Linux distro likely to have \"libbz2\" and \"dev\" in the package name.","Q_Score":28,"Tags":"python,c,compiler-construction","A_Id":813112,"CreationDate":"2009-05-01T19:03:00.000","Title":"Python's bz2 module not compiled by default","Data Science and Machine Learning":0,"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},{"Question":"It seems that Python 2.6.1 doesn't compile bz2 library by default from source.\nI don't have lib-dynload\/bz2.so\nWhat's the quickest way to add it (without installing Python from scratch)?\nOS is Linux 2.4.32-grsec+f6b+gr217+nfs+a32+fuse23+tg+++opt+c8+gr2b-v6.194 #1 SMP Tue Jun 6 15:52:09 PDT 2006 i686 GNU\/Linux\nIIRC I used only --prefix flag.","AnswerCount":4,"Available Count":3,"Score":1.0,"is_accepted":false,"ViewCount":40171,"Q_Id":812781,"Users Score":9,"Answer":"If you happen to be trying to compile Python on RHEL5 the package is called bzip2-devel, and if you have RHN set up it can be installed with this command:\n\nyum install bzip2-devel\n\nOnce that is done, you don't need either of the --enable-bz2 or --with-bz2 options, but you might need --enable-shared.","Q_Score":28,"Tags":"python,c,compiler-construction","A_Id":6848047,"CreationDate":"2009-05-01T19:03:00.000","Title":"Python's bz2 module not compiled by default","Data Science and Machine Learning":0,"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},{"Question":"What is the easiest way to do the equivalent of rm -rf in Python?","AnswerCount":7,"Available Count":1,"Score":-0.057080742,"is_accepted":false,"ViewCount":31538,"Q_Id":814167,"Users Score":-2,"Answer":"shutil.rmtree() is right answer, but just look at another useful function - os.walk()","Q_Score":83,"Tags":"python","A_Id":814535,"CreationDate":"2009-05-02T04:52:00.000","Title":"Easiest way to rm -rf 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},{"Question":"In order to be able to detect RT of a particular tweet, I plan to store hashes of each formatted tweet in the database.\nWhat hashing algorithm should I use. Cryptic is of course not essential. Just a minimal way of storing a data as something which can then be compared if it is the same, in an efficient way.\nMy first attempt at this was by using md5 hashes. But I figured there can be hashing algorithms that are much more efficient, as security is not required.","AnswerCount":7,"Available Count":3,"Score":0.057080742,"is_accepted":false,"ViewCount":798,"Q_Id":815313,"Users Score":2,"Answer":"There are a few issues here. First, RT's are not always identical. Some people add a comment. Others change the URL for tracking. Others add in the person that they are RT'ing (which may or may not be the originator).\nSo if you are going to hash the tweet, you need to boil it down to the meat of the tweet, and only hash that. Good luck.\nAbove, someone mentioned that with 32-bits, you will start having collisions at about 65K tweets. Of course, you could have collisions on tweet #2. But I think the author of that comment was confused, since 2^16 = ~65K, but 2^32 = ~4 Trillion. So you have a little more room there.\nA better algorithm might be to try to derive the \"unique\" parts of the tweet, and fingerprint it. It's not a hash, it's a fingerprint of a few key words that define uniqueness.","Q_Score":2,"Tags":"python,hash,twitter,md5","A_Id":1139680,"CreationDate":"2009-05-02T18:17:00.000","Title":"Detecting Retweets using computationally inexpensive Python hashing 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},{"Question":"In order to be able to detect RT of a particular tweet, I plan to store hashes of each formatted tweet in the database.\nWhat hashing algorithm should I use. Cryptic is of course not essential. Just a minimal way of storing a data as something which can then be compared if it is the same, in an efficient way.\nMy first attempt at this was by using md5 hashes. But I figured there can be hashing algorithms that are much more efficient, as security is not required.","AnswerCount":7,"Available Count":3,"Score":1.0,"is_accepted":false,"ViewCount":798,"Q_Id":815313,"Users Score":6,"Answer":"Do you really need to hash at all? Twitter messages are short enough (and disk space cheap enough) that it may be better to just store the whole message, rather than eating up clock cycles to hash it.","Q_Score":2,"Tags":"python,hash,twitter,md5","A_Id":815317,"CreationDate":"2009-05-02T18:17:00.000","Title":"Detecting Retweets using computationally inexpensive Python hashing 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},{"Question":"In order to be able to detect RT of a particular tweet, I plan to store hashes of each formatted tweet in the database.\nWhat hashing algorithm should I use. Cryptic is of course not essential. Just a minimal way of storing a data as something which can then be compared if it is the same, in an efficient way.\nMy first attempt at this was by using md5 hashes. But I figured there can be hashing algorithms that are much more efficient, as security is not required.","AnswerCount":7,"Available Count":3,"Score":1.2,"is_accepted":true,"ViewCount":798,"Q_Id":815313,"Users Score":0,"Answer":"You are trying to hash a string right? Builtin types can be hashed right away, just do hash(\"some string\") and you get some int. Its the same function python uses for dictonarys, so it is probably the best choice.","Q_Score":2,"Tags":"python,hash,twitter,md5","A_Id":817731,"CreationDate":"2009-05-02T18:17:00.000","Title":"Detecting Retweets using computationally inexpensive Python hashing 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},{"Question":"I've just finished writing a web server in C#. Its pretty basic and only serves static content like html, xml, and images at the moment. I would like to implement a dynamic language, however. I'm trying to choose between one of the following:\n\nASP.NET\nPHP\nPython\n\nI'd prefer to implement PHP or Python because I am much more familiar with those, however I would like to implement whichever might be easiest. How would I go about adding this functionality to my server, and which of the three languages would be the easiest to implement?\nEDIT: this is not about what language i want to do web programing in, this is about what language i want to let people who use the server program in. I would like to be able for the server to serve applications written in either asp.net, PHP or Python.","AnswerCount":5,"Available Count":2,"Score":0.0399786803,"is_accepted":false,"ViewCount":1357,"Q_Id":815446,"Users Score":1,"Answer":"Have you considered boo? It has a very configurable compiler and there are some good OSS examples out there (for example the brail view engine for Monorail & ASP.NET MVC).","Q_Score":0,"Tags":"php,asp.net,python,webserver","A_Id":815457,"CreationDate":"2009-05-02T19:25:00.000","Title":"C# Web Server: Implementing a Dynamic 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},{"Question":"I've just finished writing a web server in C#. Its pretty basic and only serves static content like html, xml, and images at the moment. I would like to implement a dynamic language, however. I'm trying to choose between one of the following:\n\nASP.NET\nPHP\nPython\n\nI'd prefer to implement PHP or Python because I am much more familiar with those, however I would like to implement whichever might be easiest. How would I go about adding this functionality to my server, and which of the three languages would be the easiest to implement?\nEDIT: this is not about what language i want to do web programing in, this is about what language i want to let people who use the server program in. I would like to be able for the server to serve applications written in either asp.net, PHP or Python.","AnswerCount":5,"Available Count":2,"Score":0.0399786803,"is_accepted":false,"ViewCount":1357,"Q_Id":815446,"Users Score":1,"Answer":"If you implement a cgi interface, you could use any kind of backend language. If you want to get fancy, you could consider looking into fastcgi.","Q_Score":0,"Tags":"php,asp.net,python,webserver","A_Id":815550,"CreationDate":"2009-05-02T19:25:00.000","Title":"C# Web Server: Implementing a Dynamic 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},{"Question":"I was wondering why smartphone\/mobile device OSs are not written to allow dynamic languages as the language of choice? iPhone uses Objective-C, Google Android uses Java, Windows Mobile uses any manner of .NET language.\nWhat would be the reasoning behind a mobile OS being written in Python, Ruby, or any other dynamic language? I understand that at a low level they would not cut it but C or C++ would be fine for that and Python, for example, could be the layer on top to interact with it. I mean, there is Jython or CPython.\nI was just wondering why we do not see more dynamic language support in today's mobile OS's.","AnswerCount":13,"Available Count":9,"Score":1.2,"is_accepted":true,"ViewCount":3120,"Q_Id":816212,"Users Score":14,"Answer":"In general it's all of these things. Memory, speed, and probably most importantly programmer familiarity. Apple has a huge investment in Objective C, Java is known by basically everyone, and C# is very popular as well. If you're trying for mass programmer appeal it makes sense to start with something popular, even if it's sort of boring.\nThere aren't really any technical requirements stopping it. We could write a whole Ruby stack and let the programmer re-implement the slow bits in C and it wouldn't be that big of a deal. It would be an investment for whatever company is making the mobile OS, and at the end of the day I'm not sure they gain as much from this.\nFinally, it's the very beginning of mobile devices. In 5 years I wouldn't be at all surprised to see a much wider mobile stack.","Q_Score":10,"Tags":"python,ruby,mobile,operating-system,dynamic-languages","A_Id":816248,"CreationDate":"2009-05-03T03:09:00.000","Title":"Python\/Ruby as mobile OS","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},{"Question":"I was wondering why smartphone\/mobile device OSs are not written to allow dynamic languages as the language of choice? iPhone uses Objective-C, Google Android uses Java, Windows Mobile uses any manner of .NET language.\nWhat would be the reasoning behind a mobile OS being written in Python, Ruby, or any other dynamic language? I understand that at a low level they would not cut it but C or C++ would be fine for that and Python, for example, could be the layer on top to interact with it. I mean, there is Jython or CPython.\nI was just wondering why we do not see more dynamic language support in today's mobile OS's.","AnswerCount":13,"Available Count":9,"Score":0.0,"is_accepted":false,"ViewCount":3120,"Q_Id":816212,"Users Score":0,"Answer":"webOS -- the new OS from Palm, which will debut on the Pre -- has you write apps against a webkit runtime in JavaScript. Time will tell how successful it is, but I suspect it will not be the first to go down this path. As mobile devices become more powerful, you'll see dynamic languages become more prevalent.","Q_Score":10,"Tags":"python,ruby,mobile,operating-system,dynamic-languages","A_Id":817560,"CreationDate":"2009-05-03T03:09:00.000","Title":"Python\/Ruby as mobile OS","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},{"Question":"I was wondering why smartphone\/mobile device OSs are not written to allow dynamic languages as the language of choice? iPhone uses Objective-C, Google Android uses Java, Windows Mobile uses any manner of .NET language.\nWhat would be the reasoning behind a mobile OS being written in Python, Ruby, or any other dynamic language? I understand that at a low level they would not cut it but C or C++ would be fine for that and Python, for example, could be the layer on top to interact with it. I mean, there is Jython or CPython.\nI was just wondering why we do not see more dynamic language support in today's mobile OS's.","AnswerCount":13,"Available Count":9,"Score":0.0,"is_accepted":false,"ViewCount":3120,"Q_Id":816212,"Users Score":0,"Answer":"Memory is also a significant factor. It's easy to eat memory in Python, unfortunately.","Q_Score":10,"Tags":"python,ruby,mobile,operating-system,dynamic-languages","A_Id":816228,"CreationDate":"2009-05-03T03:09:00.000","Title":"Python\/Ruby as mobile OS","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},{"Question":"I was wondering why smartphone\/mobile device OSs are not written to allow dynamic languages as the language of choice? iPhone uses Objective-C, Google Android uses Java, Windows Mobile uses any manner of .NET language.\nWhat would be the reasoning behind a mobile OS being written in Python, Ruby, or any other dynamic language? I understand that at a low level they would not cut it but C or C++ would be fine for that and Python, for example, could be the layer on top to interact with it. I mean, there is Jython or CPython.\nI was just wondering why we do not see more dynamic language support in today's mobile OS's.","AnswerCount":13,"Available Count":9,"Score":0.0,"is_accepted":false,"ViewCount":3120,"Q_Id":816212,"Users Score":0,"Answer":"There is a linux distribution for OpenMoko Freerunner called SHR. Most of its settings and framework code is written in python and... well, it isn't very fast. It is bearable, but it was planned from the beginning to rewrite it in Vala.\nOn the other side, my few smallish apps work fast enough (with the only drawback having big startup time) to consider python to develop user applications.\nFor the record: Freerunner has ARM-something 400MHz and 128MB of RAM. I guess that once mobile devices cross 1GHz, languages like Python will be fast enough for middle-level stuff too (the low-level being the kernel).","Q_Score":10,"Tags":"python,ruby,mobile,operating-system,dynamic-languages","A_Id":1077315,"CreationDate":"2009-05-03T03:09:00.000","Title":"Python\/Ruby as mobile OS","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},{"Question":"I was wondering why smartphone\/mobile device OSs are not written to allow dynamic languages as the language of choice? iPhone uses Objective-C, Google Android uses Java, Windows Mobile uses any manner of .NET language.\nWhat would be the reasoning behind a mobile OS being written in Python, Ruby, or any other dynamic language? I understand that at a low level they would not cut it but C or C++ would be fine for that and Python, for example, could be the layer on top to interact with it. I mean, there is Jython or CPython.\nI was just wondering why we do not see more dynamic language support in today's mobile OS's.","AnswerCount":13,"Available Count":9,"Score":0.0153834017,"is_accepted":false,"ViewCount":3120,"Q_Id":816212,"Users Score":1,"Answer":"I think that performance concerns may be part of, but not all of, the reason. Mobile devices do not have very powerful hardware to work with.\nI am partly unsure about this, though.","Q_Score":10,"Tags":"python,ruby,mobile,operating-system,dynamic-languages","A_Id":816225,"CreationDate":"2009-05-03T03:09:00.000","Title":"Python\/Ruby as mobile OS","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},{"Question":"I was wondering why smartphone\/mobile device OSs are not written to allow dynamic languages as the language of choice? iPhone uses Objective-C, Google Android uses Java, Windows Mobile uses any manner of .NET language.\nWhat would be the reasoning behind a mobile OS being written in Python, Ruby, or any other dynamic language? I understand that at a low level they would not cut it but C or C++ would be fine for that and Python, for example, could be the layer on top to interact with it. I mean, there is Jython or CPython.\nI was just wondering why we do not see more dynamic language support in today's mobile OS's.","AnswerCount":13,"Available Count":9,"Score":0.0153834017,"is_accepted":false,"ViewCount":3120,"Q_Id":816212,"Users Score":1,"Answer":"One of the most pressing matters is garbage collection. Garbage collection often times introduce unpredictable pauses in embedded machines which sometimes need real time performance.\nThis is why there is a Java Micro Edition which has a different garbage collector which reduces pauses in exchange for a slower program.\nRefcounting garbage collectors (like the one in CPython) are also less prone to pauses but can explode when data with many nested pointers (like a linked list) get deleted.","Q_Score":10,"Tags":"python,ruby,mobile,operating-system,dynamic-languages","A_Id":816233,"CreationDate":"2009-05-03T03:09:00.000","Title":"Python\/Ruby as mobile OS","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},{"Question":"I was wondering why smartphone\/mobile device OSs are not written to allow dynamic languages as the language of choice? iPhone uses Objective-C, Google Android uses Java, Windows Mobile uses any manner of .NET language.\nWhat would be the reasoning behind a mobile OS being written in Python, Ruby, or any other dynamic language? I understand that at a low level they would not cut it but C or C++ would be fine for that and Python, for example, could be the layer on top to interact with it. I mean, there is Jython or CPython.\nI was just wondering why we do not see more dynamic language support in today's mobile OS's.","AnswerCount":13,"Available Count":9,"Score":0.0,"is_accepted":false,"ViewCount":3120,"Q_Id":816212,"Users Score":0,"Answer":"There are many reasons. Among them:\n\nbusiness reasons, such as software lock-in strategies,\nefficiency: dynamic languages are usually perceived to be slower (and in some cases really are slower, or at least provide a limit to the amount of optimsation you can do. On a mobile device, optimising code is necessary much more often than on a PC), and tend to use more memory, which is a significant issue on portable devices with limited memory and little cache,,\nkeeping development simple: a platform that supports say Python and Ruby and Java out of the box:\n\n\nmeans thrice the work to write documentation and provide support,\ndivides development effort into three; it takes longer for helpful material to appear on the web and there are less developers who use the same language as you on your platform,\nrequires more storage on the device to support all these languages,\n\nmanagement need to be convinced. I've always felt that the merits of Java are easily explained to a non-technical audience. .Net and Obj-C also seem a very natural choice for a Microsoft and Apple platform, respectively.","Q_Score":10,"Tags":"python,ruby,mobile,operating-system,dynamic-languages","A_Id":816266,"CreationDate":"2009-05-03T03:09:00.000","Title":"Python\/Ruby as mobile OS","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},{"Question":"I was wondering why smartphone\/mobile device OSs are not written to allow dynamic languages as the language of choice? iPhone uses Objective-C, Google Android uses Java, Windows Mobile uses any manner of .NET language.\nWhat would be the reasoning behind a mobile OS being written in Python, Ruby, or any other dynamic language? I understand that at a low level they would not cut it but C or C++ would be fine for that and Python, for example, could be the layer on top to interact with it. I mean, there is Jython or CPython.\nI was just wondering why we do not see more dynamic language support in today's mobile OS's.","AnswerCount":13,"Available Count":9,"Score":0.0153834017,"is_accepted":false,"ViewCount":3120,"Q_Id":816212,"Users Score":1,"Answer":"Jailbroken iPhones can have python installed, and I actually use python very frequently on mine.","Q_Score":10,"Tags":"python,ruby,mobile,operating-system,dynamic-languages","A_Id":816219,"CreationDate":"2009-05-03T03:09:00.000","Title":"Python\/Ruby as mobile OS","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},{"Question":"I was wondering why smartphone\/mobile device OSs are not written to allow dynamic languages as the language of choice? iPhone uses Objective-C, Google Android uses Java, Windows Mobile uses any manner of .NET language.\nWhat would be the reasoning behind a mobile OS being written in Python, Ruby, or any other dynamic language? I understand that at a low level they would not cut it but C or C++ would be fine for that and Python, for example, could be the layer on top to interact with it. I mean, there is Jython or CPython.\nI was just wondering why we do not see more dynamic language support in today's mobile OS's.","AnswerCount":13,"Available Count":9,"Score":0.0,"is_accepted":false,"ViewCount":3120,"Q_Id":816212,"Users Score":0,"Answer":"I suspect the basic reason is a combination of security and reliability. You don't want someone to be easily able to hack the phone, and you want to have some control over what's being installed.","Q_Score":10,"Tags":"python,ruby,mobile,operating-system,dynamic-languages","A_Id":816217,"CreationDate":"2009-05-03T03:09:00.000","Title":"Python\/Ruby as mobile OS","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},{"Question":"I understand that letting any anonymous user upload any sort of file in general can be dangerous, especially if it's code. However, I have an idea to let users upload custom AI scripts to my website. I would provide the template so that the user could compete with other AI's in an online web game I wrote in Python. I either need a solution to ensure a user couldn't compromise any other files or inject malicious code via their uploaded script or a solution for client-side execution of the game. Any suggestions? (I'm looking for a solution that will work with my Python scripts)","AnswerCount":6,"Available Count":4,"Score":0.0996679946,"is_accepted":false,"ViewCount":1115,"Q_Id":818402,"Users Score":3,"Answer":"Yes.\nAllow them to script their client, not your server.","Q_Score":12,"Tags":"python,cgi","A_Id":818405,"CreationDate":"2009-05-04T00:20:00.000","Title":"Letting users upload Python scripts for 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":1},{"Question":"I understand that letting any anonymous user upload any sort of file in general can be dangerous, especially if it's code. However, I have an idea to let users upload custom AI scripts to my website. I would provide the template so that the user could compete with other AI's in an online web game I wrote in Python. I either need a solution to ensure a user couldn't compromise any other files or inject malicious code via their uploaded script or a solution for client-side execution of the game. Any suggestions? (I'm looking for a solution that will work with my Python scripts)","AnswerCount":6,"Available Count":4,"Score":0.1325487884,"is_accepted":false,"ViewCount":1115,"Q_Id":818402,"Users Score":4,"Answer":"Along with other safeguards, you can also incorporate human review of the code. Assuming part of the experience is reviewing other members' solutions, and everyone is a python developer, don't allow new code to be activated until a certain number of members vote for it. Your users aren't going to approve malicious code.","Q_Score":12,"Tags":"python,cgi","A_Id":818558,"CreationDate":"2009-05-04T00:20:00.000","Title":"Letting users upload Python scripts for 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":1},{"Question":"I understand that letting any anonymous user upload any sort of file in general can be dangerous, especially if it's code. However, I have an idea to let users upload custom AI scripts to my website. I would provide the template so that the user could compete with other AI's in an online web game I wrote in Python. I either need a solution to ensure a user couldn't compromise any other files or inject malicious code via their uploaded script or a solution for client-side execution of the game. Any suggestions? (I'm looking for a solution that will work with my Python scripts)","AnswerCount":6,"Available Count":4,"Score":0.0333209931,"is_accepted":false,"ViewCount":1115,"Q_Id":818402,"Users Score":1,"Answer":"PyPy is probably a decent bet on the server side as suggested, but I'd look into having your python backend provide well defined APIs and data formats and have the users implement the AI and logic in Javascript so it can run in their browser. So the interaction would look like: For each match\/turn\/etc, pass data to the browser in a well defined format, provide a javascript template that receives the data and can implement logic, and provide web APIs that can be invoked by the client (browser) to take the desired actions. That way you don't have to worry about security or server power.","Q_Score":12,"Tags":"python,cgi","A_Id":819227,"CreationDate":"2009-05-04T00:20:00.000","Title":"Letting users upload Python scripts for 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":1},{"Question":"I understand that letting any anonymous user upload any sort of file in general can be dangerous, especially if it's code. However, I have an idea to let users upload custom AI scripts to my website. I would provide the template so that the user could compete with other AI's in an online web game I wrote in Python. I either need a solution to ensure a user couldn't compromise any other files or inject malicious code via their uploaded script or a solution for client-side execution of the game. Any suggestions? (I'm looking for a solution that will work with my Python scripts)","AnswerCount":6,"Available Count":4,"Score":1.2,"is_accepted":true,"ViewCount":1115,"Q_Id":818402,"Users Score":0,"Answer":"Have an extensive API for the users and strip all other calls upon upload (such as import statements). Also, strip everything that has anything to do with file i\/o.\n(You might want to do multiple passes to ensure that you didn't miss anything.)","Q_Score":12,"Tags":"python,cgi","A_Id":878455,"CreationDate":"2009-05-04T00:20:00.000","Title":"Letting users upload Python scripts for 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":1},{"Question":"I have one Python module that can be called by a CGI script (passing it information from a form) or from the command line (passing it options and arguments from the command line).\nIs there a way to establish if the module has been called from the CGI script or from the command line ??","AnswerCount":2,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":308,"Q_Id":819217,"Users Score":6,"Answer":"This is a really bad design idea. Your script should be designed to work independently of how it's called. The calling programs should provide a uniform environment.\nYou'll be happiest if you design your scripts to work in exactly one consistent way. Build things like this.\n\nmyscript.py - the \"real work\" - defined in functions and classes. \nmyscript_cgi.py - a CGI interface that imports myscript and uses the classes and functions.\nmyscript_cli.py - the command-line interface that parses the command-line options, imports myscript, and uses the classes and functions.\n\nA single script that does all three things (real work, cgi interface, cli interface) is usually a mistake.","Q_Score":3,"Tags":"python,cgi","A_Id":819618,"CreationDate":"2009-05-04T08:08:00.000","Title":"Python, who is calling my 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":0,"System Administration and DevOps":0,"Web Development":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},{"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},{"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},{"Question":"I have been playing around with Python's FTP library and am starting to think that it is too slow as compared to using a script file in DOS? I run sessions where I download thousands of data files (I think I have over 8 million right now). My observation is that the download process seems to take five to ten times as long in Python than it does as compared to using the ftp commands in the DOS shell.\nSince I don't want anyone to fix my code I have not included any. I am more interested in understanding if my observation is valid or if I need to tinker more with the arguments.","AnswerCount":7,"Available Count":2,"Score":0.0855049882,"is_accepted":false,"ViewCount":8009,"Q_Id":834840,"Users Score":3,"Answer":"FTPlib may not be the cleanest Python API, I don't think it so bad that it run ten times slower than a DOS shell script.\nUnless you do not provide any code to compare, e.g you shell and you python snippet to batch dl 5000 files, I can't see how we can help you.","Q_Score":4,"Tags":"python,ftp,performance,dos","A_Id":834923,"CreationDate":"2009-05-07T14:05:00.000","Title":"Python's FTPLib too 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":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have been playing around with Python's FTP library and am starting to think that it is too slow as compared to using a script file in DOS? I run sessions where I download thousands of data files (I think I have over 8 million right now). My observation is that the download process seems to take five to ten times as long in Python than it does as compared to using the ftp commands in the DOS shell.\nSince I don't want anyone to fix my code I have not included any. I am more interested in understanding if my observation is valid or if I need to tinker more with the arguments.","AnswerCount":7,"Available Count":2,"Score":0.1137907297,"is_accepted":false,"ViewCount":8009,"Q_Id":834840,"Users Score":4,"Answer":"The speed problem is probably in your code. FTPlib is not 10 times slower.","Q_Score":4,"Tags":"python,ftp,performance,dos","A_Id":835474,"CreationDate":"2009-05-07T14:05:00.000","Title":"Python's FTPLib too 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":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am writing a server-client application to receive user message and publish it.\nThinking about authentication method.\n\nAsymmetric encryption, probably RSA.\nHash (salt+password+'msg'+'userid'), SHA256\nHMAC, SHA256. seems to be more secured than the method 2. Also involve hashing the password and msg data.\nSymmetric Encryption of the 'msg' with static password stored on both sides, probably AES.\n\nThere is no need for encryption as the msg would be publish online anyway. So I am more lean to the HMAC or PKI method.\nI'm using java to send the request (including whatever authentication method to be implemented)\nwww.mysite.com\/foo?userid=12345&msg=hello&token=abc1234\npython on the server side to receive request and make sure the request is from the valid user.\nThe problems are in integration and make sure both sides understand each other's authentication token. It is a big factor for me. And the availability of the libraries available on both language are taken into account as well.\nOr I can choose to rewrite the server side into java. (Why not python? The client side application need to be in java)\nWhat do you think?\n\nEDIT: I would not treat this as a web application. The application does not serve any webpage. Most of the operations are not related to the web. Just the client-server communication go through internet. And sending POST\/GET via HTTP is what I thought of as the simpler albeit insecure way to do it. Feel free to suggest me any other alternative. \nSSL is a secure way for encryption. But it does not prevent attacker from sending message to the server impose as the user. Anyone can initiate a HTTPS connection. And the content of the communication does not need to be encrypted. It will be published online by the server anyway. What I need is a way to authenticate the message and sender.\nFor now I am lean to HMAC algorithm. RSA would be more secure but it comes with more developer efforts as well. Will see how it goes.\nThank you.","AnswerCount":4,"Available Count":3,"Score":0.049958375,"is_accepted":false,"ViewCount":1626,"Q_Id":834932,"Users Score":1,"Answer":"Let me just add a few random thoughts\/comments to your proposals.\n\nRSA: Since you are mainly interested in authentication, I assume you'd want to use RSA signatures. This would imply that each user needs his own privat key. To me that sounds a little bit like overkill, especially when user and server already share common secrets (i.e., passwords).\nUsing SHA256 is a good approach. I have some problems to understand why you include a salt, since a salt is commonly use to avoid that an attacker precomputes hashes of dictionaries. To be clear: dicitionary attacks are a problem here. An attacker could try to hash messages with all passwords from a dictionary. Just he has to reapeat this attack for each user and can't reuse precomputed values. One way to make such an attack a little\nmore difficult is called key strengthening, e.g. by reapeatedly hashing the result n times\nand hence forcing an attacker to perform more work during a dictionary attack.\nI completely agree that HMAC is better than just SHA-256. After all HMAC was designed for authentication. I'm not sure why you want to hash the message before computing the HMAC. HMAC does that for you.\nEncryption does not always provide authentication. This is specially in cases when the attacker learns the plaintext, as he does in your case. He might be able to exploit properties of the encryption mode to manipulate the ciphertext an know exactly how the resulting plaintext will look like (E.g. the CBC mode allows these kind of manipulations). Your previous proposal (HMAC) is preferable.\n\nFinally, if you can setup an SSL connection between user and server, as others suggest: this would be a much safer solution, since not even the dicionary attack mentioned above would be possible.","Q_Score":0,"Tags":"java,python,authentication,encryption,hash","A_Id":840803,"CreationDate":"2009-05-07T14:22:00.000","Title":"authentication method","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I am writing a server-client application to receive user message and publish it.\nThinking about authentication method.\n\nAsymmetric encryption, probably RSA.\nHash (salt+password+'msg'+'userid'), SHA256\nHMAC, SHA256. seems to be more secured than the method 2. Also involve hashing the password and msg data.\nSymmetric Encryption of the 'msg' with static password stored on both sides, probably AES.\n\nThere is no need for encryption as the msg would be publish online anyway. So I am more lean to the HMAC or PKI method.\nI'm using java to send the request (including whatever authentication method to be implemented)\nwww.mysite.com\/foo?userid=12345&msg=hello&token=abc1234\npython on the server side to receive request and make sure the request is from the valid user.\nThe problems are in integration and make sure both sides understand each other's authentication token. It is a big factor for me. And the availability of the libraries available on both language are taken into account as well.\nOr I can choose to rewrite the server side into java. (Why not python? The client side application need to be in java)\nWhat do you think?\n\nEDIT: I would not treat this as a web application. The application does not serve any webpage. Most of the operations are not related to the web. Just the client-server communication go through internet. And sending POST\/GET via HTTP is what I thought of as the simpler albeit insecure way to do it. Feel free to suggest me any other alternative. \nSSL is a secure way for encryption. But it does not prevent attacker from sending message to the server impose as the user. Anyone can initiate a HTTPS connection. And the content of the communication does not need to be encrypted. It will be published online by the server anyway. What I need is a way to authenticate the message and sender.\nFor now I am lean to HMAC algorithm. RSA would be more secure but it comes with more developer efforts as well. Will see how it goes.\nThank you.","AnswerCount":4,"Available Count":3,"Score":0.0996679946,"is_accepted":false,"ViewCount":1626,"Q_Id":834932,"Users Score":2,"Answer":"Can't you just use standard SSL sockets to secure the connection, validate the user with a password, and then send the message to be published? If there won't be many clients, you can even use a self-signed certificate and put it in a KeyStore in the client app, that way you won't need to buy a certificate from Verisign or anyone else.\nIf you are storing the user's password hash on the server (as I think you should otherwise how are you going to validate the user's password), then you can first reproduce that hash on the client side (let's assume you hash user+pass) and then append that to the message and hash the result. You send the user id, hash and message to the server.\nOn the server side you receive a request with a user id, you retrieve the user's password (the server only has stored the hash of user+pass), you append that to the message and hash it again, and compare it against the hash in the request. If it matches, the user can publish the message.\nOh and you should use HTTP POST, instead of sending data on the URL. The server should not accept data on the URL for the publish request.","Q_Score":0,"Tags":"java,python,authentication,encryption,hash","A_Id":836074,"CreationDate":"2009-05-07T14:22:00.000","Title":"authentication method","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I am writing a server-client application to receive user message and publish it.\nThinking about authentication method.\n\nAsymmetric encryption, probably RSA.\nHash (salt+password+'msg'+'userid'), SHA256\nHMAC, SHA256. seems to be more secured than the method 2. Also involve hashing the password and msg data.\nSymmetric Encryption of the 'msg' with static password stored on both sides, probably AES.\n\nThere is no need for encryption as the msg would be publish online anyway. So I am more lean to the HMAC or PKI method.\nI'm using java to send the request (including whatever authentication method to be implemented)\nwww.mysite.com\/foo?userid=12345&msg=hello&token=abc1234\npython on the server side to receive request and make sure the request is from the valid user.\nThe problems are in integration and make sure both sides understand each other's authentication token. It is a big factor for me. And the availability of the libraries available on both language are taken into account as well.\nOr I can choose to rewrite the server side into java. (Why not python? The client side application need to be in java)\nWhat do you think?\n\nEDIT: I would not treat this as a web application. The application does not serve any webpage. Most of the operations are not related to the web. Just the client-server communication go through internet. And sending POST\/GET via HTTP is what I thought of as the simpler albeit insecure way to do it. Feel free to suggest me any other alternative. \nSSL is a secure way for encryption. But it does not prevent attacker from sending message to the server impose as the user. Anyone can initiate a HTTPS connection. And the content of the communication does not need to be encrypted. It will be published online by the server anyway. What I need is a way to authenticate the message and sender.\nFor now I am lean to HMAC algorithm. RSA would be more secure but it comes with more developer efforts as well. Will see how it goes.\nThank you.","AnswerCount":4,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":1626,"Q_Id":834932,"Users Score":0,"Answer":"RSA protocol is generally used to setup a key exchange for a faster encryption means. That's how SSL works. \nIf the security requirements for your applications are so sensitive that you require PKI, then it should be said (without any intent to be harsh) that if you need to ask about it on SO, then its probably something you shouldn't attempt to do (given that generally successful attacks on secure channels attack weakpoints of the implementation).\nAs Chochos has suggested, what's wrong with simply using the existing SSL infrastructure in Java and your server to set up a secure https connection and then simply pass the user password from client to the server?","Q_Score":0,"Tags":"java,python,authentication,encryption,hash","A_Id":837532,"CreationDate":"2009-05-07T14:22:00.000","Title":"authentication method","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"Does a easy to use Ruby to Python bridge exist? Or am I better off using system()?","AnswerCount":5,"Available Count":2,"Score":-0.0399786803,"is_accepted":false,"ViewCount":6499,"Q_Id":837256,"Users Score":-1,"Answer":"For python code to run the interpreter needs to be launched as a process. So system() is your best option.\nFor calling the python code you could use RPC or network sockets, got for the simplest thing which could possibly work.","Q_Score":5,"Tags":"python,ruby","A_Id":837862,"CreationDate":"2009-05-07T21:59:00.000","Title":"How do I invoke Python code from 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":1,"Web Development":1},{"Question":"Does a easy to use Ruby to Python bridge exist? Or am I better off using system()?","AnswerCount":5,"Available Count":2,"Score":0.0798297691,"is_accepted":false,"ViewCount":6499,"Q_Id":837256,"Users Score":2,"Answer":"I don't think there's any way to invoke Python from Ruby without forking a process, via system() or something. The language run times are utterly diferent, they'd need to be in separate processes anyway.","Q_Score":5,"Tags":"python,ruby","A_Id":837296,"CreationDate":"2009-05-07T21:59:00.000","Title":"How do I invoke Python code from 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":1,"Web Development":1},{"Question":"I just got a project where I have to do the following on a Windows OS:\n\ndetect how many drives (C: D: E:\n..etc) are connected to current\nsystem \nwhat the system labels are\nfor each volume \nhow much storage\n(both used and free) for each of the\ndrives\nwhat format each drive is\n(NTFS\/FAT32) \nhow many files are\nin a given directory in any of those\ndrives \nhow big each file size is\nFile processing (each file is\nabout 2GB) where I have to do a lot\nof C-like fseek(), and binary data\nparsing, and big to little-endian\nconversion. Have to write some logic\ncode as well.\n\nI'm an experienced C\\C++ programmer, but I thought this would be a perfect time for me to start learning about scripting.\nCandidates that I thought of are: ( Python || Ruby ) && PowerShell.\nAre those the kinds of things I can accomplish with, say, IronPython+Powershell? Or are there better tools\/languages out there? \nPS: Is PowerShell meant to replace VBScript? Also, what is VB.net good for anyway now that C#, WPF, and Powershell exist?","AnswerCount":7,"Available Count":3,"Score":1.0,"is_accepted":false,"ViewCount":501,"Q_Id":841669,"Users Score":8,"Answer":"Except for the seventh item on your list this should be fairly trivial using Powershell and WMI, as this is perhaps the natural domain for Powershell. Since you won't need another language for the first six list items it shouldn't really matter what you use for the last one. You probably can use PS (I've never done IO with it, though) or whatever suits you.\nAs for your second question: VBScript is probably not going to go away in the near future as the Windows Script Host is still a safer bet when writing small scripts for deployment, as it comes preinstalled on every Windows since 98. Powershell is only included in Windows 7 and later. That being said, Powershell is surely targeted at obsoleting WSH and CMD for automation purposes since it offers the same features of the aforementioned ones and much more (like easy .NET and WMI access).\nVB.NET on the other hand is one of the primary .NET languages marketed by Microsoft. It has little to no relation to VBScript, is no competitor to Powershell or WPF (heck, those are completely different technologies). You may see some convergence with C# going on as both languages still seem to struggle a little finding their intended market. Still, VB.NET is the easiest choice of switching to .NET when you're a VB programmer and there were\/are lots of them MS didn't want to lose just because they created .NET.","Q_Score":0,"Tags":".net,ruby,powershell,scripting,ironpython","A_Id":841689,"CreationDate":"2009-05-08T20:35:00.000","Title":"Advice for Windows system scripting+programming","Data Science and Machine Learning":0,"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},{"Question":"I just got a project where I have to do the following on a Windows OS:\n\ndetect how many drives (C: D: E:\n..etc) are connected to current\nsystem \nwhat the system labels are\nfor each volume \nhow much storage\n(both used and free) for each of the\ndrives\nwhat format each drive is\n(NTFS\/FAT32) \nhow many files are\nin a given directory in any of those\ndrives \nhow big each file size is\nFile processing (each file is\nabout 2GB) where I have to do a lot\nof C-like fseek(), and binary data\nparsing, and big to little-endian\nconversion. Have to write some logic\ncode as well.\n\nI'm an experienced C\\C++ programmer, but I thought this would be a perfect time for me to start learning about scripting.\nCandidates that I thought of are: ( Python || Ruby ) && PowerShell.\nAre those the kinds of things I can accomplish with, say, IronPython+Powershell? Or are there better tools\/languages out there? \nPS: Is PowerShell meant to replace VBScript? Also, what is VB.net good for anyway now that C#, WPF, and Powershell exist?","AnswerCount":7,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":501,"Q_Id":841669,"Users Score":0,"Answer":"As for Perl, Ruby too has access to all Win32 API and WMI functions.","Q_Score":0,"Tags":".net,ruby,powershell,scripting,ironpython","A_Id":844915,"CreationDate":"2009-05-08T20:35:00.000","Title":"Advice for Windows system scripting+programming","Data Science and Machine Learning":0,"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},{"Question":"I just got a project where I have to do the following on a Windows OS:\n\ndetect how many drives (C: D: E:\n..etc) are connected to current\nsystem \nwhat the system labels are\nfor each volume \nhow much storage\n(both used and free) for each of the\ndrives\nwhat format each drive is\n(NTFS\/FAT32) \nhow many files are\nin a given directory in any of those\ndrives \nhow big each file size is\nFile processing (each file is\nabout 2GB) where I have to do a lot\nof C-like fseek(), and binary data\nparsing, and big to little-endian\nconversion. Have to write some logic\ncode as well.\n\nI'm an experienced C\\C++ programmer, but I thought this would be a perfect time for me to start learning about scripting.\nCandidates that I thought of are: ( Python || Ruby ) && PowerShell.\nAre those the kinds of things I can accomplish with, say, IronPython+Powershell? Or are there better tools\/languages out there? \nPS: Is PowerShell meant to replace VBScript? Also, what is VB.net good for anyway now that C#, WPF, and Powershell exist?","AnswerCount":7,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":501,"Q_Id":841669,"Users Score":0,"Answer":"I'll give you the unpopular answer then since no one else has added it: Perl.\nIf you're comfortable with the Win32 API as a C\/C++ programmer, Perl may be the easier way to go. It has modules for accessing the Win32 API and Perl is quite easy for C\/C++ programmers to get up to speed in. Perl has always done the job for me in the past.","Q_Score":0,"Tags":".net,ruby,powershell,scripting,ironpython","A_Id":842535,"CreationDate":"2009-05-08T20:35:00.000","Title":"Advice for Windows system scripting+programming","Data Science and Machine Learning":0,"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},{"Question":"Is there an easy way to call Python objects from C#, that is without any COM mess?","AnswerCount":3,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":10077,"Q_Id":845502,"Users Score":8,"Answer":"Yes, by hosting IronPython.","Q_Score":6,"Tags":"c#,python,ironpython","A_Id":845506,"CreationDate":"2009-05-10T15:11:00.000","Title":"using Python objects 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},{"Question":"I've been programming Ruby pretty extensively for the past four years or so, and I'm extremely comfortable with the language. For no particular reason, I've decided to learn some Python this week. Is there a specific book, tutorial, or reference that would be well-suited to someone coming from a nearly-identical language, or should I just \"Dive into Python\"?\nThanks!","AnswerCount":4,"Available Count":1,"Score":0.1488850336,"is_accepted":false,"ViewCount":4331,"Q_Id":846139,"Users Score":3,"Answer":"After running through some tutorials on-line (the ones posted so far look pretty good), find a current Ruby project you've done (or are working on) and re-write it in Python. I've used this technique to transition from various languages, and it's helped enormously.","Q_Score":17,"Tags":"python,ruby","A_Id":846168,"CreationDate":"2009-05-10T21:25:00.000","Title":"What's the quickest way for a Ruby programmer to pick up 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},{"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},{"Question":"To squeeze into the limited amount of filesystem storage available in an embedded system I'm currently playing with, I would like to eliminate any files that could reasonably be removed without significantly impacting functionality or performance. The *.py, *.pyo, and *.pyc files in the Python library account for a sizable amount of space, I'm wondering which of these options would be most reasonable for a Python 2.6 installation in a small embedded system:\n\nKeep *.py, eliminate *.pyc and *.pyo (Maintain ability to debug, performance suffers?)\nKeep *.py and *.pyc, eliminate *.pyo (Does optimization really buy anything?)\nKeep *.pyc, eliminate *.pyo and *.py (Will this work?)\nKeep *.py, *.pyc, and *.pyo (All are needed?)","AnswerCount":5,"Available Count":2,"Score":0.1194272985,"is_accepted":false,"ViewCount":7405,"Q_Id":850630,"Users Score":3,"Answer":"Number 3 should and will work. You do not need the .pyo or .py files in order to use the compiled python code.","Q_Score":12,"Tags":"python,embedded","A_Id":850642,"CreationDate":"2009-05-12T00:18:00.000","Title":"Python *.py, *.pyo, *.pyc: Which can be eliminated for an Embedded 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":0},{"Question":"To squeeze into the limited amount of filesystem storage available in an embedded system I'm currently playing with, I would like to eliminate any files that could reasonably be removed without significantly impacting functionality or performance. The *.py, *.pyo, and *.pyc files in the Python library account for a sizable amount of space, I'm wondering which of these options would be most reasonable for a Python 2.6 installation in a small embedded system:\n\nKeep *.py, eliminate *.pyc and *.pyo (Maintain ability to debug, performance suffers?)\nKeep *.py and *.pyc, eliminate *.pyo (Does optimization really buy anything?)\nKeep *.pyc, eliminate *.pyo and *.py (Will this work?)\nKeep *.py, *.pyc, and *.pyo (All are needed?)","AnswerCount":5,"Available Count":2,"Score":0.0798297691,"is_accepted":false,"ViewCount":7405,"Q_Id":850630,"Users Score":2,"Answer":"I would recommend keeping only .py files. The difference in startup time isn't that great, and having the source around is a plus, as it will run under different python versions without any issues.\nAs of python 2.6, setting sys.dont_write_bytecode to True will suppress compilation of .pyc and .pyo files altogether, so you may want to use that option if you have 2.6 available.","Q_Score":12,"Tags":"python,embedded","A_Id":851194,"CreationDate":"2009-05-12T00:18:00.000","Title":"Python *.py, *.pyo, *.pyc: Which can be eliminated for an Embedded 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":0},{"Question":"I'm trying to change my PYTHONPATH. I've tried to change it in \"My Computer\" etc, but it doesn't exist there. I searched in the registry in some places, and even ran a whole search for the word 'PYTHONPATH', but to no avail.\nHowever, it Python I can easily see it exists. So where is it?","AnswerCount":9,"Available Count":4,"Score":0.0,"is_accepted":false,"ViewCount":45286,"Q_Id":859594,"Users Score":0,"Answer":"What's it set to? Have you tried creating a PYTHONPATH environment variable?","Q_Score":12,"Tags":"python,windows,path","A_Id":859615,"CreationDate":"2009-05-13T18:28:00.000","Title":"Can't find my 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":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to change my PYTHONPATH. I've tried to change it in \"My Computer\" etc, but it doesn't exist there. I searched in the registry in some places, and even ran a whole search for the word 'PYTHONPATH', but to no avail.\nHowever, it Python I can easily see it exists. So where is it?","AnswerCount":9,"Available Count":4,"Score":0.0,"is_accepted":false,"ViewCount":45286,"Q_Id":859594,"Users Score":0,"Answer":"You need modify your environment variables. How to do this depends on which version of Windows you have.\nIf the PYTHONPATH variable doesn't exist, you have to create it. It might not exist if you haven't already created it.","Q_Score":12,"Tags":"python,windows,path","A_Id":859618,"CreationDate":"2009-05-13T18:28:00.000","Title":"Can't find my 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":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to change my PYTHONPATH. I've tried to change it in \"My Computer\" etc, but it doesn't exist there. I searched in the registry in some places, and even ran a whole search for the word 'PYTHONPATH', but to no avail.\nHowever, it Python I can easily see it exists. So where is it?","AnswerCount":9,"Available Count":4,"Score":0.022218565,"is_accepted":false,"ViewCount":45286,"Q_Id":859594,"Users Score":1,"Answer":"MacOS 10.5.8, Python 2.6, Eclipse+Pydev 1.5.7\n\nPython installation's site-package is, for example:\n\/Library\/Frameworks\/Python.framework\/Versions\/2.6\/lib\/python2.6\/site-packages\ncreate symlinks YOUR LIBRARY inside into site-package, for example:\ncd \/Library\/Frameworks\/Python.framework\/Versions\/2.6\/lib\/python2.6\/site-packages\nln -s \/path\/to\/YOUR\/LIBRARY\/ YOUR_LIBRARY_NAME\n\nNow You can use in commandline: import YOUR_LIBRARY_NAME \nrun Eclipse with Pydev, go to Preferences->Pydev->Interpreter Python\nremove Your Python interpreter record, if exists;\nclick New and add Python 2.6 interpreter path, for example:\n\/Library\/Frameworks\/Python.framework\/Versions\/2.6\/bin\/python2.6\n\nnotice, that Eclipse Pydev display Python System Library, accept that\nin Library section click New Folder and write path to YOUR LIBRARY, for example:\n\/path\/to\/YOUR\/LIBRARY\/\nclick Apply - it is essential, because Eclipse Pydev built now his own \"library map\", when this operation finish - click [OK]\nclose Eclipse\nrun Eclipse again - now You should use in Pydev: import YOUR_LIBRARY_NAME","Q_Score":12,"Tags":"python,windows,path","A_Id":3079003,"CreationDate":"2009-05-13T18:28:00.000","Title":"Can't find my 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":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to change my PYTHONPATH. I've tried to change it in \"My Computer\" etc, but it doesn't exist there. I searched in the registry in some places, and even ran a whole search for the word 'PYTHONPATH', but to no avail.\nHowever, it Python I can easily see it exists. So where is it?","AnswerCount":9,"Available Count":4,"Score":0.0,"is_accepted":false,"ViewCount":45286,"Q_Id":859594,"Users Score":0,"Answer":"I had same problem and oliver-zehentleitner's answer in github solved my problem.\nHe said: Maybe You install package with pip for python2 and run with python3, just try to install with pip3 or python3 -m pip install python-binance and then run your script again.\nI hope this can solve yours too.","Q_Score":12,"Tags":"python,windows,path","A_Id":67562437,"CreationDate":"2009-05-13T18:28:00.000","Title":"Can't find my 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":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm currently reading a great book called 'Programming Collective Intelligence' by Toby Segaran (which i highly recommend)\nThe code examples are all written in Python, and as I have already learnt one new language this year (graduating from VB.net to C#) i'm not keen to jump on another learning curve.\nThis leaves my with the issue of translating the python examples into C#. \nQuestion is: How critical is it that the code stay in python? Are there thing in python that I can't do in a normal managed statically typed language?","AnswerCount":6,"Available Count":3,"Score":0.0665680765,"is_accepted":false,"ViewCount":2273,"Q_Id":863253,"Users Score":2,"Answer":"I suggest translating them to C#. I have been porting chapter 2 \"Recommendations\" to VB.Net. Along the way I'm learning Python as a side-effect. Toby does some amazing things with Python lists.\nDealing with the the extra Python libraries is another story. Ndelicious is a close match to pyDelicious, but it is missing a few key features (popular posts!).","Q_Score":3,"Tags":"python,collective-intelligence","A_Id":986107,"CreationDate":"2009-05-14T13:11:00.000","Title":"Python and Collective Intelligence","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm currently reading a great book called 'Programming Collective Intelligence' by Toby Segaran (which i highly recommend)\nThe code examples are all written in Python, and as I have already learnt one new language this year (graduating from VB.net to C#) i'm not keen to jump on another learning curve.\nThis leaves my with the issue of translating the python examples into C#. \nQuestion is: How critical is it that the code stay in python? Are there thing in python that I can't do in a normal managed statically typed language?","AnswerCount":6,"Available Count":3,"Score":0.0333209931,"is_accepted":false,"ViewCount":2273,"Q_Id":863253,"Users Score":1,"Answer":"The book is about algorithms, not the details of programming, and the language of choice is just to make the examples concrete. As the author says, \"The code examples in this book are written in Python... but I provide explanations of all the algorithms so that programmers of other languages can follow.\" (p. xv)\nPython is a great language and easy to learn, but I suspect the difficulties in applying ideas from the book will not be in the translating of the code to another language or set of libraries, but in understanding the ideas and modifying the code to suite your needs. I think there are two main reasons to stay with a language you're familiar with: 1) when your code doesn't work, if you're writing in an unfamiliar language, you won't know where to start looking for errors, e.g. if you're like most people you'll even start wondering if it's due to a bug in Python, which it won't be, but you'll wonder and it will distract. 2) There are just natural limits to how much you can remember in a certain length of time; and learning a language at the same time will give you twice as much to remember.\nIt depends though how well you know C#, and what you lose by leaving it.","Q_Score":3,"Tags":"python,collective-intelligence","A_Id":863568,"CreationDate":"2009-05-14T13:11:00.000","Title":"Python and Collective Intelligence","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm currently reading a great book called 'Programming Collective Intelligence' by Toby Segaran (which i highly recommend)\nThe code examples are all written in Python, and as I have already learnt one new language this year (graduating from VB.net to C#) i'm not keen to jump on another learning curve.\nThis leaves my with the issue of translating the python examples into C#. \nQuestion is: How critical is it that the code stay in python? Are there thing in python that I can't do in a normal managed statically typed language?","AnswerCount":6,"Available Count":3,"Score":1.2,"is_accepted":true,"ViewCount":2273,"Q_Id":863253,"Users Score":20,"Answer":"One challenge you'll find is that not only are the algorithms implemented in Python, but the book makes extensive use of Python libraries like BeautifulSoup, Numpy, PIL, and others (see appendix A).\nI doubt there are any specifics of the algorithms that you couldn't port to another language, but you'll have trouble working through the exercises. Also, to translate the code, you'll have to learn Python at least a little bit, no? \nI suggest you just dive in and learn Python. You can use IronPython if you have any concern about interoperability with your C# projects.","Q_Score":3,"Tags":"python,collective-intelligence","A_Id":863292,"CreationDate":"2009-05-14T13:11:00.000","Title":"Python and Collective Intelligence","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm working on a Python program that makes heavy use of eggs (Plone). That means there are 198 directories full of Python code I might want to search through while debugging. Is there a good way to search only the .py files in only those directories, avoiding unrelated code and large binary files?","AnswerCount":12,"Available Count":3,"Score":0.0333209931,"is_accepted":false,"ViewCount":12967,"Q_Id":865382,"Users Score":2,"Answer":"And simply because there are not enough answers...\nIf you're developing routinely, it's well worth the effort to install Eclipse with Pydev (or even easier, Aptana Studio - which is a modified Eclipse), in which case the find tools are right there.","Q_Score":23,"Tags":"python,grep,plone,zope","A_Id":5189472,"CreationDate":"2009-05-14T19:58:00.000","Title":"How do you grep through code that lives in many different 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":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm working on a Python program that makes heavy use of eggs (Plone). That means there are 198 directories full of Python code I might want to search through while debugging. Is there a good way to search only the .py files in only those directories, avoiding unrelated code and large binary files?","AnswerCount":12,"Available Count":3,"Score":0.0665680765,"is_accepted":false,"ViewCount":12967,"Q_Id":865382,"Users Score":4,"Answer":"This problem was the motivation for the creation of collective.recipe.omelette. It is a buildout recipe which can symlink all the eggs from your working set into one directory structure, which you can point your favorite search utility at.","Q_Score":23,"Tags":"python,grep,plone,zope","A_Id":5131554,"CreationDate":"2009-05-14T19:58:00.000","Title":"How do you grep through code that lives in many different 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":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm working on a Python program that makes heavy use of eggs (Plone). That means there are 198 directories full of Python code I might want to search through while debugging. Is there a good way to search only the .py files in only those directories, avoiding unrelated code and large binary files?","AnswerCount":12,"Available Count":3,"Score":0.0333209931,"is_accepted":false,"ViewCount":12967,"Q_Id":865382,"Users Score":2,"Answer":"Just in case you want a non-commandline OSS solution...\nI use pycharm. It has built in support for buildout. You point it at a buildout generated bin\/instance and it sets the projects external dependencies to all the eggs used by the instance. Then all the IDE's introspection and code navigation work nicely. Goto definition, goto instances, refactoring support and of course search.","Q_Score":23,"Tags":"python,grep,plone,zope","A_Id":5131426,"CreationDate":"2009-05-14T19:58:00.000","Title":"How do you grep through code that lives in many different 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":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Why mod_python is oop but mod_php is not ?\nExample :We go to www.example.com\/dir1\/dir2\nif you use mod_python apache opens www\/dir1.py and calls dir2 method\nbut if you use php module apache opens www\/dir1\/dir2\/index.php","AnswerCount":6,"Available Count":5,"Score":0.1325487884,"is_accepted":false,"ViewCount":2975,"Q_Id":872695,"Users Score":4,"Answer":"I think you have some misconceptions about how HTTP works. Nothing in the http standard requires you to have a certain file as a resource. It is just the way how mod_php works, that for a given path, this path is translated to a php file on the disk of the server, which in turn is interpreted by the compiler.\nThe mod_python module on the other hand is much more generic, it allows you to map any resource to a call to some python object. It just happens that some configurations are available out of the box, to make it easier to start with. In most cases the dispatch of the url is managed by your framework, and how that works is up to the framework implementor.\nBecause of the generic nature of the mod_python module you are also able to access some apache features which are not available in the mod_php module, for instance you may write your own authentication handler, which my not only apply to your python webapp, but also to other apps in your apache as well.","Q_Score":4,"Tags":"php,python,mod-python","A_Id":872913,"CreationDate":"2009-05-16T16:01:00.000","Title":"mod_php vs mod_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},{"Question":"Why mod_python is oop but mod_php is not ?\nExample :We go to www.example.com\/dir1\/dir2\nif you use mod_python apache opens www\/dir1.py and calls dir2 method\nbut if you use php module apache opens www\/dir1\/dir2\/index.php","AnswerCount":6,"Available Count":5,"Score":-0.0333209931,"is_accepted":false,"ViewCount":2975,"Q_Id":872695,"Users Score":-1,"Answer":"Perhaps I misunderstand your question, but both Python and PHP support both procedural and object-oriented programming. (Though one could argue that Python's support for OO is the stronger of the two.)","Q_Score":4,"Tags":"php,python,mod-python","A_Id":872710,"CreationDate":"2009-05-16T16:01:00.000","Title":"mod_php vs mod_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},{"Question":"Why mod_python is oop but mod_php is not ?\nExample :We go to www.example.com\/dir1\/dir2\nif you use mod_python apache opens www\/dir1.py and calls dir2 method\nbut if you use php module apache opens www\/dir1\/dir2\/index.php","AnswerCount":6,"Available Count":5,"Score":0.0,"is_accepted":false,"ViewCount":2975,"Q_Id":872695,"Users Score":0,"Answer":"in PHP you can program your web pages the top-to-bottom scripts, procedural programming and function calls, OOP. this is the main reason why PHP was first created, and how it evolved. mod_php is just a module for web servers to utilize PHP as a preprocessor. so it just passes HTTP information and the PHP script to PHP interpreter.\nthe PHP way of web page creation is do what you want; write a top-to-bottom script, define functions in different files and include those and call functions, or write your app in OOP, you can also use many full-featured frameworks today to make sure your application design and structure meets today best practices and design patterns.\nI'm new to Python, and am not familiar with web programming with python. but as much as I know, python was not created to make web programming easier. it was intended to be a general purpose programming language, so although it might be possible to write simple top-to-bottom scripts in python and run them as web page responses (I'm not sure if such thing is possible), it is not the pythonic way, and so I think developers of the mod_python wanted web programming in python to be in a pythonic way.","Q_Score":4,"Tags":"php,python,mod-python","A_Id":873885,"CreationDate":"2009-05-16T16:01:00.000","Title":"mod_php vs mod_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},{"Question":"Why mod_python is oop but mod_php is not ?\nExample :We go to www.example.com\/dir1\/dir2\nif you use mod_python apache opens www\/dir1.py and calls dir2 method\nbut if you use php module apache opens www\/dir1\/dir2\/index.php","AnswerCount":6,"Available Count":5,"Score":1.2,"is_accepted":true,"ViewCount":2975,"Q_Id":872695,"Users Score":8,"Answer":"Let's talk about mod_python vs. mod_php.\nSince the Python language is NOT specifically designed for serving web pages, mod_python must do some additional work. \nSince the PHP language IS specifically designed to serve web pages, mod_php simply starts a named PHP module.\nIn the case of mod_python (different from mod_fastcgi or mod_wsgi), the designer of mod_python decided that the best way to invoke Python is to call a method of an object defined in a module. Hopefully, that method of that object will write the headers and web page content to stdout. \nIn the case of mod_wsgi, the designer decided that the best way to invoke Python is to call a function (or callable object) in a module. Hopefully that function will use the supplied object to create header and return a list strings with the web page content.\nIn the case of mod_php, they just invoke the module because PHP modules are designed to serve web pages. The program runs and the result of that run is a page of content; usually HTML.\nThe reason mod_php works one way, mod_python works another and mod_wsgi works a third way is because they're different. Written by different people with different definitions of the way to produce a web page. \nThe php page can be object-oriented. A mod_wsgi function may be a callable object or it may be a simplef unction. Those are design choices.\nThe mod_python requirement for a class is a design choice made by the designer of mod_python.\nThe reason \"why\" is never useful. The reason \"why\" is because someone decided to design it that way.","Q_Score":4,"Tags":"php,python,mod-python","A_Id":873822,"CreationDate":"2009-05-16T16:01:00.000","Title":"mod_php vs mod_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},{"Question":"Why mod_python is oop but mod_php is not ?\nExample :We go to www.example.com\/dir1\/dir2\nif you use mod_python apache opens www\/dir1.py and calls dir2 method\nbut if you use php module apache opens www\/dir1\/dir2\/index.php","AnswerCount":6,"Available Count":5,"Score":0.1325487884,"is_accepted":false,"ViewCount":2975,"Q_Id":872695,"Users Score":4,"Answer":"Because mod_python is abstracting the URL into a \"RPC-like\" mechanism. You can achieve the same in PHP. I always did it by hand, but I am pretty sure there are prepackaged pear modules for this.\nNote the mod_python behavior is not forcibly \"the best\". It all amounts to the type of design you want to give to your application, and how it behaves to the clients. As far as I see, the mod_python approach assumes that for every URL you have a function, like mapping the module structure into a URL tree. This is technically not a particularly nice approach, because there's a tight correlation between the technology you are using (mod_python) and the URL layout of your application.\nOn the reason why, theres' no reason. Some people like one food, and some other like another. Design is, in some cases, a matter of taste and artistic choices, not only technical restrains.","Q_Score":4,"Tags":"php,python,mod-python","A_Id":872824,"CreationDate":"2009-05-16T16:01:00.000","Title":"mod_php vs mod_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},{"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},{"Question":"Brand new to web design, using python. Got Apache up and running, test python script working in cgi-bin directory. Get valid results when I type in the URL explicitly: \"...\/cgi-bin\/showenv.py\"\nBut I don't want the URL to look that way. Here at stackoverflow, for example, the URLs that display in my address bar never have the messy details showing the script that was used to run them. They're clean of cgi-bin, .py, etc. extensions. How do I do that?\nEDIT: Thanks for responses, every single one helpful, lots to learn. I'm going with URL Rewriting for now; example in the docs looks extremely close to what I actually want to do. But I'm committed to python, so will have to look at WSGI down the road.","AnswerCount":6,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":10240,"Q_Id":882430,"Users Score":3,"Answer":"Just use some good web framework e.g. django and you can have such URLs\nmore than URLs you will have a better infrastructure, templates, db orm etc","Q_Score":13,"Tags":"python,cgi","A_Id":882444,"CreationDate":"2009-05-19T12:24:00.000","Title":"How to hide \"cgi-bin\", \".py\", etc from my URLs?","Data Science and Machine Learning":0,"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},{"Question":"I have a python cgi script that accepts user uploads (via sys.stdin.read).\nAfter receiving the file (whether successfully or unsuccessfully), the script needs to do some cleanup. This works fine when upload finishes correctly, however if the user closes the client, the cgi script is silently killed on the server, and as a result no cleanup code gets executed. How can i force the script to always finish.","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":1833,"Q_Id":886653,"Users Score":1,"Answer":"The script is probably not killed silently; you just don't see the exception which python throws. I suggest to wrap the whole script in try-except and write any exception to a log file.\nThis way, you can see what really happens. The logging module is your friend.","Q_Score":2,"Tags":"python,cgi","A_Id":886956,"CreationDate":"2009-05-20T07:44:00.000","Title":"Making a python cgi script to finish gracefully","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I'm trying to figure out Python lambdas. Is lambda one of those \"interesting\" language items that in real life should be forgotten?\nI'm sure there are some edge cases where it might be needed, but given the obscurity of it, the potential of it being redefined in future releases (my assumption based on the various definitions of it) and the reduced coding clarity - should it be avoided?\nThis reminds me of overflowing (buffer overflow) of C types - pointing to the top variable and overloading to set the other field values. It feels like sort of a techie showmanship but maintenance coder nightmare.","AnswerCount":26,"Available Count":6,"Score":1.0,"is_accepted":false,"ViewCount":576496,"Q_Id":890128,"Users Score":8,"Answer":"Lambdas are deeply linked to functional programming style in general. The idea that you can solve problems by applying a function to some data, and merging the results, is what google uses to implement most of its algorithms. \nPrograms written in functional programming style, are easily parallelized and hence are becoming more and more important with modern multi-core machines.\nSo in short, NO you should not forget them.","Q_Score":971,"Tags":"python,function,lambda,closures","A_Id":890156,"CreationDate":"2009-05-20T20:40:00.000","Title":"How are lambdas useful?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to figure out Python lambdas. Is lambda one of those \"interesting\" language items that in real life should be forgotten?\nI'm sure there are some edge cases where it might be needed, but given the obscurity of it, the potential of it being redefined in future releases (my assumption based on the various definitions of it) and the reduced coding clarity - should it be avoided?\nThis reminds me of overflowing (buffer overflow) of C types - pointing to the top variable and overloading to set the other field values. It feels like sort of a techie showmanship but maintenance coder nightmare.","AnswerCount":26,"Available Count":6,"Score":1.0,"is_accepted":false,"ViewCount":576496,"Q_Id":890128,"Users Score":6,"Answer":"I'm just beginning Python and ran head first into Lambda- which took me a while to figure out.\n\nNote that this isn't a condemnation of anything. Everybody has a different set of things that don't come easily.\n\nIs lambda one of those 'interesting' language items that in real life should be forgotten?\n\nNo.\n\nI'm sure there are some edge cases where it might be needed, but given the obscurity of it,\n\nIt's not obscure. The past 2 teams I've worked on, everybody used this feature all the time.\n\nthe potential of it being redefined in future releases (my assumption based on the various definitions of it)\n\nI've seen no serious proposals to redefine it in Python, beyond fixing the closure semantics a few years ago.\n\nand the reduced coding clarity - should it be avoided?\n\nIt's not less clear, if you're using it right. On the contrary, having more language constructs available increases clarity.\n\nThis reminds me of overflowing (buffer overflow) of C types - pointing to the top variable and overloading to set the other field values...sort of a techie showmanship but maintenance coder nightmare..\n\nLambda is like buffer overflow? Wow. I can't imagine how you're using lambda if you think it's a \"maintenance nightmare\".","Q_Score":971,"Tags":"python,function,lambda,closures","A_Id":890217,"CreationDate":"2009-05-20T20:40:00.000","Title":"How are lambdas useful?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to figure out Python lambdas. Is lambda one of those \"interesting\" language items that in real life should be forgotten?\nI'm sure there are some edge cases where it might be needed, but given the obscurity of it, the potential of it being redefined in future releases (my assumption based on the various definitions of it) and the reduced coding clarity - should it be avoided?\nThis reminds me of overflowing (buffer overflow) of C types - pointing to the top variable and overloading to set the other field values. It feels like sort of a techie showmanship but maintenance coder nightmare.","AnswerCount":26,"Available Count":6,"Score":1.0,"is_accepted":false,"ViewCount":576496,"Q_Id":890128,"Users Score":26,"Answer":"Pretty much anything you can do with lambda you can do better with either named functions or list and generator expressions.\nConsequently, for the most part you should just one of those in basically any situation (except maybe for scratch code written in the interactive interpreter).","Q_Score":971,"Tags":"python,function,lambda,closures","A_Id":890151,"CreationDate":"2009-05-20T20:40:00.000","Title":"How are lambdas useful?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to figure out Python lambdas. Is lambda one of those \"interesting\" language items that in real life should be forgotten?\nI'm sure there are some edge cases where it might be needed, but given the obscurity of it, the potential of it being redefined in future releases (my assumption based on the various definitions of it) and the reduced coding clarity - should it be avoided?\nThis reminds me of overflowing (buffer overflow) of C types - pointing to the top variable and overloading to set the other field values. It feels like sort of a techie showmanship but maintenance coder nightmare.","AnswerCount":26,"Available Count":6,"Score":0.0153834017,"is_accepted":false,"ViewCount":576496,"Q_Id":890128,"Users Score":2,"Answer":"Lambda is a procedure constructor. You can synthesize programs at run-time, although Python's lambda is not very powerful. Note that few people understand that kind of programming.","Q_Score":971,"Tags":"python,function,lambda,closures","A_Id":890192,"CreationDate":"2009-05-20T20:40:00.000","Title":"How are lambdas useful?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to figure out Python lambdas. Is lambda one of those \"interesting\" language items that in real life should be forgotten?\nI'm sure there are some edge cases where it might be needed, but given the obscurity of it, the potential of it being redefined in future releases (my assumption based on the various definitions of it) and the reduced coding clarity - should it be avoided?\nThis reminds me of overflowing (buffer overflow) of C types - pointing to the top variable and overloading to set the other field values. It feels like sort of a techie showmanship but maintenance coder nightmare.","AnswerCount":26,"Available Count":6,"Score":0.0384425844,"is_accepted":false,"ViewCount":576496,"Q_Id":890128,"Users Score":5,"Answer":"I started reading David Mertz's book today 'Text Processing in Python.' While he has a fairly terse description of Lambda's the examples in the first chapter combined with the explanation in Appendix A made them jump off the page for me (finally) and all of a sudden I understood their value. That is not to say his explanation will work for you and I am still at the discovery stage so I will not attempt to add to these responses other than the following:\nI am new to Python\nI am new to OOP\nLambdas were a struggle for me\nNow that I read Mertz, I think I get them and I see them as very useful as I think they allow a cleaner approach to programming. \nHe reproduces the Zen of Python, one line of which is Simple is better than complex. As a non-OOP programmer reading code with lambdas (and until last week list comprehensions) I have thought-This is simple?. I finally realized today that actually these features make the code much more readable, and understandable than the alternative-which is invariably a loop of some sort. I also realized that like financial statements-Python was not designed for the novice user, rather it is designed for the user that wants to get educated. I can't believe how powerful this language is. When it dawned on me (finally) the purpose and value of lambdas I wanted to rip up about 30 programs and start over putting in lambdas where appropriate.","Q_Score":971,"Tags":"python,function,lambda,closures","A_Id":890997,"CreationDate":"2009-05-20T20:40:00.000","Title":"How are lambdas useful?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to figure out Python lambdas. Is lambda one of those \"interesting\" language items that in real life should be forgotten?\nI'm sure there are some edge cases where it might be needed, but given the obscurity of it, the potential of it being redefined in future releases (my assumption based on the various definitions of it) and the reduced coding clarity - should it be avoided?\nThis reminds me of overflowing (buffer overflow) of C types - pointing to the top variable and overloading to set the other field values. It feels like sort of a techie showmanship but maintenance coder nightmare.","AnswerCount":26,"Available Count":6,"Score":1.0,"is_accepted":false,"ViewCount":576496,"Q_Id":890128,"Users Score":11,"Answer":"As stated above, the lambda operator in Python defines an anonymous function, and in Python functions are closures. It is important not to confuse the concept of closures with the operator lambda, which is merely syntactic methadone for them.\nWhen I started in Python a few years ago, I used lambdas a lot, thinking they were cool, along with list comprehensions. However, I wrote and have to maintain a big website written in Python, with on the order of several thousand function points. I've learnt from experience that lambdas might be OK to prototype things with, but offer nothing over inline functions (named closures) except for saving a few key-stokes, or sometimes not.\nBasically this boils down to several points:\n\nit is easier to read software that is explicitly written using meaningful names. Anonymous closures by definition cannot have a meaningful name, as they have no name. This brevity seems, for some reason, to also infect lambda parameters, hence we often see examples like lambda x: x+1 \nit is easier to reuse named closures, as they can be referred to by name more than once, when there is a name to refer to them by.\nit is easier to debug code that is using named closures instead of lambdas, because the name will appear in tracebacks, and around the error.\n\nThat's enough reason to round them up and convert them to named closures. However, I hold two other grudges against anonymous closures.\nThe first grudge is simply that they are just another unnecessary keyword cluttering up the language.\nThe second grudge is deeper and on the paradigm level, i.e. I do not like that they promote a functional-programming style, because that style is less flexible than the message passing, object oriented or procedural styles, because the lambda calculus is not Turing-complete (luckily in Python, we can still break out of that restriction even inside a lambda). The reasons I feel lambdas promote this style are:\n\nThere is an implicit return, i.e. they seem like they 'should' be functions.\nThey are an alternative state-hiding mechanism to another, more explicit, more readable, more reusable and more general mechanism: methods.\n\nI try hard to write lambda-free Python, and remove lambdas on sight. I think Python would be a slightly better language without lambdas, but that's just my opinion.","Q_Score":971,"Tags":"python,function,lambda,closures","A_Id":3961969,"CreationDate":"2009-05-20T20:40:00.000","Title":"How are lambdas useful?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Can anyone share some pointers on building a Donations module for Satchmo? I'm comfortable customizing Satchmo's product models etc but unable to find anything related to Donations\nI realize it's possible to create a Donations virtual product but as far as I can tell this still requires setting the amount beforehand ($5, $10 etc). I want users to be able to donate arbitrary amounts","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":253,"Q_Id":891934,"Users Score":3,"Answer":"It looks like the satchmo_cart_details_query signal is the way to go about doing this. It allows you to add a price change value (in my case, donation amount) to a cart item\nI'll post the full solution if anyone is interested","Q_Score":2,"Tags":"python,django,e-commerce,satchmo","A_Id":901050,"CreationDate":"2009-05-21T08:46:00.000","Title":"Satchmo donations","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"buildin an smtp client in python . which can send mail , and also show that mail has been received through any mail service for example gmail !!","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":769,"Q_Id":892196,"Users Score":0,"Answer":"Depends what you mean by \"received\". It's possible to verify \"delivery\" of a message to a server but there is no 100% reliable guarantee it actually ended up in a mailbox. smtplib will throw an exception on certain conditions (like the remote end reporting user not found) but just as often the remote end will accept the mail and then either filter it or send a bounce notice at a later time.","Q_Score":0,"Tags":"python,smtp","A_Id":892264,"CreationDate":"2009-05-21T10:04:00.000","Title":"How would one build an smtp client 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},{"Question":"Assuming the webserver is configured to handle .exe, Can i compile a python CGI file into an exe for speed. What would some pros and cons be to such a desession?","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":712,"Q_Id":895163,"Users Score":0,"Answer":"Since the RDBMS and the network are the bottlenecks, I see no value in fussing around creating an EXE. \nOn average, most of a web site's transfers are static content (images, .CSS, .JS, etc.) which is best handled by Apache without any Python in the loop. This has huge impact.\nReserve Python for the \"interesting\" and \"complex\" parts of creating the dynamic HTML. Use a framework.","Q_Score":0,"Tags":"python","A_Id":895181,"CreationDate":"2009-05-21T21:06:00.000","Title":"Compiled 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":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Assuming the webserver is configured to handle .exe, Can i compile a python CGI file into an exe for speed. What would some pros and cons be to such a desession?","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":712,"Q_Id":895163,"Users Score":1,"Answer":"You probably don't want to run Python as a CGI if you want it fast. Look at proxies, mod_python, WSGI or FastCGI, as those techinques avoid re-loading python runtime and your app on each request.","Q_Score":0,"Tags":"python","A_Id":895211,"CreationDate":"2009-05-21T21:06:00.000","Title":"Compiled 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":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"How do I set up module imports so that each module can access the objects of all the others?\nI have a medium size Python application with modules files in various subdirectories. I have created modules that append these subdirectories to sys.path and imports a group of modules, using import thisModule as tm. Module objects are referred to with that qualification. I then import that module into the others with from moduleImports import *. The code is sloppy right now and has several of these things, which are often duplicative.\nFirst, the application is failing because some module references aren't assigned. This same code does run when unit tested.\nSecond, I'm worried that I'm causing a problem with recursive module imports. Importing moduleImports imports thisModule, which imports moduleImports . . . .\nWhat is the right way to do this?","AnswerCount":4,"Available Count":3,"Score":0.1488850336,"is_accepted":false,"ViewCount":16427,"Q_Id":896112,"Users Score":3,"Answer":"You won't get recursion on imports because Python caches each module and won't reload one it already has.","Q_Score":11,"Tags":"python,python-import","A_Id":896128,"CreationDate":"2009-05-22T02:09:00.000","Title":"Properly importing modules 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},{"Question":"How do I set up module imports so that each module can access the objects of all the others?\nI have a medium size Python application with modules files in various subdirectories. I have created modules that append these subdirectories to sys.path and imports a group of modules, using import thisModule as tm. Module objects are referred to with that qualification. I then import that module into the others with from moduleImports import *. The code is sloppy right now and has several of these things, which are often duplicative.\nFirst, the application is failing because some module references aren't assigned. This same code does run when unit tested.\nSecond, I'm worried that I'm causing a problem with recursive module imports. Importing moduleImports imports thisModule, which imports moduleImports . . . .\nWhat is the right way to do this?","AnswerCount":4,"Available Count":3,"Score":1.0,"is_accepted":false,"ViewCount":16427,"Q_Id":896112,"Users Score":6,"Answer":"Few pointers\n\nYou may have already split\nfunctionality in various module. If\ncorrectly done most of the time you\nwill not fall into circular import\nproblems (e.g. if module a depends\non b and b on a you can make a third\nmodule c to remove such circular\ndependency). As last resort, in a\nimport b but in b import a at the\npoint where a is needed e.g. inside\nfunction.\nOnce functionality is properly in\nmodules group them in packages under\na subdir and add a __init__.py file\nto it so that you can import the\npackage. Keep such pakages in a\nfolder e.g. lib and then either add\nto sys.path or set PYTHONPATH env\nvariable\nfrom module import * may not\nbe good idea. Instead, import whatever\nis needed. It may be fully qualified. It\ndoesn't hurt to be verbose. e.g.\nfrom pakageA.moduleB import\nCoolClass.","Q_Score":11,"Tags":"python,python-import","A_Id":896137,"CreationDate":"2009-05-22T02:09:00.000","Title":"Properly importing modules 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},{"Question":"How do I set up module imports so that each module can access the objects of all the others?\nI have a medium size Python application with modules files in various subdirectories. I have created modules that append these subdirectories to sys.path and imports a group of modules, using import thisModule as tm. Module objects are referred to with that qualification. I then import that module into the others with from moduleImports import *. The code is sloppy right now and has several of these things, which are often duplicative.\nFirst, the application is failing because some module references aren't assigned. This same code does run when unit tested.\nSecond, I'm worried that I'm causing a problem with recursive module imports. Importing moduleImports imports thisModule, which imports moduleImports . . . .\nWhat is the right way to do this?","AnswerCount":4,"Available Count":3,"Score":0.1973753202,"is_accepted":false,"ViewCount":16427,"Q_Id":896112,"Users Score":4,"Answer":"The way to do this is to avoid magic. In other words, if your module requires something from another module, it should import it explicitly. You shouldn't rely on things being imported automatically.\nAs the Zen of Python (import this) has it, explicit is better than implicit.","Q_Score":11,"Tags":"python,python-import","A_Id":897001,"CreationDate":"2009-05-22T02:09:00.000","Title":"Properly importing modules 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},{"Question":"It seems that IronPython 2.0.1 executes a script file about 3x slower than IronPython 1.x.\nI'm not convinced that it isn't something I'm doing so I'm wondering if others have had a similar experience. \nI have a 200k python script that takes 5 seconds to execute from a file on IP 1.x and nearly 18 seconds in IP 2.0.1!","AnswerCount":4,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":441,"Q_Id":898993,"Users Score":0,"Answer":"Does your timings include startup time?\nIronPython 2.6 Beta has radical improvements to startup time and code compilation\/execution. Suggest you try that release if you can.\nCheers,\nDavy","Q_Score":0,"Tags":"ironpython","A_Id":924632,"CreationDate":"2009-05-22T17:25:00.000","Title":"IronPython 2.0 executes code slowly","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"Following on my previous question, if I have some hosting how can I put a python script on their that I can then run from there? Do I need to do something special to run it\/install something?\nEDIT-Clarification-I would like to be able to upload the script which does stuff on the internet-no data is stored on my computer. I then need to schedule it to run once a day.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":243,"Q_Id":905902,"Users Score":0,"Answer":"Usually python is already installed, but it depends on your hoster. Ask them.","Q_Score":0,"Tags":"python,hosting","A_Id":905924,"CreationDate":"2009-05-25T08:42:00.000","Title":"Storing Python scripts on a 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":0,"Web Development":0},{"Question":"Following on my previous question, if I have some hosting how can I put a python script on their that I can then run from there? Do I need to do something special to run it\/install something?\nEDIT-Clarification-I would like to be able to upload the script which does stuff on the internet-no data is stored on my computer. I then need to schedule it to run once a day.","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":243,"Q_Id":905902,"Users Score":1,"Answer":"You have to ensure your hoster system supports Python.\nYou can ask them about that.\nTo run the script once it is there, you can act in several ways, depending on what you want to do.\nYou can have your server side language to invoke it (i.e. from the backend of a web page), or if you have a shell access to the machine you can invoke it manually.\nBtw, very often hosting providers give a scheduling tool (i.e. an interface for crontab or at) via the hosting plan administration panel, which you could use to start your script. \nFirst thing, anyway, you have to ask your hoster and check Python availability.","Q_Score":0,"Tags":"python,hosting","A_Id":906016,"CreationDate":"2009-05-25T08:42:00.000","Title":"Storing Python scripts on a 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":0,"Web Development":0},{"Question":"I have an application written in python. I created a plugin system for the application that uses egg files. Egg files contain compiled python files and can be easily decompiled and used to hack the application. Is there a way to secure this system? I'd like to use digital signature for this - sign these egg files and check the signature before loading such egg file. Is there a way to do this programmatically from python? Maybe using winapi?","AnswerCount":2,"Available Count":1,"Score":0.2913126125,"is_accepted":false,"ViewCount":1311,"Q_Id":908285,"Users Score":3,"Answer":"Is there a way to secure this system?\n\nThe answer is \"that depends\".\nThe two questions you should ask is \"what are people supposed to be able to do\" and \"what are people able to do (for a given implementation)\". If there exists an implementation where the latter is a subset of the former, the system can be secured.\nOne of my friend is working on a programming competition judge: a program which runs a user-submitted program on some test data and compares its output to a reference output. That's damn hard to secure: you want to run other peoples' code, but you don't want to let them run arbitrary code. Is your scenario somewhat similar to this? Then the answer is \"it's difficult\".\nDo you want users to download untrustworthy code from the web and run it with some assurance that it won't hose their machine? Then look at various web languages. One solution is not offering access to system calls (JavaScript) or offering limited access to certain potentially dangerous calls (Java's SecurityManager). None of them can be done in python as far as I'm aware, but you can always hack the interpreter and disallow the loading of external modules not on some whitelist. This is probably error-prone.\nDo you want users to write plugins, and not be able to tinker with what the main body of code in your application does? Consider that users can decompile .pyc files and modify them. Assume that those running your code can always modify it, and consider the gold-farming bots for WoW.\nOne Linux-only solution, similar to the sandboxed web-ish model, is to use AppArmor, which limits which files your app can access and which system calls it can make. This might be a feasible solution, but I don't know much about it so I can't give you advice other than \"investigate\".\nIf all you worry about is evil people modifying code while it's in transit in the intertubes, standard cryptographic solutions exist (SSL). If you want to only load signed plugins (because you want to control what the users do?), signing code sounds like the right solution (but beware of crafty users or evil people who edit the .pyc files and disables the is-it-signed check).","Q_Score":2,"Tags":"python,plugins,signing","A_Id":908846,"CreationDate":"2009-05-25T22:39:00.000","Title":"Secure plugin system for python 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},{"Question":"Good afternoon,\nI would ask some suggestion about the best way to monitor events over the serial port.\nI'm using PySerial to write \"commands\" over the serial port towards some devices and\nI would like to receive feedback about the status of this devices.\nWich is the best way: 1) fullfill a pipe and read into, 2) a new thread delegated to read only, or what?\nCan I also ask for a simple code to implement the solution?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":6847,"Q_Id":911089,"Users Score":3,"Answer":"For general tips on working with pyserial, look at the search S.Lott suggested in the comment.\nRegarding the best strategy to implement your application - it all depends on how your protocols are defined. Do the devices immediately respond to queries? Or do they continually send data that must be monitored? This is important to define, as it certainly affects the way you'll want to handle the communication.\nGenerally, I've found it simple and stable to have a separate thread reading everything from the serial port and just pumping the data into a Queue. The main application logic then can query this queue whenever it needs to and read the data.","Q_Score":2,"Tags":"python,pyserial","A_Id":911772,"CreationDate":"2009-05-26T14:46:00.000","Title":"python monitoring over serial port","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"While it is fairly trivial in Python to import a \"child\" module into another module and list its attributes, it becomes slightly more difficult when you want to import all child modules.\nI'm building a library of tools for an existing 3D application. Each tool has its own menu item and sub menus. I'd like the tool to be responsible for creating its own menus as many of them change based on context and templates. I'd like my base module to be able to find all child modules and check for a create_menu() function and call it if it finds it.\nWhat is the easiest way to discover all child modules?","AnswerCount":6,"Available Count":1,"Score":0.0333209931,"is_accepted":false,"ViewCount":6221,"Q_Id":912025,"Users Score":1,"Answer":"The solution above traversing the filesystem for finding submodules is ok as long as you implement every plugin as a filesystem based module.\nA more flexible way would be an explicit plugin list in your main module, and have every plugin (whether a module created by file, dynamically, or even instance of a class) adding itself to that list explicitly. Maybe via a registerPlugin function.\nRemember: \"explicit is better than implicit\" is part of the zen of python.","Q_Score":13,"Tags":"python,module,package,python-import","A_Id":7338242,"CreationDate":"2009-05-26T18:25:00.000","Title":"How to find all child modules 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},{"Question":"I'm migrating a legacy codebase at work from python 2.4 to python 2.6. This is being done as part of a push to remove the 'legacy' tag and make a maintainable, extensible foundation for active development, so I'm getting a chance to \"do things right\", including refactoring to use new 2.6 features if that leads to cleaner, more robust code. (I'm already in raptures over the 'with' statement :)). Any good tips for the migration? Best practices, design patterns, etc? I'm mostly a ruby programmer; I've learnt some python 2.4 while working with this code but know nothing about modern python design principles, so feel free to suggest things that you might think are obvious.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":3565,"Q_Id":915135,"Users Score":5,"Answer":"Read the Python 3.0 changes. The point of 2.6 is to aim for 3.0.\nFrom 2.4 to 2.6 you gained a lot of things. These are the the most important. I'm making this answer community wiki so other folks can edit it.\n\nGenerator functions and the yield statement.\nMore consistent use of various types like list and dict -- they can be extended directly.\nfrom __future__ import with_statement\nfrom __future__ import print_function\nExceptions are new style classes, and there's more consistent exception handling. String exceptions have been removed. Attempting to use them raises a TypeError","Q_Score":4,"Tags":"python","A_Id":915195,"CreationDate":"2009-05-27T11:03:00.000","Title":"Migrating from python 2.4 to python 2.6","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm basically wondering if Python has any OOP shortcomings like PHP does. PHP has been developing their OOP practices for the last few versions. It's getting better in PHP but it's still not perfect. I'm new to Python and I'm just wondering if Python's OOP support is better or just comparable. \nIf there are some issues in Python OOP which don't follow proper OOP practices I would definitely like to know those. PHP for instance, doesn't allow for multiple inheritance as far as I'm aware. \nThanks Everyone!\nEdit:\nHow about support for Public and Private? or support of variable types. I think these are important regarding building OOP software.","AnswerCount":6,"Available Count":4,"Score":1.0,"is_accepted":false,"ViewCount":3813,"Q_Id":916962,"Users Score":8,"Answer":"Python's OOP support is very strong; it does allow multiple inheritance, and everything is manipulable as a first-class object (including classes, methods, etc). \nPolymorphism is expressed through duck typing. For example, you can iterate over a list, a tuple, a dictionary, a file, a web resource, and more all in the same way.\nThere are a lot of little pedantic things that are debatably not OO, like getting the length of a sequence with len(list) rather than list.len(), but it's best not to worry about them.","Q_Score":17,"Tags":"php,python,oop,comparison","A_Id":917005,"CreationDate":"2009-05-27T17:09:00.000","Title":"How does Python OOP compare to PHP OOP?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm basically wondering if Python has any OOP shortcomings like PHP does. PHP has been developing their OOP practices for the last few versions. It's getting better in PHP but it's still not perfect. I'm new to Python and I'm just wondering if Python's OOP support is better or just comparable. \nIf there are some issues in Python OOP which don't follow proper OOP practices I would definitely like to know those. PHP for instance, doesn't allow for multiple inheritance as far as I'm aware. \nThanks Everyone!\nEdit:\nHow about support for Public and Private? or support of variable types. I think these are important regarding building OOP software.","AnswerCount":6,"Available Count":4,"Score":1.2,"is_accepted":true,"ViewCount":3813,"Q_Id":916962,"Users Score":20,"Answer":"I would say that Python's OOP support is much better given the fact that it was introduced into the language in its infancy as opposed to PHP which bolted OOP onto an existing procedural model.","Q_Score":17,"Tags":"php,python,oop,comparison","A_Id":916974,"CreationDate":"2009-05-27T17:09:00.000","Title":"How does Python OOP compare to PHP OOP?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm basically wondering if Python has any OOP shortcomings like PHP does. PHP has been developing their OOP practices for the last few versions. It's getting better in PHP but it's still not perfect. I'm new to Python and I'm just wondering if Python's OOP support is better or just comparable. \nIf there are some issues in Python OOP which don't follow proper OOP practices I would definitely like to know those. PHP for instance, doesn't allow for multiple inheritance as far as I'm aware. \nThanks Everyone!\nEdit:\nHow about support for Public and Private? or support of variable types. I think these are important regarding building OOP software.","AnswerCount":6,"Available Count":4,"Score":0.0996679946,"is_accepted":false,"ViewCount":3813,"Q_Id":916962,"Users Score":3,"Answer":"Also: Python has native operator overloading, unlike PHP (although it does exist an extension). Love it or hate it, it's there.","Q_Score":17,"Tags":"php,python,oop,comparison","A_Id":917052,"CreationDate":"2009-05-27T17:09:00.000","Title":"How does Python OOP compare to PHP OOP?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm basically wondering if Python has any OOP shortcomings like PHP does. PHP has been developing their OOP practices for the last few versions. It's getting better in PHP but it's still not perfect. I'm new to Python and I'm just wondering if Python's OOP support is better or just comparable. \nIf there are some issues in Python OOP which don't follow proper OOP practices I would definitely like to know those. PHP for instance, doesn't allow for multiple inheritance as far as I'm aware. \nThanks Everyone!\nEdit:\nHow about support for Public and Private? or support of variable types. I think these are important regarding building OOP software.","AnswerCount":6,"Available Count":4,"Score":0.0333209931,"is_accepted":false,"ViewCount":3813,"Q_Id":916962,"Users Score":1,"Answer":"If you are looking for \"more pure\" OOP, you should be looking at SmallTalk and\/or Ruby.\nPHP has grown considerably with it's support for OOP, but because of the way it works (reloads everything every time), things can get really slow if OOP best practices are followed. Which is one of the reasons you don't hear about PHP on Rails much.","Q_Score":17,"Tags":"php,python,oop,comparison","A_Id":917054,"CreationDate":"2009-05-27T17:09:00.000","Title":"How does Python OOP compare to PHP OOP?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"How do I read back all of the cookies in Python without knowing their names?","AnswerCount":4,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":43214,"Q_Id":921532,"Users Score":4,"Answer":"Look at the Cookie: headers in the HTTP response you get, parse their contents with module Cookie in the standard library.","Q_Score":20,"Tags":"python,cookies","A_Id":921544,"CreationDate":"2009-05-28T15:35:00.000","Title":"Retrieving all Cookies 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},{"Question":"Is it possible to run \"paster shell blah.ini\" (or a variant thereof) and have it automatically load certain libraries?\nI hate having to always type \"from foo.bar import mystuff\" as the first command in every paster shell, and would like the computer to do it for me.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1107,"Q_Id":922351,"Users Score":0,"Answer":"If you set the environment variable PYTHONSTARTUP to the name of a file, it will execute that file on opening the interactive prompt.\nI don't know anything about paster shell, but I assume it works similarly.\nAlternatively you could look into iPython, which has much more powerful features (particularly when installed with the readline library). For example %run allows you to run a script in the current namespace, or you can use history completion.\nEdit:\nOkay. Having looked into it a bit more, I'm fairly certain that paster shell just does a set of useful imports, and could be easily replicated with a short script and ipython and then %run myscript.py\nEdit:\nHaving looked at the source, it would be very hard to do (I was wrong about the default imports. It parses your config file as well), however if you have Pylons and iPython both installed, then paster shell should use iPython automagically. Double check that both are installed properly, and double check that paster shell isn't using iPython already (it might be looking like normal python prompt).","Q_Score":5,"Tags":"python,pylons,paster","A_Id":980897,"CreationDate":"2009-05-28T18:01:00.000","Title":"Is it possible to launch a Paster shell with some modules pre-imported?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I'm am trying to roll out a test application to test the feasibility of righting a Click Once Smart Client app that also uses a rules engine customizable by embedding IronPython.\nSo far all users but me get this error (below) when invoking the script engine.\nDo I need to do something special to force deployment of the IronPython and Scripting assemblies? I thought that would be automatic because they were referenced in my project.\nIs this just not feasible in .NET 2.0? \nThoughts?\n\n************** Exception Text **************\nSystem.MissingMethodException: Method not found: 'Void System.Reflection.Emit.DynamicMethod..ctor(System.String, System.Type, System.Type[], Boolean)'.\n at Microsoft.Scripting.Utils.Helpers.CreateDynamicMethod(String name, Type returnType, Type[] parameterTypes)\n at Microsoft.Linq.Expressions.Compiler.Snippets.CreateDynamicMethod(String name, Type returnType, Type[] parameterTypes)\n at Microsoft.Linq.Expressions.Compiler.LambdaCompiler.CreateDynamicLambdaCompiler(CompilerScope scope, String methodName, Type returnType, IList`1 paramTypes, IList`1 paramNames, Boolean closure, Boolean emitDebugSymbols, Boolean forceDynamic)\n at Microsoft.Linq.Expressions.Compiler.LambdaCompiler.CompileLambda(LambdaExpression lambda, Type delegateType, Boolean emitDebugSymbols, Boolean forceDynamic, MethodInfo& method)\n at Microsoft.Linq.Expressions.Compiler.LambdaCompiler.CompileLambda[T](LambdaExpression lambda, Boolean emitDebugSymbols)\n at Microsoft.Linq.Expressions.LambdaExpression.Compile[T](Boolean emitDebugSymbols)\n at Microsoft.Scripting.Runtime.OptimizedScriptCode.InvokeTarget(LambdaExpression code, Scope scope)\n at Microsoft.Scripting.SourceUnit.Execute(Scope scope, ErrorSink errorSink)\n at Microsoft.Scripting.Hosting.ScriptSource.Execute(ScriptScope scope)\n at UAP.UI.Form1.button1_Click(Object sender, EventArgs e)\n at System.Windows.Forms.Control.OnClick(EventArgs e)\n at System.Windows.Forms.Button.OnClick(EventArgs e)\n at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)\n at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)\n at System.Windows.Forms.Control.WndProc(Message& m)\n at System.Windows.Forms.ButtonBase.WndProc(Message& m)\n at System.Windows.Forms.Button.WndProc(Message& m)\n at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)\n at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)\n at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":1241,"Q_Id":922681,"Users Score":0,"Answer":"If you right click your project and go to Properties theres a Publish tab, that allows you to specify prerequisite installs for your application.\nPresumably you can supply a path to the IronPython install executable here.","Q_Score":2,"Tags":"c#,.net,scripting,ironpython","A_Id":922701,"CreationDate":"2009-05-28T19:14:00.000","Title":"IronPython, Click Once, .NET 2.0 Error - thoughts?","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},{"Question":"I'm am trying to roll out a test application to test the feasibility of righting a Click Once Smart Client app that also uses a rules engine customizable by embedding IronPython.\nSo far all users but me get this error (below) when invoking the script engine.\nDo I need to do something special to force deployment of the IronPython and Scripting assemblies? I thought that would be automatic because they were referenced in my project.\nIs this just not feasible in .NET 2.0? \nThoughts?\n\n************** Exception Text **************\nSystem.MissingMethodException: Method not found: 'Void System.Reflection.Emit.DynamicMethod..ctor(System.String, System.Type, System.Type[], Boolean)'.\n at Microsoft.Scripting.Utils.Helpers.CreateDynamicMethod(String name, Type returnType, Type[] parameterTypes)\n at Microsoft.Linq.Expressions.Compiler.Snippets.CreateDynamicMethod(String name, Type returnType, Type[] parameterTypes)\n at Microsoft.Linq.Expressions.Compiler.LambdaCompiler.CreateDynamicLambdaCompiler(CompilerScope scope, String methodName, Type returnType, IList`1 paramTypes, IList`1 paramNames, Boolean closure, Boolean emitDebugSymbols, Boolean forceDynamic)\n at Microsoft.Linq.Expressions.Compiler.LambdaCompiler.CompileLambda(LambdaExpression lambda, Type delegateType, Boolean emitDebugSymbols, Boolean forceDynamic, MethodInfo& method)\n at Microsoft.Linq.Expressions.Compiler.LambdaCompiler.CompileLambda[T](LambdaExpression lambda, Boolean emitDebugSymbols)\n at Microsoft.Linq.Expressions.LambdaExpression.Compile[T](Boolean emitDebugSymbols)\n at Microsoft.Scripting.Runtime.OptimizedScriptCode.InvokeTarget(LambdaExpression code, Scope scope)\n at Microsoft.Scripting.SourceUnit.Execute(Scope scope, ErrorSink errorSink)\n at Microsoft.Scripting.Hosting.ScriptSource.Execute(ScriptScope scope)\n at UAP.UI.Form1.button1_Click(Object sender, EventArgs e)\n at System.Windows.Forms.Control.OnClick(EventArgs e)\n at System.Windows.Forms.Button.OnClick(EventArgs e)\n at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)\n at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)\n at System.Windows.Forms.Control.WndProc(Message& m)\n at System.Windows.Forms.ButtonBase.WndProc(Message& m)\n at System.Windows.Forms.Button.WndProc(Message& m)\n at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)\n at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)\n at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)","AnswerCount":2,"Available Count":2,"Score":0.3799489623,"is_accepted":false,"ViewCount":1241,"Q_Id":922681,"Users Score":4,"Answer":"IronPython requiers .NET 2.0SP1 or later to run. This exception is happening due to an overload that was added in SP1.","Q_Score":2,"Tags":"c#,.net,scripting,ironpython","A_Id":923395,"CreationDate":"2009-05-28T19:14:00.000","Title":"IronPython, Click Once, .NET 2.0 Error - thoughts?","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},{"Question":"Does anyone know of a syntax highlight for Mako templates for Eclipse or for TextMate?\nI know that there is a .mako syntax highlighter for the default text editor in Ubuntu.","AnswerCount":7,"Available Count":3,"Score":0.057080742,"is_accepted":false,"ViewCount":5178,"Q_Id":922771,"Users Score":2,"Answer":"What I ended up doing was naming my Mako Templates with .html suffix and thus getting the usual HTML syntax highlighting etc. that I am used to. Alternatively I could have associated .mako suffix with the HTML handler. While this does not address Mako specifically, it was enough for me, since I find most of the template is plain HTML anyway.","Q_Score":12,"Tags":"python,templates,mako","A_Id":923030,"CreationDate":"2009-05-28T19:34:00.000","Title":"Syntax Highlight for Mako in Eclipse or TextMate?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"Does anyone know of a syntax highlight for Mako templates for Eclipse or for TextMate?\nI know that there is a .mako syntax highlighter for the default text editor in Ubuntu.","AnswerCount":7,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":5178,"Q_Id":922771,"Users Score":0,"Answer":"Windows (menu) > Preference > General > Editor > File Associations\nAdd *.mako in File Types (upper box) and add Html editor in Associated editor (lower box)\nWindows (menu) > Preference > General > Editor > Content Types\n\nUnder Text find HTML and add *.mako in File associations.","Q_Score":12,"Tags":"python,templates,mako","A_Id":30838894,"CreationDate":"2009-05-28T19:34:00.000","Title":"Syntax Highlight for Mako in Eclipse or TextMate?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"Does anyone know of a syntax highlight for Mako templates for Eclipse or for TextMate?\nI know that there is a .mako syntax highlighter for the default text editor in Ubuntu.","AnswerCount":7,"Available Count":3,"Score":0.0285636566,"is_accepted":false,"ViewCount":5178,"Q_Id":922771,"Users Score":1,"Answer":"You can go to:\n\nPreferences->General->Editors->File Associations.\nClick to add a new file type and type *.mak and click OK.\nIn File types click on *.mak and under Associated editors add HTML editor(default), Text Editor, Text Editor(studio) and Web Browser.\n\nThis colors the text, works OK for me :)\nP.S. Be sure to have the Aptana plugin installed.","Q_Score":12,"Tags":"python,templates,mako","A_Id":8544623,"CreationDate":"2009-05-28T19:34:00.000","Title":"Syntax Highlight for Mako in Eclipse or TextMate?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"Scenario:\nI have a php page in which I call a python script. \nPython script when run on the command line (Linux) shows output on the command line, as well as writes the output to a file.\nPython script when run through php, doesn't do either.\nElaboration:\nI use a simple system command in PHP to run the python script as:\n\/var\/www\/html\/1.php:\n system('\/usr\/python\/bin\/python3 ..\/cgi-bin\/tabular.py 1');\n\/var\/www\/cgi-bin\/tabular.py\n--This python file basically parses a data file, uses python's regular expression to search for specific headings and outputs the headings to the stdout, as well as write it to a file.\nThis python script has a few routines in it which get executed, so I put print statements to debug. I noticed only a few initial print statements' output in the PHP page, all the ones from the function that actually does something are not seen.\nAlso, as part of my test, I thought well the py script is in a different folder so let me change it to the \/var\/www\/html folder, no go.\nI hope I captured the problem statement with sufficient detail and someone is able to reproduce this issue at their end. If I make any progress on this one myself, I'll annotate this question. Thanks everyone.\nGaurav","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":1882,"Q_Id":923680,"Users Score":1,"Answer":"A permission problem is most likely the case.\nIf apache is running as apache, then it will not have access to write to a file unless\n\nThe file is owned by apache\nThe file is in the group apache and group writable\nThe file is world writable\n\nThis is a \"sticky\" problem on a multi-user machine, as different people have access to Apache. \nTry chmod 666 output.txt on the file and then re-run your test.\n\nConsiderations:\n\nHave the python script write the output to a database\nUse PHP's popen functionality to open the process and communicate over pipes\nRe-write using PHP's regular expressions\nWrite the output file to \/tmp and then read the results using PHP as soon as the python script is done.\netc...","Q_Score":1,"Tags":"php,python,linux","A_Id":924481,"CreationDate":"2009-05-28T23:21:00.000","Title":"When calling a Python script from a PHP script, temporary file that is created on a console run, is not created via the PHP invocation","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"Scenario:\nI have a php page in which I call a python script. \nPython script when run on the command line (Linux) shows output on the command line, as well as writes the output to a file.\nPython script when run through php, doesn't do either.\nElaboration:\nI use a simple system command in PHP to run the python script as:\n\/var\/www\/html\/1.php:\n system('\/usr\/python\/bin\/python3 ..\/cgi-bin\/tabular.py 1');\n\/var\/www\/cgi-bin\/tabular.py\n--This python file basically parses a data file, uses python's regular expression to search for specific headings and outputs the headings to the stdout, as well as write it to a file.\nThis python script has a few routines in it which get executed, so I put print statements to debug. I noticed only a few initial print statements' output in the PHP page, all the ones from the function that actually does something are not seen.\nAlso, as part of my test, I thought well the py script is in a different folder so let me change it to the \/var\/www\/html folder, no go.\nI hope I captured the problem statement with sufficient detail and someone is able to reproduce this issue at their end. If I make any progress on this one myself, I'll annotate this question. Thanks everyone.\nGaurav","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":1882,"Q_Id":923680,"Users Score":0,"Answer":"Check that the user the python script is running is has write permissions in CWD. Also, try shell_exec() or passthru() to call the script, rather than system().","Q_Score":1,"Tags":"php,python,linux","A_Id":923761,"CreationDate":"2009-05-28T23:21:00.000","Title":"When calling a Python script from a PHP script, temporary file that is created on a console run, is not created via the PHP invocation","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I am writing automation code in python to test the behavior of a network application. As such, my code needs to be able to start a process\/script (say, tcpdump or a python script) on a server in the network, disconnect, run other processes and then later return and shutdown\/evaluate the process started earlier. My network is a mix of windows and linux machines and all of the machines have sshd and python running (via Cygwin for the windows machines). \nI've considered a couple of ideas, namely:\n- Starting a process and moving it to the background via a trailing ampersand (&)\n- Using screen in some fashion\n- Using python threads\nWhat else should I be considering? In your experience what have you found to be the best way to accomplish a task like this?","AnswerCount":8,"Available Count":4,"Score":0.0,"is_accepted":false,"ViewCount":2588,"Q_Id":923691,"Users Score":0,"Answer":"Most commercial products install an \"Agent\" on the remote machines.\nIn the linux world, you have numerous such agents. rexec and rlogin and rsh all jump to mind.\nThese are all clients that communication with daemons running on the remote hosts.\nIf you don't want to use these agents, you can read about them and reinvent these wheels in pure Python. Essentially, the client (rexec for example) communicates with the server (rexecd) to send work requests.","Q_Score":2,"Tags":"python,testing,scripting","A_Id":923720,"CreationDate":"2009-05-28T23:25:00.000","Title":"How to start a process on a remote server, disconnect, then later collect 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":1,"Web Development":0},{"Question":"I am writing automation code in python to test the behavior of a network application. As such, my code needs to be able to start a process\/script (say, tcpdump or a python script) on a server in the network, disconnect, run other processes and then later return and shutdown\/evaluate the process started earlier. My network is a mix of windows and linux machines and all of the machines have sshd and python running (via Cygwin for the windows machines). \nI've considered a couple of ideas, namely:\n- Starting a process and moving it to the background via a trailing ampersand (&)\n- Using screen in some fashion\n- Using python threads\nWhat else should I be considering? In your experience what have you found to be the best way to accomplish a task like this?","AnswerCount":8,"Available Count":4,"Score":0.0,"is_accepted":false,"ViewCount":2588,"Q_Id":923691,"Users Score":0,"Answer":"As @Gandalf mentions, you'll need nohup in addition to the backgrounding &, or the process will be SIGKILLed when the login session terminates. If you redirect your output to a log file, you'll be able to look at it later easily (and not have to install screen on all your machines).","Q_Score":2,"Tags":"python,testing,scripting","A_Id":923719,"CreationDate":"2009-05-28T23:25:00.000","Title":"How to start a process on a remote server, disconnect, then later collect 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":1,"Web Development":0},{"Question":"I am writing automation code in python to test the behavior of a network application. As such, my code needs to be able to start a process\/script (say, tcpdump or a python script) on a server in the network, disconnect, run other processes and then later return and shutdown\/evaluate the process started earlier. My network is a mix of windows and linux machines and all of the machines have sshd and python running (via Cygwin for the windows machines). \nI've considered a couple of ideas, namely:\n- Starting a process and moving it to the background via a trailing ampersand (&)\n- Using screen in some fashion\n- Using python threads\nWhat else should I be considering? In your experience what have you found to be the best way to accomplish a task like this?","AnswerCount":8,"Available Count":4,"Score":0.0748596907,"is_accepted":false,"ViewCount":2588,"Q_Id":923691,"Users Score":3,"Answer":"nohup for starters (at least on *nix boxes) - and redirect the output to some log file where you can come back and monitor it of course.","Q_Score":2,"Tags":"python,testing,scripting","A_Id":923703,"CreationDate":"2009-05-28T23:25:00.000","Title":"How to start a process on a remote server, disconnect, then later collect 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":1,"Web Development":0},{"Question":"I am writing automation code in python to test the behavior of a network application. As such, my code needs to be able to start a process\/script (say, tcpdump or a python script) on a server in the network, disconnect, run other processes and then later return and shutdown\/evaluate the process started earlier. My network is a mix of windows and linux machines and all of the machines have sshd and python running (via Cygwin for the windows machines). \nI've considered a couple of ideas, namely:\n- Starting a process and moving it to the background via a trailing ampersand (&)\n- Using screen in some fashion\n- Using python threads\nWhat else should I be considering? In your experience what have you found to be the best way to accomplish a task like this?","AnswerCount":8,"Available Count":4,"Score":0.0,"is_accepted":false,"ViewCount":2588,"Q_Id":923691,"Users Score":0,"Answer":"If you are using python to run the automation... I would attempt to automate everything using paramiko. It's a versatile ssh library for python. Instead of going back to the output, you could collect multiple lines of output live and then disconnect when you no longer need the process and let ssh do the killing for you.","Q_Score":2,"Tags":"python,testing,scripting","A_Id":20889031,"CreationDate":"2009-05-28T23:25:00.000","Title":"How to start a process on a remote server, disconnect, then later collect 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":1,"Web Development":0},{"Question":"Fedora Core 9 includes Python 2.5.1. I can use YUM to get latest and greatest releases.\nTo get ready for 2.6 official testing, I wanted to start with 2.5.4. It appears that there's no Fedora 9 YUM package, because 2.5.4 isn't an official part of FC9.\nI downloaded 2.5.4, did .\/configure; make; make install and wound up with two Pythons. The official 2.5.1 (in \/usr\/bin) and the new 2.5.4. (in \/usr\/local\/bin).\nNone of my technology stack is installed in \/usr\/local\/lib\/python2.5. \nIt appears that I have several choices for going forward. Anyone have any preferences?\n\nCopy \/usr\/lib\/python2.5\/* to \/usr\/local\/lib\/python2.5 to replicate my environment. This should work, unless some part of the Python libraries have \/usr\/bin\/python wired in during installation. This is sure simple, but is there a down side?\nReinstall everything by running easy_install. Except, easy_install is (currently) hard-wired to \/usr\/bin\/python. So, I'd have to fix easy_install first, then reinstall everything. \nThis takes some time, but it gives me a clean, new latest-and-greatest environment. But is there a down-side? [And why does easy_install hard-wire itself?]\nRelink \/usr\/bin\/python to be \/usr\/local\/bin\/python. I'd still have to copy or reinstall the library, so I don't think this does me any good. [It would make easy_install work; but so would editing \/usr\/bin\/easy_install.]\n\nHas anyone copied their library? Is it that simple? \nOr should I fix easy_install and simply step through the installation guide and build a new, clean, latest-and-greatest?\n\nEdit\nOr, should I \n\nSkip trying to resolve the 2.5.1 and 2.5.4 issues and just jump straight to 2.6?","AnswerCount":3,"Available Count":2,"Score":0.1325487884,"is_accepted":false,"ViewCount":1989,"Q_Id":925965,"Users Score":2,"Answer":"I suggest you create a virtualenv (or several) for installing packages into.","Q_Score":0,"Tags":"python,fedora,easy-install","A_Id":926006,"CreationDate":"2009-05-29T13:29:00.000","Title":"Fedora Python Upgrade broke easy_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},{"Question":"Fedora Core 9 includes Python 2.5.1. I can use YUM to get latest and greatest releases.\nTo get ready for 2.6 official testing, I wanted to start with 2.5.4. It appears that there's no Fedora 9 YUM package, because 2.5.4 isn't an official part of FC9.\nI downloaded 2.5.4, did .\/configure; make; make install and wound up with two Pythons. The official 2.5.1 (in \/usr\/bin) and the new 2.5.4. (in \/usr\/local\/bin).\nNone of my technology stack is installed in \/usr\/local\/lib\/python2.5. \nIt appears that I have several choices for going forward. Anyone have any preferences?\n\nCopy \/usr\/lib\/python2.5\/* to \/usr\/local\/lib\/python2.5 to replicate my environment. This should work, unless some part of the Python libraries have \/usr\/bin\/python wired in during installation. This is sure simple, but is there a down side?\nReinstall everything by running easy_install. Except, easy_install is (currently) hard-wired to \/usr\/bin\/python. So, I'd have to fix easy_install first, then reinstall everything. \nThis takes some time, but it gives me a clean, new latest-and-greatest environment. But is there a down-side? [And why does easy_install hard-wire itself?]\nRelink \/usr\/bin\/python to be \/usr\/local\/bin\/python. I'd still have to copy or reinstall the library, so I don't think this does me any good. [It would make easy_install work; but so would editing \/usr\/bin\/easy_install.]\n\nHas anyone copied their library? Is it that simple? \nOr should I fix easy_install and simply step through the installation guide and build a new, clean, latest-and-greatest?\n\nEdit\nOr, should I \n\nSkip trying to resolve the 2.5.1 and 2.5.4 issues and just jump straight to 2.6?","AnswerCount":3,"Available Count":2,"Score":0.1325487884,"is_accepted":false,"ViewCount":1989,"Q_Id":925965,"Users Score":2,"Answer":"I've had similar experiences and issues when installing Python 2.5 on an older release of ubuntu that supplied 2.4 out of the box.\nI first tried to patch easy_install, but this led to problems with anything that wanted to use the os-supplied version of python. I was often fiddling with the tool chain to fix different errors that might crop up with every install. Installing any python software via apt, or installing any software from apt that had a python easy_install script as part of the install, was often amusing. I'm sure I could probably have been more vigilant in patching easy_install, but I gave up.\nInstead, I copied the library, and everything worked. As you say, there may be issues depending on what you have installed, but I didn't run into issues. Double-checking Python's site.py module, I did see that it operates entirely on relative paths, building absolute paths dynamically; this gave me some confidence to try the \"copy everything\" approach. I double-checked any .pth files, then went for it.","Q_Score":0,"Tags":"python,fedora,easy-install","A_Id":926636,"CreationDate":"2009-05-29T13:29:00.000","Title":"Fedora Python Upgrade broke easy_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},{"Question":"How can I get the owner and group IDs of a directory using Python under Linux?","AnswerCount":6,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":26467,"Q_Id":927866,"Users Score":0,"Answer":"Use the os.stat function.","Q_Score":25,"Tags":"python,linux,directory,owner","A_Id":927888,"CreationDate":"2009-05-29T20:04:00.000","Title":"How to get the owner and group of a folder with Python on a Linux machine?","Data Science and Machine Learning":0,"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},{"Question":"How can I get the owner and group IDs of a directory using Python under Linux?","AnswerCount":6,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":26467,"Q_Id":927866,"Users Score":0,"Answer":"If you are using Linux, it is much easier.\nInstall tree with the command yum install tree. Then execute the command 'tree -a -u -g'","Q_Score":25,"Tags":"python,linux,directory,owner","A_Id":71426599,"CreationDate":"2009-05-29T20:04:00.000","Title":"How to get the owner and group of a folder with Python on a Linux machine?","Data Science and Machine Learning":0,"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},{"Question":"Can someone please tell me if there is an equivalent for Python's lambda functions in Java?","AnswerCount":7,"Available Count":1,"Score":0.0285636566,"is_accepted":false,"ViewCount":12221,"Q_Id":929988,"Users Score":1,"Answer":"With the release of Java 8, lambda-expression is now available. \nAnd the lambda function in java is actually \"more powerful\" than the python ones.\nIn Python, lambda-expression may only have a single expression for its body, and no return statement is permitted. In Java, you can do something like this: (int a, int b) -> { return a * b; }; and other optional things as well. \nJava 8 also introduces another interface called the Function Interface. You might want to check that out as well.","Q_Score":23,"Tags":"java,python,function,lambda","A_Id":41144957,"CreationDate":"2009-05-30T15:49:00.000","Title":"Equivalent for Python's lambda functions 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":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Is there a similar or equivalent function in Python to the PHP function htmlspecialchars()? The closest thing I've found so far is htmlentitydefs.entitydefs().","AnswerCount":8,"Available Count":1,"Score":-0.024994793,"is_accepted":false,"ViewCount":12591,"Q_Id":931423,"Users Score":-1,"Answer":"If you are using django 1.0 then your template variables will already be encoded and ready for display. You also use the safe operator {{ var|safe }} if you don't want it globally turned on.","Q_Score":20,"Tags":"php,python,html-entities,htmlspecialchars","A_Id":931442,"CreationDate":"2009-05-31T05:58:00.000","Title":"Is there a Python equivalent to the PHP function htmlspecialchars()?","Data Science and Machine Learning":0,"Database and SQL":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},{"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},{"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},{"Question":"There seem to be a few good pure Python SSH2 client implementations out there, but I haven't been able to find one for SSH1. Is there some specific reason for this other than lack of interest in such a project? I am fully aware of the many SSH1 vulnerabilities, but a pure Python SSH1 client implementation would still be very useful to those of us who want to write SSH clients to manage older embedded devices which only support SSH1 (Cisco PIX for example). I also know I'm not the only person looking for this.\nThe reason I'm asking is because I'm bored, and I've been thinking about taking a stab at writing this myself. I've just been hesitant to start, since I know there are a lot of people out there who are much smarter than me, and I figured there might be some reason why nobody has done it yet.","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":1865,"Q_Id":936783,"Users Score":1,"Answer":"Well, the main reason probably was that when people started getting interested in such things in VHLLs such as Python, it didn't make sense to them to implement a standard which they themselves would not find useful.\nI am not familiar with the protocol differences, but would it be possible for you to adapt an existing codebase to the older protocol?","Q_Score":4,"Tags":"python,ssh","A_Id":936816,"CreationDate":"2009-06-01T21:06:00.000","Title":"Why no pure Python SSH1 (version 1) client implementations?","Data Science and Machine Learning":0,"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},{"Question":"There seem to be a few good pure Python SSH2 client implementations out there, but I haven't been able to find one for SSH1. Is there some specific reason for this other than lack of interest in such a project? I am fully aware of the many SSH1 vulnerabilities, but a pure Python SSH1 client implementation would still be very useful to those of us who want to write SSH clients to manage older embedded devices which only support SSH1 (Cisco PIX for example). I also know I'm not the only person looking for this.\nThe reason I'm asking is because I'm bored, and I've been thinking about taking a stab at writing this myself. I've just been hesitant to start, since I know there are a lot of people out there who are much smarter than me, and I figured there might be some reason why nobody has done it yet.","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":1865,"Q_Id":936783,"Users Score":3,"Answer":"SSHv1 was considered deprecated in 2001, so I assume nobody really wanted to put the effort into it. I'm not sure if there's even an rfc for SSH1, so getting the full protocol spec may require reading through old source code.\nSince there are known vulnerabilities, it's not much better than telnet, which is almost universally supported on old and\/or embedded devices.","Q_Score":4,"Tags":"python,ssh","A_Id":940483,"CreationDate":"2009-06-01T21:06:00.000","Title":"Why no pure Python SSH1 (version 1) client implementations?","Data Science and Machine Learning":0,"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},{"Question":"I'm looking for a free library for python that can calculate your direction and your speed from GPS coordinates and maybe can calculate if you are in some boundaries or things like this.\nAre there Libraries that you know and that worked well for you?\nWe are using python on a linux machine and getting the data from the gpsd. So I hope there is no need for a speciel library for only talking to the device. What I'm looking for is python code doing some basic calculations with the data. Such as comparing the last positions and calculate speed and direction.","AnswerCount":6,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":32709,"Q_Id":953701,"Users Score":9,"Answer":"Apparently the python module that comes with gpsd is the best module to go with for us.\nThe gps module coming with the gpsd has some very useful functions. The first one is getting the data from gpsd and transforming those data in a usable data structure.\nThen the moduls give you access to your speed, and your current heading relative to north.\nAlso included is a function for calculating the distance between two coordinates on the earth taking the spherical nature of earth into account.\nThe functions that are missing for our special case are:\n\nCalculating the heading between to points. Means I am at point a facing north to which degree do I have to turn to face the point I want to navigate to.\n\nTaking the data of the first function and our current heading to calculate a turn in degrees that we have to do to face a desired point (not a big deal because it is mostly only a subtraction)\n\n\nThe biggest problem for working with this library is that it is mostly a wrapper for the gpsd so if you are programming on a different OS then you gpscode should work on like Windows or MacOS you are not able to run the code or to install the module.","Q_Score":8,"Tags":"python,gps,gpsd","A_Id":973022,"CreationDate":"2009-06-05T00:01:00.000","Title":"Which gps library would you recommend 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},{"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},{"Question":"I'm thinking of trying to make some simple 2d games, but I've yet to choose a language. A lot of people recommend either C++ with SDL or python with pygame. I keep hearing that developement on C++ is fairly slow, and developement time with Python is fairly fast.\nAnyways, could anyone elaborate on this? What exactly makes development in C++ so time consuming? The programs I've made have been Project Euler-style in that they're very short and math-based, so I have no experience in larger projects.","AnswerCount":13,"Available Count":11,"Score":1.0,"is_accepted":false,"ViewCount":5902,"Q_Id":977404,"Users Score":13,"Answer":"I've heard these complaints before about C++, but the fact is, programming in any language with which you are unfamiliar is time consuming. \nA good C++ programmer can probably crank out the app much faster than an okay Python programmer and visa versa. \nI think C++ often gets a bad reputation because it allows you get much lower level - pointers, memory management, etc, and if you aren't used to thinking about such things, it can take a bit of time. If you are used to working in that environment, it can become second nature.\nUnless choice of language is something imposed upon you by your company, team, client, etc. I usually recommend that folks go with the language they are most comfortable with OR most interested in learning more about. If speed is the issue you are concerned with, look at the learning curve for each language and your past experience. C++ tends to have a higher learning curve, but that too depends on the person.\nKindof a non-answer I know.","Q_Score":19,"Tags":"c++,python","A_Id":977443,"CreationDate":"2009-06-10T18:33:00.000","Title":"C++ slow, python fast? (in terms of development time)","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},{"Question":"I'm thinking of trying to make some simple 2d games, but I've yet to choose a language. A lot of people recommend either C++ with SDL or python with pygame. I keep hearing that developement on C++ is fairly slow, and developement time with Python is fairly fast.\nAnyways, could anyone elaborate on this? What exactly makes development in C++ so time consuming? The programs I've made have been Project Euler-style in that they're very short and math-based, so I have no experience in larger projects.","AnswerCount":13,"Available Count":11,"Score":1.0,"is_accepted":false,"ViewCount":5902,"Q_Id":977404,"Users Score":24,"Answer":"There are two things that are relevant between C++ and Python that will affect your time-to-develop any project including a game. There are the languages themselves and the libraries. I've played with the SDL to some extent and peeked at PyGame and for your specific instance I don't think the libraries are going to be much of a factor. So I'll focus on the languages themselves.\nPython is a dynamically-typed, garbage-collected language. C++ is a statically-typed, non-garbage-collected language. What this means is that in C++ a lot of your development time will be spent managing memory and dealing with your type structure. This affords you a lot of power, but the question is do you really need it?\nIf you're looking to write a simple game with some basic graphics and some good gameplay, then I don't think you truly need all the power that C++ will give you. If you're looking to write something that will push the envelope, be the next A-list game, be the next MMO, fit on a console or a handheld device, then you will likely need the power that C++ affords.","Q_Score":19,"Tags":"c++,python","A_Id":977451,"CreationDate":"2009-06-10T18:33:00.000","Title":"C++ slow, python fast? (in terms of development time)","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},{"Question":"I'm thinking of trying to make some simple 2d games, but I've yet to choose a language. A lot of people recommend either C++ with SDL or python with pygame. I keep hearing that developement on C++ is fairly slow, and developement time with Python is fairly fast.\nAnyways, could anyone elaborate on this? What exactly makes development in C++ so time consuming? The programs I've made have been Project Euler-style in that they're very short and math-based, so I have no experience in larger projects.","AnswerCount":13,"Available Count":11,"Score":0.0307595242,"is_accepted":false,"ViewCount":5902,"Q_Id":977404,"Users Score":2,"Answer":"It's time consuming because in C++ you have to deal with more low-level tasks.\nIn Python you are free to focus on the development of the actual game instead of dealing with memory management etc.","Q_Score":19,"Tags":"c++,python","A_Id":977412,"CreationDate":"2009-06-10T18:33:00.000","Title":"C++ slow, python fast? (in terms of development time)","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},{"Question":"I'm thinking of trying to make some simple 2d games, but I've yet to choose a language. A lot of people recommend either C++ with SDL or python with pygame. I keep hearing that developement on C++ is fairly slow, and developement time with Python is fairly fast.\nAnyways, could anyone elaborate on this? What exactly makes development in C++ so time consuming? The programs I've made have been Project Euler-style in that they're very short and math-based, so I have no experience in larger projects.","AnswerCount":13,"Available Count":11,"Score":0.0,"is_accepted":false,"ViewCount":5902,"Q_Id":977404,"Users Score":0,"Answer":"Some people would argue that development time is slower in C++ when compared to Python. \nWouldn't it be the case that the time you saved in developing an application (or game) in python is the time you gonna use in improving performance after its developed? and in the later part when you have least options left?\nIt largely depends upon the purpose for which you are going to develop the application. \nIf you are thinking for an enterprise application in which case it is going to be hit by millions (web-app) or an application with focus on low-footprint, faster loading into memory, faster execution, then your choice is C++. \nIf you are projecting your application for not being use at this level, surely Python is the choice to go for. \nMaintainability is considerable, but disciplined code can overcome this.\nLargely depends upon long term projections. On how serious and critical the application is going to be.","Q_Score":19,"Tags":"c++,python","A_Id":4546946,"CreationDate":"2009-06-10T18:33:00.000","Title":"C++ slow, python fast? (in terms of development time)","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},{"Question":"I'm thinking of trying to make some simple 2d games, but I've yet to choose a language. A lot of people recommend either C++ with SDL or python with pygame. I keep hearing that developement on C++ is fairly slow, and developement time with Python is fairly fast.\nAnyways, could anyone elaborate on this? What exactly makes development in C++ so time consuming? The programs I've made have been Project Euler-style in that they're very short and math-based, so I have no experience in larger projects.","AnswerCount":13,"Available Count":11,"Score":0.0,"is_accepted":false,"ViewCount":5902,"Q_Id":977404,"Users Score":0,"Answer":"Why limit yourself to those two options? With C# or Java you get access to a huge collection of useful libraries plus garbage collection and (in the case of C#) JIT compiling.\nFurthermore, you're saying that you're looking to do game development, but from your task description it sounds like you're also looking at coding your own engine. Is that part of the exercise? Otherwise you should definitely take a look at the available Indie engines out there - lots are cheap of not free and open source.\nNeedless to say, working from an existing engine is definitely faster than going from scratch :)","Q_Score":19,"Tags":"c++,python","A_Id":1079100,"CreationDate":"2009-06-10T18:33:00.000","Title":"C++ slow, python fast? (in terms of development time)","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},{"Question":"I'm thinking of trying to make some simple 2d games, but I've yet to choose a language. A lot of people recommend either C++ with SDL or python with pygame. I keep hearing that developement on C++ is fairly slow, and developement time with Python is fairly fast.\nAnyways, could anyone elaborate on this? What exactly makes development in C++ so time consuming? The programs I've made have been Project Euler-style in that they're very short and math-based, so I have no experience in larger projects.","AnswerCount":13,"Available Count":11,"Score":0.0307595242,"is_accepted":false,"ViewCount":5902,"Q_Id":977404,"Users Score":2,"Answer":"It takes about the same amount of time to write the same code in pretty much all of the high level languages. The win is that in certain languages it is easier to use other peoples code. In a lot of Python\/Ruby\/Perl apps, you write 10% of the code and import libraries to do the other 90%. That is harder in C\/C++ since the libraries have different interfaces and other incompatibilities.\nC++ vs Python is a pretty personal choice. Personally I feel I lose more time with not having the C\/Java class system (more run time errors\/debugging time, don't have anywhere near as good auto completion, need to do more documentation and optimization) than I gain (not having to write interfaces\/stub function and being able to worry less about memory managment). Other people feel the exact opposite.\nIn the end it probably depends on the type of game. If your processor intensive go to C++ (maybe with a scripting language if it makes sense). Otherwise use whatever language you prefer","Q_Score":19,"Tags":"c++,python","A_Id":1009820,"CreationDate":"2009-06-10T18:33:00.000","Title":"C++ slow, python fast? (in terms of development time)","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},{"Question":"I'm thinking of trying to make some simple 2d games, but I've yet to choose a language. A lot of people recommend either C++ with SDL or python with pygame. I keep hearing that developement on C++ is fairly slow, and developement time with Python is fairly fast.\nAnyways, could anyone elaborate on this? What exactly makes development in C++ so time consuming? The programs I've made have been Project Euler-style in that they're very short and math-based, so I have no experience in larger projects.","AnswerCount":13,"Available Count":11,"Score":0.0461211021,"is_accepted":false,"ViewCount":5902,"Q_Id":977404,"Users Score":3,"Answer":"Python has some big advantages over programming languages like C++. I myself have programmed a lot with C++, C and other programming languages. Lately I am also programming in Python and I got to like it very much!\nYou can have a quick start with Python. Since it is rather simple to learn (at least with some programming experience and enough abstract thinking), you can have fast successes. Also the script-like behaviour makes starting easy and it is also possible, to quickly test some things in the integrated shell. This can also be good for debugging.\nThe whole language is packed with powerful features and it has a good and rather complete set of libraries.\nThere was the argument that with the \"right library\" you can develop as quickly with C++ as with Python. This might (partly) be, but I myself have never experienced it, because such libraries are rare. I had also a big library at hand, but still lacked many valuable features in C++. The so called \"standard template library\" STL makes things even worse in my opinion. It is a really powerful library. But it is also that complex, that it adds the complexity of an additional programming language to C++. I really disliked it and in a company I worked in, much worktime was lost, because the compiler was not able to give useful error-output in case of errors in the STL.\nPython is different. Instead of putting the \"speed of the programm\" on the throne -- sacrificing all else (as C++ and especially the STL does) -- it puts \"speed of development\" first. The language gives you a powerful toolkit and it is accompanied by a huge library. When you need speed, you can also implement time critical things in C or C++ and call it from Python.\nThere is also at least one big online Game implemented in Python.","Q_Score":19,"Tags":"c++,python","A_Id":986810,"CreationDate":"2009-06-10T18:33:00.000","Title":"C++ slow, python fast? (in terms of development time)","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},{"Question":"I'm thinking of trying to make some simple 2d games, but I've yet to choose a language. A lot of people recommend either C++ with SDL or python with pygame. I keep hearing that developement on C++ is fairly slow, and developement time with Python is fairly fast.\nAnyways, could anyone elaborate on this? What exactly makes development in C++ so time consuming? The programs I've made have been Project Euler-style in that they're very short and math-based, so I have no experience in larger projects.","AnswerCount":13,"Available Count":11,"Score":0.0,"is_accepted":false,"ViewCount":5902,"Q_Id":977404,"Users Score":0,"Answer":"Do you have any programming experience at all? If not, I would start with Python which is easier to learn, even if it is not a better tool for game development. If you decide you want to program games for living, you'll probably need to switch to C++ at some point.","Q_Score":19,"Tags":"c++,python","A_Id":977759,"CreationDate":"2009-06-10T18:33:00.000","Title":"C++ slow, python fast? (in terms of development time)","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},{"Question":"I'm thinking of trying to make some simple 2d games, but I've yet to choose a language. A lot of people recommend either C++ with SDL or python with pygame. I keep hearing that developement on C++ is fairly slow, and developement time with Python is fairly fast.\nAnyways, could anyone elaborate on this? What exactly makes development in C++ so time consuming? The programs I've made have been Project Euler-style in that they're very short and math-based, so I have no experience in larger projects.","AnswerCount":13,"Available Count":11,"Score":0.0,"is_accepted":false,"ViewCount":5902,"Q_Id":977404,"Users Score":0,"Answer":"Short Answer\nYes python is faster in terms of development time. There are many case studies in real life that show this. However, you don't want to do a 3d graphics engine in Python.","Q_Score":19,"Tags":"c++,python","A_Id":977460,"CreationDate":"2009-06-10T18:33:00.000","Title":"C++ slow, python fast? (in terms of development time)","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},{"Question":"I'm thinking of trying to make some simple 2d games, but I've yet to choose a language. A lot of people recommend either C++ with SDL or python with pygame. I keep hearing that developement on C++ is fairly slow, and developement time with Python is fairly fast.\nAnyways, could anyone elaborate on this? What exactly makes development in C++ so time consuming? The programs I've made have been Project Euler-style in that they're very short and math-based, so I have no experience in larger projects.","AnswerCount":13,"Available Count":11,"Score":0.0,"is_accepted":false,"ViewCount":5902,"Q_Id":977404,"Users Score":0,"Answer":"I'd focus more on choosing a framework to build your game on than trying to pick a language. Unless the goal is to learn how games work inside and out, you're going to want to use a framework. Try out a couple, and pick the one that meets your requirements and feels nice to you.\nOnce you've picked the framework, the language choice becomes easy - use the language for which the framework is written.\nThere are many options for game frameworks in C++ - pygame works for python. There are many that work with other languages\/tools as well (including .NET, Lua, etc.)","Q_Score":19,"Tags":"c++,python","A_Id":977452,"CreationDate":"2009-06-10T18:33:00.000","Title":"C++ slow, python fast? (in terms of development time)","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},{"Question":"I'm thinking of trying to make some simple 2d games, but I've yet to choose a language. A lot of people recommend either C++ with SDL or python with pygame. I keep hearing that developement on C++ is fairly slow, and developement time with Python is fairly fast.\nAnyways, could anyone elaborate on this? What exactly makes development in C++ so time consuming? The programs I've made have been Project Euler-style in that they're very short and math-based, so I have no experience in larger projects.","AnswerCount":13,"Available Count":11,"Score":0.0307595242,"is_accepted":false,"ViewCount":5902,"Q_Id":977404,"Users Score":2,"Answer":"there are many things that make c++ longer to develop in. Its lower level, has pointers, different libraries for different systems, the type system, and there are others I am sure I am missing.","Q_Score":19,"Tags":"c++,python","A_Id":977414,"CreationDate":"2009-06-10T18:33:00.000","Title":"C++ slow, python fast? (in terms of development time)","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},{"Question":"I am kind of hitting a wall on this problem and I was wondering if some fresh brains could help me out.\nI have a large list of four element tuples in the format:\n(ID number, Type, Start Index, End Index) \nPreviously in the code, I have searched through thousands of blocks of text for two specific types of substrings. These tuples store in which large chunk of text the substring was found, which of the two types of substrings it is, and the start and end index of this substring.\nThe final goal is to look through this list to find all instances where a type 1 substring occurs before a type 2 substring in a block of text with the same ID. Then I would like to store these objects in the format (ID, Type 1, Start, End, Type2, Start, End).\nI've tried to mess around with a bunch of stuff that was super inefficient. I have the list sorted by ID then Start Index, and if been trying varying ways of popping the items off the list for comparisons. I have to imagine there is a more elegant solution. Any brilliant people out there wish to assist my tired brain???\nThanks in advance","AnswerCount":5,"Available Count":2,"Score":0.0399786803,"is_accepted":false,"ViewCount":551,"Q_Id":988346,"Users Score":1,"Answer":"I don't know how many types you have. But If we assume you have only type 1 and type 2, then it sounds like a problem similar to a merge sort. Doing it with a merge sort, you make a single pass through the list. \nTake two indexes, one for type 1 and one for type 2 (I1, I2). Sort the list by id, start1. Start I1 as the first instance of type1, and I2 as zero. If I1.id < I2.Id then increment I1. If I2.id < I1.id then increment I2. If I1.id = I2.id then check iStart. \nI1 can only stop on a type one record and I2 can only stop on a type 2 record. Keep incrementing the index till it lands on an appropriate record.\nYou can make some assumptions to make this faster. When you find an block that succeeds, you can move I1 to the next block. Whenever I2 < I1, you can start I2 at I1 + 1 (WOOPS MAKE SURE YOU DONT DO THIS, BECAUSE YOU WOULD MISS THE FAILURE CASE!) Whenever you detect an obvious failure case, move I1 and I2 to the next block (on appropriate recs of course).","Q_Score":2,"Tags":"python,algorithm,list,tuples","A_Id":988462,"CreationDate":"2009-06-12T18:47:00.000","Title":"Efficient Tuple List Comparisons","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am kind of hitting a wall on this problem and I was wondering if some fresh brains could help me out.\nI have a large list of four element tuples in the format:\n(ID number, Type, Start Index, End Index) \nPreviously in the code, I have searched through thousands of blocks of text for two specific types of substrings. These tuples store in which large chunk of text the substring was found, which of the two types of substrings it is, and the start and end index of this substring.\nThe final goal is to look through this list to find all instances where a type 1 substring occurs before a type 2 substring in a block of text with the same ID. Then I would like to store these objects in the format (ID, Type 1, Start, End, Type2, Start, End).\nI've tried to mess around with a bunch of stuff that was super inefficient. I have the list sorted by ID then Start Index, and if been trying varying ways of popping the items off the list for comparisons. I have to imagine there is a more elegant solution. Any brilliant people out there wish to assist my tired brain???\nThanks in advance","AnswerCount":5,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":551,"Q_Id":988346,"Users Score":0,"Answer":"Assuming there are lots of entries for each ID, I would (pseudo-code)\n\n for each ID:\n for each type2 substring of that ID:\n store it in an ordered list, sorted by start point\n for each type1 substring of that ID:\n calculate the end point (or whatever)\n look it up in the ordered list\n if there's anything to the right, you have a hit\n\nSo, if you have control of the initial sort, then instead of (ID, start), you want them sorted by ID, then by type (2 before 1). Then within the type, sort by start point for type2, and the offset you're going to compare for type1. I'm not sure whether by \"A before B\" you mean \"A starts before B starts\" or \"A ends before B starts\", but do whatever's appropriate. \nThen you can do the whole operation by running over the list once. You don't need to actually construct an index of type2s, because they're already in order. Since the type1s are sorted too, you can do each lookup with a linear or binary search starting from the result of the previous search. Use a linear search if there are lots of type1s compared with type2s (so results are close together), and a binary search if there are lots of type2s compared with type1s (so results are sparse). Or just stick with the linear search as it's simpler - this lookup is the inner loop, but its performance might not be critical.\nIf you don't have control of the sort, then I don't know whether it's faster to build the list of type2 substrings for each ID as you go; or to sort the entire list before you start into the required order; or just to work with what you've got, by writing a \"lookup\" that ignores the type1 entries when searching through the type2s (which are already sorted as required). Test it, or just do whatever results in clearer code. Even without re-sorting, you can still use the merge-style optimisation unless \"sorted by start index\" is the wrong thing for the type1s.","Q_Score":2,"Tags":"python,algorithm,list,tuples","A_Id":988650,"CreationDate":"2009-06-12T18:47:00.000","Title":"Efficient Tuple List Comparisons","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":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},{"Question":"I want to be able to execute openssh with some custom arguments and then be able to automatically login to the server. I want that my script will enter the password if needed and inject 'yes' if I'm prompted to add the fingerprint to the known hosts.\nI've found SharpSsh for C# that do that, but I also need to use -D parameter and use ProxyCommand that I define in SSH, and the library is quite lacking for that usage.\nAnother thing that I've found was pexcept for Python that should do the trick but I couldn't find where to download it, on the offical page I'm being redirectred from sourceforge to some broken link.\nAny help would be appreciated,\nBill.","AnswerCount":7,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":3061,"Q_Id":1002627,"Users Score":0,"Answer":"pexpect can't import on Windows. So, I use plink.exe with a Python subprocess to connect to the ssh server.","Q_Score":1,"Tags":"c#,python,windows,ssh","A_Id":11246704,"CreationDate":"2009-06-16T16:34:00.000","Title":"Automate SSH login under 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},{"Question":"In a POSIX system, I want to see if a given process (PID 4356, for example) is running. It would be even better if I could get metadata about that process.","AnswerCount":6,"Available Count":1,"Score":0.0333209931,"is_accepted":false,"ViewCount":2206,"Q_Id":1005972,"Users Score":1,"Answer":"Look at \/proc\/pid. This exists only of the process is running, and contains lots of information.","Q_Score":7,"Tags":"python,posix","A_Id":1006030,"CreationDate":"2009-06-17T09:12:00.000","Title":"What is the easiest way to see if a process with a given pid exists 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},{"Question":"I manage the testing for a very large financial pricing system. Recently our HQ have insisted that we verify that every single part of our project has a meaningful test in place. At the very least they want a system which guarantees that when we change something we can spot unintentional changes to other sub-systems. Preferably they want something which validates the correctness of every component in our system.\nThat's obviously going to be quite a lot of work! It could take years, but for this kind of project it's worth it. \nI need to find out which parts of our code are not covered by any of our unit-tests. If I knew which parts of my system were untested then I could set about developing new tests which would eventually approach towards my goal of complete test-coverage. \nSo how can I go about running this kind of analysis. What tools are available to me?\nI use Python 2.4 on Windows 32bit XP\nUPDATE0:\nJust to clarify: We have a very comprehensive unit-test suite (plus a seperate and very comprehensive regtest suite which is outside the scope of this exercise). We also have a very stable continuous integration platform (built with Hudson) which is designed to split-up and run standard python unit-tests across our test facility: Approx 20 PCs built to the company spec.\nThe object of this exercise is to plug any gaps in our python unittest suite (only) suite so that every component has some degree of unittest coverage. Other developers will be taking responsibility for non Python components of the project (which are also outside of scope).\n\"Component\" is intentionally vague: Sometime it will be a class, other time an entire module or assembly of modules. It might even refer to a single financial concept (e.g. a single type of financial option or a financial model used by many types of option). This cake can be cut in many ways. \n\"Meaningful\" tests (to me) are ones which validate that the function does what the developer originally intended. We do not want to simply reproduce the regtests in pure python. Often the developer's intent is not immediatly obvious, hence the need to research and clarify anything which looks vague and then enshrine this knowledge in a unit-test which makes the original intent quite explicit.","AnswerCount":5,"Available Count":1,"Score":0.1194272985,"is_accepted":false,"ViewCount":3113,"Q_Id":1006189,"Users Score":3,"Answer":"\"every single part of our project has a meaningful test in place\"\n\"Part\" is undefined. \"Meaningful\" is undefined. That's okay, however, since it gets better further on.\n\"validates the correctness of every component in our system\"\n\"Component\" is undefined. But correctness is defined, and we can assign a number of alternatives to component. You only mention Python, so I'll assume the entire project is pure Python.\n\nValidates the correctness of every module.\nValidates the correctness of every class of every module.\nValidates the correctness of every method of every class of every module.\n\nYou haven't asked about line of code coverage or logic path coverage, which is a good thing. That way lies madness.\n\"guarantees that when we change something we can spot unintentional changes to other sub-systems\"\nThis is regression testing. That's a logical consequence of any unit testing discipline.\nHere's what you can do.\n\nEnumerate every module. Create a unittest for that module that is just a unittest.main(). This should be quick -- a few days at most.\nWrite a nice top-level unittest script that uses a testLoader to all unit tests in your tests directory and runs them through the text runner. At this point, you'll have a lot of files -- one per module -- but no actual test cases. Getting the testloader and the top-level script to work will take a few days. It's important to have this overall harness working.\nPrioritize your modules. A good rule is \"most heavily reused\". Another rule is \"highest risk from failure\". Another rule is \"most bugs reported\". This takes a few hours.\nStart at the top of the list. Write a TestCase per class with no real methods or anything. Just a framework. This takes a few days at most. Be sure the docstring for each TestCase positively identifies the Module and Class under test and the status of the test code. You can use these docstrings to determine test coverage.\n\nAt this point you'll have two parallel tracks. You have to actually design and implement the tests. Depending on the class under test, you may have to build test databases, mock objects, all kinds of supporting material.\n\nTesting Rework. Starting with your highest priority untested module, start filling in the TestCases for each class in each module.\nNew Development. For every code change, a unittest.TestCase must be created for the class being changed.\n\nThe test code follows the same rules as any other code. Everything is checked in at the end of the day. It has to run -- even if the tests don't all pass.\nGive the test script to the product manager (not the QA manager, the actual product manager who is responsible for shipping product to customers) and make sure they run the script every day and find out why it didn't run or why tests are failing.\nThe actual running of the master test script is not a QA job -- it's everyone's job. Every manager at every level of the organization has to be part of the daily build script output. All of their jobs have to depend on \"all tests passed last night\". Otherwise, the product manager will simply pull resources away from testing and you'll have nothing.","Q_Score":5,"Tags":"python,testing","A_Id":1006454,"CreationDate":"2009-06-17T10:20:00.000","Title":"How to do a meaningful code-coverage analysis of my 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":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Can anyone tell me if its possible to redeclare a C# class in IronPython? If I have a C# class, would I be able to monkey-patch it from IronPython?","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":324,"Q_Id":1008686,"Users Score":0,"Answer":"You can monkey-patch from IronPython, but IPy is the only environment that will respect your changes; i.e. if you tried to mock out File.Create from IronPython, this would work fine for any IPy code, but if you called a C# method which called File.Create, it would get the real one, not the mock.","Q_Score":1,"Tags":"c#,ironpython,monkeypatching","A_Id":1040151,"CreationDate":"2009-06-17T18:08:00.000","Title":"Redeclare .net classes 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":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Can anyone tell me if its possible to redeclare a C# class in IronPython? If I have a C# class, would I be able to monkey-patch it from IronPython?","AnswerCount":3,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":324,"Q_Id":1008686,"Users Score":0,"Answer":"You cannot monkey patch from IronPython. IronPython treats all .NET classes just like CPython treats built-in types: they cannot be monkey patched. IronRuby on the other hand does support this.","Q_Score":1,"Tags":"c#,ironpython,monkeypatching","A_Id":3155159,"CreationDate":"2009-06-17T18:08:00.000","Title":"Redeclare .net classes 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":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm trying to use python to sftp a file, and the code works great in the interactive shell -- even pasting it in all at once.\nWhen I try to import the file (just to compile it), the code hangs with no exceptions or obvious errors. \nHow do I get the code to compile, or does someone have working code that accomplishes sftp by some other method?\nThis code hangs right at the ssh.connect() statement:\n\n\"\"\" ProblemDemo.py\n Chopped down from the paramiko demo file.\n\n This code works in the shell but hangs when I try to import it!\n\"\"\"\nfrom time import sleep\nimport os\n\nimport paramiko\n\n\nsOutputFilename = \"redacted.htm\" #-- The payload file\n\nhostname = \"redacted.com\"\n####-- WARNING! Embedded passwords! Remove ASAP.\nsUsername = \"redacted\"\nsPassword = \"redacted\"\nsTargetDir = \"redacted\"\n\n#-- Get host key, if we know one.\nhostkeytype = None\nhostkey = None\nhost_keys = {}\ntry:\n host_keys = paramiko.util.load_host_keys(os.path.expanduser('~\/.ssh\/known_hosts'))\nexcept IOError:\n try:\n # try ~\/ssh\/ too, because windows can't have a folder named ~\/.ssh\/\n host_keys = paramiko.util.load_host_keys(os.path.expanduser('~\/ssh\/known_hosts'))\n except IOError:\n print '*** Unable to open host keys file'\n host_keys = {}\n\nif host_keys.has_key(hostname):\n hostkeytype = host_keys[hostname].keys()[0]\n hostkey = host_keys[hostname][hostkeytype]\n print 'Using host key of type %s' % hostkeytype\n\n\nssh = paramiko.Transport((hostname, 22))\n\nssh.connect(username=sUsername, password=sPassword, hostkey=hostkey)\n\nsftp = paramiko.SFTPClient.from_transport(ssh)\n\nsftp.chdir (sTargetDir)\n\nsftp.put (sOutputFilename, sOutputFilename)\n\nssh.close()","AnswerCount":3,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":6518,"Q_Id":1013064,"Users Score":0,"Answer":"Weirdness aside, I was just using import to compile the code. Turning the script into a function seems like an unnecessary complication for this kind of application.\nSearched for alternate means to compile and found:\n\nimport py_compile\npy_compile.compile(\"ProblemDemo.py\")\n\nThis generated a pyc file that works as intended.\nSo the lesson learned is that import is not a robust way to compile python scripts.","Q_Score":3,"Tags":"python,shell,compilation,sftp","A_Id":1013366,"CreationDate":"2009-06-18T14:45:00.000","Title":"Why does this python code hang on import\/compile but work in the shell?","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},{"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},{"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},{"Question":"I'm trying to build some statistics for an email group I participate. Is there any Python API to access the email data on a GoogleGroup?\nAlso, I know some statistics are available on the group's main page. I'm looking for something more complex than what is shown there.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1163,"Q_Id":1017794,"Users Score":3,"Answer":"There isn't an API that I know of, however you can access the XML feed and manipulate it as required.","Q_Score":6,"Tags":"python,google-groups","A_Id":1017810,"CreationDate":"2009-06-19T12:48:00.000","Title":"Is there an API to access a Google Group data?","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},{"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},{"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},{"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},{"Question":"My background is C and C++. I like Python a lot, but there's one aspect of it (and other interpreted languages I guess) that is really hard to work with when you're used to compiled languages.\nWhen I've written something in Python and come to the point where I can run it, there's still no guarantee that no language-specific errors remain. For me that means that I can't rely solely on my runtime defense (rigorous testing of input, asserts etc.) to avoid crashes, because in 6 months when some otherwise nice code finally gets run, it might crack due to some stupid typo.\nClearly a system should be tested enough to make sure all code has been run, but most of the time I use Python for in-house scripts and small tools, which ofcourse never gets the QA attention they need. Also, some code is so simple that (if your background is C\/C++) you know it will work fine as long as it compiles (e.g. getter-methods inside classes, usually a simple return of a member variable).\nSo, my question is the obvious - is there any way (with a special tool or something) I can make sure all the code in my Python script will \"compile\" and run?","AnswerCount":5,"Available Count":3,"Score":0.0798297691,"is_accepted":false,"ViewCount":1051,"Q_Id":1026966,"Users Score":2,"Answer":"Others have mentioned tools like PyLint which are pretty good, but the long and the short of it is that it's simply not possible to do 100%. In fact, you might not even want to do it. Part of the benefit to Python's dynamicity is that you can do crazy things like insert names into the local scope through a dictionary access.\nWhat it comes down to is that if you want a way to catch type errors at compile time, you shouldn't use Python. A language choice always involves a set of trade-offs. If you choose Python over C, just be aware that you're trading a strong type system for faster development, better string manipulation, etc.","Q_Score":14,"Tags":"python,parsing,code-analysis","A_Id":1061573,"CreationDate":"2009-06-22T12:36:00.000","Title":"How can I make sure all my Python code \"compiles\"?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"My background is C and C++. I like Python a lot, but there's one aspect of it (and other interpreted languages I guess) that is really hard to work with when you're used to compiled languages.\nWhen I've written something in Python and come to the point where I can run it, there's still no guarantee that no language-specific errors remain. For me that means that I can't rely solely on my runtime defense (rigorous testing of input, asserts etc.) to avoid crashes, because in 6 months when some otherwise nice code finally gets run, it might crack due to some stupid typo.\nClearly a system should be tested enough to make sure all code has been run, but most of the time I use Python for in-house scripts and small tools, which ofcourse never gets the QA attention they need. Also, some code is so simple that (if your background is C\/C++) you know it will work fine as long as it compiles (e.g. getter-methods inside classes, usually a simple return of a member variable).\nSo, my question is the obvious - is there any way (with a special tool or something) I can make sure all the code in my Python script will \"compile\" and run?","AnswerCount":5,"Available Count":3,"Score":0.0399786803,"is_accepted":false,"ViewCount":1051,"Q_Id":1026966,"Users Score":1,"Answer":"I think what you are looking for is code test line coverage. You want to add tests to your script that will make sure all of your lines of code, or as many as you have time to, get tested. Testing is a great deal of work, but if you want the kind of assurance you are asking for, there is no free lunch, sorry :( .","Q_Score":14,"Tags":"python,parsing,code-analysis","A_Id":1026984,"CreationDate":"2009-06-22T12:36:00.000","Title":"How can I make sure all my Python code \"compiles\"?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"My background is C and C++. I like Python a lot, but there's one aspect of it (and other interpreted languages I guess) that is really hard to work with when you're used to compiled languages.\nWhen I've written something in Python and come to the point where I can run it, there's still no guarantee that no language-specific errors remain. For me that means that I can't rely solely on my runtime defense (rigorous testing of input, asserts etc.) to avoid crashes, because in 6 months when some otherwise nice code finally gets run, it might crack due to some stupid typo.\nClearly a system should be tested enough to make sure all code has been run, but most of the time I use Python for in-house scripts and small tools, which ofcourse never gets the QA attention they need. Also, some code is so simple that (if your background is C\/C++) you know it will work fine as long as it compiles (e.g. getter-methods inside classes, usually a simple return of a member variable).\nSo, my question is the obvious - is there any way (with a special tool or something) I can make sure all the code in my Python script will \"compile\" and run?","AnswerCount":5,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":1051,"Q_Id":1026966,"Users Score":0,"Answer":"Your code actually gets compiled when you run it, the Python runtime will complain if there is a syntax error in the code. Compared to statically compiled languages like C\/C++ or Java, it does not check whether variable names and types are correct \u2013 for that you need to actually run the code (e.g. with automated tests).","Q_Score":14,"Tags":"python,parsing,code-analysis","A_Id":1027032,"CreationDate":"2009-06-22T12:36:00.000","Title":"How can I make sure all my Python code \"compiles\"?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Firstly, what is the best\/simplest way to detect if X11 is running and available for a python script.\nparent process?\nsession leader?\nX environment variables?\nother? \nSecondly, I would like to have a utility (python script) to present a gui if available, otherwise use a command line backed tool.\nOff the top of my head I thought of this\n-main python script (detects if gui is available and launches appropriate script)\n-gui or command line python script starts\n-both use a generic module to do actual work \nI am very open to suggestions to simplify this.","AnswerCount":3,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":3965,"Q_Id":1027894,"Users Score":5,"Answer":"You could simply launch the gui part, and catch the exception it raises when X (or any other platform dependent graphics system is not available.\nMake sure you really have an interactive terminal before running the text based part. Your process might have been started without a visible terminal, as is common in graphical user environments like KDE, gnome or windows.","Q_Score":6,"Tags":"python,user-interface","A_Id":1027918,"CreationDate":"2009-06-22T15:38:00.000","Title":"Detect if X11 is available (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},{"Question":"I have quite a few years experience of developing PHP web applications, and have recently started to delve into Python as well. Recently I've been interested in getting into desktop applications as well, but have absolutely no experience in that area. I've seen very little written about PHP-gtk and wonder whether it's really a good area to get stuck in to.\nWhat I'm really looking for is something that will allow me to quite quickly develop some decent small\/medium sized apps, and be able to deploy them in Linux and Windows. Something in Python or PHP would be great (but I'd be happy to learn something else if it has big advantages).\nWhat do you guys recommend?\nThanks","AnswerCount":4,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":1720,"Q_Id":1029435,"Users Score":0,"Answer":"Why would you like to develop a desktop app in php??\nGet yourself a descent programming environment (c\/java\/c#\/) instead of abusing php\nespecially with c# and java you get pretty quick very nice results. And both are cross platform (although java is easier for cross platform stuff).\nC(++) in combination with QT or GTK is also possible, but there the results appear slower","Q_Score":8,"Tags":"php,python,gtk,desktop,pygtk","A_Id":1029459,"CreationDate":"2009-06-22T21:15:00.000","Title":"PHP desktop 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},{"Question":"I have quite a few years experience of developing PHP web applications, and have recently started to delve into Python as well. Recently I've been interested in getting into desktop applications as well, but have absolutely no experience in that area. I've seen very little written about PHP-gtk and wonder whether it's really a good area to get stuck in to.\nWhat I'm really looking for is something that will allow me to quite quickly develop some decent small\/medium sized apps, and be able to deploy them in Linux and Windows. Something in Python or PHP would be great (but I'd be happy to learn something else if it has big advantages).\nWhat do you guys recommend?\nThanks","AnswerCount":4,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":1720,"Q_Id":1029435,"Users Score":2,"Answer":"Python and Java are both excellent for working on both Linux and Windows environment. They are generally hassle-free as long as you're not doing any OS specific type of work. Python for creating desktop apps is fairly simple and easy to learn as well if you're coming from a PHP background, especially if you're used to doing object oriented PHP.","Q_Score":8,"Tags":"php,python,gtk,desktop,pygtk","A_Id":1029486,"CreationDate":"2009-06-22T21:15:00.000","Title":"PHP desktop 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},{"Question":"I am making a little webgame that has tasks and solutions, the solutions are solved by entering a code given to user after completion of a task. To have some security (against cheating) i dont want to store the codes genereted by the game in plain text. But since i need to be able to give a player the code when he has accomplished the task i cant hash it since then i cant retrive it.\nSo what is the most secure way to encrypt\/decrypt something using python?","AnswerCount":4,"Available Count":1,"Score":0.2449186624,"is_accepted":false,"ViewCount":4268,"Q_Id":1043735,"Users Score":5,"Answer":"The most secure encryption is no encryption. Passwords should be reduced to a hash. This is a one-way transformation, making the password (almost) unrecoverable.\nWhen giving someone a code, you can do the following to be actually secure. \n(1) generate some random string.\n(2) give them the string.\n(3) save the hash of the string you generated.\nOnce.\nIf they \"forget\" the code, you have to (1) be sure they're authorized to be given the code, then (2) do the process again (generate a new code, give it to them, save the hash.)","Q_Score":5,"Tags":"python,security,encryption","A_Id":1043762,"CreationDate":"2009-06-25T12:52:00.000","Title":"What is the most secure python \"password\" encryption","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"i am using Solaris 10 OS(x86). i installed beanstalkd and it starts fine by using command \"beanstalkd -d -l hostip -p 11300\".\ni have Python 2.4.4 on my system i installed YAML and beanstalkc python libraries to connect beanstalkd with python my problem is when i try to write some code:\nimport beanstalkc\nbeanstalk = beanstalkc.Connection(host='hostip', port=11300) \nno error so far but when i try to do someting on beanstalk like say listing queues. nothing happens.\nbeanstalk.tubes()\nit just hangs and nothing returns. if i cancel the operation(using ctr+c on python env.) or stop the server i immediately see an output:\nTraceback (most recent call last):\n File \"\", line 1, in ?\n File \"\/usr\/lib\/python2.4\/site-packages\/beanstalkc-0.1.1-py2.4.egg\/beanstalkc.py\", line 134, in tubes\n return self._interact_yaml('list-tubes\\r\\n', ['OK'])\n File \"\/usr\/lib\/python2.4\/site-packages\/beanstalkc-0.1.1-py2.4.egg\/beanstalkc.py\", line 83, in _interact_yaml\n size, = self._interact(command, expected_ok, expected_err)\n File \"\/usr\/lib\/python2.4\/site-packages\/beanstalkc-0.1.1-py2.4.egg\/beanstalkc.py\", line 57, in _interact\n status, results = self._read_response()\n File \"\/usr\/lib\/python2.4\/site-packages\/beanstalkc-0.1.1-py2.4.egg\/beanstalkc.py\", line 66, in _read_response\n response = self.socket_file.readline().split()\n File \"\/usr\/lib\/python2.4\/socket.py\", line 332, in readline\n data = self._sock.recv(self._rbufsize)\nany idea whats going? i am an Unix newbie so i have no idea what i did setup wrong to cause this. \nedit: seems like the problem lies within BeanStalkd itself, anyone have used this on Solaris 10? if so which version did you use? The v1.3 labeled one doesnt compile on Solaris while the latest from git code repository compiles it causes the above problem(or perhaps there is some configuration to do on Solaris?).\nedit2: i installed and compiled same components with beanstalkd, PyYAML, pythonbeanstalc and libevent to an UBUNTU machine and it works fine. problems seems to be about compilation of beanstalkd on solaris, i have yet to produce or read any solution.","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":394,"Q_Id":1044473,"Users Score":1,"Answer":"After looking in the code (beanstalkc):\nyour client has send his 'list-tubes' message, and is waiting for an answer.\n(until you kill it)\nyour server doesn't answer or can't send the answer to the client.\n(or the answer is shorter than the client expect)\nis a network-admin at your side (or site) :-)","Q_Score":2,"Tags":"python,solaris,yaml,beanstalkd","A_Id":1048086,"CreationDate":"2009-06-25T15:06:00.000","Title":"BeanStalkd on Solaris doesnt return anything when called from the python 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":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"i am using Solaris 10 OS(x86). i installed beanstalkd and it starts fine by using command \"beanstalkd -d -l hostip -p 11300\".\ni have Python 2.4.4 on my system i installed YAML and beanstalkc python libraries to connect beanstalkd with python my problem is when i try to write some code:\nimport beanstalkc\nbeanstalk = beanstalkc.Connection(host='hostip', port=11300) \nno error so far but when i try to do someting on beanstalk like say listing queues. nothing happens.\nbeanstalk.tubes()\nit just hangs and nothing returns. if i cancel the operation(using ctr+c on python env.) or stop the server i immediately see an output:\nTraceback (most recent call last):\n File \"\", line 1, in ?\n File \"\/usr\/lib\/python2.4\/site-packages\/beanstalkc-0.1.1-py2.4.egg\/beanstalkc.py\", line 134, in tubes\n return self._interact_yaml('list-tubes\\r\\n', ['OK'])\n File \"\/usr\/lib\/python2.4\/site-packages\/beanstalkc-0.1.1-py2.4.egg\/beanstalkc.py\", line 83, in _interact_yaml\n size, = self._interact(command, expected_ok, expected_err)\n File \"\/usr\/lib\/python2.4\/site-packages\/beanstalkc-0.1.1-py2.4.egg\/beanstalkc.py\", line 57, in _interact\n status, results = self._read_response()\n File \"\/usr\/lib\/python2.4\/site-packages\/beanstalkc-0.1.1-py2.4.egg\/beanstalkc.py\", line 66, in _read_response\n response = self.socket_file.readline().split()\n File \"\/usr\/lib\/python2.4\/socket.py\", line 332, in readline\n data = self._sock.recv(self._rbufsize)\nany idea whats going? i am an Unix newbie so i have no idea what i did setup wrong to cause this. \nedit: seems like the problem lies within BeanStalkd itself, anyone have used this on Solaris 10? if so which version did you use? The v1.3 labeled one doesnt compile on Solaris while the latest from git code repository compiles it causes the above problem(or perhaps there is some configuration to do on Solaris?).\nedit2: i installed and compiled same components with beanstalkd, PyYAML, pythonbeanstalc and libevent to an UBUNTU machine and it works fine. problems seems to be about compilation of beanstalkd on solaris, i have yet to produce or read any solution.","AnswerCount":3,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":394,"Q_Id":1044473,"Users Score":1,"Answer":"I might know what is wrong: don't start it in daemon (-d) mode. I have experienced the same and by accident I found out what is wrong.\nOr rather, I don't know what is wrong, but it works without running it in daemon mode.\n.\/beanstalkd -p 9977 & \nas an alternative.","Q_Score":2,"Tags":"python,solaris,yaml,beanstalkd","A_Id":1093128,"CreationDate":"2009-06-25T15:06:00.000","Title":"BeanStalkd on Solaris doesnt return anything when called from the python 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":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have written several Python tools for my company. Is there any good reason to convert them from Python to C# now that their usefulness has been proven? Would I be better off just leaving them in Python?","AnswerCount":12,"Available Count":12,"Score":0.0166651236,"is_accepted":false,"ViewCount":406,"Q_Id":1045334,"Users Score":1,"Answer":"IF you are looking for reasons to convert them, I can think of a few. These don't necessarily mean you should, these are just possible reasons in the \"recode\" corner.\n\nMaintainability\n\nIf you have a dev-shop that is primarily C# focused, then have python applications around may not be useful for maintainability reasons. It would mean that they need to keep python staffers around (assuming it's a complicated app) in order to maintain it. This probably isn't a restriction they want, especially if they don't intend to write anything in python from here on out.\n\nConsistency\n\nThis sort of falls under maintainability, but it is of a different flavour. If they wanted to integrate part of this (python) application into a C# application, but not the whole thing, it's possible to write some boilerplate code, but again, that's messy to maintain. Ultimately, you would want to code of P_App to be able to be seamlessly integrated into C#_App, and not have to run them separately. \n\nOn the other side of the coin, it is fair to point out that you are throwing time and money at converting something which already works.","Q_Score":4,"Tags":"c#,.net,python","A_Id":1045606,"CreationDate":"2009-06-25T17:59:00.000","Title":"Is there any good reason to convert an app written in python to 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},{"Question":"I have written several Python tools for my company. Is there any good reason to convert them from Python to C# now that their usefulness has been proven? Would I be better off just leaving them in Python?","AnswerCount":12,"Available Count":12,"Score":1.0,"is_accepted":false,"ViewCount":406,"Q_Id":1045334,"Users Score":8,"Answer":"There's IronPython , a python implementation for .NET. You could port it to that if you really need to get away from the \"standard\" python vm and onto the .NET platform","Q_Score":4,"Tags":"c#,.net,python","A_Id":1045361,"CreationDate":"2009-06-25T17:59:00.000","Title":"Is there any good reason to convert an app written in python to 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},{"Question":"I have written several Python tools for my company. Is there any good reason to convert them from Python to C# now that their usefulness has been proven? Would I be better off just leaving them in Python?","AnswerCount":12,"Available Count":12,"Score":-0.0166651236,"is_accepted":false,"ViewCount":406,"Q_Id":1045334,"Users Score":-1,"Answer":"i will convert it from language a to language b for 1 million dollars. <--- this would be the only business reason I would consider legit.","Q_Score":4,"Tags":"c#,.net,python","A_Id":1045479,"CreationDate":"2009-06-25T17:59:00.000","Title":"Is there any good reason to convert an app written in python to 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},{"Question":"I have written several Python tools for my company. Is there any good reason to convert them from Python to C# now that their usefulness has been proven? Would I be better off just leaving them in Python?","AnswerCount":12,"Available Count":12,"Score":0.0166651236,"is_accepted":false,"ViewCount":406,"Q_Id":1045334,"Users Score":1,"Answer":"Short and to the point answer: No, there is no reason.","Q_Score":4,"Tags":"c#,.net,python","A_Id":1046028,"CreationDate":"2009-06-25T17:59:00.000","Title":"Is there any good reason to convert an app written in python to 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},{"Question":"I have written several Python tools for my company. Is there any good reason to convert them from Python to C# now that their usefulness has been proven? Would I be better off just leaving them in Python?","AnswerCount":12,"Available Count":12,"Score":0.0,"is_accepted":false,"ViewCount":406,"Q_Id":1045334,"Users Score":0,"Answer":"Some reasons that come to mind:\n\nPerformance \nEasier to find developers\nHuge huge huge developer and tools\necosystem\n\nBut I second what the others have stated: if it ain't broke, don't fix it. Unless your boss is saying, \"hey, we're moving all our crap to .NET\", or you're presented with some other business reason for migrating, just stick with what you've got.","Q_Score":4,"Tags":"c#,.net,python","A_Id":1045561,"CreationDate":"2009-06-25T17:59:00.000","Title":"Is there any good reason to convert an app written in python to 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},{"Question":"I have written several Python tools for my company. Is there any good reason to convert them from Python to C# now that their usefulness has been proven? Would I be better off just leaving them in Python?","AnswerCount":12,"Available Count":12,"Score":0.0,"is_accepted":false,"ViewCount":406,"Q_Id":1045334,"Users Score":0,"Answer":"The only thing I can think of is the performance boost C# will give you.","Q_Score":4,"Tags":"c#,.net,python","A_Id":1045532,"CreationDate":"2009-06-25T17:59:00.000","Title":"Is there any good reason to convert an app written in python to 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},{"Question":"I have written several Python tools for my company. Is there any good reason to convert them from Python to C# now that their usefulness has been proven? Would I be better off just leaving them in Python?","AnswerCount":12,"Available Count":12,"Score":0.0166651236,"is_accepted":false,"ViewCount":406,"Q_Id":1045334,"Users Score":1,"Answer":"As long as the application is running fine there is no reason to switch to C#.","Q_Score":4,"Tags":"c#,.net,python","A_Id":1045512,"CreationDate":"2009-06-25T17:59:00.000","Title":"Is there any good reason to convert an app written in python to 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},{"Question":"I have written several Python tools for my company. Is there any good reason to convert them from Python to C# now that their usefulness has been proven? Would I be better off just leaving them in Python?","AnswerCount":12,"Available Count":12,"Score":1.0,"is_accepted":false,"ViewCount":406,"Q_Id":1045334,"Users Score":6,"Answer":"Leave them as Python unless you hear a very good business reason to convert.","Q_Score":4,"Tags":"c#,.net,python","A_Id":1045356,"CreationDate":"2009-06-25T17:59:00.000","Title":"Is there any good reason to convert an app written in python to 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},{"Question":"I have written several Python tools for my company. Is there any good reason to convert them from Python to C# now that their usefulness has been proven? Would I be better off just leaving them in Python?","AnswerCount":12,"Available Count":12,"Score":0.0665680765,"is_accepted":false,"ViewCount":406,"Q_Id":1045334,"Users Score":4,"Answer":"Changing languages just for the sake of changing languages is rarely a good idea. If the app is doing its obj then let it do its job. If you've got a corporate mandate to only use C#, that may be a different story (estimate the work involved, give the estimate to management, let them decide to pursue it or write up an exception). Even if there isn't a strong (or any) knowledge of Python across the organization, developers are rather proficient at picking up new languages {it's a survival thing}, so that tends to be less of a concern.\nMoral of the story, if an app is to be rewritten, there should really be more of a justification to do the rewrite than just to change languages. If you were to add features that would be significantly easier to implement and maintain using another languages library\/framework ... good justification. If maintaining the environment\/framework for one language is causing a significant operational expense that could be saved by a re-write, cool. \"Because our other code is in c#\" ... not cool.","Q_Score":4,"Tags":"c#,.net,python","A_Id":1045446,"CreationDate":"2009-06-25T17:59:00.000","Title":"Is there any good reason to convert an app written in python to 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},{"Question":"I have written several Python tools for my company. Is there any good reason to convert them from Python to C# now that their usefulness has been proven? Would I be better off just leaving them in Python?","AnswerCount":12,"Available Count":12,"Score":0.0166651236,"is_accepted":false,"ViewCount":406,"Q_Id":1045334,"Users Score":1,"Answer":"I would not convert unless you are converting as part of an enterprise-wide switch from one language to another. Even then I would avoid converting until absolutely necessary. If it works, why change it?","Q_Score":4,"Tags":"c#,.net,python","A_Id":1045349,"CreationDate":"2009-06-25T17:59:00.000","Title":"Is there any good reason to convert an app written in python to 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},{"Question":"I have written several Python tools for my company. Is there any good reason to convert them from Python to C# now that their usefulness has been proven? Would I be better off just leaving them in Python?","AnswerCount":12,"Available Count":12,"Score":1.2,"is_accepted":true,"ViewCount":406,"Q_Id":1045334,"Users Score":13,"Answer":"Quote: \"If it doesn't break, don't fix it.\"\nUnless your company is moving towards .NET and\/or there are no more qualified Python developer available anymore, then don't.","Q_Score":4,"Tags":"c#,.net,python","A_Id":1045351,"CreationDate":"2009-06-25T17:59:00.000","Title":"Is there any good reason to convert an app written in python to 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},{"Question":"I have written several Python tools for my company. Is there any good reason to convert them from Python to C# now that their usefulness has been proven? Would I be better off just leaving them in Python?","AnswerCount":12,"Available Count":12,"Score":0.049958375,"is_accepted":false,"ViewCount":406,"Q_Id":1045334,"Users Score":3,"Answer":"If you're the only Python developer in a C# shop, then it makes plenty of sense to convert. If you quit tomorrow, no one will be able to maintain these systems.","Q_Score":4,"Tags":"c#,.net,python","A_Id":1045378,"CreationDate":"2009-06-25T17:59:00.000","Title":"Is there any good reason to convert an app written in python to 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},{"Question":"Let's say I'm programming in Java or Python or C++ for a simple problem, could be to build an TCP\/UDP echo server or computation of factorial. Do I've to bother about the architecture details, i.e., if it is 32 or 64-bit?\nIMHO, unless I'm programming something to do with fairly low-level stuff then I don't have to bother if its 32 or 64 bit. Where am I going wrong? Or am I correct???","AnswerCount":11,"Available Count":9,"Score":0.0544914242,"is_accepted":false,"ViewCount":1267,"Q_Id":1046068,"Users Score":3,"Answer":"In Java and Python, architecture details are abstracted away so that it is in fact more or less impossible to write architecture-dependant code.\nWith C++, this is an entirely different matter - you can certainly write code that does not depend on architecture details, but you have be careful to avoid pitfalls, specifically concerning basic data types that are are architecture-dependant, such as int.","Q_Score":6,"Tags":"java,c++,python,64-bit,32-bit","A_Id":1046149,"CreationDate":"2009-06-25T20:30:00.000","Title":"Would one have to know the machine architecture to write 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":0},{"Question":"Let's say I'm programming in Java or Python or C++ for a simple problem, could be to build an TCP\/UDP echo server or computation of factorial. Do I've to bother about the architecture details, i.e., if it is 32 or 64-bit?\nIMHO, unless I'm programming something to do with fairly low-level stuff then I don't have to bother if its 32 or 64 bit. Where am I going wrong? Or am I correct???","AnswerCount":11,"Available Count":9,"Score":0.0181798149,"is_accepted":false,"ViewCount":1267,"Q_Id":1046068,"Users Score":1,"Answer":"If you are programming in Python or in Java, the interpreter and the virtual machine respectively abstract this layer of the architecture. You then need not to worry if it's running on a 32 or 64 bits architecture.\nThe same cannot be said for C++, in which you'll have to ask yourself sometimes if you are running on a 32 or 64 bits machine","Q_Score":6,"Tags":"java,c++,python,64-bit,32-bit","A_Id":1046141,"CreationDate":"2009-06-25T20:30:00.000","Title":"Would one have to know the machine architecture to write 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":0},{"Question":"Let's say I'm programming in Java or Python or C++ for a simple problem, could be to build an TCP\/UDP echo server or computation of factorial. Do I've to bother about the architecture details, i.e., if it is 32 or 64-bit?\nIMHO, unless I'm programming something to do with fairly low-level stuff then I don't have to bother if its 32 or 64 bit. Where am I going wrong? Or am I correct???","AnswerCount":11,"Available Count":9,"Score":0.0,"is_accepted":false,"ViewCount":1267,"Q_Id":1046068,"Users Score":0,"Answer":"In C++, you have to be very careful if you want to write code that works indifferently on 32 or 64 bits.\nMany people wrongly assume that int can store a pointer, for example.","Q_Score":6,"Tags":"java,c++,python,64-bit,32-bit","A_Id":1046113,"CreationDate":"2009-06-25T20:30:00.000","Title":"Would one have to know the machine architecture to write 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":0},{"Question":"Let's say I'm programming in Java or Python or C++ for a simple problem, could be to build an TCP\/UDP echo server or computation of factorial. Do I've to bother about the architecture details, i.e., if it is 32 or 64-bit?\nIMHO, unless I'm programming something to do with fairly low-level stuff then I don't have to bother if its 32 or 64 bit. Where am I going wrong? Or am I correct???","AnswerCount":11,"Available Count":9,"Score":0.0,"is_accepted":false,"ViewCount":1267,"Q_Id":1046068,"Users Score":0,"Answer":"A 32 bit machine will allow you to have a maximum of 4 GB of addressable virtual memory. (In practice, it's even less than that, usually 2 GB or 3 GB depending on the OS and various linker options.) On a 64 bit machine, you can have a HUGE virtual address space (in any practical sense, limited only by disk) and a pretty damn big RAM.\nSo if you are expecting 6GB data sets for some computation (let's say something that needs incoherent access and can't just be streamed a bit at a time), on a 64 bit architecture you could just read it into RAM and do your stuff, whereas on a 32 bit architecture you need a fundamentally different way to approach it, since you simply do not have the option of keeping the entire data set resident.","Q_Score":6,"Tags":"java,c++,python,64-bit,32-bit","A_Id":1046737,"CreationDate":"2009-06-25T20:30:00.000","Title":"Would one have to know the machine architecture to write 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":0},{"Question":"Let's say I'm programming in Java or Python or C++ for a simple problem, could be to build an TCP\/UDP echo server or computation of factorial. Do I've to bother about the architecture details, i.e., if it is 32 or 64-bit?\nIMHO, unless I'm programming something to do with fairly low-level stuff then I don't have to bother if its 32 or 64 bit. Where am I going wrong? Or am I correct???","AnswerCount":11,"Available Count":9,"Score":0.0363476168,"is_accepted":false,"ViewCount":1267,"Q_Id":1046068,"Users Score":2,"Answer":"As long as you do things correctly, you almost never need to know for most languages. On many, you never need to know, as the language behavior doesn't vary (Java, for example, specifies the runtime behavior precisely).\nIn C++ and C, doing things correctly includes not making assumptions about int. Don't put pointers in int, and when you're doing anything with memory sizes or addresses use size_t and ptrdiff_t. Don't count on the size of data types: int must be at least 16 bits, almost always is 32, and may be 64 on some architectures. Don't assume that floating-point arithmetic will be done in exactly the same way on different machines (the IEEE standards have some leeway in them).\nPretty much all OSes that support networking will give you some way to deal with possible endianness problems. Use them. Use language facilities like isalpha() to classify characters, rather than arithmetic operations on characters (which might be something weird like EBCDIC). (Of course, it's now more usual to use wchar_t as character type, and use Unicode internally.)","Q_Score":6,"Tags":"java,c++,python,64-bit,32-bit","A_Id":1046182,"CreationDate":"2009-06-25T20:30:00.000","Title":"Would one have to know the machine architecture to write 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":0},{"Question":"Let's say I'm programming in Java or Python or C++ for a simple problem, could be to build an TCP\/UDP echo server or computation of factorial. Do I've to bother about the architecture details, i.e., if it is 32 or 64-bit?\nIMHO, unless I'm programming something to do with fairly low-level stuff then I don't have to bother if its 32 or 64 bit. Where am I going wrong? Or am I correct???","AnswerCount":11,"Available Count":9,"Score":0.0,"is_accepted":false,"ViewCount":1267,"Q_Id":1046068,"Users Score":0,"Answer":"With java and .net you don't really have to bother with it unless you are doing very low level stuff like twiddling bits. If you are using c, c++, fortran you might get by but I would actually recommend using things like \"stdint.h\" where you use definitive declares like uint64_t and uint32_t so as to be explicit. Also, you will need to build with particularly libraries depending on how you are linking, for example a 64 bit system might use gcc in a default 64 bit compile mode.","Q_Score":6,"Tags":"java,c++,python,64-bit,32-bit","A_Id":1046298,"CreationDate":"2009-06-25T20:30:00.000","Title":"Would one have to know the machine architecture to write 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":0},{"Question":"Let's say I'm programming in Java or Python or C++ for a simple problem, could be to build an TCP\/UDP echo server or computation of factorial. Do I've to bother about the architecture details, i.e., if it is 32 or 64-bit?\nIMHO, unless I'm programming something to do with fairly low-level stuff then I don't have to bother if its 32 or 64 bit. Where am I going wrong? Or am I correct???","AnswerCount":11,"Available Count":9,"Score":0.0,"is_accepted":false,"ViewCount":1267,"Q_Id":1046068,"Users Score":0,"Answer":"You will need to care about \"endian-ness\" only if you send and receive raw C structs \nover the wire like\n\nret = send(socket, &myStruct, sizeof(myStruct));\n\nHowever this is not a recommended practice.\nIt's recommended that you define a protocol between the parties such it doesn't matter\nthe parties' machine architectures.","Q_Score":6,"Tags":"java,c++,python,64-bit,32-bit","A_Id":1046100,"CreationDate":"2009-06-25T20:30:00.000","Title":"Would one have to know the machine architecture to write 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":0},{"Question":"Let's say I'm programming in Java or Python or C++ for a simple problem, could be to build an TCP\/UDP echo server or computation of factorial. Do I've to bother about the architecture details, i.e., if it is 32 or 64-bit?\nIMHO, unless I'm programming something to do with fairly low-level stuff then I don't have to bother if its 32 or 64 bit. Where am I going wrong? Or am I correct???","AnswerCount":11,"Available Count":9,"Score":1.2,"is_accepted":true,"ViewCount":1267,"Q_Id":1046068,"Users Score":16,"Answer":"correct for most circumstances\nThe runtime\/language\/compiler will abstract those details unless you are dealing directly with word sizes or binary at a low level.\nEven byteorder is abstracted by the NIC\/Network stack in the kernel. It is translated for you. When programming sockets in C, you do sometimes have to deal with byte ordering for the network when sending data ... but that doesn't concern 32 or 64 bit differences.\nWhen dealing with blobs of binary data, mapping them from one architecture to another (as an overlay to a C struct for example) can cause problems as others have mentioned, but this is why we develop architecture independent protocols based on characters and so on.\nIn-fact things like Java run in a virtual machine that abstracts the machine another step!\nKnowing a bit about the instruction set of the architecture, and how the syntax is compiled to that can help you understand the platform and write cleaner, tighter code. I know I grimace at some old C code after studying compilers!","Q_Score":6,"Tags":"java,c++,python,64-bit,32-bit","A_Id":1046099,"CreationDate":"2009-06-25T20:30:00.000","Title":"Would one have to know the machine architecture to write 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":0},{"Question":"Let's say I'm programming in Java or Python or C++ for a simple problem, could be to build an TCP\/UDP echo server or computation of factorial. Do I've to bother about the architecture details, i.e., if it is 32 or 64-bit?\nIMHO, unless I'm programming something to do with fairly low-level stuff then I don't have to bother if its 32 or 64 bit. Where am I going wrong? Or am I correct???","AnswerCount":11,"Available Count":9,"Score":1.0,"is_accepted":false,"ViewCount":1267,"Q_Id":1046068,"Users Score":16,"Answer":"Knowing how things work, be it how the virtual machine works, and how it works on your platform, or how certain C++ constructs are transformed into assembly will always make you a better programmer, because you will understand why things should be done the way they are.\nYou need to understand things like memory to know what cache-misses are and why those might affect your program. You should know how certain things are implemented, even though you might only use an interface or high-level way to get to it, knowing how it works will make sure you're doing it in the best way.\nFor packet work, you need to understand how data is stored on platforms and how sending that across the network to a different platform might change how the data is read (endian-ness).\nYour compiler will make best use of the platform you're compiling on, so as long as you stick to standards and code well, you can ignore most things and assume the compiler will whip out what's best.\nSo in short, no. You don't need to know the low level stuff, but it never hurts to know.","Q_Score":6,"Tags":"java,c++,python,64-bit,32-bit","A_Id":1046128,"CreationDate":"2009-06-25T20:30:00.000","Title":"Would one have to know the machine architecture to write 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":0},{"Question":"I'm storing a value in memcached using PHP's Memcache extension and trying to retrieve it in a daemon written in Python sitting behind my webapp. But, it keeps returning None or throwing \"local variable 'val' referenced before assignment\".\nI'm sure I'm looking for the same key, and there's only one mc server available to either app (localhost). If I try setting the key on a Python terminal, it returns False and unsets it (i.e., I can no longer retrieve it through PHP). Any ideas?","AnswerCount":2,"Available Count":2,"Score":0.3799489623,"is_accepted":false,"ViewCount":1069,"Q_Id":1046847,"Users Score":4,"Answer":"By default, the PHP client stores keys in PHP's serialized format (which Python won't understand by default). If the Python client does something similar (using its own serialization format), that'd be your problem.\nYou can always use telnet\/netcat to see what exactly is getting stored.","Q_Score":1,"Tags":"php,python,memcached","A_Id":1046859,"CreationDate":"2009-06-26T00:28:00.000","Title":"Accessing a PHP-set memcache key 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},{"Question":"I'm storing a value in memcached using PHP's Memcache extension and trying to retrieve it in a daemon written in Python sitting behind my webapp. But, it keeps returning None or throwing \"local variable 'val' referenced before assignment\".\nI'm sure I'm looking for the same key, and there's only one mc server available to either app (localhost). If I try setting the key on a Python terminal, it returns False and unsets it (i.e., I can no longer retrieve it through PHP). Any ideas?","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":1069,"Q_Id":1046847,"Users Score":1,"Answer":"You could serialise the \"data\" into json, which I've done once.","Q_Score":1,"Tags":"php,python,memcached","A_Id":4357288,"CreationDate":"2009-06-26T00:28:00.000","Title":"Accessing a PHP-set memcache key 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},{"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},{"Question":"I want to extend a large C project with some new functionality, but I really want to write it in Python. Basically, I want to call Python code from C code. However, Python->C wrappers like SWIG allow for the OPPOSITE, that is writing C modules and calling C from Python.\nI'm considering an approach involving IPC or RPC (I don't mind having multiple processes); that is, having my pure-Python component run in a separate process (on the same machine) and having my C project communicate with it by writing\/reading from a socket (or unix pipe). my python component can read\/write to socket to communicate. Is that a reasonable approach? Is there something better? Like some special RPC mechanism?\nThanks for the answer so far - however, i'd like to focus on IPC-based approaches since I want to have my Python program in a separate process as my C program. I don't want to embed a Python interpreter. Thanks!","AnswerCount":9,"Available Count":3,"Score":0.022218565,"is_accepted":false,"ViewCount":79185,"Q_Id":1056051,"Users Score":1,"Answer":"I haven't used an IPC approach for Python<->C communication but it should work pretty well. I would have the C program do a standard fork-exec and use redirected stdin and stdout in the child process for the communication. A nice text-based communication will make it very easy to develop and test the Python program.","Q_Score":52,"Tags":"python,c,interop,cross-domain","A_Id":1056105,"CreationDate":"2009-06-28T23:37:00.000","Title":"How do you call Python code from C 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},{"Question":"I want to extend a large C project with some new functionality, but I really want to write it in Python. Basically, I want to call Python code from C code. However, Python->C wrappers like SWIG allow for the OPPOSITE, that is writing C modules and calling C from Python.\nI'm considering an approach involving IPC or RPC (I don't mind having multiple processes); that is, having my pure-Python component run in a separate process (on the same machine) and having my C project communicate with it by writing\/reading from a socket (or unix pipe). my python component can read\/write to socket to communicate. Is that a reasonable approach? Is there something better? Like some special RPC mechanism?\nThanks for the answer so far - however, i'd like to focus on IPC-based approaches since I want to have my Python program in a separate process as my C program. I don't want to embed a Python interpreter. Thanks!","AnswerCount":9,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":79185,"Q_Id":1056051,"Users Score":0,"Answer":"apparently Python need to be able to compile to win32 dll, it will solve the problem\nIn such a way that converting c# code to win32 dlls will make it usable by any development tool","Q_Score":52,"Tags":"python,c,interop,cross-domain","A_Id":1621442,"CreationDate":"2009-06-28T23:37:00.000","Title":"How do you call Python code from C 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},{"Question":"I want to extend a large C project with some new functionality, but I really want to write it in Python. Basically, I want to call Python code from C code. However, Python->C wrappers like SWIG allow for the OPPOSITE, that is writing C modules and calling C from Python.\nI'm considering an approach involving IPC or RPC (I don't mind having multiple processes); that is, having my pure-Python component run in a separate process (on the same machine) and having my C project communicate with it by writing\/reading from a socket (or unix pipe). my python component can read\/write to socket to communicate. Is that a reasonable approach? Is there something better? Like some special RPC mechanism?\nThanks for the answer so far - however, i'd like to focus on IPC-based approaches since I want to have my Python program in a separate process as my C program. I don't want to embed a Python interpreter. Thanks!","AnswerCount":9,"Available Count":3,"Score":1.0,"is_accepted":false,"ViewCount":79185,"Q_Id":1056051,"Users Score":7,"Answer":"Have you considered just wrapping your python application in a shell script and invoking it from within your C application?\nNot the most elegant solution, but it is very simple.","Q_Score":52,"Tags":"python,c,interop,cross-domain","A_Id":1056087,"CreationDate":"2009-06-28T23:37:00.000","Title":"How do you call Python code from C 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},{"Question":"I have been doing active development in C# for several years now. I primarily build enterprise application and in house frameworks on the .NET stack.\nI've never had the need to use any other mainstream high level languages besides C# for my tasks, since .NET is the standard platform we use.\nThere are some legacy Python applications that I have been asked to support going forward, I have no exposure to python and dynamic languages in general(although I've done a fair bit of JavaScript).\nI was hoping to get some guidance\/advise to aid in how to go about learning a language like python for the statically typed mind.\nEDIT: Using IronPython is not an option!","AnswerCount":8,"Available Count":2,"Score":0.0748596907,"is_accepted":false,"ViewCount":14771,"Q_Id":1072530,"Users Score":3,"Answer":"You're going to experience quite a bit of culture-shock going from C# to the wild duck-typed outback of Python. Lack of types and intellisense can be pretty daunting. Good thing that you're experienced in JavaScript. Also know that indent-sensitive block rules of Python can be very confusing for the inexperience (usually you either love it or hate it :-)\nApart from that the biggest challenge moving from one language to another is usually the framework. Getting to know all the classes and functions Just Takes Time unfortunately.","Q_Score":22,"Tags":"c#,.net,python,dynamic-languages","A_Id":1073426,"CreationDate":"2009-07-02T04:42:00.000","Title":"Learning Python for a .NET developer","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have been doing active development in C# for several years now. I primarily build enterprise application and in house frameworks on the .NET stack.\nI've never had the need to use any other mainstream high level languages besides C# for my tasks, since .NET is the standard platform we use.\nThere are some legacy Python applications that I have been asked to support going forward, I have no exposure to python and dynamic languages in general(although I've done a fair bit of JavaScript).\nI was hoping to get some guidance\/advise to aid in how to go about learning a language like python for the statically typed mind.\nEDIT: Using IronPython is not an option!","AnswerCount":8,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":14771,"Q_Id":1072530,"Users Score":4,"Answer":"There is a big initial hurdle of getting comfortable with dynamic typing. The first step is when you look at Python-code and realize that variables aren't defined anywhere, you just create them out of thin air, which feels like jumping over a cliff. There is a brief moment before your hang glider catches the air properly. \nAnd then it's going to take time before you trust your newfound dynamic wings, and you probably only can get their by doing aerobatics with them. Learn how python handles references, have fun with monkey-patching methods, duck type various animals. Try to learn some ugly tricks.\nAnd although you can't use IronPython for this, there is no reason you can't use it to learn Python.","Q_Score":22,"Tags":"c#,.net,python,dynamic-languages","A_Id":1072788,"CreationDate":"2009-07-02T04:42:00.000","Title":"Learning Python for a .NET developer","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":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.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},{"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},{"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},{"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},{"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},{"Question":"We have several cron jobs that ftp proxy logs to a centralized server. These files can be rather large and take some time to transfer. Part of the requirement of this project is to provide a logging mechanism in which we log the success or failure of these transfers. This is simple enough.\nMy question is, is there a way to check if a file is currently being written to? My first solution was to just check the file size twice within a given timeframe and check the file size. But a co-worker said that there may be able to hook into the EXT3 file system via python and check the attributes to see if the file is currently being appended to. My Google-Fu came up empty. \nIs there a module for EXT3 or something else that would allow me to check the state of a file? The server is running Fedora Core 9 with EXT3 file system.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":640,"Q_Id":1075391,"Users Score":7,"Answer":"no need for ext3-specific hooks; just check lsof, or more exactly, \/proc\/\/fd\/* and \/proc\/\/fdinfo\/* (that's where lsof gets it's info, AFAICT). There you can check if the file is open, if it's writeable, and the 'cursor' position.\nThat's not the whole picture; but any more is done in processpace by stdlib on the writing process, as most writes are buffered and the kernel only sees bigger chunks of data, so any 'ext3-aware' monitor wouldn't get that either.","Q_Score":4,"Tags":"python,linux,ext3","A_Id":1075459,"CreationDate":"2009-07-02T16:32:00.000","Title":"Does python have hooks into EXT3","Data Science and Machine Learning":0,"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},{"Question":"I have a problem of upgrading python from 2.4 to 2.6:\nI have CentOS 5 (Full). It has python 2.4 living in \/usr\/lib\/python2.4\/ . Additional modules are living in \/usr\/lib\/python2.4\/site-packages\/ . I've built python 2.6 from sources at \/usr\/local\/lib\/python2.6\/ . I've set default python to python2.6 . Now old modules for 2.4 are out of pythonpath and are \"lost\". In particular, yum is broken (\"no module named yum\").\nSo what is the right way to migrate\/install modules to python2.6?","AnswerCount":4,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":6767,"Q_Id":1081698,"Users Score":0,"Answer":"easy_install is good one but there are low level way for installing module, just:\n\nunpack module source to some directory\ntype \"python setup.py install\"\n\nOf course you should do this with required installed python interpreter version; for checking it type:\npython -V","Q_Score":3,"Tags":"python,linux,upgrade,centos,python-2.6","A_Id":1085044,"CreationDate":"2009-07-04T06:59:00.000","Title":"Transition from Python2.4 to Python2.6 on CentOS, module migration problem","Data Science and Machine Learning":0,"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},{"Question":"I have a problem of upgrading python from 2.4 to 2.6:\nI have CentOS 5 (Full). It has python 2.4 living in \/usr\/lib\/python2.4\/ . Additional modules are living in \/usr\/lib\/python2.4\/site-packages\/ . I've built python 2.6 from sources at \/usr\/local\/lib\/python2.6\/ . I've set default python to python2.6 . Now old modules for 2.4 are out of pythonpath and are \"lost\". In particular, yum is broken (\"no module named yum\").\nSo what is the right way to migrate\/install modules to python2.6?","AnswerCount":4,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":6767,"Q_Id":1081698,"Users Score":0,"Answer":"There are a couple of options...\n\nIf the modules will run under Python 2.6, you can simply create symbolic links to them from the 2.6 site-packages directory to the 2.4 site-packages directory.\nIf they will not run under 2.6, then you may need to re-compile them against 2.6, or install up-to-date versions of them. Just make sure you are using 2.6 when calling \"python setup.py\"\n\n...\nYou may want to post this on serverfault.com, if you run into additional challenges.","Q_Score":3,"Tags":"python,linux,upgrade,centos,python-2.6","A_Id":1081705,"CreationDate":"2009-07-04T06:59:00.000","Title":"Transition from Python2.4 to Python2.6 on CentOS, module migration problem","Data Science and Machine Learning":0,"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},{"Question":"I have a problem of upgrading python from 2.4 to 2.6:\nI have CentOS 5 (Full). It has python 2.4 living in \/usr\/lib\/python2.4\/ . Additional modules are living in \/usr\/lib\/python2.4\/site-packages\/ . I've built python 2.6 from sources at \/usr\/local\/lib\/python2.6\/ . I've set default python to python2.6 . Now old modules for 2.4 are out of pythonpath and are \"lost\". In particular, yum is broken (\"no module named yum\").\nSo what is the right way to migrate\/install modules to python2.6?","AnswerCount":4,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":6767,"Q_Id":1081698,"Users Score":0,"Answer":"Some Python libs may be still not accessible as with Python 2.6 site-packages is changed to dist-packages. \nThe only way in that case is to do move all stuff generated in site-packages (e.g. by make install) to dist-packages and create a sym-link.","Q_Score":3,"Tags":"python,linux,upgrade,centos,python-2.6","A_Id":1082045,"CreationDate":"2009-07-04T06:59:00.000","Title":"Transition from Python2.4 to Python2.6 on CentOS, module migration problem","Data Science and Machine Learning":0,"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},{"Question":"When i tried recording using QTP, every thing goes well till the application sign in. i.e it gets upto the user Id and password entry, But QTP fails to recognise afterthat. Is there any way to handle this?\nApplication is to be invoked using Citirx, in VPN.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":697,"Q_Id":1086758,"Users Score":0,"Answer":"QTP performs GUI recognition and interaction through Windows Handle. \nSo it has to be running under Citrix (i.e. installed on the same virtual machine as your Application Under Test). \nIf you have the above, make sure Screen Resolution, Windows Theme, Font size, and other global GUI settings are the same.","Q_Score":1,"Tags":"c#,python,ruby","A_Id":1121154,"CreationDate":"2009-07-06T12:40:00.000","Title":"How to use QTP to test the application which operates in citrix of Remote Machine?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I am using Pylons to develop an application and I want my controller actions to send emails to certain addresses. Is there a built in Pylons feature for sending email?","AnswerCount":3,"Available Count":1,"Score":0.1325487884,"is_accepted":false,"ViewCount":1532,"Q_Id":1089576,"Users Score":2,"Answer":"Can't you just use standard Python library modules, email to prepare the mail and smtp to send it? What extra value beyond that are you looking for from the \"built-in feature\"?","Q_Score":4,"Tags":"python,pylons","A_Id":1089588,"CreationDate":"2009-07-06T22:55:00.000","Title":"Sending an email from Pylons","Data Science and Machine Learning":0,"Database and SQL":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},{"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},{"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},{"Question":"I need to upload a potentially huge plain-text file to a very simple wsgi-app without eating up all available memory on the server. How do I accomplish that? I want to use standard python modules and avoid third-party modules if possible.","AnswerCount":3,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":1494,"Q_Id":1103940,"Users Score":3,"Answer":"wsgi.input should be a file like stream object. You can read from that in blocks, and write those blocks directly to disk. That shouldn't use up any significant memory.\nOr maybe I misunderstood the question?","Q_Score":1,"Tags":"python,file,upload,wsgi","A_Id":1104012,"CreationDate":"2009-07-09T13:36:00.000","Title":"Upload a potentially huge textfile to a plain WSGI-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":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I need to upload a potentially huge plain-text file to a very simple wsgi-app without eating up all available memory on the server. How do I accomplish that? I want to use standard python modules and avoid third-party modules if possible.","AnswerCount":3,"Available Count":2,"Score":0.1325487884,"is_accepted":false,"ViewCount":1494,"Q_Id":1103940,"Users Score":2,"Answer":"If you use the cgi module to parse the input (which most frameworks use, e.g., Pylons, WebOb, CherryPy) then it will automatically save the uploaded file to a temporary file, and not load it into memory.","Q_Score":1,"Tags":"python,file,upload,wsgi","A_Id":1209507,"CreationDate":"2009-07-09T13:36:00.000","Title":"Upload a potentially huge textfile to a plain WSGI-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":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have the 'luck' of develop and enhance a legacy python web application for almost 2 years. The major contribution I consider I made is the introduction of the use of unit test, nosestest, pychecker and CI server. Yes, that's right, there are still project out there that has no single unit test (To be fair, it has a few doctest, but are broken).\nNonetheless, progress is slow, because literally the coverage is limited by how many unit tests you can afford to write. \nFrom time to time embarrassing mistakes still occur, and it does not look good on management reports. (e.g. even pychecker cannot catch certain \"missing attribute\" situation, and the program just blows up in run time)\nI just want to know if anyone has any suggestion about what additional thing I can do to improve the QA. The application uses WebWare 0.8.1, but I have expermentially ported it to cherrypy, so I can potentially take advantage of WSGI to conduct integration tests. \nMixed language development and\/or hiring an additional tester are also options I am thinking.\nNothing is too wild, as long as it works.","AnswerCount":5,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":664,"Q_Id":1107858,"Users Score":0,"Answer":"Few things help as much as testing.\nThese two quotes are really important.\n\n\"how many unit tests you can afford to write.\"\n\"From time to time embarrassing mistakes still occur,\"\n\nIf mistakes occur, you haven't written enough tests. If you're still having mistakes, then you can afford to write more unit tests. It's that simple. \nEach embarrassing mistake is a direct result of not writing enough unit tests. \nEach management report that describes an embarrassing mistake should also describe what testing is required to prevent that mistake from ever happening again. \nA unit test is a permanent prevention of further problems.","Q_Score":1,"Tags":"python,testing,integration-testing","A_Id":1108750,"CreationDate":"2009-07-10T05:29:00.000","Title":"Looking for testing\/QA idea for Python Web Application 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":1},{"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},{"Question":"I have a small Python program, which uses a Google Maps API secret key. I'm getting ready to check-in my code, and I don't want to include the secret key in SVN. \nIn the canonical PHP app you put secret keys, database passwords, and other app specific config in LocalSettings.php. Is there a similar file\/location which Python programmers expect to find and modify?","AnswerCount":3,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":3025,"Q_Id":1113479,"Users Score":3,"Answer":"No, there's no standard location - on Windows, it's usually in the directory os.path.join(os.environ['APPDATA'], 'appname') and on Unix it's usually os.path.join(os.environ['HOME'], '.appname').","Q_Score":3,"Tags":"python,configuration,google-maps","A_Id":1113496,"CreationDate":"2009-07-11T10:57:00.000","Title":"Where to store secret keys and password 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},{"Question":"Is it considered as a good practice to pick Unicode string over regular string when coding in Python? I mainly work on the Windows platform, where most of the string types are Unicode these days (i.e. .NET String, '_UNICODE' turned on by default on a new c++ project, etc ). Therefore, I tend to think that the case where non-Unicode string objects are used is a sort of rare case. Anyway, I'm curious about what Python practitioners do in real-world projects.","AnswerCount":6,"Available Count":5,"Score":0.1325487884,"is_accepted":false,"ViewCount":3614,"Q_Id":1116449,"Users Score":4,"Answer":"Additional to Mihails comment I would say: Use Unicode, since it is the future. In Python 3.0, Non-Unicode will be gone, and as much I know, all the \"U\"-Prefixes will make trouble, since they are also gone.","Q_Score":20,"Tags":"python,unicode","A_Id":1116549,"CreationDate":"2009-07-12T17:13:00.000","Title":"Should I use Unicode string by default?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Is it considered as a good practice to pick Unicode string over regular string when coding in Python? I mainly work on the Windows platform, where most of the string types are Unicode these days (i.e. .NET String, '_UNICODE' turned on by default on a new c++ project, etc ). Therefore, I tend to think that the case where non-Unicode string objects are used is a sort of rare case. Anyway, I'm curious about what Python practitioners do in real-world projects.","AnswerCount":6,"Available Count":5,"Score":1.2,"is_accepted":true,"ViewCount":3614,"Q_Id":1116449,"Users Score":19,"Answer":"From my practice -- use unicode. \nAt beginning of one project we used usuall strings, however our project was growing, we were implementing new features and using new third-party libraries. In that mess with non-unicode\/unicode string some functions started failing. We started spending time localizing this problems and fixing them. However, some third-party modules doesn't supported unicode and started failing after we switched to it (but this is rather exclusion than a rule). \nAlso I have some experience when we needed to rewrite some third party modules(e.g. SendKeys) cause they were not supporting unicode. If it was done in unicode from beginning it will be better :) \nSo I think today we should use unicode.\nP.S. All that mess upwards is only my hamble opinion :)","Q_Score":20,"Tags":"python,unicode","A_Id":1116476,"CreationDate":"2009-07-12T17:13:00.000","Title":"Should I use Unicode string by default?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Is it considered as a good practice to pick Unicode string over regular string when coding in Python? I mainly work on the Windows platform, where most of the string types are Unicode these days (i.e. .NET String, '_UNICODE' turned on by default on a new c++ project, etc ). Therefore, I tend to think that the case where non-Unicode string objects are used is a sort of rare case. Anyway, I'm curious about what Python practitioners do in real-world projects.","AnswerCount":6,"Available Count":5,"Score":0.0665680765,"is_accepted":false,"ViewCount":3614,"Q_Id":1116449,"Users Score":2,"Answer":"If you are dealing with severely constrained memory or disk space, use ASCII strings. In this case, you should additionally write your software in C or something even more compact :)","Q_Score":20,"Tags":"python,unicode","A_Id":1116487,"CreationDate":"2009-07-12T17:13:00.000","Title":"Should I use Unicode string by default?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Is it considered as a good practice to pick Unicode string over regular string when coding in Python? I mainly work on the Windows platform, where most of the string types are Unicode these days (i.e. .NET String, '_UNICODE' turned on by default on a new c++ project, etc ). Therefore, I tend to think that the case where non-Unicode string objects are used is a sort of rare case. Anyway, I'm curious about what Python practitioners do in real-world projects.","AnswerCount":6,"Available Count":5,"Score":1.0,"is_accepted":false,"ViewCount":3614,"Q_Id":1116449,"Users Score":13,"Answer":"Yes, use unicode. \nSome hints:\n\nWhen doing input output in any sort of binary format, decode directly after reading and encode directly before writing, so that you never need to mix strings and unicode. Because mixing that tends to lead to UnicodeEncodeDecodeErrors sooner or later.\n[Forget about this one, my explanations just made it even more confusing. It's only an issue when porting to Python 3, you can care about it then.]\nCommon Python newbie errors with Unicode (not saying you are a newbie, but this may be read by newbies): Don't confuse encode and decode. Remember, UTF-8 is an ENcoding, so you ENcode Unicode to UTF-8 and DEcode from it.\nDo not fall into the temptation of setting the default encoding in Python (by setdefaultencoding in sitecustomize.py or similar) to whatever you use most. That is just going to give you problems if you reinstall or move to another computer or suddenly need to use another encoding. Be explicit.\nRemember, not all of Python 2s standard library accepts unicode. If you feed a method unicode and it doesn't work, but it should, try feeding it ascii and see. Examples: urllib.urlopen(), which fails with unhelpful errors if you give it a unicode object instead of a string.\n\nHm. That's all I can think of now!","Q_Score":20,"Tags":"python,unicode","A_Id":1116660,"CreationDate":"2009-07-12T17:13:00.000","Title":"Should I use Unicode string by default?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Is it considered as a good practice to pick Unicode string over regular string when coding in Python? I mainly work on the Windows platform, where most of the string types are Unicode these days (i.e. .NET String, '_UNICODE' turned on by default on a new c++ project, etc ). Therefore, I tend to think that the case where non-Unicode string objects are used is a sort of rare case. Anyway, I'm curious about what Python practitioners do in real-world projects.","AnswerCount":6,"Available Count":5,"Score":1.0,"is_accepted":false,"ViewCount":3614,"Q_Id":1116449,"Users Score":6,"Answer":"It can be tricky to consistently use unicode strings in Python 2.x - be it because somebody inadvertently uses the more natural str(blah) where they meant unicode(blah), forgetting the u prefix on string literals, third-party module incompatibilities - whatever. So in Python 2.x, use unicode only if you have to, and are prepared to provide good unit test coverage.\nIf you have the option of using Python 3.x however, you don't need to care - strings will be unicode with no extra effort.","Q_Score":20,"Tags":"python,unicode","A_Id":1116581,"CreationDate":"2009-07-12T17:13:00.000","Title":"Should I use Unicode string by default?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"How would you convert an integer to base 62 (like hexadecimal, but with these digits: '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ').\nI have been trying to find a good Python library for it, but they all seems to be occupied with converting strings. The Python base64 module only accepts strings and turns a single digit into four characters. I was looking for something akin to what URL shorteners use.","AnswerCount":22,"Available Count":1,"Score":0.0272659675,"is_accepted":false,"ViewCount":83868,"Q_Id":1119722,"Users Score":3,"Answer":"You probably want base64, not base62. There's an URL-compatible version of it floating around, so the extra two filler characters shouldn't be a problem.\nThe process is fairly simple; consider that base64 represents 6 bits and a regular byte represents 8. Assign a value from 000000 to 111111 to each of the 64 characters chosen, and put the 4 values together to match a set of 3 base256 bytes. Repeat for each set of 3 bytes, padding at the end with your choice of padding character (0 is generally useful).","Q_Score":103,"Tags":"python,math,base62","A_Id":1119762,"CreationDate":"2009-07-13T14:19:00.000","Title":"Base 62 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},{"Question":"I'm working with a Python development team who is experienced with programming in Python, but is just now trying to pick up TDD. Since I have some experience working with TDD myself, I've been asked to give a presentation on it. Mainly, I'm just wanting to see articles on this so that I can see how other people are teaching TDD and get some ideas for material to put in my presentation.\nPreferably, I'd like the intro to be for Python, but any language will do as long as the examples are easy to read and the concepts transfer to Python easily.","AnswerCount":7,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":6164,"Q_Id":1126173,"Users Score":0,"Answer":"I started unit testing a handful of years ago, and I've read quite a few on it since my initial book.\nHowever, my initial was \"Test Driven\" by Lasse.\nFor me, the author made it simple to understand.\nPerhaps you could pull some info from it for your teaching.\nAnd btw, I've taught TDD as well.\nI have found that ensuring the audience understands how to use unit tests before going into TDD to be quite handy.\nGood luck! :-)","Q_Score":17,"Tags":"python,unit-testing,testing,tdd","A_Id":8462601,"CreationDate":"2009-07-14T15:28:00.000","Title":"Are there any good online tutorials to TDD for an experienced programmer who is new to 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},{"Question":"It's a high level conceptual question. I have two separate code bases that serve the same purpose, one built in Python and the other in Ruby. I need to develop something that will run on JVM. So I have two choices: convert the Python code to Jython or convert the Ruby to JRuby. Since I don't know any of them, I was wondering if anyone can give me some guidance. Like which one runs faster, or more importantly which one has tools available for easy code migration(.pyc to .jar files)?","AnswerCount":5,"Available Count":3,"Score":0.0399786803,"is_accepted":false,"ViewCount":5421,"Q_Id":1130697,"Users Score":1,"Answer":"The compatibility in either case is at the source-code level; with necessary changes where the Python or Ruby code invokes packages that involve native code (especially, standard Python packages like ctypes are not present in Jython).","Q_Score":4,"Tags":"python,ruby,jruby,jython","A_Id":1130727,"CreationDate":"2009-07-15T10:50:00.000","Title":"Jython or JRuby?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"It's a high level conceptual question. I have two separate code bases that serve the same purpose, one built in Python and the other in Ruby. I need to develop something that will run on JVM. So I have two choices: convert the Python code to Jython or convert the Ruby to JRuby. Since I don't know any of them, I was wondering if anyone can give me some guidance. Like which one runs faster, or more importantly which one has tools available for easy code migration(.pyc to .jar files)?","AnswerCount":5,"Available Count":3,"Score":0.0399786803,"is_accepted":false,"ViewCount":5421,"Q_Id":1130697,"Users Score":1,"Answer":"Anything you can do in one, you can do in the other. \nLearn enough of both to realise which one appeals to your coding sensibilities. There is no right or wrong answer here.","Q_Score":4,"Tags":"python,ruby,jruby,jython","A_Id":1140847,"CreationDate":"2009-07-15T10:50:00.000","Title":"Jython or JRuby?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"It's a high level conceptual question. I have two separate code bases that serve the same purpose, one built in Python and the other in Ruby. I need to develop something that will run on JVM. So I have two choices: convert the Python code to Jython or convert the Ruby to JRuby. Since I don't know any of them, I was wondering if anyone can give me some guidance. Like which one runs faster, or more importantly which one has tools available for easy code migration(.pyc to .jar files)?","AnswerCount":5,"Available Count":3,"Score":0.1973753202,"is_accepted":false,"ViewCount":5421,"Q_Id":1130697,"Users Score":5,"Answer":"In both cases, most of the code should Just Work\u2122. I don't know of a really compelling reason to choose Jython over JRuby or vice versa if you'll be learning either from scratch. Python places a heavy emphasis on readability and not using \"magic\", but Ruby tends to give you a little more rope to do fancy things, e.g., define your own DSL. The main difference is in the community, and largely revolves around the different focus mentioned above.","Q_Score":4,"Tags":"python,ruby,jruby,jython","A_Id":1130722,"CreationDate":"2009-07-15T10:50:00.000","Title":"Jython or JRuby?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I'm writing an application that needs to read a list of strings from a file, save them in a data structure, and then look up those strings by prefixes. The list of strings is simply a list of words in a given language. For example, if the search function gets \"stup\" as a parameter, it should return [\"stupid\", \"stupidity\", \"stupor\"...]. It should do so in O(log(n)*m) time, where n is the size of the data structure and m is the number of results and should be as fast as possible. Memory consumption is not a big issue right now. I'm writing this in python, so it would be great if you could point me to a suitable data structure (preferably) implemented in c with python wrappers.","AnswerCount":4,"Available Count":1,"Score":-0.049958375,"is_accepted":false,"ViewCount":3095,"Q_Id":1130992,"Users Score":-1,"Answer":"string array.\nthen binary search through it to search the first match\nthen step one by one through it for all subsequent matches\n(i originally had linked list here too... but of course this doesn't have random access so this was 'bs' (which probably explains why I was downvoted). My binary search algorithm still is the fastest way to go though","Q_Score":6,"Tags":"python,data-structures,dictionary,lookup","A_Id":1131017,"CreationDate":"2009-07-15T12:04:00.000","Title":"most efficient data structure for a read-only list of strings (about 100,000) with fast prefix search","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm programming a pet project in Python, and it involves users A & B interacting over network, attempting to insure that each has a local copy of the same file from user C.\nThe idea is that C gives each a file that has been digitally signed. A & B trade the digital signatures they have, and check it out on their own copy. If the signature fails, then one of them has an incorrect\/corrupt\/modified version of the file.\nThe question is, therefore, can C distribute a single file that somehow includes it's own signature? Or does C need to supply the file and signature separately?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":187,"Q_Id":1132766,"Users Score":5,"Answer":"The digital signature from C alone should be enough for both A and B to confirm that their file is not corrupted, without ever communicating with eachother. If A and B did not receive a signature from C, they could each create a cryptographic hash of the file and compare the hash, but that does not require any digital signing on C's part.\nIf you want C to sign the file, either send the signature and the file seperately, or wrap them both in some sort of container, such as a zip file or home grown solution (e.g., the first line in the file represents the signature, the rest is the payload).\nTo answer your question literally, the signature doesn't have to be outside the file per se, but the part that is being signed cannot include the signature itself.","Q_Score":1,"Tags":"python,file,cryptography,digital-signature","A_Id":1132796,"CreationDate":"2009-07-15T17:25:00.000","Title":"Must a secure cryptographic signature reside outside of the file it refers 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":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"When using mpirun, is it possible to catch signals (for example, the SIGINT generated by ^C) in the code being run?\nFor example, I'm running a parallelized python code. I can except KeyboardInterrupt to catch those errors when running python blah.py by itself, but I can't when doing mpirun -np 1 python blah.py.\nDoes anyone have a suggestion? Even finding how to catch signals in a C or C++ compiled program would be a helpful start.\nIf I send a signal to the spawned Python processes, they can handle the signals properly; however, signals sent to the parent orterun process (i.e. from exceeding wall time on a cluster, or pressing control-C in a terminal) will kill everything immediately.","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":2988,"Q_Id":1145741,"Users Score":1,"Answer":"If you use mpirun --nw, then mpirun itself should terminate as soon as it's started the subprocesses, instead of waiting for their termination; if that's acceptable then I believe your processes would be able to catch their own signals.","Q_Score":5,"Tags":"python,signals,mpi","A_Id":1149142,"CreationDate":"2009-07-17T21:18:00.000","Title":"MPI signal 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},{"Question":"I'm thinking about learning ruby and python a little bit, and it occurred to me, for what ruby\/python is good for? When to use ruby and when python, or for what ruby\/python is not for? :)\nWhat should I do in these languages?\nthanks","AnswerCount":5,"Available Count":2,"Score":0.0399786803,"is_accepted":false,"ViewCount":15641,"Q_Id":1149581,"Users Score":1,"Answer":"To avoid the holy war and maybe give another perspective I say (without requesting more information of what fun part of programming the question-ere thinks is cool to do):\nLearn python first! \nIf you haven't done any scripting language yet I would recommend python.\nThe core of python is somewhat cleaner than the core of ruby and if you learn the basic core of scripting with python first you will more or less as a bonus learn ruby.\nYou will (because you use python) write code that looks very clean and has good indentation\nright from the beginning. \nThe difficulties about what to learn is what you actually will you try to solve!\nIf you are looking for a new production language to solve X the answer get more complicated.\nIs X part of the language core? Was the language in fact invented to solve X?\nIf the question was: What single programming language should I Master and eventually reach Nirva with? My answer is, I don't have a clue! \n(CLisp, Scheme48, Erlang or Haskell should probably have been on my final list though)\nPS.\nI know that this isn't the spot on answer to the very simplified question in the post.\nwhat can ruby do that python can't or what can python do that ruby can't.\nThe point is that when you set out to learn something one usually have a hidden agenda so you try to solve your favorite problem in any language again and again.\nIf your really are out to learn without have an agenda I think that python in it's most basic form is a clean and crisp way and you should be able to use the same style when using ruby. \nDISCLAIMER: I prefer ruby in a production (commercial setup) over python. I prefer ruby over python on windows. I prefer ruby over python on the things I do at home. I do that because the things I really like to solve is more fun to solve in ruby than in python. My programming style\/habit tends to fit better in ruby.","Q_Score":8,"Tags":"python,ruby","A_Id":1149723,"CreationDate":"2009-07-19T09:56:00.000","Title":"python and ruby - for what to use 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},{"Question":"I'm thinking about learning ruby and python a little bit, and it occurred to me, for what ruby\/python is good for? When to use ruby and when python, or for what ruby\/python is not for? :)\nWhat should I do in these languages?\nthanks","AnswerCount":5,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":15641,"Q_Id":1149581,"Users Score":11,"Answer":"They are good for mostly for rapid prototyping, quick development, dynamic programs, web applications and scripts. They're general purpose languages, so you can use them for pretty much everything you want. You'll have smaller development times (compared to, say, Java or C++), but worse performance and less static error-checking.\nYou can also develop desktop apps on them, but there may be some minor complications on shipping (since you'll usually have to ship the interpreter too).\nYou shouldn't do critical code or heavy computations on them - if you need these things, make them on a faster language (like C) and make a binding for the code. I believe Python is better for this than Ruby, but I could be wrong. (OTOH, Ruby has a stronger metaprogramming)","Q_Score":8,"Tags":"python,ruby","A_Id":1149595,"CreationDate":"2009-07-19T09:56:00.000","Title":"python and ruby - for what to use 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},{"Question":"I would like to be able to perform a ping and traceroute from within Python without having to execute the corresponding shell commands so I'd prefer a native python solution.","AnswerCount":7,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":34815,"Q_Id":1151771,"Users Score":0,"Answer":"ICMP Ping is standard as part of the ICMP protocol.\nTraceroute uses features of ICMP and IP to determine a path via Time To Live values. Using TTL values, you can do traceroutes in a variety of protocols as long as IP\/ICMP work because it is the ICMP TTL EXceeded messages that tell you about the hop in the path.\nIf you attempt to access a port where no listener is available, by ICMP protocol rules, the host is supposed to send an ICMP Port Unreachable message.","Q_Score":10,"Tags":"python,ping,traceroute","A_Id":2974474,"CreationDate":"2009-07-20T05:01:00.000","Title":"How can I perform a ping or traceroute using native 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},{"Question":"I'm learning C++ because it's a very flexible language. But for internet things like Twitter, Facebook, Delicious and others, Python seems a much better solution.\nIs it possible to integrate C++ and Python in the same project?","AnswerCount":12,"Available Count":1,"Score":0.049958375,"is_accepted":false,"ViewCount":112300,"Q_Id":1153577,"Users Score":3,"Answer":"I'd recommend looking at how PyTorch does their integration.","Q_Score":74,"Tags":"c++,python,integration","A_Id":46593807,"CreationDate":"2009-07-20T13:28:00.000","Title":"Integrate Python And 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},{"Question":"I guess this question has been asked a lot around. I know Rails can scale because I have worked on it and it's awesome. And there is not much doubt about that as far as PHP frameworks are concerned.\nI don't want to know which frameworks are better.\nHow much is difference in cost of scaling Rails vs other frameworks (PHP, Python) assuming a large app with 1 million visits per month?\nThis is something I get asked a lot. I can explain to people that \"Rails does scale pretty well\" but in the long run, what are the economics?\nIf somebody can provide some metrics, that'd be great.","AnswerCount":3,"Available Count":2,"Score":0.2605204458,"is_accepted":false,"ViewCount":2847,"Q_Id":1163012,"Users Score":4,"Answer":"IMHO I don't think the cost of scaling is going to be any different between those three because none of them have \"scalability batteries\" included. I just don't see any huge architectural differences between those three choices that would cause a significant difference in scaling.\nIn other words, your application architecture is going to dominate how the application scales regardless of which of the three languages.\nIf you need memory caching you're going to at least use memcached (or something similar which will interface with all three languages). Maybe you help your scalability using nginx to serve directly from memcache, but that's obviously not going to change the performance of php\/perl\/python\/ruby.\nIf you use MySQL or Postgresql you're still going to have to design your database correctly for scaling regardless of your app language, and any tool you use to start clustering \/ mirroring is going to be outside of your app.\nI think in terms of memory usage Python (with mod_wsgi daemon mode) and Ruby (enterprise ruby with passenger\/mod_rack) have pretty decent footprints at least comparable to PHP under fcgi and probably better than PHP under mod_php (i.e. apache MPM prefork + php in all the apache processes sucks a lot of memory).\nWhere this question might be interesting is trying to compare those 3 languages vs. something like Erlang where you (supposedly) have cheap built-in scalability automatically in all Erlang processes, but even then you'll have a RDBMS database bottleneck unless your app nicely fits into one of the Erlang database ways of doing things, e.g. couchdb.","Q_Score":7,"Tags":"php,python,ruby-on-rails,scaling","A_Id":1163341,"CreationDate":"2009-07-22T04:07:00.000","Title":"Cost of scaling Rails vs cost of scaling PHP vs Python frameworks","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I guess this question has been asked a lot around. I know Rails can scale because I have worked on it and it's awesome. And there is not much doubt about that as far as PHP frameworks are concerned.\nI don't want to know which frameworks are better.\nHow much is difference in cost of scaling Rails vs other frameworks (PHP, Python) assuming a large app with 1 million visits per month?\nThis is something I get asked a lot. I can explain to people that \"Rails does scale pretty well\" but in the long run, what are the economics?\nIf somebody can provide some metrics, that'd be great.","AnswerCount":3,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":2847,"Q_Id":1163012,"Users Score":5,"Answer":"One major factor in this is that isn't affected by choice of framework is database access. No matter what approach you take, you likely put data in a relational database. Then the question is how efficiently you can get the data out of the database. This primarily depends on the RDBMS (Oracle vs. Postgres vs. MySQL), and not on the framework - except that some data mapping library may make inefficient use of SQL.\nFor the pure \"number of visits\" parameter, the question really is how fast your HTML templating system works. So the question is: how many pages can you render per second? I would make this the primary metrics to determine how good a system would scale.\nOf course, different pages may have different costs; for some, you can use caching, but not for others. So in measuring scalability, split your 1 million visits into cheap and expensive pages, and measure them separately. Together, they should give a good estimate of the load your system can take (or the number of systems you need to satisfy demand).\nThere is also the issue of memory usage. If you have the data in SQL, this shouldn't matter - but with caching, you may also need to consider scalability wrt. main memory usage.","Q_Score":7,"Tags":"php,python,ruby-on-rails,scaling","A_Id":1163208,"CreationDate":"2009-07-22T04:07:00.000","Title":"Cost of scaling Rails vs cost of scaling PHP vs Python frameworks","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I am tasked with writing unit tests for a suite of networked software written in python. Writing units for message builders and other static methods is very simple, but I've hit a wall when it comes to writing a tests for network looped threads.\nFor example: The server it connects to could be on any port, and I want to be able to test the ability to connect to numerous ports (in sequence, not parallel) without actually having to run numerous servers. What is a good way to approach this? Perhaps make server construction and destruction part of the test? Something tells me there must a simpler answer that evades me.\nI have to imagine there are methods for unit testing networked threads, but I can't seem to find any.","AnswerCount":4,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":655,"Q_Id":1173767,"Users Score":1,"Answer":"I would try to introduce a factory into your existing code that purports to create socket objects. Then in a test pass in a mock factory which creates mock sockets which just pretend they've connected to a server (or not for error cases, which you also want to test, don't you?) and log the message traffic to prove that your code has used the right ports to connect to the right types of servers.\nTry not to use threads just yet, to simplify testing.","Q_Score":2,"Tags":"python,unit-testing,networking,python-unittest","A_Id":1174498,"CreationDate":"2009-07-23T18:52:00.000","Title":"using pyunit on a network thread","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Is there an advantage? What is it?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":104,"Q_Id":1177513,"Users Score":6,"Answer":"So that everyone doesn't need to have exactly the same file structure on their hard drive? import C:\\Python\\lib\\module\\ probably wouldn't work too well on my Mac...\nEdit: Also, what the heck are you talking about with the working directory? You can certainly use modules outside the working directory, as long as they're on the PYTHONPATH.","Q_Score":2,"Tags":"python,import,module-search-path","A_Id":1177526,"CreationDate":"2009-07-24T13:06:00.000","Title":"Why is there module search path instead of typing the directory name + typing the file 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":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've been seeing some examples of Python being used with c++, and I'm trying to understand why would someone want to do it. What are the benefits of calling C++ code from an external language such as Python?\nI'd appreciate a simple example - Boost::Python will do","AnswerCount":7,"Available Count":6,"Score":0.0855049882,"is_accepted":false,"ViewCount":522,"Q_Id":1181462,"Users Score":3,"Answer":"Here's two possibilities:\n\nPerhaps the C++ code is already written & available for use. \nIt's likely the C++ code is faster\/smaller than equivalent Python","Q_Score":4,"Tags":"c++,python","A_Id":1181468,"CreationDate":"2009-07-25T07:14:00.000","Title":"Practical point of view: Why would I want to use Python with 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":0,"Web Development":0},{"Question":"I've been seeing some examples of Python being used with c++, and I'm trying to understand why would someone want to do it. What are the benefits of calling C++ code from an external language such as Python?\nI'd appreciate a simple example - Boost::Python will do","AnswerCount":7,"Available Count":6,"Score":0.057080742,"is_accepted":false,"ViewCount":522,"Q_Id":1181462,"Users Score":2,"Answer":"Here's a real-life example: I've written a DLL in C to interface with some custom hardware for work. Then for the very first stage of testing, I was writing short programs in C to verify that the different commands were working properly. The process of write, compile, run took probably 3-5 times as long as when I finally wrote a Python interface to the DLL using ctypes.\nNow, I can write testing scripts much more rapidly with much less regards to proper variable initialization and memory management that I would have to worry about in C. In fact, I've even been able to use unit testing libraries in Python to create much more robust tests than before. Would that have been possible in C? Absolutely, but it would have taken me much longer, and it would have been many more lines of code. \nFewer lines of code in Python means (in general) that there are fewer things with my main logic that can go wrong.\nMoreover, since the hardware communication is almost completely IO bound, there's no need to write any supporting code in C. I may as well program in whatever is fastest to develop.\nSo there you go, real-life example.","Q_Score":4,"Tags":"c++,python","A_Id":1182301,"CreationDate":"2009-07-25T07:14:00.000","Title":"Practical point of view: Why would I want to use Python with 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":0,"Web Development":0},{"Question":"I've been seeing some examples of Python being used with c++, and I'm trying to understand why would someone want to do it. What are the benefits of calling C++ code from an external language such as Python?\nI'd appreciate a simple example - Boost::Python will do","AnswerCount":7,"Available Count":6,"Score":0.0,"is_accepted":false,"ViewCount":522,"Q_Id":1181462,"Users Score":0,"Answer":"One nice thing about using a scripting language is that you can reload new code into the application without quitting the app, then making changes, recompile, and then relaunching the app. When people talk about quicker development times, some of that refers to this capability.\nA downside of using a scripting languages is that their debuggers are usually not as fully featured as what you would have in C++. I haven't done any Python programming so I don't know what the features are of its debugger, if it has one at all.\nThis answer doesn't exactly answer what you asked but I thought it was relevant. The answer is more the pro\/cons of using a scripting language. Please don't flame me. :)","Q_Score":4,"Tags":"c++,python","A_Id":1182051,"CreationDate":"2009-07-25T07:14:00.000","Title":"Practical point of view: Why would I want to use Python with 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":0,"Web Development":0},{"Question":"I've been seeing some examples of Python being used with c++, and I'm trying to understand why would someone want to do it. What are the benefits of calling C++ code from an external language such as Python?\nI'd appreciate a simple example - Boost::Python will do","AnswerCount":7,"Available Count":6,"Score":0.0855049882,"is_accepted":false,"ViewCount":522,"Q_Id":1181462,"Users Score":3,"Answer":"Because C++ provides a direct way of calling OS services, and (if used in a careful way) can produce code that is more efficient in memory and time, whereas Python is a high-level language, and is less painful to use in those situations where utter efficiency isn't a concern and where you already have libraries giving you access to the services you need.\nIf you're a C++ user, you may wonder why this is necessary, but the expressiveness and safety of a high-level language has such a massive relative effect on your productivity, it has to be experienced to be understood or believed.\nI can't speak for Python specifically, but I've heard people talk in terms of \"tripling\" their productivity by doing most of their development in it and using C++ only where shown to be necessary by profiling, or to create extra libraries.\nIf you're a Python user, you may not have encountered a situation where you need anything beyond the libraries already available, and you may not have a problem with the performance you get from pure Python (this is quite likely). In which case - lucky you! You can forget about all this.","Q_Score":4,"Tags":"c++,python","A_Id":1181481,"CreationDate":"2009-07-25T07:14:00.000","Title":"Practical point of view: Why would I want to use Python with 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":0,"Web Development":0},{"Question":"I've been seeing some examples of Python being used with c++, and I'm trying to understand why would someone want to do it. What are the benefits of calling C++ code from an external language such as Python?\nI'd appreciate a simple example - Boost::Python will do","AnswerCount":7,"Available Count":6,"Score":0.1418931938,"is_accepted":false,"ViewCount":522,"Q_Id":1181462,"Users Score":5,"Answer":"Generally, you'd call C++ from python in order to use an existing library or other functionality. Often someone else has written a set of functions that make your life easier, and calling compiled C code is easier than re-writing the library in python.\nThe other reason is for performance purposes. Often, specific functions of an otherwise completely scripted program are written in a pre-compiled language like C because they take a long time to run and can be more efficiently done in a lower-level language.\nA third reason is for interfacing with devices. Python doesn't natively include a lot of code for dealing with sound cards, serial ports, and so on. If your device needs a device driver, python will talk to it via pre-compiled code you include in your app.","Q_Score":4,"Tags":"c++,python","A_Id":1181476,"CreationDate":"2009-07-25T07:14:00.000","Title":"Practical point of view: Why would I want to use Python with 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":0,"Web Development":0},{"Question":"I've been seeing some examples of Python being used with c++, and I'm trying to understand why would someone want to do it. What are the benefits of calling C++ code from an external language such as Python?\nI'd appreciate a simple example - Boost::Python will do","AnswerCount":7,"Available Count":6,"Score":0.0,"is_accepted":false,"ViewCount":522,"Q_Id":1181462,"Users Score":0,"Answer":"Performance :\n\nFrom my limited experience, Python is about 10 times slower than using C.\nUsing Psyco will dramatically improve it, but still about 5 times slower than C.\nBUT, calling c module from python is only a little faster than Psyco.\n\nWhen you have some libraries in C.\nFor example, I am working heavily on SIP. It's a very complicated protocol stacks and there is no complete Python implementation. So my only choice is calling SIP libraries written in C.\n\nThere are also this kind of cases, like video\/audio decoding.","Q_Score":4,"Tags":"c++,python","A_Id":1181567,"CreationDate":"2009-07-25T07:14:00.000","Title":"Practical point of view: Why would I want to use Python with 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":0,"Web Development":0},{"Question":"I require to do a project as a part of my final year of engineering graduation studies.Can you suggest some projects pertaining to distributed systems and artificial intelligence together and which require python,c or c++ for programming?\nNote:-Please suggest a project that is attainable for a group of 2 students.","AnswerCount":7,"Available Count":3,"Score":0.0285636566,"is_accepted":false,"ViewCount":1483,"Q_Id":1184018,"Users Score":1,"Answer":"I need some kind of tool which observes the behaviour of a automation system (for instance a process control system), and is able to figure out on which inputs which actions follow, and then derives some kind of model from it which would then be usable as a simulation of the real system. It's not exactly distributed, but its engineering :-)\nOn the other hand, our code is written in java (although you could use jython instead).\nIf you are interested, drop me a mail (juergen DOT rose AT inavare DOT net).","Q_Score":0,"Tags":"c++,python,artificial-intelligence,system,distributed","A_Id":1184303,"CreationDate":"2009-07-26T08:06:00.000","Title":"Graduation 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":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I require to do a project as a part of my final year of engineering graduation studies.Can you suggest some projects pertaining to distributed systems and artificial intelligence together and which require python,c or c++ for programming?\nNote:-Please suggest a project that is attainable for a group of 2 students.","AnswerCount":7,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":1483,"Q_Id":1184018,"Users Score":0,"Answer":"How about hacking a P2P protocol and implementing something useful? I worked on a proxy cache implementation for P2P traffic. Basically, design and implement a proxy cache for P2P traffic. It will be different from web documents\/objects in that:\n1- P2P objects are immutable. You might request a web-page more than once, but you really download a P2P object (e.g., movie) once and read it from your desk multiple times.\n2- P2P objects are huge compared to web objects (up to few Gigabytes) so you'll need to cache some objects partially, and implement some kind of smart admission\/eviction policy.\n3- P2P objects have different popularity. Just because something is in the cache does not mean it should stay in the cache forever, because its popularity will degrade (i.e., once a movie is released it is very popular, downloaded a lot, then it drops and everybody forgets about it), so you can't rely on recency or frequency alone as the only replacement policy.","Q_Score":0,"Tags":"c++,python,artificial-intelligence,system,distributed","A_Id":1184275,"CreationDate":"2009-07-26T08:06:00.000","Title":"Graduation 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":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I require to do a project as a part of my final year of engineering graduation studies.Can you suggest some projects pertaining to distributed systems and artificial intelligence together and which require python,c or c++ for programming?\nNote:-Please suggest a project that is attainable for a group of 2 students.","AnswerCount":7,"Available Count":3,"Score":0.0285636566,"is_accepted":false,"ViewCount":1483,"Q_Id":1184018,"Users Score":1,"Answer":"How about a decision process that uses mapreduce, and gets more efficient at choosing the answer each time?","Q_Score":0,"Tags":"c++,python,artificial-intelligence,system,distributed","A_Id":1184030,"CreationDate":"2009-07-26T08:06:00.000","Title":"Graduation 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":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm basically trying to setup my own private pastebin where I can save html files on my private server to test and fool around - have some sort of textarea for the initial input, save the file, and after saving I'd like to be able to view all the files I saved.\nI'm trying to write this in python, just wondering what the most practical way would be of storing the file(s) or the code? SQLite? Straight up flat files? \nOne other thing I'm worried about is the uniqueness of the files, obviously I don't want conflicting filenames ( maybe save using 'title' and timestamp? ) - how should I structure it?","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":578,"Q_Id":1184116,"Users Score":0,"Answer":"Plain files are definitely more effective. Save your database for more complex queries.\nIf you need some formatting to be done on files, such as highlighting the code properly, it is better to do it before you save the file with that code. That way you don't need to apply formatting every time the file is shown.\nYou definitely would need somehow ensure all file names are unique, but this task is trivial, since you can just check, if the file already exists on the disk and if it does, add some number to its name and check again and so on.\nDon't store them all in one directory either, since filesystem can perform much worse if there are A LOT (~ 1 million) files in the single directory, so you can structure your storage like this:\nFILE_DIR\/YEAR\/MONTH\/FileID.html and store the \"YEAR\/MONTH\/FileID\" Part in the database as a unique ID for the file.\nOf course, if you don't worry about performance (not many users, for example) you can just go with storing everything in the database, which is much easier to manage.","Q_Score":0,"Tags":"python,web-applications","A_Id":1184170,"CreationDate":"2009-07-26T09:23:00.000","Title":"Storing files for testbin\/pastebin 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":1},{"Question":"I wonder what is the best way to handle parallel SSH connections in python.\nI need to open several SSH connections to keep in background and to feed commands in interactive or timed batch way.\nIs this possible to do it with the paramiko libraries? It would be nice not to spawn a different SSH process for each connection.\nThanks.","AnswerCount":6,"Available Count":4,"Score":0.0333209931,"is_accepted":false,"ViewCount":7048,"Q_Id":1185855,"Users Score":1,"Answer":"You can simply use subprocess.Popen for that purpose, without any problems.\nHowever, you might want to simply install cronjobs on the remote machines. :-)","Q_Score":3,"Tags":"python,ssh,parallel-processing","A_Id":1185871,"CreationDate":"2009-07-26T23:19:00.000","Title":"Parallel SSH 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":1,"Web Development":0},{"Question":"I wonder what is the best way to handle parallel SSH connections in python.\nI need to open several SSH connections to keep in background and to feed commands in interactive or timed batch way.\nIs this possible to do it with the paramiko libraries? It would be nice not to spawn a different SSH process for each connection.\nThanks.","AnswerCount":6,"Available Count":4,"Score":0.0333209931,"is_accepted":false,"ViewCount":7048,"Q_Id":1185855,"Users Score":1,"Answer":"Reading the paramiko API docs, it looks like it is possible to open one ssh connection, and multiplex as many ssh tunnels on top of that as are wished. Common ssh clients (openssh) often do things like this automatically behind the scene if there is already a connection open.","Q_Score":3,"Tags":"python,ssh,parallel-processing","A_Id":1185880,"CreationDate":"2009-07-26T23:19:00.000","Title":"Parallel SSH 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":1,"Web Development":0},{"Question":"I wonder what is the best way to handle parallel SSH connections in python.\nI need to open several SSH connections to keep in background and to feed commands in interactive or timed batch way.\nIs this possible to do it with the paramiko libraries? It would be nice not to spawn a different SSH process for each connection.\nThanks.","AnswerCount":6,"Available Count":4,"Score":0.0996679946,"is_accepted":false,"ViewCount":7048,"Q_Id":1185855,"Users Score":3,"Answer":"Yes, you can do this with paramiko.\nIf you're connecting to one server, you can run multiple channels through a single connection. If you're connecting to multiple servers, you can start multiple connections in separate threads. No need to manage multiple processes, although you could substitute the multiprocessing module for the threading module and have the same effect.\nI haven't looked into twisted conch in a while, but it looks like it getting updates again, which is nice. I couldn't give you a good feature comparison between the two, but I find paramiko is easier to get going. It takes a little more effort to get into twisted, but it could be well worth it if you're doing other network programming.","Q_Score":3,"Tags":"python,ssh,parallel-processing","A_Id":1188586,"CreationDate":"2009-07-26T23:19:00.000","Title":"Parallel SSH 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":1,"Web Development":0},{"Question":"I wonder what is the best way to handle parallel SSH connections in python.\nI need to open several SSH connections to keep in background and to feed commands in interactive or timed batch way.\nIs this possible to do it with the paramiko libraries? It would be nice not to spawn a different SSH process for each connection.\nThanks.","AnswerCount":6,"Available Count":4,"Score":-0.0333209931,"is_accepted":false,"ViewCount":7048,"Q_Id":1185855,"Users Score":-1,"Answer":"This might not be relevant to your question. But there are tools like pssh, clusterssh etc. that can parallely spawn connections. You can couple Expect with pssh to control them too.","Q_Score":3,"Tags":"python,ssh,parallel-processing","A_Id":1516547,"CreationDate":"2009-07-26T23:19:00.000","Title":"Parallel SSH 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":1,"Web Development":0},{"Question":"I'm trying to make a web app that will manage my Mercurial repositories for me.\nI want it so that when I tell it to load repository X:\n\nConnect to a MySQL server and make sure X exists.\nCheck if the user is allowed to access the repository.\nIf above is true, get the location of X from a mysql server.\nRun a hgweb cgi script (python) containing the path of the repository.\n\nHere is the problem, I want to: take the hgweb script, modify it, and run it.\nBut I do not want to: take the hgweb script, modify it, write it to a file and redirect there.\nI am using Apache to run the httpd process.","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":940,"Q_Id":1185867,"Users Score":0,"Answer":"As far as you question, no, you're not likely to get php to execute a modified script without writing it somewhere, whether that's a file on the disk, a virtual file mapped to ram, or something similar.\nIt sounds like you might be trying to pound a railroad spike with a twig. If you're to the point where you're filtering access based on user permissions stored in MySQL, have you looked at existing HG solutions to make sure there isn't something more applicable than hgweb? It's really built for doing exactly one thing well, and this is a fair bit beyond it's normal realm.\nI might suggest looking into apache's native authentication as a more convenient method for controlling access to repositories, then just serve the repo without modifying the script.","Q_Score":0,"Tags":"php,python,mercurial,cgi","A_Id":1185909,"CreationDate":"2009-07-26T23:24:00.000","Title":"How can I execute CGI files from 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},{"Question":"The Python manual says that you can create modules for Python in both C and C++. Can you take advantage of things like classes and templates when using C++? Wouldn't it create incompatibilities with the rest of the libraries and with the interpreter?","AnswerCount":4,"Available Count":2,"Score":0.1488850336,"is_accepted":false,"ViewCount":567,"Q_Id":1185878,"Users Score":3,"Answer":"The boost folks have a nice automated way to do the wrapping of C++ code for use by python.\nIt is called: Boost.Python\nIt deals with some of the constructs of C++ better than SWIG, particularly template metaprogramming.","Q_Score":6,"Tags":"c++,python,c,python-c-api,python-c-extension","A_Id":1185954,"CreationDate":"2009-07-26T23:30:00.000","Title":"Can I use C++ features while extending 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},{"Question":"The Python manual says that you can create modules for Python in both C and C++. Can you take advantage of things like classes and templates when using C++? Wouldn't it create incompatibilities with the rest of the libraries and with the interpreter?","AnswerCount":4,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":567,"Q_Id":1185878,"Users Score":9,"Answer":"It doesn't matter whether your implementation of the hook functions is implemented in C or in C++. In fact, I've already seen some Python extensions which make active use of C++ templates and even the Boost library. No problem. :-)","Q_Score":6,"Tags":"c++,python,c,python-c-api,python-c-extension","A_Id":1185907,"CreationDate":"2009-07-26T23:30:00.000","Title":"Can I use C++ features while extending 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},{"Question":"I'm looking for a way to read specific files from a rar archive into memory. Specifically they are a collection of numbered image files (I'm writing a comic reader). While I can simply unrar these files and load them as needed (deleting them when done), I'd prefer to avoid that if possible.\nThat all said, I'd prefer a solution that's cross platform (Windows\/Linux) if possible, but Linux is a must. Just as importantly, if you're going to point out a library to handle this for me, please understand that it must be free (as in beer) or OSS.","AnswerCount":7,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":8947,"Q_Id":1185959,"Users Score":6,"Answer":"The real answer is that there isn't a library, and you can't make one. You can use rarfile, or you can use 7zip unRAR (which is less free than 7zip, but still free as in beer), but both approaches require an external executable. The license for RAR basically requires this, as while you can get source code for unRAR, you cannot modify it in any way, and turning it into a library would constitute illegal modification.\nAlso, solid RAR archives (the best compressed) can't be randomly accessed, so you have to unarchive the entire thing anyhow. WinRAR presents a UI that seems to avoid this, but really it's just unpacking and repacking the archive in the background.","Q_Score":7,"Tags":"python,linux,stream,rar","A_Id":1186041,"CreationDate":"2009-07-27T00:25:00.000","Title":"Read content of RAR file into memory 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},{"Question":"I'm looking for a way to read specific files from a rar archive into memory. Specifically they are a collection of numbered image files (I'm writing a comic reader). While I can simply unrar these files and load them as needed (deleting them when done), I'd prefer to avoid that if possible.\nThat all said, I'd prefer a solution that's cross platform (Windows\/Linux) if possible, but Linux is a must. Just as importantly, if you're going to point out a library to handle this for me, please understand that it must be free (as in beer) or OSS.","AnswerCount":7,"Available Count":2,"Score":0.057080742,"is_accepted":false,"ViewCount":8947,"Q_Id":1185959,"Users Score":2,"Answer":"It seems like the limitation that rarsoft imposes on derivative works is that you may not use the unrar source code to create a variation of the RAR COMPRESSION algorithm. From the context, it would appear that it's specifically allowing folks to use his code (modified or not) to decompress files, but you cannot use them if you intend to write your own compression code. Here is a direct quote from the license.txt file I just downloaded:\n\nThe UnRAR sources may be used in any software to handle RAR\n archives without limitations free of charge, but cannot be used\n to re-create the RAR compression algorithm, which is proprietary.\n Distribution of modified UnRAR sources in separate form or as a\n part of other software is permitted, provided that it is clearly\n stated in the documentation and source comments that the code may\n not be used to develop a RAR (WinRAR) compatible archiver.\n\nSeeing as everyone seemed to just want something that would allow them to write a comic viewer capable of handling reading images from CBR (rar) files, I don't see why people think there's anything keeping them from using the provided source code.","Q_Score":7,"Tags":"python,linux,stream,rar","A_Id":4436131,"CreationDate":"2009-07-27T00:25:00.000","Title":"Read content of RAR file into memory 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},{"Question":"I've only used XML RPC and I haven't really delved into SOAP but I'm trying to find a good comprehensive guide, with real world examples or even a walkthrough of some minimal REST application.\nI'm most comfortable with Python\/PHP.","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":499,"Q_Id":1186839,"Users Score":1,"Answer":"I like the examples in the Richardson & Ruby book, \"RESTful Web Services\" from O'Reilly.","Q_Score":0,"Tags":"php,python,xml,rest,soap","A_Id":1186876,"CreationDate":"2009-07-27T07:11:00.000","Title":"Real world guide on using and\/or setting up REST web services?","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},{"Question":"Hierarchical Bayes models are commonly used in Marketing, Political Science, and Econometrics. Yet, the only package I know of is bayesm, which is really a companion to a book (Bayesian Statistics and Marketing, by Rossi, et al.) Am I missing something? Is there a software package for R or Python doing the job out there, and\/or a worked-out example in the associated language?","AnswerCount":7,"Available Count":3,"Score":0.057080742,"is_accepted":false,"ViewCount":8690,"Q_Id":1191689,"Users Score":2,"Answer":"I apply hierarchical Bayes models in R in combination with JAGS (Linux) or sometimes WinBUGS (Windows, or Wine). Check out the book of Andrew Gelman, as referred to above.","Q_Score":12,"Tags":"python,r,statistics","A_Id":1832314,"CreationDate":"2009-07-28T02:43:00.000","Title":"Hierarchical Bayes for 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},{"Question":"Hierarchical Bayes models are commonly used in Marketing, Political Science, and Econometrics. Yet, the only package I know of is bayesm, which is really a companion to a book (Bayesian Statistics and Marketing, by Rossi, et al.) Am I missing something? Is there a software package for R or Python doing the job out there, and\/or a worked-out example in the associated language?","AnswerCount":7,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":8690,"Q_Id":1191689,"Users Score":0,"Answer":"This answer comes almost ten years late, but it will hopefully help someone in the future.\nThe brms package in R is a very good option for Bayesian hierarchical\/multilevel models, using a syntax very similar to the lme4 package.\nThe brms package uses the probabilistic programming language Stan in the back to do the inferences. Stan uses more advanced sampling methods than JAGS and BUGS, such as Hamiltonian Monte Carlo, which provides more efficient and reliable samples from the posterior distribution.\nIf you wish to model more complicated phenomena, then you can use the rstanpackage to compile Stan models from R. There is also the Python alternative PyStan. However, in order to do this, you must learn how to use Stan.","Q_Score":12,"Tags":"python,r,statistics","A_Id":55978470,"CreationDate":"2009-07-28T02:43:00.000","Title":"Hierarchical Bayes for 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},{"Question":"Hierarchical Bayes models are commonly used in Marketing, Political Science, and Econometrics. Yet, the only package I know of is bayesm, which is really a companion to a book (Bayesian Statistics and Marketing, by Rossi, et al.) Am I missing something? Is there a software package for R or Python doing the job out there, and\/or a worked-out example in the associated language?","AnswerCount":7,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":8690,"Q_Id":1191689,"Users Score":0,"Answer":"The lme4 package, which estimates hierarchical models using frequentist methods, has a function called mcmcsamp that allows you to sample from the posterior distribution of the model using MCMC. This currently works only for linear models, quite unfortunately.","Q_Score":12,"Tags":"python,r,statistics","A_Id":1197766,"CreationDate":"2009-07-28T02:43:00.000","Title":"Hierarchical Bayes for 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},{"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},{"Question":"We have a python project that we want to start testing using buildbot. Its unit tests include tests that should only work on some platforms. So, we've got tests that should pass on all platforms, tests that should only run on 1 specific platform, tests that should pass on platforms A, B, C and tests that pass on B and D.\nWhat is the best way of doing this? Simple suites would be a hassle, since, as described, each test can have a different list of target platforms. I thought about adding \"@run_on\" and \"@ignore_on\" decorators that would match platforms to test methods. Is there anything better?","AnswerCount":3,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":709,"Q_Id":1199493,"Users Score":0,"Answer":"We've decided to go with decorators that, using platform module and others, check whether the tests should be executed, and if not simply let it pass (though, we saw that python2.7 already has in its trunk a SkipTest exception that could be raised in such cases, to ignore the test).","Q_Score":5,"Tags":"python,unit-testing,buildbot","A_Id":1371766,"CreationDate":"2009-07-29T11:13:00.000","Title":"How to distribute and execute platform-specific 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":0,"Web Development":0},{"Question":"I've been told by my hosting company that Python is installed on their servers. How would I go about using it to output a simple HTML page? This is just as a learning exercise at the moment, but one day I'd like to use Python in the same way as I currently use PHP.","AnswerCount":4,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":2969,"Q_Id":1199703,"Users Score":2,"Answer":"If your server is running Apache HTTP server, then you need something like mod_wsgi or mod_python installed and running as a module (your server signature may tell you this).\nOnce running, you may need to add a handler to your apache config, or a default may be setup.\nAfter that, look at the documentation for the middleware of the module you are running, then maybe go on and use something like Django.","Q_Score":3,"Tags":"python,server-side","A_Id":1199744,"CreationDate":"2009-07-29T11:49:00.000","Title":"How do I use Python serverside with shared hosting?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I need to port some code that relies heavily on lxml from a CPython application to IronPython.\nlxml is very Pythonic and I would like to keep using it under IronPython, but it depends on libxslt and libxml2, which are C extensions.\nDoes anyone know of a workaround to allow lxml under IronPython or a version of lxml that doesn't have those C-extension dependencies?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":2349,"Q_Id":1200726,"Users Score":1,"Answer":"Something which you might have already considered: \nAn alternative is to first port the lxml library to IPy and then your code (depending on the code size). You might have to write some C# wrappers for the native C calls to the C extensions -- I'm not sure what issues, if any, are involved in this with regards to IPy.\nOr if the code which you are porting is small, as compared to lxml, then maybe you can just remove the lxml dependency and use the .NET XML libraries.","Q_Score":6,"Tags":".net,xml,ironpython,python,lxml","A_Id":1211395,"CreationDate":"2009-07-29T14:36:00.000","Title":"How to get lxml working under IronPython?","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},{"Question":"I'm trying to raise an exception on the Server Side of an SimpleXMLRPCServer; however, all attempts get a \"Fault 1\" exception on the client side.\nRPC_Server.AbortTest()\n File \"C:\\Python25\\lib\\xmlrpclib.py\", line 1147, in call\n return self.__send(self.__name, args)\n File \"C:\\Python25\\lib\\xmlrpclib.py\", line 1437, in __request\n verbose=self.__verbose\n File \"C:\\Python25\\lib\\xmlrpclib.py\", line 1201, in request\n return self._parse_response(h.getfile(), sock)\n File \"C:\\Python25\\lib\\xmlrpclib.py\", line 1340, in _parse_response\n return u.close()\n File \"C:\\Python25\\lib\\xmlrpclib.py\", line 787, in close\n raise Fault(**self._stack[0])\nxmlrpclib.Fault: :Test Aborted by a RPC\nrequest\">","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":746,"Q_Id":1201507,"Users Score":1,"Answer":"Yes, this is what happens when you raise an exception on the server side. Are you expecting the SimpleXMLRPCServer to return the exception to the client?\nYou can only use objects that can be marshalled through XML. This includes\n\nboolean : The True and False constants\nintegers : Pass in directly\nfloating-point numbers : Pass in directly\nstrings : Pass in directly\narrays : Any Python sequence type containing conformable elements. Arrays are returned as lists\nstructures : A Python dictionary. Keys must be strings, values may be any conformable type. Objects of user-defined classes can be passed in; only their __dict__ attribute is transmitted.\ndates : in seconds since the epoch (pass in an instance of the DateTime class) or a datetime.datetime instance.\nbinary data : pass in an instance of the Binary wrapper class","Q_Score":0,"Tags":"python,exception,simplexmlrpcserver","A_Id":1202742,"CreationDate":"2009-07-29T16:34:00.000","Title":"Sending an exception on the SimpleXMLRPCServer","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},{"Question":"I have to deploy some Web Services on a server that only supports the Java ones, but some of them will be done using perl or python. I want to know if is possible to develop a Java wrapper to call a specific code written in perl or python. So, I want to have all the Web Services in Java, but some of them will call some code using other languages.\nThanks in advance.\nRegards,\nUkrania","AnswerCount":5,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":2709,"Q_Id":1201628,"Users Score":4,"Answer":"This depends heavily upon your needs. If Jython is an option for the Python code (it isn't always 100% compatible), then it is probably the best option there. Otherwise, you will need to use Java's Process Builder to call the interpretters directly and return the results on their output stream. This will not be fast (but then again, Jython isn't that fast either, relative to regular Java code), but it is an extremely flexible solution.","Q_Score":4,"Tags":"java,python,perl,web-services,wrapper","A_Id":1201722,"CreationDate":"2009-07-29T16:53:00.000","Title":"Java Wrapper to Perl\/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":1,"Web Development":1},{"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},{"Question":"I'm starting to learn python and loving it. I work on a Mac mainly as well as Linux. I'm finding that on Linux (Ubuntu 9.04 mostly) when I install a python module using apt-get it works fine. I can import it with no trouble.\nOn the Mac, I'm used to using Macports to install all the Unixy stuff. However, I'm finding that most of the python modules I install with it are not being seen by python. I've spent some time playing around with PATH settings and using python_select . Nothing has really worked and at this point I'm not really understanding, instead I'm just poking around.\nI get the impression that Macports isn't universally loved for managing python modules. I'd like to start fresh using a more \"accepted\" (if that's the right word) approach. \nSo, I was wondering, what is the method that Mac python developers use to manage their modules?\nBonus questions: \nDo you use Apple's python, or some other version?\nDo you compile everything from source or is there a package manger that works well (Fink?).","AnswerCount":13,"Available Count":3,"Score":0.0307595242,"is_accepted":false,"ViewCount":168159,"Q_Id":1213690,"Users Score":2,"Answer":"You may already have pip3 pre-installed, so just try it!","Q_Score":127,"Tags":"python,macos,module,packages,macports","A_Id":49869959,"CreationDate":"2009-07-31T16:58:00.000","Title":"What is the most compatible way to install python modules on a 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":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I'm starting to learn python and loving it. I work on a Mac mainly as well as Linux. I'm finding that on Linux (Ubuntu 9.04 mostly) when I install a python module using apt-get it works fine. I can import it with no trouble.\nOn the Mac, I'm used to using Macports to install all the Unixy stuff. However, I'm finding that most of the python modules I install with it are not being seen by python. I've spent some time playing around with PATH settings and using python_select . Nothing has really worked and at this point I'm not really understanding, instead I'm just poking around.\nI get the impression that Macports isn't universally loved for managing python modules. I'd like to start fresh using a more \"accepted\" (if that's the right word) approach. \nSo, I was wondering, what is the method that Mac python developers use to manage their modules?\nBonus questions: \nDo you use Apple's python, or some other version?\nDo you compile everything from source or is there a package manger that works well (Fink?).","AnswerCount":13,"Available Count":3,"Score":1.0,"is_accepted":false,"ViewCount":168159,"Q_Id":1213690,"Users Score":7,"Answer":"I use MacPorts to install Python and any third-party modules tracked by MacPorts into \/opt\/local, and I install any manually installed modules (those not in the MacPorts repository) into \/usr\/local, and this has never caused any problems. I think you may be confused as to the use of certain MacPorts scripts and environment variables.\nMacPorts python_select is used to select the \"current\" version of Python, but it has nothing to do with modules. This allows you to, e.g., install both Python 2.5 and Python 2.6 using MacPorts, and switch between installs.\nThe $PATH environment variables does not affect what Python modules are loaded. $PYTHONPATH is what you are looking for. $PYTHONPATH should point to directories containing Python modules you want to load. In my case, my $PYTHONPATH variable contains \/usr\/local\/lib\/python26\/site-packages. If you use MacPorts' Python, it sets up the other proper directories for you, so you only need to add additional paths to $PYTHONPATH. But again, $PATH isn't used at all when Python searches for modules you have installed.\n$PATH is used to find executables, so if you install MacPorts' Python, make sure \/opt\/local\/bin is in your $PATH.","Q_Score":127,"Tags":"python,macos,module,packages,macports","A_Id":1214123,"CreationDate":"2009-07-31T16:58:00.000","Title":"What is the most compatible way to install python modules on a 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":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I'm starting to learn python and loving it. I work on a Mac mainly as well as Linux. I'm finding that on Linux (Ubuntu 9.04 mostly) when I install a python module using apt-get it works fine. I can import it with no trouble.\nOn the Mac, I'm used to using Macports to install all the Unixy stuff. However, I'm finding that most of the python modules I install with it are not being seen by python. I've spent some time playing around with PATH settings and using python_select . Nothing has really worked and at this point I'm not really understanding, instead I'm just poking around.\nI get the impression that Macports isn't universally loved for managing python modules. I'd like to start fresh using a more \"accepted\" (if that's the right word) approach. \nSo, I was wondering, what is the method that Mac python developers use to manage their modules?\nBonus questions: \nDo you use Apple's python, or some other version?\nDo you compile everything from source or is there a package manger that works well (Fink?).","AnswerCount":13,"Available Count":3,"Score":1.0,"is_accepted":false,"ViewCount":168159,"Q_Id":1213690,"Users Score":6,"Answer":"If you use Python from MacPorts, it has it's own easy_install located at: \/opt\/local\/bin\/easy_install-2.6 (for py26, that is). It's not the same one as simply calling easy_install directly, even if you used python_select to change your default python command.","Q_Score":127,"Tags":"python,macos,module,packages,macports","A_Id":2380159,"CreationDate":"2009-07-31T16:58:00.000","Title":"What is the most compatible way to install python modules on a 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":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I'm working on a statistical project that involves iterating over every possible way to partition a collection of strings and running a simple calculation on each. Specifically, each possible substring has a probability associated with it, and I'm trying to get the sum across all partitions of the product of the substring probability in the partition. \nFor example, if the string is 'abc', then there would be probabilities for 'a', 'b', 'c', 'ab, 'bc' and 'abc'. There are four possible partitionings of the string: 'abc', 'ab|c', 'a|bc' and 'a|b|c'. The algorithm needs to find the product of the component probabilities for each partitioning, then sum the four resultant numbers. \nCurrently, I've written a python iterator that uses binary representations of integers for the partitions (eg 00, 01, 10, 11 for the example above) and simply runs through the integers. Unfortunately, this is immensely slow for strings longer than 20 or so characters. \nCan anybody think of a clever way to perform this operation without simply running through every partition one at a time? I've been stuck on this for days now. \nIn response to some comments here is some more information:\nThe string can be just about anything, eg \"foobar(foo2)\" -- our alphabet is lowercase alphanumeric plus all three type of braces (\"(\",\"[\",\"{\"), hyphens and spaces.\nThe goal is to get the likelihood of the string given individual 'word' likelihoods. So L(S='abc')=P('abc') + P('ab')P('c') + P('a')P('bc') + P('a')P('b')P('c') (Here \"P('abc')\" indicates the probability of the 'word' 'abc', while \"L(S='abc')\" is the statistical likelihood of observing the string 'abc').","AnswerCount":5,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":323,"Q_Id":1223007,"Users Score":0,"Answer":"You should look into the itertools module. It can create a generator for you that is very fast. Given your input string, it will provide you with all possible permutations. Depending on what you need, there is also a combinations() generator. I'm not quite sure if you're looking at \"b|ca\" when you're looking at \"abc,\" but either way, this module may prove useful to you.","Q_Score":3,"Tags":"python,string,partitioning","A_Id":1223236,"CreationDate":"2009-08-03T15:33:00.000","Title":"Are there any cleverly efficient algorithms to perform a calculation over the space of partitionings 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},{"Question":"I am looking for a good config file library for c that is not xml. Optimally I would really like one that also has python bindings. The best option I have come up with is to use a JSON library in both c and python. What would you recommend, or what method of reading\/writing configuration settings do you prefer?","AnswerCount":4,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1054,"Q_Id":1227031,"Users Score":0,"Answer":"Despite being hated by techies and disowned by Microsoft, INI files are actually quite popular with users, as they are easy to understand and edit. They are also very simple to write parsers for, should your libraries not already support them.","Q_Score":5,"Tags":"python,c,configuration-management","A_Id":1227256,"CreationDate":"2009-08-04T11:48:00.000","Title":"What is a good configuration file library for c thats not xml (preferably has 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},{"Question":"Taking speed as an issue it may be better to choose another language, but what is your library\/module\/implementation of choice for doing a 1D fast Fourier transform (FFT) in Python?","AnswerCount":3,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":2655,"Q_Id":1241797,"Users Score":8,"Answer":"I would recommend numpy library, I not sure if it's the fastest implementation that exist but but surely it's one of best scientific module on the \"market\".","Q_Score":5,"Tags":"python,benchmarking,fft","A_Id":1241961,"CreationDate":"2009-08-06T22:07:00.000","Title":"What is the recommended Python module for fast Fourier transforms (FFT)?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a python script which I can run from pythonwin on which I give the arguments. \nIs it possible to automate this so that when I just click on the *.py file, I don't see the script and it asks for the path in a dos window?","AnswerCount":4,"Available Count":1,"Score":0.1488850336,"is_accepted":false,"ViewCount":6240,"Q_Id":1245818,"Users Score":3,"Answer":"Rename it to *.pyw to hide the console on execution in Windows.","Q_Score":2,"Tags":"python","A_Id":1245828,"CreationDate":"2009-08-07T16:48:00.000","Title":"Run Python script without opening Pythonwin","Data Science and Machine Learning":0,"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},{"Question":"Since I am working with different Platforms and programming languages, I found there are many good libraries that are ported with different programming language than its original. For example JUnit and Log4j which has been ported into several different languages. Sometimes if I am already used to working with these libraries, I would find the ported version for it if I'm working with another programming language.\nWhat are other libraries that you have found been ported to different languages and as good as the original?\nPlease make it one library per answer so others can vote.\nFormat: \nOriginal-Library-Name, Original-Programming-Language\n\nPorted-Library-Name, Ported-Programming-Language\n\nIf possible with the links to the website of the libraries.","AnswerCount":16,"Available Count":3,"Score":-0.012499349,"is_accepted":false,"ViewCount":1282,"Q_Id":1253232,"Users Score":-1,"Answer":"GTK, originally in C.\nPorted to Java, Python, Ruby, C++, and most every other common language you can think of.","Q_Score":10,"Tags":"java,python,.net,ruby,perl","A_Id":2274406,"CreationDate":"2009-08-10T05:29:00.000","Title":"Which libraries have been ported to different 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":0},{"Question":"Since I am working with different Platforms and programming languages, I found there are many good libraries that are ported with different programming language than its original. For example JUnit and Log4j which has been ported into several different languages. Sometimes if I am already used to working with these libraries, I would find the ported version for it if I'm working with another programming language.\nWhat are other libraries that you have found been ported to different languages and as good as the original?\nPlease make it one library per answer so others can vote.\nFormat: \nOriginal-Library-Name, Original-Programming-Language\n\nPorted-Library-Name, Ported-Programming-Language\n\nIf possible with the links to the website of the libraries.","AnswerCount":16,"Available Count":3,"Score":0.0374824318,"is_accepted":false,"ViewCount":1282,"Q_Id":1253232,"Users Score":3,"Answer":"Java,Java\n\nC#, .NET\n\nOhh com'on, just kidding, ok, down vote me now!","Q_Score":10,"Tags":"java,python,.net,ruby,perl","A_Id":1269650,"CreationDate":"2009-08-10T05:29:00.000","Title":"Which libraries have been ported to different 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":0},{"Question":"Since I am working with different Platforms and programming languages, I found there are many good libraries that are ported with different programming language than its original. For example JUnit and Log4j which has been ported into several different languages. Sometimes if I am already used to working with these libraries, I would find the ported version for it if I'm working with another programming language.\nWhat are other libraries that you have found been ported to different languages and as good as the original?\nPlease make it one library per answer so others can vote.\nFormat: \nOriginal-Library-Name, Original-Programming-Language\n\nPorted-Library-Name, Ported-Programming-Language\n\nIf possible with the links to the website of the libraries.","AnswerCount":16,"Available Count":3,"Score":0.024994793,"is_accepted":false,"ViewCount":1282,"Q_Id":1253232,"Users Score":2,"Answer":"Hibernate, Java\n\nNHibernate, .NET","Q_Score":10,"Tags":"java,python,.net,ruby,perl","A_Id":1253957,"CreationDate":"2009-08-10T05:29:00.000","Title":"Which libraries have been ported to different 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":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},{"Question":"I'm studying Smalltalk right now. It looks very similar to python (actually, the opposite, python is very similar to Smalltalk), so I was wondering, as a python enthusiast, if it's really worth for me to study it.\nApart from message passing, what are other notable conceptual differences between Smalltalk and python which could allow me to see new programming horizons ?","AnswerCount":5,"Available Count":3,"Score":1.0,"is_accepted":false,"ViewCount":5971,"Q_Id":1269242,"Users Score":10,"Answer":"As someone new to smalltalk, the two things that really strike me are the image-based system, and that reflection is everywhere. These two simple facts appear to give rise to everything else cool in the system:\n\nThe image means that you do everything by manipulating objects, including writing and compiling code\nReflection allows you to inspect the state of any object. Since classes are objects and their sources are objects, you can inspect and manipulate code\nYou have access to the current execution context, so you can have a look at the stack, and from there, compiled code and the source of that code and so on\nThe stack is an object, so you can save it away and then resume later. Bingo, continuations!\n\nAll of the above starts to come together in cool ways:\n\nThe browser lets you explore the source of literally everything, including the VM in Squeak\nYou can make changes that affect your live program, so there's no need to restart and navigate your way through to whatever you're working on\nEven better, when your program throws an exception you can debug the live code. You fix the bug, update the state if it's become inconsistent and then have your program continue.\nThe browser will tell you if it thinks you've made a typo\nIt's absurdly easy to browse up and down the class hierarchy, or find out what messages a object responds to, or which code sends a given message, or which objects can receive a given message\nYou can inspect and manipulate the state of any object in the system\nYou can make any two objects literally switch places with become:, which lets you do crazy stuff like stub out any object and then lazily pull it in from elsewhere if it's sent a message.\n\nThe image system and reflection has made all of these perfectly natural and normal things for a smalltalker for about thirty years.","Q_Score":10,"Tags":"python,smalltalk","A_Id":1271000,"CreationDate":"2009-08-12T23:17:00.000","Title":"Differences between Smalltalk 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":0},{"Question":"I'm studying Smalltalk right now. It looks very similar to python (actually, the opposite, python is very similar to Smalltalk), so I was wondering, as a python enthusiast, if it's really worth for me to study it.\nApart from message passing, what are other notable conceptual differences between Smalltalk and python which could allow me to see new programming horizons ?","AnswerCount":5,"Available Count":3,"Score":1.0,"is_accepted":false,"ViewCount":5971,"Q_Id":1269242,"Users Score":7,"Answer":"Smalltalk historically has had an amazing IDE built in. I have missed this IDE on many languages.\nSmalltalk also has the lovely property that it is typically in a living system. You start up clean and start modifying things. This is basically an object persistent storage system. That being said, this is both good and bad. What you run is part of your system and part of what you ship. The system can be setup quite nicely before being distributed. The down side, is that the system has everything you run as part of what you ship. You need to be very careful packaging for redistribution.\nNow, that being said, it has been a while since I have worked with Smalltalk (about 20 years). Yes, I know, fun times for those who do the math. Smalltalk is a nice language, fun to program in, fun to learn, but I have found it a little hard to ship things in.\nEnjoy playing with it if you do. I have been playing with Python and loving it.\nJacob","Q_Score":10,"Tags":"python,smalltalk","A_Id":1269259,"CreationDate":"2009-08-12T23:17:00.000","Title":"Differences between Smalltalk 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":0},{"Question":"I'm studying Smalltalk right now. It looks very similar to python (actually, the opposite, python is very similar to Smalltalk), so I was wondering, as a python enthusiast, if it's really worth for me to study it.\nApart from message passing, what are other notable conceptual differences between Smalltalk and python which could allow me to see new programming horizons ?","AnswerCount":5,"Available Count":3,"Score":0.0798297691,"is_accepted":false,"ViewCount":5971,"Q_Id":1269242,"Users Score":2,"Answer":"The language aspect often isn't that important, and many languages are quite samey,\nFrom what I see, Python and Smalltalk share OOP ideals ... but are very different in their implementation and the power in the presented language interface.\nthe real value comes in what the subtle differences in the syntax allows in terms of implementation. Take a look at Self and other meta-heavy languages.\nLook past the syntax and immediate semantics to what the subtle differences allow the implementation to do.\nFor example:\n\nEverything in Smalltalk-80 is available for modification from within a running program\n\nWhat differences between Python and Smalltalk allow deeper maniplation if any? How does the language enable the implementation of the compiler\/runtime?","Q_Score":10,"Tags":"python,smalltalk","A_Id":1269266,"CreationDate":"2009-08-12T23:17:00.000","Title":"Differences between Smalltalk 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":0},{"Question":"I'm looking for the simplest way of using python and SQLAlchemy to produce some XML for a jQuery based HTTP client. Right now I'm using mod_python's CGI handler but I'm unhappy with the fact that I can't persist stuff like the SQLAlchemy session.\nThe mod_python publisher handler that is apparently capable of persisting stuff does not allow requests with XML content type (as used by jQuery's ajax stuff) so I can't use it.\nWhat other options are there?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1222,"Q_Id":1272325,"Users Score":2,"Answer":"You could always write your own handler, which is the way mod_python is normally intended to be used. You would have to set some HTTP headers (and you could have a look at the publisher handler's source code for inspiration on that), but otherwise I don't think it's much more complicated than what you've been trying to do.\nThough as long as you're at it, I would suggest trying mod_wsgi instead of mod_python, which is probably eventually going to supersede mod_python. WSGI is a Python standard for writing web applications.","Q_Score":2,"Tags":"python,cgi,mod-python","A_Id":1272579,"CreationDate":"2009-08-13T14:29:00.000","Title":"Alternatives to mod_python's CGI handler","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},{"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},{"Question":"I have the Python expression n <<= 1 \nHow do you express this in PHP?","AnswerCount":3,"Available Count":2,"Score":0.1325487884,"is_accepted":false,"ViewCount":527,"Q_Id":1274493,"Users Score":2,"Answer":"$n <<= 1; is valid php","Q_Score":1,"Tags":"php,python,operators,bitwise-operators","A_Id":1274508,"CreationDate":"2009-08-13T20:50:00.000","Title":"How can I write 'n <<= 1' (Python) 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":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have the Python expression n <<= 1 \nHow do you express this in PHP?","AnswerCount":3,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":527,"Q_Id":1274493,"Users Score":5,"Answer":"It's the same operator in php. $n <<= 1;","Q_Score":1,"Tags":"php,python,operators,bitwise-operators","A_Id":1274505,"CreationDate":"2009-08-13T20:50:00.000","Title":"How can I write 'n <<= 1' (Python) 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":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Sequence 1.1.1 ATGCGCGCGATAAGGCGCTA\n ATATTATAGCGCGCGCGCGGATATATATATATATATATATT\n Sequence 1.2.2 ATATGCGCGCGCGCGCGGCG\n ACCCCGCGCGCGCGCGGCGCGATATATATATATATATATATT\n Sequence 2.1.1 ATTCGCGCGAGTATAGCGGCG\n\nNOW,I would like to remove the last digit from each of the line that starts with '>'. For example, in this first line, i would like to remove '.1' (rightmost) and in second instance i would like to remove '.2' and then write the rest of the file to a new file. Thanks,","AnswerCount":6,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":336,"Q_Id":1278664,"Users Score":2,"Answer":"map \"\".join(line.split('.')[:-1]) to each line of the file.","Q_Score":1,"Tags":"python,file","A_Id":1278690,"CreationDate":"2009-08-14T15:52:00.000","Title":"How to eliminate last digit from each of the top lines","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Question:\nHow do I get a byte stream that works like StringIO for Python 2.5?\nApplication:\nI'm converting a PDF to text, but don't want to save a file to the hard disk.\nOther Thoughts:\nI figured I could use StringIO, but there's no mode parameter (I guess \"String\" implies text mode). \nApparently the io.BytesIO class is new in v2.6, so that doesn't work for me either.\nI've got a solution with the tempfile module, but I'd like to avoid any reads\/writes to\/from the hard disk.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":4303,"Q_Id":1279244,"Users Score":4,"Answer":"In Python 2.x, \"string\" means \"bytes\", and \"unicode\" means \"string\". You should use the StringIO or cStringIO modules. The mode will depend on which kind of data you pass in as the buffer parameter.","Q_Score":1,"Tags":"python,stringio,bytesio","A_Id":1279251,"CreationDate":"2009-08-14T17:54:00.000","Title":"BytesIO with python v2.5","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I'm not familiar with the PDF specification at all. I was wondering if it's possible to directly manipulate a PDF file so that certain blocks of text that I've identified as important are highlighted in colors of my choice. Language of choice would be python.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":6726,"Q_Id":1283065,"Users Score":0,"Answer":"Highlight is possible in pdf file using PDF annotations but doing it natively is not that easy job. If any of the mentioned library provide such facility is something that you may look for.","Q_Score":12,"Tags":"python,pdf,fonts","A_Id":1285029,"CreationDate":"2009-08-15T22:52:00.000","Title":"Programmatically change font color of text in PDF","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I'd like for a script of mine to have 2 behaviours, one when started as a scheduled task, and another if started manually. How could I test for interactiveness?\nEDIT: this could either be a cron job, or started by a windows batch file, through the scheduled tasks.","AnswerCount":3,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":1179,"Q_Id":1285024,"Users Score":11,"Answer":"You should simply add a command-line switch in the scheduled task, and check for it in your script, modifying the behavior as appropriate. Explicit is better than implicit.\nOne benefit to this design: you'll be able to test both behaviors, regardless of how you actually invoked the script.","Q_Score":2,"Tags":"python,interactive","A_Id":1285056,"CreationDate":"2009-08-16T18:48:00.000","Title":"How can I check to see if a Python script was started interactively?","Data Science and Machine Learning":0,"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},{"Question":"I am using Pyme to interface with GPGME and have had no problems signing \/ encrypting. When I try to decrypt, however, it always brings up the prompt for the passphrase despite having set it via a c.set_passphrase_cb callback. Am I doing something wrong?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1048,"Q_Id":1288959,"Users Score":0,"Answer":"Add \"c.set_armor(1)\" before you set the passphrase callback.","Q_Score":0,"Tags":"python,gnupg,pyme,gpgme","A_Id":2618041,"CreationDate":"2009-08-17T16:19:00.000","Title":"Python Pyme: Simple decryption without user interaction","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"Long story short, I created a new gmail account, and linked several other accounts to it (each with 1000s of messages), which I am importing. All imported messages arrive as unread, but I need them to appear as read.\nI have a little experience with python, but I've only used mail and imaplib modules for sending mail, not processing accounts.\nIs there a way to bulk process all items in an inbox, and simply mark messages older than a specified date as read?","AnswerCount":4,"Available Count":2,"Score":0.049958375,"is_accepted":false,"ViewCount":5833,"Q_Id":1296446,"Users Score":1,"Answer":"Just go to the Gmail web interface, do an advanced search by date, then select all and mark as read.","Q_Score":5,"Tags":"python,email,gmail,imap,pop3","A_Id":1296476,"CreationDate":"2009-08-18T20:52:00.000","Title":"Parse Gmail with Python and mark all older than date as \"read\"","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},{"Question":"Long story short, I created a new gmail account, and linked several other accounts to it (each with 1000s of messages), which I am importing. All imported messages arrive as unread, but I need them to appear as read.\nI have a little experience with python, but I've only used mail and imaplib modules for sending mail, not processing accounts.\nIs there a way to bulk process all items in an inbox, and simply mark messages older than a specified date as read?","AnswerCount":4,"Available Count":2,"Score":0.049958375,"is_accepted":false,"ViewCount":5833,"Q_Id":1296446,"Users Score":1,"Answer":"Rather than try to parse our HTML why not just use the IMAP interface? Hook it up to a standard mail client and then just sort by date and mark whichever ones you want as read.","Q_Score":5,"Tags":"python,email,gmail,imap,pop3","A_Id":1296465,"CreationDate":"2009-08-18T20:52:00.000","Title":"Parse Gmail with Python and mark all older than date as \"read\"","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},{"Question":"scope.SetVariable(\"math\", ?? typeof(System.Math) ??);\nor do I need create a module?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1921,"Q_Id":1300265,"Users Score":7,"Answer":"You can do:\nscope.SetVariable(\"math\", DynamicHelpers.GetPythonTypeFromType(typeof(System.Math)));\nDynamicHelpers is in IronPython.Runtime.Types.","Q_Score":5,"Tags":"c#,static,ironpython,dynamic-language-runtime","A_Id":1301404,"CreationDate":"2009-08-19T14:15:00.000","Title":"How to import static class (or static method) into IronPython (or DLR) using C# code(not 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},{"Question":"I have setup the logging module for my new python script. I have two handlers, one sending stuff to a file, and one for email alerts. The SMTPHandler is setup to mail anything at the ERROR level or above.\nEverything works great, unless the SMTP connection fails. If the SMTP server does not respond or authentication fails (it requires SMTP auth), then the whole script dies.\nI am fairly new to python, so I am trying to figure out how to capture the exception that the SMTPHandler is raising so that any problems sending the log message via email won't bring down my entire script. Since I am also writing errors to a log file, if the SMTP alert fails, I just want to keep going, not halt anything.\nIf I need a \"try:\" statement, would it go around the logging.handlers.SMTPHandler setup, or around the individual calls to my_logger.error()?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1574,"Q_Id":1304593,"Users Score":0,"Answer":"You probably need to do both. To figure this out, I suggest to install a local mail server and use that. This way, you can shut it down while your script runs and note down the error message.\nTo keep the code maintainable, you should extends SMTPHandler in such a way that you can handle the exceptions in a single place (instead of wrapping every logger call with try-except).","Q_Score":1,"Tags":"python,logging,handler","A_Id":1304622,"CreationDate":"2009-08-20T07:45:00.000","Title":"Python logging SMTPHandler - handling offline SMTP server","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},{"Question":"Is there a Python module for the translation of texts from one human language to another? I'm planning to work with texts that are to be pre and post processed with Python scripts.\nWhat other Python-integrated approaches can be used?","AnswerCount":5,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":31530,"Q_Id":1316386,"Users Score":0,"Answer":"What to use depends on what you want to translate.\n\nTexts that are a part of your application, like UI etc. Then use gettext directly, or zope.i18n, which wraps gettext so it's easier to use.\nArbitrary texts: The Google Translation API is the thing for you.\n\"Content\", ie things that the user of the application will modify and translate: Well... nothing, really. You have to implement that yourself.\n\nOn your description, it sounds like you are after #2.","Q_Score":14,"Tags":"python,linguistics","A_Id":1316803,"CreationDate":"2009-08-22T16:33:00.000","Title":"Translating human languages 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},{"Question":"im looking for simple script that will compile to exe , and i found py2exe \nbefore i decide to work with it , what do you think are the pros and cons of the py2exe tool?","AnswerCount":3,"Available Count":1,"Score":0.1325487884,"is_accepted":false,"ViewCount":969,"Q_Id":1318311,"Users Score":2,"Answer":"Look through the third-party libraries that you use. Some libraries (e.g. PIL) do tricks with conditional imports that make it hard for py2exe to bundle the right code. These issues can often be worked around, but a bit of googling up front might save you some headaches later.","Q_Score":2,"Tags":"python,py2exe","A_Id":1319719,"CreationDate":"2009-08-23T11:13:00.000","Title":"what are the pros\/cons of py2exe","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I was just reviewing one of my client's applications which uses some old outdated php framework that doesn't rely on caching at all and is pretty much completely database dependent.\nI figure I'll just rewrite it from scratch because it's really outdated and in this rewrite I want to implement a caching system. It'd be nice if I could get a few pointers if anyone has done this prior.\n\nRewrite will be done in either PHP or Python\nWould be nice if I could profile before and after this implementation\nI have my own server so I'm not restricted by shared hosting","AnswerCount":4,"Available Count":3,"Score":1.0,"is_accepted":false,"ViewCount":385,"Q_Id":1338777,"Users Score":6,"Answer":"If your site performance is fine then there's no reason to add caching. Lots of sites can get by without any cache at all, or by moving to a file-system based cache. It's only the super high traffic sites that need memcached.\nWhat's \"crazy\" is code architecture (or a lack of architecture) that makes adding caching in latter difficult.","Q_Score":2,"Tags":"php,python,memcached,scalability","A_Id":1338810,"CreationDate":"2009-08-27T03:57:00.000","Title":"Is it crazy to not rely on a caching system like memcached nowadays ( for dynamic sites )?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I was just reviewing one of my client's applications which uses some old outdated php framework that doesn't rely on caching at all and is pretty much completely database dependent.\nI figure I'll just rewrite it from scratch because it's really outdated and in this rewrite I want to implement a caching system. It'd be nice if I could get a few pointers if anyone has done this prior.\n\nRewrite will be done in either PHP or Python\nWould be nice if I could profile before and after this implementation\nI have my own server so I'm not restricted by shared hosting","AnswerCount":4,"Available Count":3,"Score":1.2,"is_accepted":true,"ViewCount":385,"Q_Id":1338777,"Users Score":10,"Answer":"Caching, when it works right (==high hit rate), is one of the few general-purpose techniques that can really help with latency -- the harder part of problems generically describes as \"performance\". You can enhance QPS (queries per second) measures of performance just by throwing more hardware at the problem -- but latency doesn't work that way (i.e., it doesn't take just one month to make a babies if you set nine mothers to work on it;-).\nHowever, the main resource used by caching is typically memory (RAM or disk as it may be). As you mention in a comment that the only performance problem you observe is memory usage, caching wouldn't help: it would just earmark some portion of memory to use for caching purposes, leaving even less available as a \"general fund\". As a resident of California I'm witnessing first-hand what happens when too many resources are earmarked, and I couldn't recommend such a course of action with a clear conscience!-)","Q_Score":2,"Tags":"php,python,memcached,scalability","A_Id":1338828,"CreationDate":"2009-08-27T03:57:00.000","Title":"Is it crazy to not rely on a caching system like memcached nowadays ( for dynamic sites )?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I was just reviewing one of my client's applications which uses some old outdated php framework that doesn't rely on caching at all and is pretty much completely database dependent.\nI figure I'll just rewrite it from scratch because it's really outdated and in this rewrite I want to implement a caching system. It'd be nice if I could get a few pointers if anyone has done this prior.\n\nRewrite will be done in either PHP or Python\nWould be nice if I could profile before and after this implementation\nI have my own server so I'm not restricted by shared hosting","AnswerCount":4,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":385,"Q_Id":1338777,"Users Score":0,"Answer":"Depending on the specific nature of the codebase and traffic patterns, you might not even need to re-write the whole site. Horribly inefficient code is not such a big deal if it can be bypassed via cache for 99.9% of page requests.\nWhen choosing PHP or Python, make sure you figure out where you're going to host the site (or if you even get to make that call). Many of my clients are already set up on a webserver and Python is not an option. You should also make sure any databases\/external programs you want to interface with are well-supported in PHP or Python.","Q_Score":2,"Tags":"php,python,memcached,scalability","A_Id":1338864,"CreationDate":"2009-08-27T03:57:00.000","Title":"Is it crazy to not rely on a caching system like memcached nowadays ( for dynamic sites )?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"Is there a consensus about the best place to put Python unittests?\nShould the unittests be included within the same module as the functionality being tested (executed when the module is run on its own (if __name__ == '__main__', etc.)), or is it better to include the unittests within different modules?\nPerhaps a combination of both approaches is best, including module level tests within each module and adding higher level tests which test functionality included in more than one module as separate modules (perhaps in a \/test subdirectory?).\nI assume that test discovery is more straightforward if the tests are included in separate modules, but there's an additional burden on the developer if he\/she has to remember to update the additional test module if the module under test is modified.\nI'd be interested to know peoples' thoughts on the best way of organizing unittests.","AnswerCount":7,"Available Count":6,"Score":1.2,"is_accepted":true,"ViewCount":5565,"Q_Id":1340892,"Users Score":13,"Answer":"Where you have to if using a library specifying where unittests should live,\nin the modules themselves for small projects, or\nin a tests\/ subdirectory in your package for larger projects.\n\nIt's a matter of what works best for the project you're creating.\nSometimes the libraries you're using determine where tests should go, as is the case with Django (where you put your tests in models.py, tests.py or a tests\/ subdirectory in your apps).\nIf there are no existing constraints, it's a matter of personal preference. For a small set of modules, it may be more convenient to put the unittests in the files you're creating.\nFor anything more than a few modules I create the tests separately in a tests\/ directory in the package. Having testing code mixed with the implementation adds unnecessary noise for anyone reading the code.","Q_Score":19,"Tags":"python,unit-testing,testing","A_Id":1341053,"CreationDate":"2009-08-27T12:52:00.000","Title":"Should Python unittests be in a separate 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},{"Question":"Is there a consensus about the best place to put Python unittests?\nShould the unittests be included within the same module as the functionality being tested (executed when the module is run on its own (if __name__ == '__main__', etc.)), or is it better to include the unittests within different modules?\nPerhaps a combination of both approaches is best, including module level tests within each module and adding higher level tests which test functionality included in more than one module as separate modules (perhaps in a \/test subdirectory?).\nI assume that test discovery is more straightforward if the tests are included in separate modules, but there's an additional burden on the developer if he\/she has to remember to update the additional test module if the module under test is modified.\nI'd be interested to know peoples' thoughts on the best way of organizing unittests.","AnswerCount":7,"Available Count":6,"Score":0.1137907297,"is_accepted":false,"ViewCount":5565,"Q_Id":1340892,"Users Score":4,"Answer":"I generally keep test code in a separate module, and ship the module\/package and tests in a single distribution. If the user installs using setup.py they can run the tests from the test directory to ensure that everything works in their environment, but only the module's code ends up under Lib\/site-packages.","Q_Score":19,"Tags":"python,unit-testing,testing","A_Id":1340964,"CreationDate":"2009-08-27T12:52:00.000","Title":"Should Python unittests be in a separate 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},{"Question":"Is there a consensus about the best place to put Python unittests?\nShould the unittests be included within the same module as the functionality being tested (executed when the module is run on its own (if __name__ == '__main__', etc.)), or is it better to include the unittests within different modules?\nPerhaps a combination of both approaches is best, including module level tests within each module and adding higher level tests which test functionality included in more than one module as separate modules (perhaps in a \/test subdirectory?).\nI assume that test discovery is more straightforward if the tests are included in separate modules, but there's an additional burden on the developer if he\/she has to remember to update the additional test module if the module under test is modified.\nI'd be interested to know peoples' thoughts on the best way of organizing unittests.","AnswerCount":7,"Available Count":6,"Score":0.0,"is_accepted":false,"ViewCount":5565,"Q_Id":1340892,"Users Score":0,"Answer":"if __name__ == '__main__', etc. is great for small tests.","Q_Score":19,"Tags":"python,unit-testing,testing","A_Id":1341011,"CreationDate":"2009-08-27T12:52:00.000","Title":"Should Python unittests be in a separate 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},{"Question":"Is there a consensus about the best place to put Python unittests?\nShould the unittests be included within the same module as the functionality being tested (executed when the module is run on its own (if __name__ == '__main__', etc.)), or is it better to include the unittests within different modules?\nPerhaps a combination of both approaches is best, including module level tests within each module and adding higher level tests which test functionality included in more than one module as separate modules (perhaps in a \/test subdirectory?).\nI assume that test discovery is more straightforward if the tests are included in separate modules, but there's an additional burden on the developer if he\/she has to remember to update the additional test module if the module under test is modified.\nI'd be interested to know peoples' thoughts on the best way of organizing unittests.","AnswerCount":7,"Available Count":6,"Score":0.0855049882,"is_accepted":false,"ViewCount":5565,"Q_Id":1340892,"Users Score":3,"Answer":"There might be reasons other than testing to use the if __name__ == '__main__' check. Keeping the tests in other modules leaves that option open to you. Also - if you refactor the implementation of a module and your tests are in another module that was not edited - you KNOW the tests have not been changed when you run them against the refactored code.","Q_Score":19,"Tags":"python,unit-testing,testing","A_Id":1341048,"CreationDate":"2009-08-27T12:52:00.000","Title":"Should Python unittests be in a separate 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},{"Question":"Is there a consensus about the best place to put Python unittests?\nShould the unittests be included within the same module as the functionality being tested (executed when the module is run on its own (if __name__ == '__main__', etc.)), or is it better to include the unittests within different modules?\nPerhaps a combination of both approaches is best, including module level tests within each module and adding higher level tests which test functionality included in more than one module as separate modules (perhaps in a \/test subdirectory?).\nI assume that test discovery is more straightforward if the tests are included in separate modules, but there's an additional burden on the developer if he\/she has to remember to update the additional test module if the module under test is modified.\nI'd be interested to know peoples' thoughts on the best way of organizing unittests.","AnswerCount":7,"Available Count":6,"Score":0.0285636566,"is_accepted":false,"ViewCount":5565,"Q_Id":1340892,"Users Score":1,"Answer":"I usually have them in a separate folder called most often test\/. Personally I am not using the if __name__ == '__main__' check, because I use nosetests and it handles the test detection by itself.","Q_Score":19,"Tags":"python,unit-testing,testing","A_Id":1341060,"CreationDate":"2009-08-27T12:52:00.000","Title":"Should Python unittests be in a separate 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},{"Question":"Is there a consensus about the best place to put Python unittests?\nShould the unittests be included within the same module as the functionality being tested (executed when the module is run on its own (if __name__ == '__main__', etc.)), or is it better to include the unittests within different modules?\nPerhaps a combination of both approaches is best, including module level tests within each module and adding higher level tests which test functionality included in more than one module as separate modules (perhaps in a \/test subdirectory?).\nI assume that test discovery is more straightforward if the tests are included in separate modules, but there's an additional burden on the developer if he\/she has to remember to update the additional test module if the module under test is modified.\nI'd be interested to know peoples' thoughts on the best way of organizing unittests.","AnswerCount":7,"Available Count":6,"Score":1.0,"is_accepted":false,"ViewCount":5565,"Q_Id":1340892,"Users Score":15,"Answer":"YES, do use a separate module.\nIt does not really make sense to use the __main__ trick. Just assume that you have several files in your module, and it does not work anymore, because you don't want to run each source file separately when testing your module.\nAlso, when installing a module, most of the time you don't want to install the tests. Your end-user does not care about tests, only the developers should care.\nNo, really. Put your tests in tests\/, your doc in doc, and have a Makefile ready around for a make test. Any other approaches are just intermediate solutions, only valid for specific tiny modules.","Q_Score":19,"Tags":"python,unit-testing,testing","A_Id":1341119,"CreationDate":"2009-08-27T12:52:00.000","Title":"Should Python unittests be in a separate 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},{"Question":"I have a friend who I am trying to teach how to program. He comes from a very basic PHP background, and for some reason is ANTI C#, I guess because some of his PHP circles condemn anything that comes from Microsoft.\nAnyways - I've told him its possible to use either Ruby or Python with the VS2008 IDE, because I've read somewhere that this is possible. \nBut I was wondering. Is it really that practical, can you do EVERYTHING with Python in VS2008 that you can do with C# or VB.net. \nI guess without starting a debate... I want to know if you're a developer using VS IDE with a language other than VB.net or C#, then please leave an answer with your experience. \nIf you are (like me) either a VB.net or C# developer, please don't post speculative or subjective answers. This is a serious question, and I don't want it being closed as subjective. ...\nThank you very much.\nupdate\nSo far we've established that IronPython is the right tool for the job. \nNow how practical is it really?\nMono for example runs C# code in Linux, but... ever tried to use it? Not practical at all, lots of code refactoring needs to take place, no support for .net v3.5, etc...","AnswerCount":6,"Available Count":2,"Score":0.0333209931,"is_accepted":false,"ViewCount":505,"Q_Id":1342377,"Users Score":1,"Answer":"Firstly, there seems to be a question as to whether python (or various implementations) are as 'powerful' as C#. I'm not quite sure what to take powerful to mean, but in my experience of both languages it will be somewhat easier and faster to write a given piece of code in python than in C#. C# is faster than cpython (although if speed is desired, the psyco python module is well worth a look).\nAlso I would object to your dismissal of Mono. Mono is great on Linux if you write an application for it from scratch. It is not really meant to be a compatibility layer between Windows and Linux (see Wine!), and if you treat it as such you will only be disappointed.\nIt just seems to me that you are taking the wrong approach. If you want to convince him that not everything Microsoft is evil, and he is adamant about not learning C#, get him to learn Python (or Ruby, or LUA or whatever) until he is competent, and then introduce him to C# and get him to make his own judgement - I'm fairly in favour of open source, and am far from a rabid Microsoft supporter, but I tried C#, and found I quite liked it.\nI think that getting him to use python and visual studio in a suboptimal way will turn him against both of them - far from your desired goal!","Q_Score":2,"Tags":"python,visual-studio,ironpython","A_Id":1343191,"CreationDate":"2009-08-27T16:57:00.000","Title":"Can you really use the Visual Studio 2008 IDE to code 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},{"Question":"I have a friend who I am trying to teach how to program. He comes from a very basic PHP background, and for some reason is ANTI C#, I guess because some of his PHP circles condemn anything that comes from Microsoft.\nAnyways - I've told him its possible to use either Ruby or Python with the VS2008 IDE, because I've read somewhere that this is possible. \nBut I was wondering. Is it really that practical, can you do EVERYTHING with Python in VS2008 that you can do with C# or VB.net. \nI guess without starting a debate... I want to know if you're a developer using VS IDE with a language other than VB.net or C#, then please leave an answer with your experience. \nIf you are (like me) either a VB.net or C# developer, please don't post speculative or subjective answers. This is a serious question, and I don't want it being closed as subjective. ...\nThank you very much.\nupdate\nSo far we've established that IronPython is the right tool for the job. \nNow how practical is it really?\nMono for example runs C# code in Linux, but... ever tried to use it? Not practical at all, lots of code refactoring needs to take place, no support for .net v3.5, etc...","AnswerCount":6,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":505,"Q_Id":1342377,"Users Score":2,"Answer":"I find it odd that your friend is against C# but is ok with Visual Studio. There is, after all, an open source development environment for .NET called SharpDevelop. The C# language is a standard. .NET is free (as in beer) and there is an open source implementation of that platform called Mono. The only \"un-free\" thing is Visual Studio (though there are \"Express\" versions which are free as in beer).","Q_Score":2,"Tags":"python,visual-studio,ironpython","A_Id":1342463,"CreationDate":"2009-08-27T16:57:00.000","Title":"Can you really use the Visual Studio 2008 IDE to code 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},{"Question":"I'm writing an application where users can enter a python script and execute it in a sandbox. I need a way to prevent the exec'ed code from importing certain modules, so malicious code won't be as much of a problem. Is there a way to do this in Python?","AnswerCount":7,"Available Count":2,"Score":0.0285636566,"is_accepted":false,"ViewCount":21579,"Q_Id":1350466,"Users Score":1,"Answer":"Unfortunately, I think that what you're trying to do is fundamentally impossible. If users can execute arbitrary code in your application then they can do whatever they want. Even if you were able to prevent them from importing certain modules there would be nothing stopping them from writing equivalent functionality themselves (from scratch or using some of the modules that are available).\nI don't really know the specifics of implementing a sandbox in Python, but I would imagine it's something that needs to be done at the interpreter level and is far from easy!","Q_Score":26,"Tags":"python,module,sandbox","A_Id":1350473,"CreationDate":"2009-08-29T04:39:00.000","Title":"Preventing Python code from importing certain 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},{"Question":"I'm writing an application where users can enter a python script and execute it in a sandbox. I need a way to prevent the exec'ed code from importing certain modules, so malicious code won't be as much of a problem. Is there a way to do this in Python?","AnswerCount":7,"Available Count":2,"Score":-0.0855049882,"is_accepted":false,"ViewCount":21579,"Q_Id":1350466,"Users Score":-3,"Answer":"You can overload the import mechanism. We used this to have a licensing system for plugins, you can easily have a whitelist \/ blacklist of module names.","Q_Score":26,"Tags":"python,module,sandbox","A_Id":1350472,"CreationDate":"2009-08-29T04:39:00.000","Title":"Preventing Python code from importing certain 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},{"Question":"I'm new to Python, coming from a C# background and I'm trying to get up to speed. I understand that Python is dynamically typed, whereas C# is strongly-typed. -> see comments. What conceptual obstacles should I watch out for when attempting to learn Python? Are there concepts for which no analog exists in Python? How important is object-oriented analysis? \nI believe answers to these and any other questions you might be able to think of would speed up my understanding Python besides the Nike mentality (\"just do it\")?\nA little more context: My company is moving from ASP.NET C# Web Forms to Django. I've gone through the Django tutorial and it was truly great. I need to get up to speed in about 2 weeks time (ridiculous maybe? LOL)\nThank you all for your time and efforts to respond to a realllly broad question(s).","AnswerCount":5,"Available Count":3,"Score":1.2,"is_accepted":true,"ViewCount":3579,"Q_Id":1351227,"Users Score":9,"Answer":"\" I understand that Python is dynamically typed, whereas C# is strongly-typed. \"\nThis is weirdly wrong.\n\nPython is strongly typed. A list or integer or dictionary is always of the given type. The object's type cannot be changed.\nPython variables are not strongly typed. Indeed, Python variables are just labels on objects. Variables are not declared; hence the description of Python as \"dynamic\". \nC# is statically typed. The variables are declared to the compiler to be of a specific type. The code is generated based on certain knowledge about the variables use at run-time.\n\nPython is \"interpreted\" -- things are done at run-time -- little is assumed. [Technically, the Python source is compiled into byte code and the byte code is interpreted. Some folks think this is an important distinction.]\nC# is compiled -- the compiler generates code based on the declared assumptions.\n\nWhat conceptual obstacles should I watch out for when attempting to learn Python?\nNone. If you insist that Python should be like something else; or you insist that something else is more intuitive then you've polluted your own thinking with inappropriate concepts.\nNo programming language has obstacles. We bring our own obstacles when we impose things on the language.\nAre there concepts for which no analog exists in Python?\nSince Python has object-oriented, procedural and functional elements, you'd be hard-pressed to find something missing from Python.\nHow important is object-oriented analysis?\nOO analysis helps all phases of software development -- even if you aren't doing an OO implementation. This is unrelated to Python and should be a separate question.\nI need to get up to speed in about 2 weeks time (ridiculous maybe?)\nPerhaps not. If you start with a fresh, open mind, then Python can be learned in a week or so of diligent work.\nIf, on the other hand, you compare and contrast Python with C#, it can take you years to get past your C# bias and learn Python. Don't translate C# to Python. Don't translate Python to C#. \nDon't go to the well with a full bucket.","Q_Score":3,"Tags":"c#,asp.net,python,django,programming-languages","A_Id":1351670,"CreationDate":"2009-08-29T11:39:00.000","Title":"What are some of the core conceptual differences between C# 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":0},{"Question":"I'm new to Python, coming from a C# background and I'm trying to get up to speed. I understand that Python is dynamically typed, whereas C# is strongly-typed. -> see comments. What conceptual obstacles should I watch out for when attempting to learn Python? Are there concepts for which no analog exists in Python? How important is object-oriented analysis? \nI believe answers to these and any other questions you might be able to think of would speed up my understanding Python besides the Nike mentality (\"just do it\")?\nA little more context: My company is moving from ASP.NET C# Web Forms to Django. I've gone through the Django tutorial and it was truly great. I need to get up to speed in about 2 weeks time (ridiculous maybe? LOL)\nThank you all for your time and efforts to respond to a realllly broad question(s).","AnswerCount":5,"Available Count":3,"Score":0.0798297691,"is_accepted":false,"ViewCount":3579,"Q_Id":1351227,"Users Score":2,"Answer":"You said that Python is dynamically typed and C# is strongly typed but this isn't true. Strong vs. weak typing and static vs. dynamic typing are orthagonal. Strong typing means str + int doesn't coerce one of the opperands, so in this regard both Python and C# are strongly typed (whereas PHP or C is weakly typed). Python is dynamically typed which means names don't have a defined type at compile time, whereas in C# they do.","Q_Score":3,"Tags":"c#,asp.net,python,django,programming-languages","A_Id":1351664,"CreationDate":"2009-08-29T11:39:00.000","Title":"What are some of the core conceptual differences between C# 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":0},{"Question":"I'm new to Python, coming from a C# background and I'm trying to get up to speed. I understand that Python is dynamically typed, whereas C# is strongly-typed. -> see comments. What conceptual obstacles should I watch out for when attempting to learn Python? Are there concepts for which no analog exists in Python? How important is object-oriented analysis? \nI believe answers to these and any other questions you might be able to think of would speed up my understanding Python besides the Nike mentality (\"just do it\")?\nA little more context: My company is moving from ASP.NET C# Web Forms to Django. I've gone through the Django tutorial and it was truly great. I need to get up to speed in about 2 weeks time (ridiculous maybe? LOL)\nThank you all for your time and efforts to respond to a realllly broad question(s).","AnswerCount":5,"Available Count":3,"Score":0.0399786803,"is_accepted":false,"ViewCount":3579,"Q_Id":1351227,"Users Score":1,"Answer":"The conceptual differences are important, but mostly in how they result in different attitudes. \nMost important of those are \"duck typing\". Ie, forget what type things are, you don't need to care. You only need to care about what attributes and methods objects have. \"If it looks like a duck and walks like a duck, it's a duck\". Usually, these attitude changes come naturally after a while.\nThe biggest conceptual hurdles seems to be\n\nThe significant indenting. But the only ones who hate it are people who have, or are forced to work with, people who change their editors tab expansion from something other than the default 8.\nNo compiler, and hence no type testing at the compile stage. Many people coming from statically typed languages believe that the type checking during compilation finds many bugs. It doesn't, in my experience.","Q_Score":3,"Tags":"c#,asp.net,python,django,programming-languages","A_Id":1351334,"CreationDate":"2009-08-29T11:39:00.000","Title":"What are some of the core conceptual differences between C# 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":0},{"Question":"Anyone know this? I've never been able to find an answer.","AnswerCount":5,"Available Count":3,"Score":0.1973753202,"is_accepted":false,"ViewCount":38302,"Q_Id":1352922,"Users Score":5,"Answer":"It finds 'python' also in \/usr\/local\/bin, ~\/bin, \/opt\/bin, ... or wherever it may hide.","Q_Score":71,"Tags":"python,bash","A_Id":1352927,"CreationDate":"2009-08-30T02:30:00.000","Title":"Why is '#!\/usr\/bin\/env python' supposedly more correct than just '#!\/usr\/bin\/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},{"Question":"Anyone know this? I've never been able to find an answer.","AnswerCount":5,"Available Count":3,"Score":1.0,"is_accepted":false,"ViewCount":38302,"Q_Id":1352922,"Users Score":10,"Answer":"it finds the python executable in your environment and uses that. it's more portable because python may not always be in \/usr\/bin\/python. env is always located in \/usr\/bin.","Q_Score":71,"Tags":"python,bash","A_Id":1352941,"CreationDate":"2009-08-30T02:30:00.000","Title":"Why is '#!\/usr\/bin\/env python' supposedly more correct than just '#!\/usr\/bin\/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},{"Question":"Anyone know this? I've never been able to find an answer.","AnswerCount":5,"Available Count":3,"Score":1.2,"is_accepted":true,"ViewCount":38302,"Q_Id":1352922,"Users Score":67,"Answer":"If you're prone to installing python in various and interesting places on your PATH (as in $PATH in typical Unix shells, %PATH on typical Windows ones), using \/usr\/bin\/env will accomodate your whim (well, in Unix-like environments at least) while going directly to \/usr\/bin\/python won't. But losing control of what version of Python your scripts run under is no unalloyed bargain... if you look at my code you're more likely to see it start with, e.g., #!\/usr\/local\/bin\/python2.5 rather than with an open and accepting #!\/usr\/bin\/env python -- assuming the script is important I like to ensure it's run with the specific version I have tested and developed it with, NOT a semi-random one;-).","Q_Score":71,"Tags":"python,bash","A_Id":1352938,"CreationDate":"2009-08-30T02:30:00.000","Title":"Why is '#!\/usr\/bin\/env python' supposedly more correct than just '#!\/usr\/bin\/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},{"Question":"I recall when I first read Pragmatic Programmer that they suggested using scripting languages to make you a more productive programmer.\nI am in a quandary putting this into practice.\nI want to know specific ways that using Python or Ruby can make me a more productive .NET developer.\nOne specific way per answer, and even better if you can say whether I could use Python or Ruby or Both for it.\nSee standard format below.","AnswerCount":8,"Available Count":6,"Score":0.049958375,"is_accepted":false,"ViewCount":403,"Q_Id":1353211,"Users Score":2,"Answer":"Embedding a script engine\nUse of IronPython for a scripting engine inside your .NET application. For example enabling end-users of your application to change customizable parts with a full fledge language such as Python.\nA possible example might be to expose custom logic to end-users for a work flow engine.","Q_Score":4,"Tags":"python,.net,ruby","A_Id":1353301,"CreationDate":"2009-08-30T06:13:00.000","Title":"I'm a .NET Programmer. What are specific uses of Python and\/or Ruby for that will make me more productive?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I recall when I first read Pragmatic Programmer that they suggested using scripting languages to make you a more productive programmer.\nI am in a quandary putting this into practice.\nI want to know specific ways that using Python or Ruby can make me a more productive .NET developer.\nOne specific way per answer, and even better if you can say whether I could use Python or Ruby or Both for it.\nSee standard format below.","AnswerCount":8,"Available Count":6,"Score":0.049958375,"is_accepted":false,"ViewCount":403,"Q_Id":1353211,"Users Score":2,"Answer":"Advanced Text Processing\nTraditional strengths of awk and perl. You can just glue together a bunch of regular expressions to create a simple data-mining system on the go.","Q_Score":4,"Tags":"python,.net,ruby","A_Id":1353228,"CreationDate":"2009-08-30T06:13:00.000","Title":"I'm a .NET Programmer. What are specific uses of Python and\/or Ruby for that will make me more productive?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I recall when I first read Pragmatic Programmer that they suggested using scripting languages to make you a more productive programmer.\nI am in a quandary putting this into practice.\nI want to know specific ways that using Python or Ruby can make me a more productive .NET developer.\nOne specific way per answer, and even better if you can say whether I could use Python or Ruby or Both for it.\nSee standard format below.","AnswerCount":8,"Available Count":6,"Score":0.024994793,"is_accepted":false,"ViewCount":403,"Q_Id":1353211,"Users Score":1,"Answer":"Quick Prototyping - Both\nIn the simplest cases when firing a python interpreter and writing a line or two is way faster than creating a new project in visual studio.\nAnd you can use ruby to. Or lua, or evel perl, whatever. The point is implicit typing and light-weight feel.","Q_Score":4,"Tags":"python,.net,ruby","A_Id":1353220,"CreationDate":"2009-08-30T06:13:00.000","Title":"I'm a .NET Programmer. What are specific uses of Python and\/or Ruby for that will make me more productive?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I recall when I first read Pragmatic Programmer that they suggested using scripting languages to make you a more productive programmer.\nI am in a quandary putting this into practice.\nI want to know specific ways that using Python or Ruby can make me a more productive .NET developer.\nOne specific way per answer, and even better if you can say whether I could use Python or Ruby or Both for it.\nSee standard format below.","AnswerCount":8,"Available Count":6,"Score":0.024994793,"is_accepted":false,"ViewCount":403,"Q_Id":1353211,"Users Score":1,"Answer":"Cross platform\nCompared to .NET a simple script Python is more easily ported to other platforms such as Linux. Although possible to achieve the same with the likes of Mono it simpler to run a Python script file on different platforms.","Q_Score":4,"Tags":"python,.net,ruby","A_Id":1353244,"CreationDate":"2009-08-30T06:13:00.000","Title":"I'm a .NET Programmer. What are specific uses of Python and\/or Ruby for that will make me more productive?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I recall when I first read Pragmatic Programmer that they suggested using scripting languages to make you a more productive programmer.\nI am in a quandary putting this into practice.\nI want to know specific ways that using Python or Ruby can make me a more productive .NET developer.\nOne specific way per answer, and even better if you can say whether I could use Python or Ruby or Both for it.\nSee standard format below.","AnswerCount":8,"Available Count":6,"Score":0.0996679946,"is_accepted":false,"ViewCount":403,"Q_Id":1353211,"Users Score":4,"Answer":"Less Code\nI think productivity is direct result on how proficient you are in a specific language. That said the terseness of a language like Python might save some time on getting certain things done.\nIf I compare how much less code I have to write for simple administration scripts (e.g. clean-up of old files) compared to .NET code there is certain amount of productivity gain. (Plus it is more fun which also helps getting the job done)","Q_Score":4,"Tags":"python,.net,ruby","A_Id":1353229,"CreationDate":"2009-08-30T06:13:00.000","Title":"I'm a .NET Programmer. What are specific uses of Python and\/or Ruby for that will make me more productive?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I recall when I first read Pragmatic Programmer that they suggested using scripting languages to make you a more productive programmer.\nI am in a quandary putting this into practice.\nI want to know specific ways that using Python or Ruby can make me a more productive .NET developer.\nOne specific way per answer, and even better if you can say whether I could use Python or Ruby or Both for it.\nSee standard format below.","AnswerCount":8,"Available Count":6,"Score":0.024994793,"is_accepted":false,"ViewCount":403,"Q_Id":1353211,"Users Score":1,"Answer":"Processing received Email\nPython has built-in support for POP3 and IMAP where the standard .NET framework doesn't. Useful for automating email triggered tasks.","Q_Score":4,"Tags":"python,.net,ruby","A_Id":1353255,"CreationDate":"2009-08-30T06:13:00.000","Title":"I'm a .NET Programmer. What are specific uses of Python and\/or Ruby for that will make me more productive?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I had an argument with a colleague about writing python efficiently. He claimed that though you are programming python you still have to optimise the little bits of your software as much as possible, as if you are writing an efficient algorithm in C++.\nThings like:\n\nIn an if statement with an or always put the condition most likely to fail first, so the second will not be checked.\nUse the most efficient functions for manipulating strings in common use. Not code that grinds strings, but simple things like doing joins and splits, and finding substrings.\nCall as less functions as possible, even if it comes on the expense of readability, because of the overhead this creates.\n\nI say, that in most cases it doesn't matter. I should also say that context of the code is not a super-efficient NOC or missile-guidance systems. We're mostly writing tests in python.\nWhat's your view of the matter?","AnswerCount":10,"Available Count":7,"Score":1.0,"is_accepted":false,"ViewCount":805,"Q_Id":1353715,"Users Score":10,"Answer":"This sort of premature micro-optimisation is usually a waste of time in my experience, even in C and C++. Write readable code first. If it's running too slowly, run it through a profiler, and if necessary, fix the hot-spots.\nFundamentally, you need to think about return on investment. Is it worth the extra effort in reading and maintaining \"optimised\" code for the couple of microseconds it saves you? In most cases it isn't.\n(Also, compilers and runtimes are getting cleverer. Some micro-optimisations may become micro-pessimisations over time.)","Q_Score":5,"Tags":"python,performance","A_Id":1353775,"CreationDate":"2009-08-30T11:49:00.000","Title":"Should I optimise my python code like C++? Does it matter?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I had an argument with a colleague about writing python efficiently. He claimed that though you are programming python you still have to optimise the little bits of your software as much as possible, as if you are writing an efficient algorithm in C++.\nThings like:\n\nIn an if statement with an or always put the condition most likely to fail first, so the second will not be checked.\nUse the most efficient functions for manipulating strings in common use. Not code that grinds strings, but simple things like doing joins and splits, and finding substrings.\nCall as less functions as possible, even if it comes on the expense of readability, because of the overhead this creates.\n\nI say, that in most cases it doesn't matter. I should also say that context of the code is not a super-efficient NOC or missile-guidance systems. We're mostly writing tests in python.\nWhat's your view of the matter?","AnswerCount":10,"Available Count":7,"Score":0.0599281035,"is_accepted":false,"ViewCount":805,"Q_Id":1353715,"Users Score":3,"Answer":"I should also say that context of the code is not a super-efficient NOC or missile-guidance systems. We're mostly writing tests in python.\n\nGiven this, I'd say that you should take your colleague's advice about writing efficient Python but ignore anything he says that goes against prioritizing readability and maintainability of the code, which will probably be more important than the speed at which it'll execute.","Q_Score":5,"Tags":"python,performance","A_Id":1353728,"CreationDate":"2009-08-30T11:49:00.000","Title":"Should I optimise my python code like C++? Does it matter?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I had an argument with a colleague about writing python efficiently. He claimed that though you are programming python you still have to optimise the little bits of your software as much as possible, as if you are writing an efficient algorithm in C++.\nThings like:\n\nIn an if statement with an or always put the condition most likely to fail first, so the second will not be checked.\nUse the most efficient functions for manipulating strings in common use. Not code that grinds strings, but simple things like doing joins and splits, and finding substrings.\nCall as less functions as possible, even if it comes on the expense of readability, because of the overhead this creates.\n\nI say, that in most cases it doesn't matter. I should also say that context of the code is not a super-efficient NOC or missile-guidance systems. We're mostly writing tests in python.\nWhat's your view of the matter?","AnswerCount":10,"Available Count":7,"Score":0.0798297691,"is_accepted":false,"ViewCount":805,"Q_Id":1353715,"Users Score":4,"Answer":"I agree with others: readable code first (\"Performance is not a problem until performance is a problem.\").\nI only want to add that when you absolutely need to write some unreadable and\/or non-intuitive code, you can generally isolate it in few specific methods, for which you can write detailed comments, and keep the rest of your code highly readable. If you do so, you'll end up having easy to maintain code, and you'll only have to go through the unreadable parts when you really need to.","Q_Score":5,"Tags":"python,performance","A_Id":1353788,"CreationDate":"2009-08-30T11:49:00.000","Title":"Should I optimise my python code like C++? Does it matter?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I had an argument with a colleague about writing python efficiently. He claimed that though you are programming python you still have to optimise the little bits of your software as much as possible, as if you are writing an efficient algorithm in C++.\nThings like:\n\nIn an if statement with an or always put the condition most likely to fail first, so the second will not be checked.\nUse the most efficient functions for manipulating strings in common use. Not code that grinds strings, but simple things like doing joins and splits, and finding substrings.\nCall as less functions as possible, even if it comes on the expense of readability, because of the overhead this creates.\n\nI say, that in most cases it doesn't matter. I should also say that context of the code is not a super-efficient NOC or missile-guidance systems. We're mostly writing tests in python.\nWhat's your view of the matter?","AnswerCount":10,"Available Count":7,"Score":0.0399786803,"is_accepted":false,"ViewCount":805,"Q_Id":1353715,"Users Score":2,"Answer":"I think there are several related 'urban legends' here.\n\nFalse Putting the more often-checked condition first in a conditional and similar optimizations save enough time for a typical program that it is worthy for a typical programmer.\nTrue Some, but not many, people are using such styles in Python in the incorrect belief outlined above.\nTrue Many people use such style in Python when they think that it improves readability of a Python program.\n\nAbout readability: I think it's indeed useful when you give the most useful conditional first, since this is what people notice first anyway. You should also use ''.join() if you mean concatenation of strings since it's the most direct way to do it (the s += x operation could mean something different). \n\"Call as less functions as possible\" decreases readability and goes against Pythonic principle of code reuse. And so it's not a style people use in Python.","Q_Score":5,"Tags":"python,performance","A_Id":1354718,"CreationDate":"2009-08-30T11:49:00.000","Title":"Should I optimise my python code like C++? Does it matter?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I had an argument with a colleague about writing python efficiently. He claimed that though you are programming python you still have to optimise the little bits of your software as much as possible, as if you are writing an efficient algorithm in C++.\nThings like:\n\nIn an if statement with an or always put the condition most likely to fail first, so the second will not be checked.\nUse the most efficient functions for manipulating strings in common use. Not code that grinds strings, but simple things like doing joins and splits, and finding substrings.\nCall as less functions as possible, even if it comes on the expense of readability, because of the overhead this creates.\n\nI say, that in most cases it doesn't matter. I should also say that context of the code is not a super-efficient NOC or missile-guidance systems. We're mostly writing tests in python.\nWhat's your view of the matter?","AnswerCount":10,"Available Count":7,"Score":0.0199973338,"is_accepted":false,"ViewCount":805,"Q_Id":1353715,"Users Score":1,"Answer":"My visceral reaction is this:\nI've worked with guys like your colleague and in general I wouldn't take advice from them.\nAsk him if he's ever even used a profiler.","Q_Score":5,"Tags":"python,performance","A_Id":1354833,"CreationDate":"2009-08-30T11:49:00.000","Title":"Should I optimise my python code like C++? Does it matter?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I had an argument with a colleague about writing python efficiently. He claimed that though you are programming python you still have to optimise the little bits of your software as much as possible, as if you are writing an efficient algorithm in C++.\nThings like:\n\nIn an if statement with an or always put the condition most likely to fail first, so the second will not be checked.\nUse the most efficient functions for manipulating strings in common use. Not code that grinds strings, but simple things like doing joins and splits, and finding substrings.\nCall as less functions as possible, even if it comes on the expense of readability, because of the overhead this creates.\n\nI say, that in most cases it doesn't matter. I should also say that context of the code is not a super-efficient NOC or missile-guidance systems. We're mostly writing tests in python.\nWhat's your view of the matter?","AnswerCount":10,"Available Count":7,"Score":1.0,"is_accepted":false,"ViewCount":805,"Q_Id":1353715,"Users Score":13,"Answer":"The answer is really simple :\n\nFollow Python best practices, not C++ best practices.\nReadability in Python is more important that speed.\nIf performance becomes an issue, measure, then start optimizing.","Q_Score":5,"Tags":"python,performance","A_Id":1353732,"CreationDate":"2009-08-30T11:49:00.000","Title":"Should I optimise my python code like C++? Does it matter?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I had an argument with a colleague about writing python efficiently. He claimed that though you are programming python you still have to optimise the little bits of your software as much as possible, as if you are writing an efficient algorithm in C++.\nThings like:\n\nIn an if statement with an or always put the condition most likely to fail first, so the second will not be checked.\nUse the most efficient functions for manipulating strings in common use. Not code that grinds strings, but simple things like doing joins and splits, and finding substrings.\nCall as less functions as possible, even if it comes on the expense of readability, because of the overhead this creates.\n\nI say, that in most cases it doesn't matter. I should also say that context of the code is not a super-efficient NOC or missile-guidance systems. We're mostly writing tests in python.\nWhat's your view of the matter?","AnswerCount":10,"Available Count":7,"Score":1.2,"is_accepted":true,"ViewCount":805,"Q_Id":1353715,"Users Score":14,"Answer":"My answer to that would be :\n\nWe should forget about small\n efficiencies, say about 97% of the\n time: premature optimization is the\n root of all evil.\n\n(Quoting Knuth, Donald. Structured Programming with go to Statements, ACM Journal Computing Surveys, Vol 6, No. 4, Dec. 1974. p.268)\n\nIf your application is doing anything like a query to the database, that one query will take more time than anything you can gain with those kind of small optimizations, anyway...\nAnd if running after performances like that, why not code in assembly language, afterall ? Because Python is easier\/faster to write and maintain ? Well, if so, you are right :-)\nThe most important thing is that your code is easy to maintain ; not a couple micro-seconds of CPU-time !\nWell, maybe except if you have thousands of servers -- but is it your case ?","Q_Score":5,"Tags":"python,performance","A_Id":1353722,"CreationDate":"2009-08-30T11:49:00.000","Title":"Should I optimise my python code like C++? Does it matter?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am writing a python script that will perform performance test in linux file system. so besides deadlocks, race conditions and time takes to perform an action (delete, read, write and create) what other variables\/parameters should the test contain?","AnswerCount":4,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1679,"Q_Id":1356240,"Users Score":0,"Answer":"You might be inetersting in looking at tools like caollectd and iotop. Then again, yopu mightalso by interested in just using them instead of reinventing the wheel - as far as I see, such performance analysis is not learned in a day, and these guys invested significant amounts of time and knowledge in building these tools.","Q_Score":1,"Tags":"python,filesystems,performance-testing","A_Id":1356966,"CreationDate":"2009-08-31T07:29:00.000","Title":"file system performance 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":1,"Web Development":0},{"Question":"I have been exploring and developing an application in Python for mission critical work in the commercial banking arena. \nBanks are way conservative in selecting new applications.\nI need real proof of stability and others using. \nHave looked at the Python site but now I'm hoping this crowd can tell me more.\nSo far I don't have a development bank partner which I will need next stage, so I'm gathering proof and pitch info. All help and comments appreciated.","AnswerCount":10,"Available Count":3,"Score":1.0,"is_accepted":false,"ViewCount":16188,"Q_Id":1358084,"Users Score":6,"Answer":"Of course you can implement mission-critical software (whatever that is in your case) using Python. At the end of the day the success of your application is going to weigh more on its capabilities than whether it is written in Python. Some all .NET companies will even bring in Python applications provided that there is a way to talk to the system from .NET.\nI would not market your application as being a Python application. This is going to cause you trouble down the road because you will run into roadblocks. This often happens when you satisfy a business customer and he speaks to their IT guy who says \"whoa we can't support that\" without a full analysis of the cost\/benefit to the business. This is the place that references to use of Python in mission-critical systems will arise. Try to avoid this area.\nWith Python you can always target the popular platforms if you build your application under certain constraints. IronPython runs on .NET and Jython runs on Java. Being able to fire back with info on how to run your application on these platforms might be helpful.","Q_Score":22,"Tags":"python,enterprise,banking,onlinebanking","A_Id":1358743,"CreationDate":"2009-08-31T15:47:00.000","Title":"Python in the enterprise: Pros and cons","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I have been exploring and developing an application in Python for mission critical work in the commercial banking arena. \nBanks are way conservative in selecting new applications.\nI need real proof of stability and others using. \nHave looked at the Python site but now I'm hoping this crowd can tell me more.\nSo far I don't have a development bank partner which I will need next stage, so I'm gathering proof and pitch info. All help and comments appreciated.","AnswerCount":10,"Available Count":3,"Score":-1.0,"is_accepted":false,"ViewCount":16188,"Q_Id":1358084,"Users Score":-5,"Answer":"Python doesn't have anywhere close to as much money backing it as MSFT or Redhat etc. If Guido gets hit by a bus, Python is in trouble.\nI <3 python for a lot of things, but a financial transaction system probably wants a real, trusted, stable company backing it.\nEdit: this isn't flame bait; this is a major lesson learned from watching a colleague push a platform backed by a small company, and the resulting 'business-strategic' nightmare that ended with his project getting dropped in favor of someone using a far crappier project with lots of money. There's more to project success than the technical bit.","Q_Score":22,"Tags":"python,enterprise,banking,onlinebanking","A_Id":1358385,"CreationDate":"2009-08-31T15:47:00.000","Title":"Python in the enterprise: Pros and cons","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I have been exploring and developing an application in Python for mission critical work in the commercial banking arena. \nBanks are way conservative in selecting new applications.\nI need real proof of stability and others using. \nHave looked at the Python site but now I'm hoping this crowd can tell me more.\nSo far I don't have a development bank partner which I will need next stage, so I'm gathering proof and pitch info. All help and comments appreciated.","AnswerCount":10,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":16188,"Q_Id":1358084,"Users Score":0,"Answer":"i know topic is rather old, but anyway.\nif we talk about mission critical.\nPython is widly used in Thales software provided with is hardware encryption solutions.\nand in PayShield application for example, which i believe really mission critical.\nAlthough Java is being used there more than Python.","Q_Score":22,"Tags":"python,enterprise,banking,onlinebanking","A_Id":7913484,"CreationDate":"2009-08-31T15:47:00.000","Title":"Python in the enterprise: Pros and cons","Data Science and Machine Learning":0,"Database and SQL":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},{"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},{"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},{"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},{"Question":"I'm attempting to learn IronPython, to broaden my .NET horizons. I want to be able to use Python to write the unit-tests for my next personal project. So being able to access C#.NET assemblies from my Python code is necessary. I also wanted an IDE with auto-complete and smart indenting. PyScripter seemed like a good option, but can I run IronPython from it, and can I link to .NET assemblies from it? \nWhat kind of setup (IDE et al) do I need to run IronPython unit tests of C#.NET developed assemblies?","AnswerCount":5,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":210,"Q_Id":1377548,"Users Score":0,"Answer":"You can also consider using Eclipse with PyDev which has support for IronPython","Q_Score":0,"Tags":".net,python,ironpython","A_Id":1383258,"CreationDate":"2009-09-04T06:28:00.000","Title":"What kind of setup (IDE et al) do I need to run IronPython unit tests of C#.NET developed assemblies?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm attempting to learn IronPython, to broaden my .NET horizons. I want to be able to use Python to write the unit-tests for my next personal project. So being able to access C#.NET assemblies from my Python code is necessary. I also wanted an IDE with auto-complete and smart indenting. PyScripter seemed like a good option, but can I run IronPython from it, and can I link to .NET assemblies from it? \nWhat kind of setup (IDE et al) do I need to run IronPython unit tests of C#.NET developed assemblies?","AnswerCount":5,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":210,"Q_Id":1377548,"Users Score":0,"Answer":"FWIW, Frood himself uses Wing IDE.\nBut, if its on Windows, why not VS?","Q_Score":0,"Tags":".net,python,ironpython","A_Id":1378519,"CreationDate":"2009-09-04T06:28:00.000","Title":"What kind of setup (IDE et al) do I need to run IronPython unit tests of C#.NET developed assemblies?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm attempting to learn IronPython, to broaden my .NET horizons. I want to be able to use Python to write the unit-tests for my next personal project. So being able to access C#.NET assemblies from my Python code is necessary. I also wanted an IDE with auto-complete and smart indenting. PyScripter seemed like a good option, but can I run IronPython from it, and can I link to .NET assemblies from it? \nWhat kind of setup (IDE et al) do I need to run IronPython unit tests of C#.NET developed assemblies?","AnswerCount":5,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":210,"Q_Id":1377548,"Users Score":0,"Answer":"You can use Visual Studio. I use IronPython Studio integrated with VS2008. But I feel that it has very poor intellisense for Python.","Q_Score":0,"Tags":".net,python,ironpython","A_Id":1389592,"CreationDate":"2009-09-04T06:28:00.000","Title":"What kind of setup (IDE et al) do I need to run IronPython unit tests of C#.NET developed assemblies?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Many languages of REPL consoles with additional features like autocomplete and intellisense. For instance, iPython, Mathematica, and PyCrust all make some effort to go beyond a basic read eval loop. REPLs are particularly useful in languages where interactive exploration is very important, such as Matlab or R.\nI'm looking for inspiration. What application provides the slickest REPL? Or what features do you always wish existed in your REPL of choice?","AnswerCount":4,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":352,"Q_Id":1380592,"Users Score":4,"Answer":"I really like Safari's Web Inspector Javascript console. Specifically:\n\nCollapsible interactive object hierarchies\nsprintf-style logging\nPretty-printing of closures, allowing you to peer into the internals of anonymous functions\nAuto-complete \/ hinting of object properties on the command-line","Q_Score":3,"Tags":"python,matlab,console","A_Id":1380716,"CreationDate":"2009-09-04T17:35:00.000","Title":"Slickest REPL console in any 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},{"Question":"Many languages of REPL consoles with additional features like autocomplete and intellisense. For instance, iPython, Mathematica, and PyCrust all make some effort to go beyond a basic read eval loop. REPLs are particularly useful in languages where interactive exploration is very important, such as Matlab or R.\nI'm looking for inspiration. What application provides the slickest REPL? Or what features do you always wish existed in your REPL of choice?","AnswerCount":4,"Available Count":2,"Score":0.2449186624,"is_accepted":false,"ViewCount":352,"Q_Id":1380592,"Users Score":5,"Answer":"Common Lisp and emacs with SLIME. All you could really want, think of, dream of, and then some.","Q_Score":3,"Tags":"python,matlab,console","A_Id":1380870,"CreationDate":"2009-09-04T17:35:00.000","Title":"Slickest REPL console in any 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},{"Question":"I'm a fairly strong Python coder, but too much of my style is a little haphazard, and I'm sure there are more Pythonic solutions to many problems than the ones I come up with. Which PEPs are essential for any well versed Pythonista to read?","AnswerCount":7,"Available Count":2,"Score":0.0285636566,"is_accepted":false,"ViewCount":7197,"Q_Id":1382648,"Users Score":1,"Answer":"I'd also recommend PEPs 8 and 257. I know this deviates slightly from the original question, but I'd like to point out that PyCharm (probably the best Python IDE around in my opinion) automatically checks if you're following some of the most important PEP 8 guidelines, just in case anyone's interested...","Q_Score":70,"Tags":"python,pep","A_Id":21502630,"CreationDate":"2009-09-05T06:43:00.000","Title":"Which PEP's are must reads?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm a fairly strong Python coder, but too much of my style is a little haphazard, and I'm sure there are more Pythonic solutions to many problems than the ones I come up with. Which PEPs are essential for any well versed Pythonista to read?","AnswerCount":7,"Available Count":2,"Score":1.0,"is_accepted":false,"ViewCount":7197,"Q_Id":1382648,"Users Score":8,"Answer":"I found that reading the declined ones can give some good insights into what's Pythonic and what isn't.\nThis was a while ago so I don't have any specific examples.","Q_Score":70,"Tags":"python,pep","A_Id":1382662,"CreationDate":"2009-09-05T06:43:00.000","Title":"Which PEP's are must reads?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a class called Path for which there are defined about 10 methods, in a dedicated module Path.py. Recently I had a need to write 5 more methods for Path, however these new methods are quite obscure and technical and 90% of the time they are irrelevant.\nWhere would be a good place to put them so their context is clear? Of course I can just put them with the class definition, but I don't like that because I like to keep the important things separate from the obscure things.\nCurrently I have these methods as functions that are defined in a separate module, just to keep things separate, but it would be better to have them as bound methods. (Currently they take the Path instance as an explicit parameter.) \nDoes anyone have a suggestion?","AnswerCount":6,"Available Count":6,"Score":0.0,"is_accepted":false,"ViewCount":328,"Q_Id":1383590,"Users Score":0,"Answer":"Put them in the Path class, and document that they are \"obscure\" either with comments or docstrings. Separate them at the end if you like.","Q_Score":2,"Tags":"python,code-organization","A_Id":1383613,"CreationDate":"2009-09-05T15:25:00.000","Title":"Code organization in Python: Where is a good place to put obscure methods?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a class called Path for which there are defined about 10 methods, in a dedicated module Path.py. Recently I had a need to write 5 more methods for Path, however these new methods are quite obscure and technical and 90% of the time they are irrelevant.\nWhere would be a good place to put them so their context is clear? Of course I can just put them with the class definition, but I don't like that because I like to keep the important things separate from the obscure things.\nCurrently I have these methods as functions that are defined in a separate module, just to keep things separate, but it would be better to have them as bound methods. (Currently they take the Path instance as an explicit parameter.) \nDoes anyone have a suggestion?","AnswerCount":6,"Available Count":6,"Score":0.1325487884,"is_accepted":false,"ViewCount":328,"Q_Id":1383590,"Users Score":4,"Answer":"If the method is relevant to the Path - no matter how obscure - I think it should reside within the class itself.\nIf you have multiple places where you have path-related functionality, it leads to problems. For example, if you want to check if some functionality already exists, how will a new programmer know to check the other, less obvious places?\nI think a good practice might be to order functions by importance. As you may have heard, some suggest putting public members of classes first, and private\/protected ones after. You could consider putting the common methods in your class higher than the obscure ones.","Q_Score":2,"Tags":"python,code-organization","A_Id":1383607,"CreationDate":"2009-09-05T15:25:00.000","Title":"Code organization in Python: Where is a good place to put obscure methods?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a class called Path for which there are defined about 10 methods, in a dedicated module Path.py. Recently I had a need to write 5 more methods for Path, however these new methods are quite obscure and technical and 90% of the time they are irrelevant.\nWhere would be a good place to put them so their context is clear? Of course I can just put them with the class definition, but I don't like that because I like to keep the important things separate from the obscure things.\nCurrently I have these methods as functions that are defined in a separate module, just to keep things separate, but it would be better to have them as bound methods. (Currently they take the Path instance as an explicit parameter.) \nDoes anyone have a suggestion?","AnswerCount":6,"Available Count":6,"Score":0.0,"is_accepted":false,"ViewCount":328,"Q_Id":1383590,"Users Score":0,"Answer":"I would just prepend the names with an underscore _, to show that the reader shouldn't bother about them.\nIt's conventionally the same thing as private members in other languages.","Q_Score":2,"Tags":"python,code-organization","A_Id":1383601,"CreationDate":"2009-09-05T15:25:00.000","Title":"Code organization in Python: Where is a good place to put obscure methods?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a class called Path for which there are defined about 10 methods, in a dedicated module Path.py. Recently I had a need to write 5 more methods for Path, however these new methods are quite obscure and technical and 90% of the time they are irrelevant.\nWhere would be a good place to put them so their context is clear? Of course I can just put them with the class definition, but I don't like that because I like to keep the important things separate from the obscure things.\nCurrently I have these methods as functions that are defined in a separate module, just to keep things separate, but it would be better to have them as bound methods. (Currently they take the Path instance as an explicit parameter.) \nDoes anyone have a suggestion?","AnswerCount":6,"Available Count":6,"Score":0.0,"is_accepted":false,"ViewCount":328,"Q_Id":1383590,"Users Score":0,"Answer":"Oh wait, I thought of something -- I can just define them in the Path.py module, where every obscure method will be a one-liner that will call the function from the separate module that currently exists. With this compromise, the obscure methods will comprise of maybe 10 lines in the end of the file instead of 50% of its bulk.","Q_Score":2,"Tags":"python,code-organization","A_Id":1383639,"CreationDate":"2009-09-05T15:25:00.000","Title":"Code organization in Python: Where is a good place to put obscure methods?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a class called Path for which there are defined about 10 methods, in a dedicated module Path.py. Recently I had a need to write 5 more methods for Path, however these new methods are quite obscure and technical and 90% of the time they are irrelevant.\nWhere would be a good place to put them so their context is clear? Of course I can just put them with the class definition, but I don't like that because I like to keep the important things separate from the obscure things.\nCurrently I have these methods as functions that are defined in a separate module, just to keep things separate, but it would be better to have them as bound methods. (Currently they take the Path instance as an explicit parameter.) \nDoes anyone have a suggestion?","AnswerCount":6,"Available Count":6,"Score":1.2,"is_accepted":true,"ViewCount":328,"Q_Id":1383590,"Users Score":2,"Answer":"If you're keen to put those methods in a different source file at any cost, AND keen to have them at methods at any cost, you can achieve both goals by using the different source file to define a mixin class and having your Path class import that method and multiply-inherit from that mixin. So, technically, it's quite feasible.\nHowever, I would not recommend this course of action: it's worth using \"the big guns\" (such as multiple inheritance) only to serve important goals (such as reuse and removing repetition), and separating methods out in this way is not really a particularly crucial goal.\nIf those \"obscure methods\" played no role you would not be implementing them, so they must have SOME importance, after all; so I'd just clarify in docstrings and comments what they're for, maybe explicitly mention that they're rarely needed, and leave it at that.","Q_Score":2,"Tags":"python,code-organization","A_Id":1383623,"CreationDate":"2009-09-05T15:25:00.000","Title":"Code organization in Python: Where is a good place to put obscure methods?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a class called Path for which there are defined about 10 methods, in a dedicated module Path.py. Recently I had a need to write 5 more methods for Path, however these new methods are quite obscure and technical and 90% of the time they are irrelevant.\nWhere would be a good place to put them so their context is clear? Of course I can just put them with the class definition, but I don't like that because I like to keep the important things separate from the obscure things.\nCurrently I have these methods as functions that are defined in a separate module, just to keep things separate, but it would be better to have them as bound methods. (Currently they take the Path instance as an explicit parameter.) \nDoes anyone have a suggestion?","AnswerCount":6,"Available Count":6,"Score":0.0,"is_accepted":false,"ViewCount":328,"Q_Id":1383590,"Users Score":0,"Answer":"I suggest making them accessible from a property of the Path class called something like \"Utilties\". For example: Path.Utilities.RazzleDazzle. This will help with auto-completion tools and general maintenance.","Q_Score":2,"Tags":"python,code-organization","A_Id":8028755,"CreationDate":"2009-09-05T15:25:00.000","Title":"Code organization in Python: Where is a good place to put obscure methods?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've been considering a templating solution, although my choices are between Mako and Genshi. I find templating in Genshi a bit ugly, so I'm shifting more towards Mako.\nI've gone to wonder: what is so good about the fact that Mako allows embedded Python code? How is it convenient for the average joe?\nWouldn't templating JUST suffice without having embedded Python code?","AnswerCount":5,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":6454,"Q_Id":1384634,"Users Score":0,"Answer":"You could discipline yourself to not inject any Python code within the template unless it's really the last resort to get the job done. I have faced a similar issue with Django's template where I have to do some serious CSS gymnastics to display my content. If I could have used some Python code in the template, it would have been better.","Q_Score":7,"Tags":"python,template-engine,mako,genshi","A_Id":1384847,"CreationDate":"2009-09-06T01:11:00.000","Title":"Should I use Mako for Templating?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I've been considering a templating solution, although my choices are between Mako and Genshi. I find templating in Genshi a bit ugly, so I'm shifting more towards Mako.\nI've gone to wonder: what is so good about the fact that Mako allows embedded Python code? How is it convenient for the average joe?\nWouldn't templating JUST suffice without having embedded Python code?","AnswerCount":5,"Available Count":3,"Score":0.0798297691,"is_accepted":false,"ViewCount":6454,"Q_Id":1384634,"Users Score":2,"Answer":"This seems to be a bit of a religious issue. Django templates take a hard line: no code in templates. They do this because of their history as a system used in shops where there's a clear separation between those who write code and those who create pages. Others (perhaps you) don't make such a clear distinction, and would feel more comfortable having a more flexible line between layout and logic.\nIt really comes down to a matter of taste.","Q_Score":7,"Tags":"python,template-engine,mako,genshi","A_Id":1384671,"CreationDate":"2009-09-06T01:11:00.000","Title":"Should I use Mako for Templating?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I've been considering a templating solution, although my choices are between Mako and Genshi. I find templating in Genshi a bit ugly, so I'm shifting more towards Mako.\nI've gone to wonder: what is so good about the fact that Mako allows embedded Python code? How is it convenient for the average joe?\nWouldn't templating JUST suffice without having embedded Python code?","AnswerCount":5,"Available Count":3,"Score":1.0,"is_accepted":false,"ViewCount":6454,"Q_Id":1384634,"Users Score":16,"Answer":"Wouldn't templating JUST suffice without having embedded Python code?\n\nOnly if your templating language has enough logical functionality that it is essentially a scripting language in itself. At which point, you might just as well have used Python.\nMore involved sites often need complex presentation logic and non-trivial templated structures like sections repeated in different places\/pages and recursive trees. This is no fun if your templating language ties your hands behind your back because it takes the religious position that \"code in template are BAD\".\nThen you just end up writing presentation helper functions in your Python business logic, which is a worse blending of presentation and application logic than you had to start with. Languages that take power away from you because they don't trust you to use it tastefully are lame.","Q_Score":7,"Tags":"python,template-engine,mako,genshi","A_Id":1391510,"CreationDate":"2009-09-06T01:11:00.000","Title":"Should I use Mako for Templating?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I have been trying to learn a cross platform language with a fast learning curve, and so it seemed obvious Python was the logical choice. I've never programmed before but I have been reading on pragmatic programming and agile development for quite some time. The question comes, \"What is the single best choice to create a desktop software that is built heavily in python and can handle flexibilty of SQL injections, along with rich interface reporting?\" e.g. SQL Alchemy, ReportLabs. \nI have been looking into pyHed found in sourceforge.net. However, it's on early development stage and is still not well documented. I checked out Titanium Desktop from Appcelerator and the concept seems exciting, but it's not in stable condition yet. \nAny suggestions, comments or ideas of what is currently being used? or new technologies out there now?","AnswerCount":6,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":2206,"Q_Id":1390868,"Users Score":2,"Answer":"There are many answers to your question because you raise a number of issues:\nAgile development is methodology and has very little to do with the language or software platform. It is more a set of principles around which software teams organize themselves. Refer to the works of Kent Beck for a bit more detail.\nDo you have an existing Python code base? If you do have an existing Python code base you could get relatively far with pyHed. Otherwise you could look at something like Java Swing or C#. \nBut really you might want to consider moving the application to a web platform - that seems to be the direction almost all desktop apps are heading. Django is well known Python framework. Or any number of the Java, C#, Ruby platforms if it strikes your fancy.\nThe jquery JavaScript framework is a good tool to provide rich Web interfaces.","Q_Score":2,"Tags":"python,database,open-source,frameworks","A_Id":1390896,"CreationDate":"2009-09-07T20:33:00.000","Title":"Agile Software Development 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},{"Question":"I am trying to understand crc32 to generate the unique url for web page.\nIf we use the crc32, what is the maximum number of urls can be used so that we can avoid duplicates?\nWhat could be the approximative string length to keep the checksum to be 2^32?\nWhen I tried UUID for an url and convert the uuid bytes to base 64, I could reduce to 22 chars long. I wonder I can reduce still further.\nMostly I want to convert the url (maximum 1024 chars) to shorted id.","AnswerCount":6,"Available Count":5,"Score":1.2,"is_accepted":true,"ViewCount":3162,"Q_Id":1401218,"Users Score":7,"Answer":"There is no such number as the \"maximum number of urls can be used so that we can avoid duplicates\" for CRC32.\nThe problem is that CRC32 can produce duplicates, and it's not a function of how many values you throw at it, it's a function of what those values look like.\nSo you might have a collision on the second url, if you're unlucky.\nYou should not base your algorithm on producing a unique hash, instead produce a unique value for each url manually.","Q_Score":5,"Tags":"c#,python,url,crc32,short-url","A_Id":1401231,"CreationDate":"2009-09-09T18:16:00.000","Title":"CRC32 to make short URL for web","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},{"Question":"I am trying to understand crc32 to generate the unique url for web page.\nIf we use the crc32, what is the maximum number of urls can be used so that we can avoid duplicates?\nWhat could be the approximative string length to keep the checksum to be 2^32?\nWhen I tried UUID for an url and convert the uuid bytes to base 64, I could reduce to 22 chars long. I wonder I can reduce still further.\nMostly I want to convert the url (maximum 1024 chars) to shorted id.","AnswerCount":6,"Available Count":5,"Score":0.1325487884,"is_accepted":false,"ViewCount":3162,"Q_Id":1401218,"Users Score":4,"Answer":"If you're already storing the full URL in a database table, an integer ID is pretty short, and can be made shorter by converting it to base 16, 64, or 85. If you can use a UUID, you can use an integer, and you may as well, since it's shorter and I don't see what benefit a UUID would provide in your lookup table.","Q_Score":5,"Tags":"c#,python,url,crc32,short-url","A_Id":1401237,"CreationDate":"2009-09-09T18:16:00.000","Title":"CRC32 to make short URL for web","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},{"Question":"I am trying to understand crc32 to generate the unique url for web page.\nIf we use the crc32, what is the maximum number of urls can be used so that we can avoid duplicates?\nWhat could be the approximative string length to keep the checksum to be 2^32?\nWhen I tried UUID for an url and convert the uuid bytes to base 64, I could reduce to 22 chars long. I wonder I can reduce still further.\nMostly I want to convert the url (maximum 1024 chars) to shorted id.","AnswerCount":6,"Available Count":5,"Score":0.0333209931,"is_accepted":false,"ViewCount":3162,"Q_Id":1401218,"Users Score":1,"Answer":"CRC32 means cyclic redundancy check with 32 bits where any arbitrary amount of bits is summed up to a 32 bit check sum. And check sum functions are surjective, that means multiple input values have the same output value. So you cannot inverse the function.","Q_Score":5,"Tags":"c#,python,url,crc32,short-url","A_Id":1401243,"CreationDate":"2009-09-09T18:16:00.000","Title":"CRC32 to make short URL for web","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},{"Question":"I am trying to understand crc32 to generate the unique url for web page.\nIf we use the crc32, what is the maximum number of urls can be used so that we can avoid duplicates?\nWhat could be the approximative string length to keep the checksum to be 2^32?\nWhen I tried UUID for an url and convert the uuid bytes to base 64, I could reduce to 22 chars long. I wonder I can reduce still further.\nMostly I want to convert the url (maximum 1024 chars) to shorted id.","AnswerCount":6,"Available Count":5,"Score":0.0,"is_accepted":false,"ViewCount":3162,"Q_Id":1401218,"Users Score":0,"Answer":"No, even you use md5, or any other check sum, the URL CAN BE duplicate, it all depends on your luck.\nSo don't make an unique url base on those check sum","Q_Score":5,"Tags":"c#,python,url,crc32,short-url","A_Id":1401286,"CreationDate":"2009-09-09T18:16:00.000","Title":"CRC32 to make short URL for web","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},{"Question":"I am trying to understand crc32 to generate the unique url for web page.\nIf we use the crc32, what is the maximum number of urls can be used so that we can avoid duplicates?\nWhat could be the approximative string length to keep the checksum to be 2^32?\nWhen I tried UUID for an url and convert the uuid bytes to base 64, I could reduce to 22 chars long. I wonder I can reduce still further.\nMostly I want to convert the url (maximum 1024 chars) to shorted id.","AnswerCount":6,"Available Count":5,"Score":0.0665680765,"is_accepted":false,"ViewCount":3162,"Q_Id":1401218,"Users Score":2,"Answer":"The right way to make a short URL is to store the full one in the database and publish something that maps to the row index. A compact way is to use the Base64 of the row ID, for example. Or you could use a UID for the primary key and show that.\nDo not use a checksum, because it's too small and very likely to conflict. A cryptographic hash is larger and less likely, but it's still not the right way to go.","Q_Score":5,"Tags":"c#,python,url,crc32,short-url","A_Id":1401331,"CreationDate":"2009-09-09T18:16:00.000","Title":"CRC32 to make short URL for web","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},{"Question":"Okay. So I have about 250,000 high resolution images. What I want to do is go through all of them and find ones that are corrupted. If you know what 4scrape is, then you know the nature of the images I.\nCorrupted, to me, is the image is loaded into Firefox and it says\n\nThe image \u201csuch and such image\u201d cannot be displayed, because it contains errors.\n\nNow, I could select all of my 250,000 images (~150gb) and drag-n-drop them into Firefox. That would be bad though, because I don't think Mozilla designed Firefox to open 250,000 tabs. No, I need a way to programmatically check whether an image is corrupted.\nDoes anyone know a PHP or Python library which can do something along these lines? Or an existing piece of software for Windows?\nI have already removed obviously corrupted images (such as ones that are 0 bytes) but I'm about 99.9% sure that there are more diseased images floating around in my throng of a collection.","AnswerCount":5,"Available Count":1,"Score":0.1194272985,"is_accepted":false,"ViewCount":23397,"Q_Id":1401527,"Users Score":3,"Answer":"If your exact requirements are that it show correctly in FireFox you may have a difficult time - the only way to be sure would be to link to the exact same image loading source code as FireFox.\nBasic image corruption (file is incomplete) can be detected simply by trying to open the file using any number of image libraries.\nHowever many images can fail to display simply because they stretch a part of the file format that the particular viewer you are using can't handle (GIF in particular has a lot of these edge cases, but you can find JPEG and the rare PNG file that can only be displayed in specific viewers). There are also some ugly JPEG edge cases where the file appears to be uncorrupted in viewer X, but in reality the file has been cut short and is only displaying correctly because very little information has been lost (FireFox can show some cut off JPEGs correctly [you get a grey bottom], but others result in FireFox seeming the load them half way and then display the error message instead of the partial image)","Q_Score":20,"Tags":"php,python,image","A_Id":1401566,"CreationDate":"2009-09-09T19:15:00.000","Title":"How do I programmatically check whether an image (PNG, JPEG, or GIF) is corrupted?","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},{"Question":"I don't see that the compilation step is adding any value.","AnswerCount":3,"Available Count":2,"Score":0.3215127375,"is_accepted":false,"ViewCount":626,"Q_Id":1407364,"Users Score":5,"Answer":"Reading just quickly about .mo files, it is clear that:\n\nIt is a machine-readable representation\nIt is a hash table\n\nGiven gettext's function, to lookup strings by keys at runtime, it is reasonable for this lookup to be implemented efficiently.\nAlso, it is needed for gettext's performance impact to be negligible; else interest to play nice with the international community would be even lower for english-speaking hackers (from all countries, we all speak english, programming languages are in english).\nMaking the .mo file an already processed representation is good since\n\nThe format is well suited for quick lookup (hash table)\nThe format needs little processing at application launch (custom-representation binary)","Q_Score":0,"Tags":"python,gettext","A_Id":1408109,"CreationDate":"2009-09-10T19:52:00.000","Title":"Why does the Python gettext module require a compilation step (.po -> .mo)?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I don't see that the compilation step is adding any value.","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":626,"Q_Id":1407364,"Users Score":1,"Answer":"Because gettext module in Python follows GNU gettext standards which required to use PO files for do translations by people, and MO files for using by application in runtime. When you're using gettext module you're actually using GNUTranslations class, which name suggests it's implementation of GNU gettext.\nBut you can provide your own Translations class and load translations from PO files, there is nothing special about it. There is even some implementation of PO files reader in standard Python distribution, see script msgfmt.py in Tools directory.","Q_Score":0,"Tags":"python,gettext","A_Id":2021653,"CreationDate":"2009-09-10T19:52:00.000","Title":"Why does the Python gettext module require a compilation step (.po -> .mo)?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"os.stat returns st_mtime and st_ctime attributes, the modification time is st_mtime and st_ctime \"change time\" on POSIX.\nis there any function that return the creation time of a file using python and under Linux?","AnswerCount":7,"Available Count":1,"Score":-0.0285636566,"is_accepted":false,"ViewCount":11846,"Q_Id":1408272,"Users Score":-1,"Answer":"What do you mean it can't be done [1]? The function, os.stat(path).st_birthtime, works great.\n\n[1]:\nSomebody said that it couldn\u2019t be done\n But he with a chuckle replied\nThat \u201cmaybe it couldn\u2019t,\u201d but he would be one\n Who wouldn\u2019t say so till he\u2019d tried.\nSo he buckled right in with the trace of a grin\n On his face. If he worried he hid it.\nHe started to sing as he tackled the thing\n That couldn\u2019t be done, and he did it!\n-- Edgar Albert Guest","Q_Score":21,"Tags":"python,linux","A_Id":48969869,"CreationDate":"2009-09-10T23:35:00.000","Title":"Get file creation time 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},{"Question":"I know that this is a difficult question to answer, but I thought I would try anwyays....\nI am just starting at a new company where they have a minimal existing code base. It probably has a month of man effort invested at this point. It is currently written in Ruby. \nIt is also currently using Ruby on Rails -- but mostly just for the sake of testing out the Ruby code. \nThe ultimate goal of the code is actually to drive a backend to a site that will be written in php (could be a backend to Drupal, Echo, etc...). \nI have no experience with Ruby, so I would tend to want to go with a language I know better (like Python), but am not willing to rule Ruby out for no reason.\nIf you are not going to use Ruby for a Rails project, is it still worth it? Will I be better off going with Python or some other language?\nHow do the libraries stack up?\nThanks!!!","AnswerCount":6,"Available Count":5,"Score":0.0,"is_accepted":false,"ViewCount":567,"Q_Id":1416570,"Users Score":0,"Answer":"Using Ruby f\u00fcr two years now , i find it powerful, easy to learn, having good libraries, good community.\nBut how should we know if it fits your needs? Try it an you will find out.","Q_Score":1,"Tags":"python,ruby","A_Id":25123266,"CreationDate":"2009-09-13T00:59:00.000","Title":"To Ruby or not to 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":1},{"Question":"I know that this is a difficult question to answer, but I thought I would try anwyays....\nI am just starting at a new company where they have a minimal existing code base. It probably has a month of man effort invested at this point. It is currently written in Ruby. \nIt is also currently using Ruby on Rails -- but mostly just for the sake of testing out the Ruby code. \nThe ultimate goal of the code is actually to drive a backend to a site that will be written in php (could be a backend to Drupal, Echo, etc...). \nI have no experience with Ruby, so I would tend to want to go with a language I know better (like Python), but am not willing to rule Ruby out for no reason.\nIf you are not going to use Ruby for a Rails project, is it still worth it? Will I be better off going with Python or some other language?\nHow do the libraries stack up?\nThanks!!!","AnswerCount":6,"Available Count":5,"Score":0.1325487884,"is_accepted":false,"ViewCount":567,"Q_Id":1416570,"Users Score":4,"Answer":"Ruby Madness. Sure, it seems cool, but it might lead to the hard stuff: Lisp\n\nMy predictions:\n\nIt's pretty clear that you are OK with either Ruby or Python, and obviously php can be made to work. \nYou will really like Ruby.\n\nI'm a little bit worried that after Ruby the only place left to go will be Lisp, and that I will become one of those raving lisp maniacs with bad haircuts waving my arms and muttering about The One True Macro Processor.\nSlightly more seriously, though Lisp and Smalltalk are still in tiny niche spaces after 60 and 40 years, it turns out that the child of the two bore fruit. Various Lisp and Smalltalk hackers are starting to show up speaking about their child Ruby at Ruby and Rails cons. As it happens, Ruby (timeframe 15 years) has quite a bit of the Lisp and Smalltalk magic.\nAnd, to this party, Ruby brings about every single bit of the day-to-day and 3-line-script usefulness of Perl. Ruby is an explosion on the language scene that combines the scripting superpower of Perl with the object-orient superpower of an exotic language like Smalltalk.\nRuby is an awesome and groundbreaking language with or without Rails. I say, drink the kool-aid.","Q_Score":1,"Tags":"python,ruby","A_Id":1416827,"CreationDate":"2009-09-13T00:59:00.000","Title":"To Ruby or not to 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":1},{"Question":"I know that this is a difficult question to answer, but I thought I would try anwyays....\nI am just starting at a new company where they have a minimal existing code base. It probably has a month of man effort invested at this point. It is currently written in Ruby. \nIt is also currently using Ruby on Rails -- but mostly just for the sake of testing out the Ruby code. \nThe ultimate goal of the code is actually to drive a backend to a site that will be written in php (could be a backend to Drupal, Echo, etc...). \nI have no experience with Ruby, so I would tend to want to go with a language I know better (like Python), but am not willing to rule Ruby out for no reason.\nIf you are not going to use Ruby for a Rails project, is it still worth it? Will I be better off going with Python or some other language?\nHow do the libraries stack up?\nThanks!!!","AnswerCount":6,"Available Count":5,"Score":0.0333209931,"is_accepted":false,"ViewCount":567,"Q_Id":1416570,"Users Score":1,"Answer":"Rails apps can potentially make a great REST backend for a php based system.\nThe REST stuff is made for it. You want xml? ok. You want json? ok. \nIf you and the staff aren't comfy with it, use something you are more comfy in to write a REST interface. :)","Q_Score":1,"Tags":"python,ruby","A_Id":1416574,"CreationDate":"2009-09-13T00:59:00.000","Title":"To Ruby or not to 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":1},{"Question":"I know that this is a difficult question to answer, but I thought I would try anwyays....\nI am just starting at a new company where they have a minimal existing code base. It probably has a month of man effort invested at this point. It is currently written in Ruby. \nIt is also currently using Ruby on Rails -- but mostly just for the sake of testing out the Ruby code. \nThe ultimate goal of the code is actually to drive a backend to a site that will be written in php (could be a backend to Drupal, Echo, etc...). \nI have no experience with Ruby, so I would tend to want to go with a language I know better (like Python), but am not willing to rule Ruby out for no reason.\nIf you are not going to use Ruby for a Rails project, is it still worth it? Will I be better off going with Python or some other language?\nHow do the libraries stack up?\nThanks!!!","AnswerCount":6,"Available Count":5,"Score":0.0,"is_accepted":false,"ViewCount":567,"Q_Id":1416570,"Users Score":0,"Answer":"Why wouldn't you just keep it consistent and use PHP?","Q_Score":1,"Tags":"python,ruby","A_Id":1416583,"CreationDate":"2009-09-13T00:59:00.000","Title":"To Ruby or not to 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":1},{"Question":"I know that this is a difficult question to answer, but I thought I would try anwyays....\nI am just starting at a new company where they have a minimal existing code base. It probably has a month of man effort invested at this point. It is currently written in Ruby. \nIt is also currently using Ruby on Rails -- but mostly just for the sake of testing out the Ruby code. \nThe ultimate goal of the code is actually to drive a backend to a site that will be written in php (could be a backend to Drupal, Echo, etc...). \nI have no experience with Ruby, so I would tend to want to go with a language I know better (like Python), but am not willing to rule Ruby out for no reason.\nIf you are not going to use Ruby for a Rails project, is it still worth it? Will I be better off going with Python or some other language?\nHow do the libraries stack up?\nThanks!!!","AnswerCount":6,"Available Count":5,"Score":0.0,"is_accepted":false,"ViewCount":567,"Q_Id":1416570,"Users Score":0,"Answer":"IMO, if you're comfortable with Python then you shouldn't have too much trouble picking up Ruby. This doesn't mean Ruby is the best choice - you should still evaluate the options.","Q_Score":1,"Tags":"python,ruby","A_Id":1416625,"CreationDate":"2009-09-13T00:59:00.000","Title":"To Ruby or not to 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":1},{"Question":"How can I find out the http request my python cgi received? I need different behaviors for HEAD and GET.\nThanks!","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":6773,"Q_Id":1417715,"Users Score":0,"Answer":"Why do you need to distinguish between GET and HEAD?\nNormally you shouldn't distinguish and should treat a HEAD request just like a GET. This is because a HEAD request is meant to return the exact same headers as a GET. The only difference is there will be no response content. Just because there is no response content though doesn't mean you no longer have to return a valid Content-Length header, or other headers, which are dependent on the response content.\nIn mod_wsgi, which various people are pointing you at, it will actually deliberately change the request method from HEAD to GET in certain cases to guard against people who wrongly treat HEAD differently. The specific case where this is done is where an Apache output filter is registered. The reason that it is done in this case is because the output filter may expect to see the response content and from that generate additional response headers. If you were to decide not to bother to generate any response content for a HEAD request, you will deprive the output filter of the content and the headers they add may then not agree with what would be returned from a GET request. The end result of this is that you can stuff up caches and the operation of the browser.\nThe same can apply equally for CGI scripts behind Apache as output filters can still be added in that case as well. For CGI scripts there is nothing in place though to protect against users being stupid and doing things differently for a HEAD request.","Q_Score":12,"Tags":"python,http,httpwebrequest,cgi","A_Id":1420886,"CreationDate":"2009-09-13T13:12:00.000","Title":"Detecting the http request type (GET, HEAD, etc) from a python cgi","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},{"Question":"I'm removing an item from an array if it exists.\nTwo ways I can think of to do this\nWay #1\n\n# x array, r item to remove\nif r in x :\n x.remove( r )\n\nWay #2\n\ntry :\n x.remove( r )\nexcept :\n pass\n\nTiming it shows the try\/except way can be faster\n(some times i'm getting:)\n\n1.16225508968e-06\n8.80804972547e-07\n\n1.14314196588e-06\n8.73752536492e-07\n\n\nimport timeit\n\nruns = 10000\nx = [ '101', '102', '103', '104', '105', 'a', 'b', 'c',\n 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', '111', '112', '113',\n 'x', 'y', 'z', 'w', 'wwwwwww', 'aeiojwaef', 'iweojfoigj', 'oiowow',\n 'oiweoiwioeiowe', 'oiwjaoigjoaigjaowig',\n]\nr = 'a'\n\ncode1 =\"\"\"\nx = [ '101', '102', '103', '104', '105', 'a', 'b', 'c',\n 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', '111', '112', '113',\n 'x', 'y', 'z', 'w', 'wwwwwww', 'aeiojwaef', 'iweojfoigj', 'oiowow',\n 'oiweoiwioeiowe', 'oiwjaoigjoaigjaowig',\n]\nr = 'a'\n\nif r in x :\n x.remove(r)\n\"\"\"\nprint timeit.Timer( code1 ).timeit( runs ) \/ runs\n\ncode2 =\"\"\"\nx = [ '101', '102', '103', '104', '105', 'a', 'b', 'c',\n 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', '111', '112', '113',\n 'x', 'y', 'z', 'w', 'wwwwwww', 'aeiojwaef', 'iweojfoigj', 'oiowow',\n 'oiweoiwioeiowe', 'oiwjaoigjoaigjaowig',\n]\nr = 'a'\n\ntry :\n x.remove( r )\nexcept :\n pass\n\"\"\"\nprint timeit.Timer( code2 ).timeit( runs ) \/ runs\n\n\nWhich is more pythonic?","AnswerCount":5,"Available Count":3,"Score":0.1194272985,"is_accepted":false,"ViewCount":267,"Q_Id":1418266,"Users Score":3,"Answer":"Speed depends on the ratio of hits to misses. To be pythonic choose the clearer method.\nPersonally I think way#1 is clearer (It takes less lines to have an 'if' block rather than an exception block and also uses less brain space). It will also be faster when there are more hits than misses (an exception is more expensive than skipping a if block).","Q_Score":2,"Tags":"python","A_Id":1418321,"CreationDate":"2009-09-13T17:15:00.000","Title":"Which is more pythonic for array removal?","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},{"Question":"I'm removing an item from an array if it exists.\nTwo ways I can think of to do this\nWay #1\n\n# x array, r item to remove\nif r in x :\n x.remove( r )\n\nWay #2\n\ntry :\n x.remove( r )\nexcept :\n pass\n\nTiming it shows the try\/except way can be faster\n(some times i'm getting:)\n\n1.16225508968e-06\n8.80804972547e-07\n\n1.14314196588e-06\n8.73752536492e-07\n\n\nimport timeit\n\nruns = 10000\nx = [ '101', '102', '103', '104', '105', 'a', 'b', 'c',\n 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', '111', '112', '113',\n 'x', 'y', 'z', 'w', 'wwwwwww', 'aeiojwaef', 'iweojfoigj', 'oiowow',\n 'oiweoiwioeiowe', 'oiwjaoigjoaigjaowig',\n]\nr = 'a'\n\ncode1 =\"\"\"\nx = [ '101', '102', '103', '104', '105', 'a', 'b', 'c',\n 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', '111', '112', '113',\n 'x', 'y', 'z', 'w', 'wwwwwww', 'aeiojwaef', 'iweojfoigj', 'oiowow',\n 'oiweoiwioeiowe', 'oiwjaoigjoaigjaowig',\n]\nr = 'a'\n\nif r in x :\n x.remove(r)\n\"\"\"\nprint timeit.Timer( code1 ).timeit( runs ) \/ runs\n\ncode2 =\"\"\"\nx = [ '101', '102', '103', '104', '105', 'a', 'b', 'c',\n 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', '111', '112', '113',\n 'x', 'y', 'z', 'w', 'wwwwwww', 'aeiojwaef', 'iweojfoigj', 'oiowow',\n 'oiweoiwioeiowe', 'oiwjaoigjoaigjaowig',\n]\nr = 'a'\n\ntry :\n x.remove( r )\nexcept :\n pass\n\"\"\"\nprint timeit.Timer( code2 ).timeit( runs ) \/ runs\n\n\nWhich is more pythonic?","AnswerCount":5,"Available Count":3,"Score":0.0798297691,"is_accepted":false,"ViewCount":267,"Q_Id":1418266,"Users Score":2,"Answer":"The try\/except way","Q_Score":2,"Tags":"python","A_Id":1418275,"CreationDate":"2009-09-13T17:15:00.000","Title":"Which is more pythonic for array removal?","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},{"Question":"I'm removing an item from an array if it exists.\nTwo ways I can think of to do this\nWay #1\n\n# x array, r item to remove\nif r in x :\n x.remove( r )\n\nWay #2\n\ntry :\n x.remove( r )\nexcept :\n pass\n\nTiming it shows the try\/except way can be faster\n(some times i'm getting:)\n\n1.16225508968e-06\n8.80804972547e-07\n\n1.14314196588e-06\n8.73752536492e-07\n\n\nimport timeit\n\nruns = 10000\nx = [ '101', '102', '103', '104', '105', 'a', 'b', 'c',\n 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', '111', '112', '113',\n 'x', 'y', 'z', 'w', 'wwwwwww', 'aeiojwaef', 'iweojfoigj', 'oiowow',\n 'oiweoiwioeiowe', 'oiwjaoigjoaigjaowig',\n]\nr = 'a'\n\ncode1 =\"\"\"\nx = [ '101', '102', '103', '104', '105', 'a', 'b', 'c',\n 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', '111', '112', '113',\n 'x', 'y', 'z', 'w', 'wwwwwww', 'aeiojwaef', 'iweojfoigj', 'oiowow',\n 'oiweoiwioeiowe', 'oiwjaoigjoaigjaowig',\n]\nr = 'a'\n\nif r in x :\n x.remove(r)\n\"\"\"\nprint timeit.Timer( code1 ).timeit( runs ) \/ runs\n\ncode2 =\"\"\"\nx = [ '101', '102', '103', '104', '105', 'a', 'b', 'c',\n 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', '111', '112', '113',\n 'x', 'y', 'z', 'w', 'wwwwwww', 'aeiojwaef', 'iweojfoigj', 'oiowow',\n 'oiweoiwioeiowe', 'oiwjaoigjoaigjaowig',\n]\nr = 'a'\n\ntry :\n x.remove( r )\nexcept :\n pass\n\"\"\"\nprint timeit.Timer( code2 ).timeit( runs ) \/ runs\n\n\nWhich is more pythonic?","AnswerCount":5,"Available Count":3,"Score":1.2,"is_accepted":true,"ViewCount":267,"Q_Id":1418266,"Users Score":6,"Answer":"I've always gone with the first method. if in reads far more clearly than exception handling does.","Q_Score":2,"Tags":"python","A_Id":1418310,"CreationDate":"2009-09-13T17:15:00.000","Title":"Which is more pythonic for array removal?","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},{"Question":"Sorry if this is on the wrong site ( maybe superuser ) but I'm trying to make my python.py file executable so I can click on it and it automatically does its thing, without me specifying it to open in the terminal by that default prompt, and I already have 'chmod +x' for its permissions.\nClarification:\n\nI want to run it by clicking on it, not through the terminal ( I meant that when I said 'can click on it and it automatically does its thing ' )\nAlready have a shebang line\nWhen I click it right now, it prompts me with do you want to open it in a text file, terminal - can I make it always default to opening in the terminal or is this just an oddball request?","AnswerCount":6,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":9279,"Q_Id":1418553,"Users Score":3,"Answer":"First, pick a file extension you want for files you want to have this behavior. pyw is probably a good choice. \nName your file that, and in your file browser associate that file type with python. In GNOME, you'd open its Properties window, go to the Open With tab, and enter python as a custom command. \nNow here's the important part: That little dialog you've been getting asking you what you'd like to do with the file is because it is marked as executable. Remove the executable bit with chmod -x. Now when you double click it, it will simply be opened with the associated program.\nOf course, if you want to run it from the command line, you'll now have to start it with python explicitly since it isn't marked executable. The shebang line doesn't matter anymore, but I'd leave it in anyway in case someone else marks it executable and expects it to work.","Q_Score":3,"Tags":"python,linux","A_Id":1419455,"CreationDate":"2009-09-13T18:53:00.000","Title":"Auto executable python file without opening from 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},{"Question":"I received a Python project (which happens to be a Django project, if that matters,) that uses the fcntl module from the standard library, which seems to be available only on Linux. When I try to run it on my Windows machine, it stops with an ImportError, because this module does not exist here.\nIs there any way for me to make a small change in the program to make it work on Windows?","AnswerCount":3,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":122994,"Q_Id":1422368,"Users Score":95,"Answer":"The substitute of fcntl on windows are win32api calls. The usage is completely different. It is not some switch you can just flip.\nIn other words, porting a fcntl-heavy-user module to windows is not trivial. It requires you to analyze what exactly each fcntl call does and then find the equivalent win32api code, if any. \nThere's also the possibility that some code using fcntl has no windows equivalent, which would require you to change the module api and maybe the structure\/paradigm of the program using the module you're porting.\nIf you provide more details about the fcntl calls people can find windows equivalents.","Q_Score":86,"Tags":"python,windows,linux","A_Id":1422436,"CreationDate":"2009-09-14T15:43:00.000","Title":"fcntl substitute on 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},{"Question":"I have a GSM modem connected to my computer, i want to receive text messages sent to it using a python program i have written, am just wondering what is the best technique to poll for data. \nShould i write a program that has a infinite loop that continuously checks for incoming sms's i.e within the loop the program sends the AT commands and reads the input data. or do modems have a way of signaling an application of an incoming data(sms). \nAm trying to imagine a cellphone is just a GSM modem, and when an sms is received, the phone alerts you of the event, or does the phone software have an infinite loop that polls for incoming data.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":3845,"Q_Id":1423308,"Users Score":0,"Answer":"I find I can't remember much of the AT command set related to SMS. Andre Miller's answer seems to ring a few bells. Anyway you should read the documentation very carefully, I'm sure there were a few gotchas.\nMy recommentation for polling is at least every 5 seconds - this is just for robustness and responsiveness in the face of disconnection.\nI used a state machine to navigate between initialisation, reading and deleting messages.","Q_Score":8,"Tags":"python,modem,gsm,at-command","A_Id":1424253,"CreationDate":"2009-09-14T18:59:00.000","Title":"What is the best design for polling a modem for incoming data?","Data Science and Machine Learning":0,"Database and SQL":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},{"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},{"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},{"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},{"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},{"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},{"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},{"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},{"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},{"Question":"I have a python program which starts up a PHP script using the subprocess.Popen() function. The PHP script needs to communicate back-and-forth with Python, and I am trying to find an easy but robust way to manage the message sending\/receiving.\nI have already written a working protocol using basic sockets, but it doesn't feel very robust - I don't have any logic to handle dropped messages, and I don't even fully understand how sockets work which leaves me uncertain about what else could go wrong.\nAre there any generic libraries or IPC frameworks which are easier than raw sockets?\n\nATM I need something which supports Python and PHP, but in the future I may want to be able to use C, Perl and Ruby also.\nI am looking for something robust, i.e. when the server or client crashes, the other party needs to be able to recover gracefully.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2322,"Q_Id":1424593,"Users Score":0,"Answer":"You could look at shared memory or named pipes, but I think there are two more likely options, assuming at least one of these languages is being used for a webapp:\nA. Use your database's atomicity. In python, begin a transaction, put a message into a table, and end the transaction. From php, begin a transaction, take a message out of the table or mark it \"read\", and end the transaction. Make your PHP and\/or python self-aware enough not to post the same messages twice. Voila; reliable (and scaleable) IPC, using existing web architecture.\nB. Make your webserver (assuming as webapp) capable of running both php and python, locking down any internal processes to just localhost access, and then call them using xmlrpc or soap from your other language using standard libraries. This is also scalable, as you can change your URLs and security lock-downs later.","Q_Score":1,"Tags":"php,python,ipc","A_Id":1424687,"CreationDate":"2009-09-15T00:47:00.000","Title":"Easy, Robust IPC between Python and PHP","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},{"Question":"I want to send some modem AT commands using python code, and am wondering what is the keycode for the key combination control+z\nGath","AnswerCount":3,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":13499,"Q_Id":1431495,"Users Score":11,"Answer":"Key code? If you send AT commands you are probably sending strings with ascii text and control codes, right? Ctrl-Z is usually 26 (decimal). So chr(26) should work, or if it's a part of a string, '\\x1a' as 26 decimal is 1A hex.\nThat said, Ctrl-Z is not usually a part of the AT command set... so if this doesn't help you, maybe you could explain more what you are trying to do and why you would need to send Ctrl-Z.","Q_Score":6,"Tags":"python","A_Id":1431524,"CreationDate":"2009-09-16T07:30:00.000","Title":"What is the keycode for control+z key 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},{"Question":"I have a cherrypy web server that uses larges amounts of HTML data. Is there anyway in Python to minimize the HTML so that all comments, spaces, ext, are removed?","AnswerCount":3,"Available Count":1,"Score":0.1325487884,"is_accepted":false,"ViewCount":1549,"Q_Id":1437357,"Users Score":2,"Answer":"there are bindings to tidy for python, called mxTidy from eGenix (Marc Andr\u00e9 Lemburg)","Q_Score":1,"Tags":"python,html,minimize","A_Id":1531684,"CreationDate":"2009-09-17T07:59:00.000","Title":"Python HTML Minimizer","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I am embedding a c++ library (binding done with SIP) in my python application. Under certain circonstances (error cases), this library uses exit(), which causes my entire application to exit. \nIs there a way to catch this event, or do I need to modify the library to handle error cases differently ? \nThank you very much,","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":1407,"Q_Id":1439533,"Users Score":0,"Answer":"You can override the library linking with LD_LIBRARY_PATH and make your own exit function. Works fine.","Q_Score":7,"Tags":"python,exception,binding,exit","A_Id":8099938,"CreationDate":"2009-09-17T15:19:00.000","Title":"How to catch exit() in embedded C++ module from 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},{"Question":"I am embedding a c++ library (binding done with SIP) in my python application. Under certain circonstances (error cases), this library uses exit(), which causes my entire application to exit. \nIs there a way to catch this event, or do I need to modify the library to handle error cases differently ? \nThank you very much,","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":1407,"Q_Id":1439533,"Users Score":7,"Answer":"You must modify the source of the library. There is no \"exception handling\" in C and exit() does not return to the calling code under any circumstances.","Q_Score":7,"Tags":"python,exception,binding,exit","A_Id":1439585,"CreationDate":"2009-09-17T15:19:00.000","Title":"How to catch exit() in embedded C++ module from 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},{"Question":"I write a lot of scripts in Python to analyze and plot experimental data as well as write simple simulations to test how theories fit the data. The scripts tend to be very procedural; calculate some property, calculate some other property, plot properties, analyze plot...\nRather than just writing a procedure, would there be an benefits of using a Class? I can bury the actual analysis into functions so I can pass the data to the function and let it do it's thing but the functions are not contained in a Class. \nWhat sort of drawbacks would a Class over come and what would be the purpose of using a Class if it can be written procedurally?\nIf this has been posted before my apologies, just point me in that direction.","AnswerCount":5,"Available Count":3,"Score":0.0399786803,"is_accepted":false,"ViewCount":4545,"Q_Id":1440434,"Users Score":1,"Answer":"OOP lends itself well to complex programs. It's great for capturing the state and behavior of real world concepts and orchestrating the interplay between them. Good OO code is easy to read\/understand, protects your data's integrity, and maximizes code reuse. I'd say code reuse is one big advantage to keeping your frequently used calculations in a class.","Q_Score":7,"Tags":"python,oop,class-design,procedural-programming","A_Id":1440734,"CreationDate":"2009-09-17T18:07:00.000","Title":"Class usage 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},{"Question":"I write a lot of scripts in Python to analyze and plot experimental data as well as write simple simulations to test how theories fit the data. The scripts tend to be very procedural; calculate some property, calculate some other property, plot properties, analyze plot...\nRather than just writing a procedure, would there be an benefits of using a Class? I can bury the actual analysis into functions so I can pass the data to the function and let it do it's thing but the functions are not contained in a Class. \nWhat sort of drawbacks would a Class over come and what would be the purpose of using a Class if it can be written procedurally?\nIf this has been posted before my apologies, just point me in that direction.","AnswerCount":5,"Available Count":3,"Score":0.0399786803,"is_accepted":false,"ViewCount":4545,"Q_Id":1440434,"Users Score":1,"Answer":"Object-oriented programming isn't the solution to every coding problem.\nIn Python, functions are objects. You can mix as many objects and functions as you want.\nModules with functions are already objects with properties.\nIf you find yourself passing a lot of the same variables around \u2014 state \u2014 an object is probably better suited. If you have a lot of classes with class methods, or methods that don't use self very much, then functions are probably better.","Q_Score":7,"Tags":"python,oop,class-design,procedural-programming","A_Id":1447527,"CreationDate":"2009-09-17T18:07:00.000","Title":"Class usage 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},{"Question":"I write a lot of scripts in Python to analyze and plot experimental data as well as write simple simulations to test how theories fit the data. The scripts tend to be very procedural; calculate some property, calculate some other property, plot properties, analyze plot...\nRather than just writing a procedure, would there be an benefits of using a Class? I can bury the actual analysis into functions so I can pass the data to the function and let it do it's thing but the functions are not contained in a Class. \nWhat sort of drawbacks would a Class over come and what would be the purpose of using a Class if it can be written procedurally?\nIf this has been posted before my apologies, just point me in that direction.","AnswerCount":5,"Available Count":3,"Score":0.1586485043,"is_accepted":false,"ViewCount":4545,"Q_Id":1440434,"Users Score":4,"Answer":"You don't need to use classes in Python - it doesn't force you to do OOP. If you're more comfortable with the functional style, that's fine. I use classes when I want to model some abstraction which has variations, and I want to model those variations using classes. As the word \"class\" implies, they're useful mainly when the stuff you are working with falls naturally into various classes. When just manipulating large datasets, I've not found an overarching need to follow an OOP paradigm just for the sake of it.","Q_Score":7,"Tags":"python,oop,class-design,procedural-programming","A_Id":1440655,"CreationDate":"2009-09-17T18:07:00.000","Title":"Class usage 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},{"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},{"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},{"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},{"Question":"I want to simulate MyApp that imports a module (ResourceX) which requires a resource that is not available at the time and will not work. \nA solution for this is to make and import a mock module of ResourceX (named ResourceXSimulated) and divert it to MyApp as ResourceX. I want to do this in order to avoid breaking a lot of code and get all kinds of exception from MyApp.\nI am using Python and It should be something like:\n\"Import ResourceXSimulated as ResourceX\"\n\"ResourceX.getData()\", actually calls ResourceXSimultated.getData()\nLooking forward to find out if Python supports this kind of redirection.\nCheers.\nADDITIONAL INFO: I have access to the source files.\nUPDATE: I am thinking of adding as little code as possible to MyApp regarding using the fake module and add this code near the import statements.","AnswerCount":5,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":256,"Q_Id":1443173,"Users Score":0,"Answer":"Yes, Python can do that, and so long as the methods exposed in the ResourceXSimulated module \"look and smell\" like these of the original module, the application should not see much any difference (other than, I'm assuming, bogus data fillers, different response times and such).","Q_Score":1,"Tags":"python,testing,mocking,module,monkeypatching","A_Id":1443195,"CreationDate":"2009-09-18T08:12:00.000","Title":"Is it possible to divert a module in python? (ResourceX diverted to ResourceXSimulated)","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},{"Question":"I want to simulate MyApp that imports a module (ResourceX) which requires a resource that is not available at the time and will not work. \nA solution for this is to make and import a mock module of ResourceX (named ResourceXSimulated) and divert it to MyApp as ResourceX. I want to do this in order to avoid breaking a lot of code and get all kinds of exception from MyApp.\nI am using Python and It should be something like:\n\"Import ResourceXSimulated as ResourceX\"\n\"ResourceX.getData()\", actually calls ResourceXSimultated.getData()\nLooking forward to find out if Python supports this kind of redirection.\nCheers.\nADDITIONAL INFO: I have access to the source files.\nUPDATE: I am thinking of adding as little code as possible to MyApp regarding using the fake module and add this code near the import statements.","AnswerCount":5,"Available Count":2,"Score":0.0399786803,"is_accepted":false,"ViewCount":256,"Q_Id":1443173,"Users Score":1,"Answer":"Yes, it's possible. Some starters:\nYou can \"divert\" modules by manipulating sys.modules. It keeps a list of imported modules, and there you can make your module appear under the same name as the original one. You must do this manipulating before any module that imports the module you want to fake though.\nYou can also make a package called a different name, but in that package actually use the original module name, for your completely different module. This works well as long as the original module isn't installed.\nIn none of these cases you can use both modules at the same time. For that you need to monkey-patch the original module.\nAnd of course: It' perfectly possible to just call the new module with the old name. But it might be confusing.","Q_Score":1,"Tags":"python,testing,mocking,module,monkeypatching","A_Id":1443281,"CreationDate":"2009-09-18T08:12:00.000","Title":"Is it possible to divert a module in python? (ResourceX diverted to ResourceXSimulated)","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},{"Question":"I need identify which file is binary and which is a text in a directory. \nI tried use mimetypes but it isnt a good idea in my case because it cant identify all files mimes, and I have strangers ones here... I just need know, binary or text. Simple ? But I couldn\u00b4t find a solution... \nThanks","AnswerCount":4,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":20864,"Q_Id":1446549,"Users Score":8,"Answer":"It's inherently not simple. There's no way of knowing for sure, although you can take a reasonably good guess in most cases.\nThings you might like to do:\n\nLook for known magic numbers in binary signatures\nLook for the Unicode byte-order-mark at the start of the file\nIf the file is regularly 00 xx 00 xx 00 xx (for arbitrary xx) or vice versa, that's quite possibly UTF-16\nOtherwise, look for 0s in the file; a file with a 0 in is unlikely to be a single-byte-encoding text file.\n\nBut it's all heuristic - it's quite possible to have a file which is a valid text file and a valid image file, for example. It would probably be nonsense as a text file, but legitimate in some encoding or other...","Q_Score":17,"Tags":"python,text,binary,file-type","A_Id":1446580,"CreationDate":"2009-09-18T19:58:00.000","Title":"How to identify binary and text files 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},{"Question":"I'm building a mobile photo sharing site in Python similar to TwitPic and have been exploring various queues to handle the image processing. I've looked into RabbitMQ and ActiveMQ but I'm thinking that there is a better solution for my use case. I'm looking for something a little more lightweight. I'm open to any suggestions.","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":290,"Q_Id":1450038,"Users Score":0,"Answer":"Are you considering single machine architecture, or a cluster of machines? Forwarding the image to an available worker process on the same machine or a different machine isn't profoundly different, particularly if you use TCP sockets. Knowing what workers are available, spawning more if necessary and the resources are available, having a fail-safe mechanism if a worker crashes, etc, gradually make the problem more complicated.\nIt could be something as simple as using httplib to push the image to a private server running Apache or twisted and a collection of cgi applications. When you add another server, round robin the request amongst them.","Q_Score":2,"Tags":"python,queue","A_Id":1450105,"CreationDate":"2009-09-20T01:33:00.000","Title":"Which queue is most appropriate?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I wanted to know\nPython is suited for what kind of applications? \nI am new to Python world but I know it's a scripting language like Perl but I was not sure about the kind of applications which one would build using Python and would certainly appreciate if someone can provide some useful information.","AnswerCount":9,"Available Count":5,"Score":0.022218565,"is_accepted":false,"ViewCount":80717,"Q_Id":1452509,"Users Score":1,"Answer":"Well, the short answer is, since you mentioned Perl, anything you could build in Perl you could build in Python. You can build anything in any language, and if the language has easy C bindings, you could even do it efficiently. \nNow, this being the case, the question becomes somewhat philosophical. Python has as a key tenet \"There should only be one way to do it\". Perl is exactly the opposite. The key tenet of Perl is \"There Is More Than One Way To Do It\" (TIMTOWTDI) or ( Tim Toady, to his frineds ;) ) How do you like to do things? One clear and shining path, agreed upon by most? Or perhaps you value the almost infinite number of solution paths that any task has in Perl? \nSo, assuming that your task is I\/O bound ( like most things ) rather than CPU bound ( real time programming or games , or nipple crinkling number crunching ) then Python would be suitable. Whether its philosophy suits you is the key question.","Q_Score":25,"Tags":"python","A_Id":1452566,"CreationDate":"2009-09-21T01:24:00.000","Title":"What kind of applications are built 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},{"Question":"I wanted to know\nPython is suited for what kind of applications? \nI am new to Python world but I know it's a scripting language like Perl but I was not sure about the kind of applications which one would build using Python and would certainly appreciate if someone can provide some useful information.","AnswerCount":9,"Available Count":5,"Score":0.022218565,"is_accepted":false,"ViewCount":80717,"Q_Id":1452509,"Users Score":1,"Answer":"Most of the 3d packages these days, such as Maya, SoftImage, Houdini, RealFlow, Blender, etc. all use Python as an embedded scripting and plugin language.","Q_Score":25,"Tags":"python","A_Id":1452576,"CreationDate":"2009-09-21T01:24:00.000","Title":"What kind of applications are built 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},{"Question":"I wanted to know\nPython is suited for what kind of applications? \nI am new to Python world but I know it's a scripting language like Perl but I was not sure about the kind of applications which one would build using Python and would certainly appreciate if someone can provide some useful information.","AnswerCount":9,"Available Count":5,"Score":1.0,"is_accepted":false,"ViewCount":80717,"Q_Id":1452509,"Users Score":10,"Answer":"You say:\n\nI am new to Python world but I know it's an scripting language.\n\nI think the distinction between \"scripting languages\" and \"programming languages\" is quite arbitrary. Nearly every language developed in the last 10-20 years has some kind of runtime support, usually in the form of a bytecode interpreter or virtual machine. Python is no different: it gets compiled to bytecode and the bytecode is executed by the Python runtime. The point is, I would say there are very few things you can do in Java, C#, Ruby, etc., that you couldn't do in Python.\nThat said, however, different languages have different strengths. So there are certainly some kinds of programs that would be better suited to being written in Python. It really depends on what you want the programming language to do for you, and what you want to do yourself. The right answer depends on what kinds of problems you're interested in solving.","Q_Score":25,"Tags":"python","A_Id":1452546,"CreationDate":"2009-09-21T01:24:00.000","Title":"What kind of applications are built 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},{"Question":"I wanted to know\nPython is suited for what kind of applications? \nI am new to Python world but I know it's a scripting language like Perl but I was not sure about the kind of applications which one would build using Python and would certainly appreciate if someone can provide some useful information.","AnswerCount":9,"Available Count":5,"Score":1.2,"is_accepted":true,"ViewCount":80717,"Q_Id":1452509,"Users Score":33,"Answer":"It's hard to think of kinds of general applications where Python would be unsuitable, but there are several kinds where, like just about all higher-level languages akin to it, it might be considered a peculiar and probably inferior choice.\nIn \"hard real time\" applications, all dynamic memory allocation and freeing, and especially garbage collection, are quite understandably frowned upon; this rules out almost all modern languages (including Python, but also Java, C#, etc, etc), since almost all of them rely on dynamic memory handling and garbage collection of some kind or other.\nIf you're programming for an \"embedded device\" which you expect to be produced and sold in huge numbers, every bit of ROM may add measurably to the overall costs, so you want a language focused on squeezing the application down to the last possible bit -- any language that relies on a rich supporting runtime environment or operating system (including Python, and, again, also Java, C#, etc, etc) would no doubt force you to spend extra on many more bits of ROM (consider threaded-interpretive languages like good old Forth: they can make a substantial application's code be measurably more compact than straightforward machine code would!).\nThere many be other niches that share similar constraints (mostly focused on MEMORY: focus on using as few bits as possible and\/or strictly confining execution within precisely predefined limits -- no dynamism, no allocation, no garbage collection, etc, etc), and basically the case would once again incline in similar ways (for example, there are server applications, intended to run on myriads of servers, which can save many megabytes per server if coded in C++ [especially if without \"allegedly-smart\" pointers;-)] rather than Java, Python, C#, and so on).\nOf course there are excellent reasons most modern languages (Python, Java, C#, etc) choose to do dynamic memory allocation, garbage collection, and so forth, despite the importance of application niches where those techniques are a negative aspect: essentially, if you can possibly afford such nice memory handling, writing applications becomes MUCH, MUCH easier, and a whole class of problems and bugs connected with the need to carefully manage memory if you lack such support can go away -- programmer productivity really soars... IF garbage collection and the like can be afforded at all, that is. For example, if an application was going to run on a few hundreds or thousands of servers, I probably wouldn't bother coding it in C++ with manual memory management in order to save memory; it's only at tens and hundreds of thousands of servers, that the economics of all those extra megabytes really kicks in.\nNote that, despite the common misconception that \"interpreted languages\" (ones with a rich underlying runtime or VM, like Java, C#, Python, etc) \"are slow\", in fact for most CPU-intensive applications (such as scientific computation), Python is perfectly suitable, as long as the \"rich supporting runtime environment\" (e.g. numpy) is factored in. So, that is not really a factor -- though memory consumption and garbage collection CAN be, in some niches.","Q_Score":25,"Tags":"python","A_Id":1452532,"CreationDate":"2009-09-21T01:24:00.000","Title":"What kind of applications are built 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},{"Question":"I wanted to know\nPython is suited for what kind of applications? \nI am new to Python world but I know it's a scripting language like Perl but I was not sure about the kind of applications which one would build using Python and would certainly appreciate if someone can provide some useful information.","AnswerCount":9,"Available Count":5,"Score":0.0,"is_accepted":false,"ViewCount":80717,"Q_Id":1452509,"Users Score":0,"Answer":"Bittorrent was built on Python.","Q_Score":25,"Tags":"python","A_Id":1452528,"CreationDate":"2009-09-21T01:24:00.000","Title":"What kind of applications are built 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},{"Question":"What are people's experiences with any of the Git modules for Python? (I know of GitPython, PyGit, and Dulwich - feel free to mention others if you know of them.)\nI am writing a program which will have to interact (add, delete, commit) with a Git repository, but have no experience with Git, so one of the things I'm looking for is ease of use\/understanding with regards to Git.\nThe other things I'm primarily interested in are maturity and completeness of the library, a reasonable lack of bugs, continued development, and helpfulness of the documentation and developers.\nIf you think of something else I might want\/need to know, please feel free to mention it.","AnswerCount":11,"Available Count":3,"Score":-0.0544914242,"is_accepted":false,"ViewCount":120684,"Q_Id":1456269,"Users Score":-3,"Answer":"For the record, none of the aforementioned Git Python libraries seem to contain a \"git status\" equivalent, which is really the only thing I would want since dealing with the rest of the git commands via subprocess is so easy.","Q_Score":177,"Tags":"python,git","A_Id":2180936,"CreationDate":"2009-09-21T19:10:00.000","Title":"Python Git Module experiences?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"What are people's experiences with any of the Git modules for Python? (I know of GitPython, PyGit, and Dulwich - feel free to mention others if you know of them.)\nI am writing a program which will have to interact (add, delete, commit) with a Git repository, but have no experience with Git, so one of the things I'm looking for is ease of use\/understanding with regards to Git.\nThe other things I'm primarily interested in are maturity and completeness of the library, a reasonable lack of bugs, continued development, and helpfulness of the documentation and developers.\nIf you think of something else I might want\/need to know, please feel free to mention it.","AnswerCount":11,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":120684,"Q_Id":1456269,"Users Score":0,"Answer":"The git interaction library part of StGit is actually pretty good. However, it isn't broken out as a separate package but if there is sufficient interest, I'm sure that can be fixed.\nIt has very nice abstractions for representing commits, trees etc, and for creating new commits and trees.","Q_Score":177,"Tags":"python,git","A_Id":1478107,"CreationDate":"2009-09-21T19:10:00.000","Title":"Python Git Module experiences?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"What are people's experiences with any of the Git modules for Python? (I know of GitPython, PyGit, and Dulwich - feel free to mention others if you know of them.)\nI am writing a program which will have to interact (add, delete, commit) with a Git repository, but have no experience with Git, so one of the things I'm looking for is ease of use\/understanding with regards to Git.\nThe other things I'm primarily interested in are maturity and completeness of the library, a reasonable lack of bugs, continued development, and helpfulness of the documentation and developers.\nIf you think of something else I might want\/need to know, please feel free to mention it.","AnswerCount":11,"Available Count":3,"Score":1.0,"is_accepted":false,"ViewCount":120684,"Q_Id":1456269,"Users Score":18,"Answer":"Maybe it helps, but Bazaar and Mercurial are both using dulwich for their Git interoperability.\nDulwich is probably different than the other in the sense that's it's a reimplementation of git in python. The other might just be a wrapper around Git's commands (so it could be simpler to use from a high level point of view: commit\/add\/delete), it probably means their API is very close to git's command line so you'll need to gain experience with Git.","Q_Score":177,"Tags":"python,git","A_Id":1458963,"CreationDate":"2009-09-21T19:10:00.000","Title":"Python Git Module experiences?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":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},{"Question":"I'm trying to find a way to lazily load a module-level variable.\nSpecifically, I've written a tiny Python library to talk to iTunes, and I want to have a DOWNLOAD_FOLDER_PATH module variable. Unfortunately, iTunes won't tell you where its download folder is, so I've written a function that grabs the filepath of a few podcast tracks and climbs back up the directory tree until it finds the \"Downloads\" directory.\nThis takes a second or two, so I'd like to have it evaluated lazily, rather than at module import time.\nIs there any way to lazily assign a module variable when it's first accessed or will I have to rely on a function?","AnswerCount":8,"Available Count":1,"Score":0.024994793,"is_accepted":false,"ViewCount":14915,"Q_Id":1462986,"Users Score":1,"Answer":"If that variable lived in a class rather than a module, then you could overload getattr, or better yet, populate it in init.","Q_Score":41,"Tags":"python,module,variables,lazy-loading,itunes","A_Id":1463036,"CreationDate":"2009-09-22T22:32:00.000","Title":"Lazy module variables--can it be 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":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am currently running a high-traffic python\/django website using Apache and mod_wsgi. I'm hoping that there's a faster webserver configuration out there, and I've heard a fair number of recommendations for lighttpd and fastcgi. Is this setup faster than apache+mod_wsgi for serving dynamic django pages (I'm already convinced that lighttpd can server static files better)? The benchmarks online are either poorly conducted or inconclusive so I'm looking for some personal anecdotes. What architectural benefits does lighttpd + fastcgi provide? I understand that lighttpd uses epoll, and that a fastcgi process will be multithreaded. Also, having two separate processes, one for lighttpd and one for the python interpreter, will be largely beneficial.\nI am aware of tornado and its ability to handle thousands of file descriptors with much fewer threads using epoll and callbacks. However, I'd prefer to stick with django for now.\nThanks,\nKen","AnswerCount":4,"Available Count":1,"Score":0.049958375,"is_accepted":false,"ViewCount":3952,"Q_Id":1469770,"Users Score":1,"Answer":"Doesn't answer you question, but do you already use caching for your site? Like memcached? This might give you a better performance gain than going through the mess of switching webservers.","Q_Score":3,"Tags":"python,django,apache,fastcgi,lighttpd","A_Id":1470459,"CreationDate":"2009-09-24T04:26:00.000","Title":"Better webserver performance for Python Django: Apache mod_wsgi or Lighttpd fastcgi","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I'm setting up a web application to use IronPython for scripting various user actions and I'll be exposing various business objects ready for accessing by the script. I want to make it impossible for the user to import the CLR or other assemblies in order to keep the script's capabilities simple and restricted to the functionality I expose in my business objects.\nHow do I prevent the CLR and other assemblies\/modules from being imported?","AnswerCount":5,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":996,"Q_Id":1479454,"Users Score":0,"Answer":"If you'd like to disable certain built-in modules I'd suggest filing a feature request over at ironpython.codeplex.com. This should be an easy enough thing to implement.\nOtherwise you could simply look at either Importer.cs and disallow the import there or you could simply delete ClrModule.cs from IronPython and re-build (and potentially remove any references to it).","Q_Score":4,"Tags":"python,ironpython","A_Id":1480581,"CreationDate":"2009-09-25T20:33:00.000","Title":"IronPython - How to prevent CLR (and other modules) from being imported","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm setting up a web application to use IronPython for scripting various user actions and I'll be exposing various business objects ready for accessing by the script. I want to make it impossible for the user to import the CLR or other assemblies in order to keep the script's capabilities simple and restricted to the functionality I expose in my business objects.\nHow do I prevent the CLR and other assemblies\/modules from being imported?","AnswerCount":5,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":996,"Q_Id":1479454,"Users Score":0,"Answer":"In case anyone comes across this thread from google still (like i did)\nI managed to disable 'import clr' in python scripts by commenting out the line\n\/\/[assembly: PythonModule(\"clr\", typeof(IronPython.Runtime.ClrModule))]\nin ClrModule.cs, but i'm not convinced this is a full solution to preventing unwanted access, since you will still need to override things like the file builtin.","Q_Score":4,"Tags":"python,ironpython","A_Id":59887790,"CreationDate":"2009-09-25T20:33:00.000","Title":"IronPython - How to prevent CLR (and other modules) from being imported","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm setting up a web application to use IronPython for scripting various user actions and I'll be exposing various business objects ready for accessing by the script. I want to make it impossible for the user to import the CLR or other assemblies in order to keep the script's capabilities simple and restricted to the functionality I expose in my business objects.\nHow do I prevent the CLR and other assemblies\/modules from being imported?","AnswerCount":5,"Available Count":3,"Score":1.2,"is_accepted":true,"ViewCount":996,"Q_Id":1479454,"Users Score":1,"Answer":"You'll have to search the script for the imports you don't want them to use, and reject the script in toto if it contains any of them.\nBasically, just reject the script if it contains Assembly.Load, import or AddReference.","Q_Score":4,"Tags":"python,ironpython","A_Id":1479480,"CreationDate":"2009-09-25T20:33:00.000","Title":"IronPython - How to prevent CLR (and other modules) from being imported","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Is there a python equivalent of phpMyAdmin?\nHere's why I'm looking for a python version of phpmyadmin: While I agree that phpmyadmin really rocks, I don't want to run php on my server. I'd like to move from apache2-prefork to apache2-mpm-worker. Worker blows the doors off of prefork for performance, but php5 doesn't work with worker. (Technically it does, but it's far more complicated.) The extra memory and performance penalty for having php on this server is large to me.","AnswerCount":4,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":23600,"Q_Id":1480453,"Users Score":12,"Answer":"You can use phpMyAdmin for python project, because phpMyAdmin is meant for MySQL databases. If you are using MySQL, then regardless of whether you are using PHP or python, you can use phpMyAdmin.","Q_Score":33,"Tags":"python,phpmyadmin","A_Id":1480549,"CreationDate":"2009-09-26T04:51:00.000","Title":"phpMyAdmin equivalent in python?","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},{"Question":"I would like to write a small script that does the following (and that I can then run using my crontab):\n\nLook into a directory that contains directories whose names are in some date format, e.g. 30-10-09.\nConvert the directory name to the date it represents (of course, I could put this information as a string into a file in these directories, that doesn't matter to me).\nCompare each date with the current system time and find the one that has a specific time difference to the current system date, e.g. less than two days. \nThen, do something with the files in that directory (e.g., paste them together and send an email).\n\nI know a little bash scripting, but I don't know whether bash can itself handle this. I think I could do this in R, but the server where this needs to run doesn't have R. \nI'm curious anyway to learn a little bit of either Python or Ruby (both of which are on the server).\nCan someone point me in the right direction what might be the best way to do this?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":289,"Q_Id":1487450,"Users Score":1,"Answer":"I would suggest using Python. You'll need the following functions:\n\nos.listdir gives you the directory contents, as a list of strings\ntime.strptime(name, \"%d-%m-%y\") will try to parse such a string, and return a time tuple. You get a ValueError exception if parsing fails.\ntime.mktime will convert a time tuple into seconds since the epoch.\ntime.time returns seconds since the epoch\nthe smtplib module can send emails, assuming you know what SMTP server to use. Alternatively, you can run \/usr\/lib\/sendmail, through the subprocess module (assuming \/usr\/lib\/sendmail is correctly configured)","Q_Score":0,"Tags":"python,date,scripting","A_Id":1487702,"CreationDate":"2009-09-28T14:45:00.000","Title":"Time difference between system date and string, e.g. from directory 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":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"Perl habits die hard. Variable declaration, scoping, global\/local is different between the 2 languages. Is there a set of recommended python language idioms that will render the transition from perl coding to python coding less painful. \nSubtle variable misspelling can waste an extraordinary amount of time.\nI understand the variable declaration issue is quasi-religious among python folks\nI'm not arguing for language changes or features, just a reliable bridge between\nthe 2 languages that will not cause my perl habits sink my python efforts.\nThanks.","AnswerCount":5,"Available Count":1,"Score":0.0399786803,"is_accepted":false,"ViewCount":539,"Q_Id":1489355,"Users Score":1,"Answer":"In python $_ does not exist except in the python shell and variables with global scope are frowned upon.\nIn practice this has two major effects:\n\nIn Python you can't use regular expressions as naturally as Perl, s0 matching each iterated $_ and similarly catching matches is more cumbersome\nPython functions tend to be called explicitly or have default variables\n\nHowever these differences are fairly minor when one considers that in Python just about everything becomes a class. When I used to do Perl I thought of \"carving\"; in Python I rather feel I am \"composing\".\nPython doesn't have the idiomatic richness of Perl and I think it is probably a mistake to attempt to do the translation.","Q_Score":6,"Tags":"python,perl,transitions","A_Id":1489635,"CreationDate":"2009-09-28T21:02:00.000","Title":"Managing Perl habits in a Python 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":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"How do I find out which directories are listed in my system\u2019s PYTHONPATH variable, from within a Python script (or the interactive shell)?","AnswerCount":10,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":822516,"Q_Id":1489599,"Users Score":0,"Answer":"If using conda, you can get the env prefix using os.environ[\"CONDA_PREFIX\"].","Q_Score":447,"Tags":"python,python-module,pythonpath","A_Id":62773911,"CreationDate":"2009-09-28T22:01:00.000","Title":"How do I find out my PYTHONPATH 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":1,"Web Development":0},{"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},{"Question":"I have a memory and CPU intensive problem to solve and I need to benchmark the different solutions in ruby and python on different platforms.\nTo do the benchmark, I need to measure the time taken and the memory occupied by objects (not the entire program, but a selected list of objects) in both python and ruby.\nPlease recommend ways to do it, and also let me know if it is possible to do it without using OS specify tools like (Task Manager and ps). Thanks!\nUpdate: Yes, I know that both Python and Ruby are not strong in performance and there are better alternatives like c, c++, Java etc. I am actually more interested in comparing the performance of Python and Ruby. And please no fame-wars.","AnswerCount":5,"Available Count":1,"Score":0.0798297691,"is_accepted":false,"ViewCount":1564,"Q_Id":1490841,"Users Score":2,"Answer":"If you are using Python for CPU intensive algorithmic tasks I suggest use Numpy\/Scipy to speed up your numerical calculations and use the Psyco JIT compiler for everything else. Your speeds can approach that of much lower-level languages if you use optimized components.","Q_Score":1,"Tags":"python,ruby,performance,memory-management","A_Id":1491010,"CreationDate":"2009-09-29T06:15:00.000","Title":"Comparing performance between ruby and 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},{"Question":"I'm looking at implementing a fuzzy logic controller based on either PyFuzzy (Python) or FFLL (C++) libraries.\nI'd prefer to work with python but am unsure if the performance will be acceptable in the embedded environment it will work in (either ARM or embedded x86 proc both ~64Mbs of RAM). \nThe main concern is that response times are as fast as possible (an update rate of 5hz+ would be ideal >2Hz is required). The system would be reading from multiple (probably 5) sensors from an RS232 port and provide 2\/3 outputs based on the results of the fuzzy evaluation.\nShould I be concerned that Python will be too slow for this task?","AnswerCount":6,"Available Count":6,"Score":0.1651404129,"is_accepted":false,"ViewCount":1593,"Q_Id":1498155,"Users Score":5,"Answer":"Make it work, then make it work fast.","Q_Score":5,"Tags":"python,c,embedded,fuzzy-logic","A_Id":1498739,"CreationDate":"2009-09-30T13:32:00.000","Title":"Performance of Python worth the cost?","Data Science and Machine Learning":0,"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},{"Question":"I'm looking at implementing a fuzzy logic controller based on either PyFuzzy (Python) or FFLL (C++) libraries.\nI'd prefer to work with python but am unsure if the performance will be acceptable in the embedded environment it will work in (either ARM or embedded x86 proc both ~64Mbs of RAM). \nThe main concern is that response times are as fast as possible (an update rate of 5hz+ would be ideal >2Hz is required). The system would be reading from multiple (probably 5) sensors from an RS232 port and provide 2\/3 outputs based on the results of the fuzzy evaluation.\nShould I be concerned that Python will be too slow for this task?","AnswerCount":6,"Available Count":6,"Score":0.0333209931,"is_accepted":false,"ViewCount":1593,"Q_Id":1498155,"Users Score":1,"Answer":"If most of your runtime is spent in C libraries, the language you use to call these libraries isn't important. What language are your time-eating libraries written in ?","Q_Score":5,"Tags":"python,c,embedded,fuzzy-logic","A_Id":1499253,"CreationDate":"2009-09-30T13:32:00.000","Title":"Performance of Python worth the cost?","Data Science and Machine Learning":0,"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},{"Question":"I'm looking at implementing a fuzzy logic controller based on either PyFuzzy (Python) or FFLL (C++) libraries.\nI'd prefer to work with python but am unsure if the performance will be acceptable in the embedded environment it will work in (either ARM or embedded x86 proc both ~64Mbs of RAM). \nThe main concern is that response times are as fast as possible (an update rate of 5hz+ would be ideal >2Hz is required). The system would be reading from multiple (probably 5) sensors from an RS232 port and provide 2\/3 outputs based on the results of the fuzzy evaluation.\nShould I be concerned that Python will be too slow for this task?","AnswerCount":6,"Available Count":6,"Score":0.0,"is_accepted":false,"ViewCount":1593,"Q_Id":1498155,"Users Score":0,"Answer":"From your description, speed should not be much of a concern (and you can use C, cython, whatever you want to make it faster), but memory would be. For environments with 64 Mb max (where the OS and all should fit as well, right ?), I think there is a good chance that python may not be the right tool for target deployment.\nIf you have non trivial logic to handle, I would still prototype in python, though.","Q_Score":5,"Tags":"python,c,embedded,fuzzy-logic","A_Id":1502231,"CreationDate":"2009-09-30T13:32:00.000","Title":"Performance of Python worth the cost?","Data Science and Machine Learning":0,"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},{"Question":"I'm looking at implementing a fuzzy logic controller based on either PyFuzzy (Python) or FFLL (C++) libraries.\nI'd prefer to work with python but am unsure if the performance will be acceptable in the embedded environment it will work in (either ARM or embedded x86 proc both ~64Mbs of RAM). \nThe main concern is that response times are as fast as possible (an update rate of 5hz+ would be ideal >2Hz is required). The system would be reading from multiple (probably 5) sensors from an RS232 port and provide 2\/3 outputs based on the results of the fuzzy evaluation.\nShould I be concerned that Python will be too slow for this task?","AnswerCount":6,"Available Count":6,"Score":0.0,"is_accepted":false,"ViewCount":1593,"Q_Id":1498155,"Users Score":0,"Answer":"I never really measured the performance of pyfuzzy's examples, but as the new version 0.1.0 can read FCL files as FFLL does. Just describe your fuzzy system in this format, write some wrappers, and check the performance of both variants.\nFor reading FCL with pyfuzzy you need the antlr python runtime, but after reading you should be able to pickle the read object, so you don't need the antlr overhead on the target.","Q_Score":5,"Tags":"python,c,embedded,fuzzy-logic","A_Id":1612690,"CreationDate":"2009-09-30T13:32:00.000","Title":"Performance of Python worth the cost?","Data Science and Machine Learning":0,"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},{"Question":"I'm looking at implementing a fuzzy logic controller based on either PyFuzzy (Python) or FFLL (C++) libraries.\nI'd prefer to work with python but am unsure if the performance will be acceptable in the embedded environment it will work in (either ARM or embedded x86 proc both ~64Mbs of RAM). \nThe main concern is that response times are as fast as possible (an update rate of 5hz+ would be ideal >2Hz is required). The system would be reading from multiple (probably 5) sensors from an RS232 port and provide 2\/3 outputs based on the results of the fuzzy evaluation.\nShould I be concerned that Python will be too slow for this task?","AnswerCount":6,"Available Count":6,"Score":1.2,"is_accepted":true,"ViewCount":1593,"Q_Id":1498155,"Users Score":35,"Answer":"In general, you shouldn't obsess over performance until you've actually seen it become a problem. Since we don't know the details of your app, we can't say how it'd perform if implemented in Python. And since you haven't implemented it yet, neither can you.\nImplement the version you're most comfortable with, and can implement fastest, first. Then benchmark it. And if it is too slow, you have three options which should be done in order:\n\nFirst, optimize your Python code\nIf that's not enough, write the most performance-critical functions in C\/C++, and call that from your Python code\nAnd finally, if you really need top performance, you might have to rewrite the whole thing in C++. But then at least you'll have a working prototype in Python, and you'll have a much clearer idea of how it should be implemented. You'll know what pitfalls to avoid, and you'll have an already correct implementation to test against and compare results to.","Q_Score":5,"Tags":"python,c,embedded,fuzzy-logic","A_Id":1498214,"CreationDate":"2009-09-30T13:32:00.000","Title":"Performance of Python worth the cost?","Data Science and Machine Learning":0,"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},{"Question":"I'm looking at implementing a fuzzy logic controller based on either PyFuzzy (Python) or FFLL (C++) libraries.\nI'd prefer to work with python but am unsure if the performance will be acceptable in the embedded environment it will work in (either ARM or embedded x86 proc both ~64Mbs of RAM). \nThe main concern is that response times are as fast as possible (an update rate of 5hz+ would be ideal >2Hz is required). The system would be reading from multiple (probably 5) sensors from an RS232 port and provide 2\/3 outputs based on the results of the fuzzy evaluation.\nShould I be concerned that Python will be too slow for this task?","AnswerCount":6,"Available Count":6,"Score":1.0,"is_accepted":false,"ViewCount":1593,"Q_Id":1498155,"Users Score":12,"Answer":"Python is very slow at handling large amounts of non-string data. For some operations, you may see that it is 1000 times slower than C\/C++, so yes, you should investigate into this and do necessary benchmarks before you make time-critical algorithms in Python.\nHowever, you can extend python with modules in C\/C++ code, so that time-critical things are fast, while still being able to use python for the main code.","Q_Score":5,"Tags":"python,c,embedded,fuzzy-logic","A_Id":1498176,"CreationDate":"2009-09-30T13:32:00.000","Title":"Performance of Python worth the cost?","Data Science and Machine Learning":0,"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},{"Question":"On a Linux box I want to run a Python script as another user.\nI've already made a wrapper program in C++ that calls the script, since I've realized that the ownership of running the script is decided by the ownership of the python interpreter. After that I change the C++ program to a different user and run the C++ program.\nThis setup doesn't seem to be working. Any ideas?","AnswerCount":3,"Available Count":2,"Score":-0.0665680765,"is_accepted":false,"ViewCount":33209,"Q_Id":1499268,"Users Score":-1,"Answer":"Use the command sudo.\nIn order to run a program as a user, the system must \"authenticate\" that user.\nObviously, root can run any program as any user, and any user can su to another user with a password.\nThe program sudo can be configured to allow a group of users to sudo a particular command as a particular user.\nFor example, you could create a group scriptUsers and a user scriptRun. Then, configure sudo to let any user in scriptUsers become scriptRun ONLY to run your script.","Q_Score":14,"Tags":"python,linux","A_Id":1499282,"CreationDate":"2009-09-30T16:31:00.000","Title":"Running python script as 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":1,"Web Development":0},{"Question":"On a Linux box I want to run a Python script as another user.\nI've already made a wrapper program in C++ that calls the script, since I've realized that the ownership of running the script is decided by the ownership of the python interpreter. After that I change the C++ program to a different user and run the C++ program.\nThis setup doesn't seem to be working. Any ideas?","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":33209,"Q_Id":1499268,"Users Score":0,"Answer":"Give those users the ability to sudo su $dedicated_username and tailor the permissions on your system so that $dedicated_user has sufficient, but not excessive, access.","Q_Score":14,"Tags":"python,linux","A_Id":1499313,"CreationDate":"2009-09-30T16:31:00.000","Title":"Running python script as 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":1,"Web Development":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},{"Question":"Because I'm a Python fan, I'd like to learn the .NET framework using IronPython. Would I be missing out on something? Is this in some way not recommended?\nEDIT:\nI'm pretty knowledgeable of Java ( so learning\/using a new language is not a problem for me ). If needed, will I be able to use everything I learned in IronPython ( excluding language featurs ) to write C# code?","AnswerCount":4,"Available Count":3,"Score":0.2449186624,"is_accepted":false,"ViewCount":477,"Q_Id":1504804,"Users Score":5,"Answer":"If I wanted to just \"learn the framework\", I would do it in C# or VB for two main reasons:\n\nIntellisense - the framework is huge, and being offered suggestions for function overloads is one of the ways to find new stuff. There's almost no good intellisense for the framework with IronPython at the moment (Michael Foord has done some work on building the appropriate info for Wing, but I haven't tried it myself).\nCode samples - pretty much all the educational material that exists about the .NET framework is given with C# or VB. You'll be much more on your own with IronPython.","Q_Score":4,"Tags":"c#,.net,ironpython","A_Id":1551802,"CreationDate":"2009-10-01T15:55:00.000","Title":"Using IronPython to learn the .NET framework, is this bad?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"Because I'm a Python fan, I'd like to learn the .NET framework using IronPython. Would I be missing out on something? Is this in some way not recommended?\nEDIT:\nI'm pretty knowledgeable of Java ( so learning\/using a new language is not a problem for me ). If needed, will I be able to use everything I learned in IronPython ( excluding language featurs ) to write C# code?","AnswerCount":4,"Available Count":3,"Score":1.2,"is_accepted":true,"ViewCount":477,"Q_Id":1504804,"Users Score":11,"Answer":"No, sounds like a good way to learn to me. You get to stick with a language and syntax that you are familiar with, and learn about the huge range of classes available in the framework, and how the CLR supports your code.\nOnce you've got to grips with some of the framework and the CLR services you could always pick up C# in the future. By that point it will just be a minor syntax change from what you already know.\nBare in mind that if you are thinking with respect to a career, you won't find many iron python jobs, but like I say, this could be a good way to learn about the framework first, then build on that with C# in a month or twos time.","Q_Score":4,"Tags":"c#,.net,ironpython","A_Id":1504823,"CreationDate":"2009-10-01T15:55:00.000","Title":"Using IronPython to learn the .NET framework, is this bad?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"Because I'm a Python fan, I'd like to learn the .NET framework using IronPython. Would I be missing out on something? Is this in some way not recommended?\nEDIT:\nI'm pretty knowledgeable of Java ( so learning\/using a new language is not a problem for me ). If needed, will I be able to use everything I learned in IronPython ( excluding language featurs ) to write C# code?","AnswerCount":4,"Available Count":3,"Score":0.2449186624,"is_accepted":false,"ViewCount":477,"Q_Id":1504804,"Users Score":5,"Answer":"You can definitely do that to learn the class library, but I'm not sure if it's such a good idea when it comes to fundamental CLR concepts (e.g. delegates and events). You'll need to pay attention and distinguish what is strictly an IronPython feature, and what is CLR feature exposed in IronPython in a way that matches its dynamic semantics better.","Q_Score":4,"Tags":"c#,.net,ironpython","A_Id":1504904,"CreationDate":"2009-10-01T15:55:00.000","Title":"Using IronPython to learn the .NET framework, is this bad?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"What is the cleanest and most Pythonic way to get tomorrow's date? There must be a better way than to add one to the day, handle days at the end of the month, etc.","AnswerCount":7,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":110489,"Q_Id":1506901,"Users Score":314,"Answer":"datetime.date.today() + datetime.timedelta(days=1) should do the trick","Q_Score":166,"Tags":"python,datetime,date,time","A_Id":1506916,"CreationDate":"2009-10-01T22:45:00.000","Title":"Cleanest and most Pythonic way to get tomorrow's date?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've seen some comparisons between Smalltalk and Ruby on the one hand and Ruby and Python on the other, but not between Python and Smalltalk. I'd especially like to know what the fundamental differences in Implementation, Syntax, Extensiabillity and Philosophy are. \nFor example Python does not seem to have Metaclasses. Smalltalk has no concept of generators. And although both are said to be dynamicly typed, I believe that Python does not do dynamic method dispatch. Is this correct?","AnswerCount":5,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":3672,"Q_Id":1508256,"Users Score":7,"Answer":"Python certainly does have metaclasses.\nSmalltalk has some unusual features:\n\nHas a rather simple syntax and only about 6 (!) keywords. Everything else (including defining new classes) is accomplished by calling methods (sending messages in Smalltalk). This allows you to create some DSL within the language.\nIn Smalltalk, you don't store source files, but instead have one big memory image and you modify it on the fly. You can also modify most of the Smalltalk itself (and possibly break it ;)","Q_Score":7,"Tags":"python,comparison,language-features,smalltalk,language-comparisons","A_Id":1508312,"CreationDate":"2009-10-02T08:09:00.000","Title":"How does Smalltalk (Pharo for example) compare 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},{"Question":"I have an application that generates some large log files > 500MB.\nI have written some utilities in Python that allows me to quickly browse the log file and find data of interest. But I now get some datasets where the file is too big to load it all into memory.\nI thus want to scan the document once, build an index and then only load the section of the document into memory that I want to look at at a time.\nThis works for me when I open a 'file' read it one line at a time and store the offset with from file.tell().\nI can then come back to that section of the file later with file.seek( offset, 0 ).\nMy problem is however that I may have UTF-8 in the log files so I need to open them with the codecs module (codecs.open(, 'r', 'utf-8')). With the resulting object I can call seek and tell but they do not match up.\nI assume that codecs needs to do some buffering or maybe it returns character counts instead of bytes from tell?\nIs there a way around this?","AnswerCount":4,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":2140,"Q_Id":1510188,"Users Score":0,"Answer":"Update: You can't do seek\/tell on the object returned by codec.open(). You need to use a normal file, and decode the strings to unicode after reading.\nI do not know why it doesn't work but I can't make it work. The seek seems to only work once, for example. Then you need to close and reopen the file, which is of course not useful.\nThe tell does not use character positions, but doesn't show you where your position in the stream is (but probably where the underlying file object is in reading from disk).\nSo probably because of some sort of underlying buffering, you can't do it. But deocding after reading works just fine, so go for that.","Q_Score":6,"Tags":"python,utf-8,codec,seek","A_Id":1510303,"CreationDate":"2009-10-02T15:17:00.000","Title":"Can seek and tell work with UTF-8 encoded documents 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},{"Question":"I have an application that generates some large log files > 500MB.\nI have written some utilities in Python that allows me to quickly browse the log file and find data of interest. But I now get some datasets where the file is too big to load it all into memory.\nI thus want to scan the document once, build an index and then only load the section of the document into memory that I want to look at at a time.\nThis works for me when I open a 'file' read it one line at a time and store the offset with from file.tell().\nI can then come back to that section of the file later with file.seek( offset, 0 ).\nMy problem is however that I may have UTF-8 in the log files so I need to open them with the codecs module (codecs.open(, 'r', 'utf-8')). With the resulting object I can call seek and tell but they do not match up.\nI assume that codecs needs to do some buffering or maybe it returns character counts instead of bytes from tell?\nIs there a way around this?","AnswerCount":4,"Available Count":3,"Score":1.2,"is_accepted":true,"ViewCount":2140,"Q_Id":1510188,"Users Score":3,"Answer":"If true, this sounds like a bug or limitation of the codecs module, as it's probably confusing byte and character offsets.\nI would use the regular open() function for opening the file, then seek()\/tell() will give you byte offsets that are always consistent. Whenever you want to read, use f.readline().decode('utf-8').\nBeware though, that using the f.read() function can land you in the middle of a multi-byte character, thus producing an UTF-8 decode error. readline() will always work.\nThis doesn't transparently handle the byte-order mark for you, but chances are your log files do not have BOMs anyway.","Q_Score":6,"Tags":"python,utf-8,codec,seek","A_Id":1510276,"CreationDate":"2009-10-02T15:17:00.000","Title":"Can seek and tell work with UTF-8 encoded documents 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},{"Question":"I have an application that generates some large log files > 500MB.\nI have written some utilities in Python that allows me to quickly browse the log file and find data of interest. But I now get some datasets where the file is too big to load it all into memory.\nI thus want to scan the document once, build an index and then only load the section of the document into memory that I want to look at at a time.\nThis works for me when I open a 'file' read it one line at a time and store the offset with from file.tell().\nI can then come back to that section of the file later with file.seek( offset, 0 ).\nMy problem is however that I may have UTF-8 in the log files so I need to open them with the codecs module (codecs.open(, 'r', 'utf-8')). With the resulting object I can call seek and tell but they do not match up.\nI assume that codecs needs to do some buffering or maybe it returns character counts instead of bytes from tell?\nIs there a way around this?","AnswerCount":4,"Available Count":3,"Score":0.0996679946,"is_accepted":false,"ViewCount":2140,"Q_Id":1510188,"Users Score":2,"Answer":"For UTF-8, you don't actually need to open the file with codecs.open. Instead, it is reliable to read the file as a byte string first, and only then decode an individual section (invoking the .decode method on the string). Breaking the file at line boundaries is safe; the only unsafe way to split it would be in the middle of a multi-byte character (which you can recognize from its byte value > 128).","Q_Score":6,"Tags":"python,utf-8,codec,seek","A_Id":1510282,"CreationDate":"2009-10-02T15:17:00.000","Title":"Can seek and tell work with UTF-8 encoded documents 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},{"Question":"All. I am trying to find a python module that I can use to parse a cron entry and get the next time it will run. With perl I use the Schedule::Cron::Events module but I would like to convert to python. Thanks in advance.","AnswerCount":3,"Available Count":1,"Score":0.2605204458,"is_accepted":false,"ViewCount":8165,"Q_Id":1511854,"Users Score":4,"Answer":"I could be wrong but doesn't python crontab offer ways to read and write to crontab but nothing regarding parsing the crontab to determine the time until the next time a job will be run?","Q_Score":4,"Tags":"python,module,cron","A_Id":3256325,"CreationDate":"2009-10-02T21:22:00.000","Title":"Parse a cron entry 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},{"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},{"Question":"I am making a community for web-comic artist who will be able to sync their existing website to this site.\nHowever, I am in debate for what CMS I should use: Drupal or Wordpress.\nI have heard great things about Drupal, where it is really aimed for Social Networking. I actually got to play a little bit in the back end of Drupal and it seemed quite complicated to me, but I am not going to give up to fully understand how Drupal works.\nAs for Wordpress, I am very familiar with the Framework. I have the ability to extend it to do what I want, but I am hesitating because I think the framework is not built for communities (I think it may slow down in the future).\nI also have a unrelated question as well: Should I go with a Python CMS? \nI heard very great things about Python and how much better it is compare to PHP.\nYour advice is appreciated.","AnswerCount":6,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":3472,"Q_Id":1513062,"Users Score":9,"Answer":"Difficult decision. Normally I would say 'definitely Drupal' without hesitation, as Drupal was build as a System for community sites from the beginning, whereas Wordpress still shows its heritage as a blogging solution, at least that's what I hear quite often. But then I'm working with Drupal all the time recently and haven't had a closer look at Wordpress for quite a while.\nThat said, Drupal has grown into a pretty complex system over the years, so there is quite a learning curve for newcomers. Given that you are already familiar with Wordpress, it might be more efficient for you to go with that, provided it can do all that you need.\nSo I would recommend Drupal, but you should probably get some opinions from people experienced with Wordpress concerning the possibility to turn it into a community site first.\n\nAs for the Python vs. PHP CMS question, I'd say that the quality of a CMS is a function of the ability of its developers, the maturity of the system, the surrounding 'ecosystem', etc. and not of the particular language used to build it. (And discussions about the quality of one established language vs. another? Well - let's just not go there ;)","Q_Score":2,"Tags":"python,wordpress,drupal,content-management-system,social-networking","A_Id":1513657,"CreationDate":"2009-10-03T07:17:00.000","Title":"Drupal or Wordpress CMS as a Social Network?","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},{"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},{"Question":"This is what I've done for a project. I have a few data structures that are bascially dictionaries with some methods that operate on the data. When I save them to disk, I write them out to .py files as code that when imported as a module will load the same data into such a data structure.\nIs this reasonable? Are there any big disadvantages? The advantage I see is that when I want to operate with the saved data, I can quickly import the modules I need. Also, the modules can be used seperate from the rest of the application because you don't need a separate parser or loader functionality.","AnswerCount":5,"Available Count":3,"Score":0.1194272985,"is_accepted":false,"ViewCount":351,"Q_Id":1514228,"Users Score":3,"Answer":"The biggest drawback is that it's a potential security problem since it's hard to guarantee that the files won't contains arbitrary code, which could be really bad. So don't use this approach if anyone else than you have write-access to the files.","Q_Score":3,"Tags":"python,data-persistence,dynamic-import","A_Id":1514234,"CreationDate":"2009-10-03T16:40:00.000","Title":"Is it reasonable to save data as 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":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"This is what I've done for a project. I have a few data structures that are bascially dictionaries with some methods that operate on the data. When I save them to disk, I write them out to .py files as code that when imported as a module will load the same data into such a data structure.\nIs this reasonable? Are there any big disadvantages? The advantage I see is that when I want to operate with the saved data, I can quickly import the modules I need. Also, the modules can be used seperate from the rest of the application because you don't need a separate parser or loader functionality.","AnswerCount":5,"Available Count":3,"Score":1.2,"is_accepted":true,"ViewCount":351,"Q_Id":1514228,"Users Score":3,"Answer":"It's reasonable, and I do it all the time. Obviously it's not a format you use to exchange data, so it's not a good format for anything like a save file. \nBut for example, when I do migrations of websites to Plone, I often get data about the site (such as a list of which pages should be migrated, or a list of how old urls should be mapped to new ones, aor lists of tags). These you typically get in Word och Excel format. Also the data often needs massaging a bit, and I end up with what for all intents and purposes are a dictionaries mapping one URL to some other information.\nSure, I could save that as CVS, and parse it into a dictionary. But instead I typically save it as a Python file with a dictionary. Saves code.\nSo, yes, it's reasonable, no it's not a format you should use for any sort of save file. It however often used for data that straddles the border to configuration, like above.","Q_Score":3,"Tags":"python,data-persistence,dynamic-import","A_Id":1514248,"CreationDate":"2009-10-03T16:40:00.000","Title":"Is it reasonable to save data as 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":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"This is what I've done for a project. I have a few data structures that are bascially dictionaries with some methods that operate on the data. When I save them to disk, I write them out to .py files as code that when imported as a module will load the same data into such a data structure.\nIs this reasonable? Are there any big disadvantages? The advantage I see is that when I want to operate with the saved data, I can quickly import the modules I need. Also, the modules can be used seperate from the rest of the application because you don't need a separate parser or loader functionality.","AnswerCount":5,"Available Count":3,"Score":1.0,"is_accepted":false,"ViewCount":351,"Q_Id":1514228,"Users Score":7,"Answer":"By operating this way, you may gain some modicum of convenience, but you pay many kinds of price for that. The space it takes to save your data, and the time it takes to both save and reload it, go up substantially; and your security exposure is unbounded -- you must ferociously guard the paths from which you reload modules, as it would provide an easy avenue for any attacker to inject code of their choice to be executed under your userid (pickle itself is not rock-solid, security-wise, but, compared to this arrangement, it shines;-).\nAll in all, I prefer a simpler and more traditional arrangement: executable code lives in one module (on a typical code-loading path, that does not need to be R\/W once the module's compiled) -- it gets loaded just once and from an already-compiled form. Data live in their own files (or portions of DB, etc) in any of the many suitable formats, mostly standard ones (possibly including multi-language ones such as JSON, CSV, XML, ... &c, if I want to keep the option open to easily load those data from other languages in the future).","Q_Score":3,"Tags":"python,data-persistence,dynamic-import","A_Id":1514250,"CreationDate":"2009-10-03T16:40:00.000","Title":"Is it reasonable to save data as 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":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"This is a very basic question - but I haven't been able to find an answer by searching online.\nI am using python to control ArcGIS, and I have a simple python script, that calls some pre-written code.\nHowever, when I make a change to the pre-written code, it does not appear to result in any change. I import this module, and have tried refreshing it, but nothing happens.\nI've even moved the file it calls to another location, and the script still works fine. One thing I did yesterday was I added the folder where all my python files are to the sys path (using sys.append('path') ), and I wonder if that made a difference.\nThanks in advance, and sorry for the sloppy terminology.","AnswerCount":7,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":106481,"Q_Id":1517038,"Users Score":0,"Answer":"I had the exact same issue creating a geoprocessing script for ArcGIS 10.2. I had a python toolbox script, a tool script and then a common script. I have a parameter for Dev\/Test\/Prod in the tool that would control which version of the code was run. Dev would run the code in the dev folder, test from test folder and prod from prod folder. Changes to the common dev script would not run when the tool was run from ArcCatalog. Closing ArcCatalog made no difference. Even though I selected Dev or Test it would always run from the prod folder.\nAdding reload(myCommonModule) to the tool script resolved this issue.","Q_Score":29,"Tags":"python,refresh,reload","A_Id":27299101,"CreationDate":"2009-10-04T18:23:00.000","Title":"python refresh\/reload","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have an open source project containing both Python and C code. I'm wondering that is there any use for distutils for me, because I'm planning to do a ubuntu\/debian package. The C code is not something that I could or want to use as Python extension. C and Python programs communicate with TCP\/IP through localhost.\nSo the bottom line here is that while I'm learning packaging, does the usage of distutils specific files only make me more confused since I can't use my C-code as Python extensions? Or should I divide my C and Python functionality to separate projects to be able to understand packaging concepts better?","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":284,"Q_Id":1523874,"Users Score":1,"Answer":"distutils can be used to install end user programs, but it's most useful when using it for Python libraries, as it can create source packages and also install them in the correct place. For that I would say it's more or less required.\nBut for an end user Python program you can also use make or whatever you like and are used to, as you don't need to install any code in the Python site-packages directory, and you don't need to put your code onto PyPI and it doesn't need to be accessible from other Python-code.\nI don't think distutils will be neither more or less complicated to use in installing an end-user program compared to other tools. All such install\/packaging tools are hella-complex, as Cartman would have said.","Q_Score":0,"Tags":"python,c,packaging,distutils","A_Id":1523993,"CreationDate":"2009-10-06T06:17:00.000","Title":"Reasons to use distutils when packaging C\/Python 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":1,"Web Development":0},{"Question":"I have an open source project containing both Python and C code. I'm wondering that is there any use for distutils for me, because I'm planning to do a ubuntu\/debian package. The C code is not something that I could or want to use as Python extension. C and Python programs communicate with TCP\/IP through localhost.\nSo the bottom line here is that while I'm learning packaging, does the usage of distutils specific files only make me more confused since I can't use my C-code as Python extensions? Or should I divide my C and Python functionality to separate projects to be able to understand packaging concepts better?","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":284,"Q_Id":1523874,"Users Score":1,"Answer":"Because it uses an unified python setup.py install command? distutils, or setuptools? Whatever, just use one of those.\nFor development, it's also really useful because you don't have to care where to find such and such dependency. As long as it's standard Python\/basic system library stuff, setup.py should find it for you. With setup.py, you don't require anymore .\/configure stuff or ugly autotools to create huge Makefiles. It just works (tm)","Q_Score":0,"Tags":"python,c,packaging,distutils","A_Id":1525194,"CreationDate":"2009-10-06T06:17:00.000","Title":"Reasons to use distutils when packaging C\/Python 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":1,"Web Development":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},{"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},{"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},{"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},{"Question":"I heard that Python has automated \"garbage collection\" , but C++ does not. What does that mean?","AnswerCount":6,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":1606,"Q_Id":1530245,"Users Score":0,"Answer":"As you have got your answer, now it's better to know the cons of automated garbage collection:\nit requires large amounts of extra memory and not suitable for hard real-time deadline applications.","Q_Score":3,"Tags":"c++,python,garbage-collection","A_Id":1532646,"CreationDate":"2009-10-07T08:21:00.000","Title":"I heard that Python has automated \"garbage collection\" , but C++ does not. What does that mean?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I heard that Python has automated \"garbage collection\" , but C++ does not. What does that mean?","AnswerCount":6,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":1606,"Q_Id":1530245,"Users Score":2,"Answer":"It basically means the way they handle memory resources. When you need memory you usually ask for it to the OS and then return it back.\nWith python you don't need to worry about returning it, with C++ you need to track what you asked and return it back, one is easier, the other performant, you choose your tool.","Q_Score":3,"Tags":"c++,python,garbage-collection","A_Id":1530267,"CreationDate":"2009-10-07T08:21:00.000","Title":"I heard that Python has automated \"garbage collection\" , but C++ does not. What does that mean?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":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},{"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},{"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},{"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},{"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},{"Question":"I am a corporate C# programmer. I found some time to invest into myself and stumbed upon a dilemma. Where to go from now? C#\/.NET is easy to learn, develop for, etc. In future I would want to apply to Microsoft or Google, and want to invest spare time wisely, so what I will learn will flourish in future.\nSo: Python or C++ for a C# programmer? I am a little scared of C++ because developing anything in it takes ages. Python is easy, but I take it as a child-play language, which still need lots of patching to be some mature development tool\/language.\nAny C# developers having same dilemma?","AnswerCount":10,"Available Count":9,"Score":0.0,"is_accepted":false,"ViewCount":1673,"Q_Id":1534450,"Users Score":0,"Answer":"As someone familiar with C# and .NET you should consider IronPython. Python for .NET. This would be a good way to leverage what you know and learn a new dynamic language at the same time.","Q_Score":2,"Tags":"c#,c++,python","A_Id":1534470,"CreationDate":"2009-10-07T21:52:00.000","Title":"C++ or Python for C# programmer?","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},{"Question":"I am a corporate C# programmer. I found some time to invest into myself and stumbed upon a dilemma. Where to go from now? C#\/.NET is easy to learn, develop for, etc. In future I would want to apply to Microsoft or Google, and want to invest spare time wisely, so what I will learn will flourish in future.\nSo: Python or C++ for a C# programmer? I am a little scared of C++ because developing anything in it takes ages. Python is easy, but I take it as a child-play language, which still need lots of patching to be some mature development tool\/language.\nAny C# developers having same dilemma?","AnswerCount":10,"Available Count":9,"Score":1.0,"is_accepted":false,"ViewCount":1673,"Q_Id":1534450,"Users Score":7,"Answer":"I Am a little scared of C++ because developing anything in it takes ages.\n\nI'm not sure how you can say that when you say yourself that you have no experience in the language. C++ is a good tool for some things, Python is good for other things. What you want to do should be driving this decision, not the technology in and of itself.\nC# programmer or not, I would assume that you can pick up any language, but a language is just a tool, so your question is difficult to answer.","Q_Score":2,"Tags":"c#,c++,python","A_Id":1534460,"CreationDate":"2009-10-07T21:52:00.000","Title":"C++ or Python for C# programmer?","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},{"Question":"I am a corporate C# programmer. I found some time to invest into myself and stumbed upon a dilemma. Where to go from now? C#\/.NET is easy to learn, develop for, etc. In future I would want to apply to Microsoft or Google, and want to invest spare time wisely, so what I will learn will flourish in future.\nSo: Python or C++ for a C# programmer? I am a little scared of C++ because developing anything in it takes ages. Python is easy, but I take it as a child-play language, which still need lots of patching to be some mature development tool\/language.\nAny C# developers having same dilemma?","AnswerCount":10,"Available Count":9,"Score":0.0996679946,"is_accepted":false,"ViewCount":1673,"Q_Id":1534450,"Users Score":5,"Answer":"Python may be easier to get started with, but a dynamically typed scripting language is a very different language from C# or C++. You will learn more about programming learning it than you will by hopping to a close cousin of a language you already know. Really, solid familiarity with at least one scripting language (Python, Perl and Ruby are the favorites) should be a requirement for all programmers.","Q_Score":2,"Tags":"c#,c++,python","A_Id":1534467,"CreationDate":"2009-10-07T21:52:00.000","Title":"C++ or Python for C# programmer?","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},{"Question":"I am a corporate C# programmer. I found some time to invest into myself and stumbed upon a dilemma. Where to go from now? C#\/.NET is easy to learn, develop for, etc. In future I would want to apply to Microsoft or Google, and want to invest spare time wisely, so what I will learn will flourish in future.\nSo: Python or C++ for a C# programmer? I am a little scared of C++ because developing anything in it takes ages. Python is easy, but I take it as a child-play language, which still need lots of patching to be some mature development tool\/language.\nAny C# developers having same dilemma?","AnswerCount":10,"Available Count":9,"Score":1.2,"is_accepted":true,"ViewCount":1673,"Q_Id":1534450,"Users Score":2,"Answer":"C# is a little closer to Java and C++ than it is to Python, so learn Python first out of the two.\nHowever, my advice would be:\n\nStick with your current language and learn more techniques, such as a wider range of algorithms, functional programming, design by contract, unit testing, OOAD, etc.\nlearn C (focus on figuring out pointers, multi-dimensional arrays, data structures like linked lists, and resource management like memory allocation\/deallocation, file handles, etc)\nlearn Assembly (on a modern platform with a flat memory architecture, but doing low-level stuff like talking to hardware or drawing on a canvas)\nlearn Python or Ruby. Chances are, you'll stick with one of these for a while, knowing all of the above, unless some hot new language has come along by then.","Q_Score":2,"Tags":"c#,c++,python","A_Id":1534729,"CreationDate":"2009-10-07T21:52:00.000","Title":"C++ or Python for C# programmer?","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},{"Question":"I am a corporate C# programmer. I found some time to invest into myself and stumbed upon a dilemma. Where to go from now? C#\/.NET is easy to learn, develop for, etc. In future I would want to apply to Microsoft or Google, and want to invest spare time wisely, so what I will learn will flourish in future.\nSo: Python or C++ for a C# programmer? I am a little scared of C++ because developing anything in it takes ages. Python is easy, but I take it as a child-play language, which still need lots of patching to be some mature development tool\/language.\nAny C# developers having same dilemma?","AnswerCount":10,"Available Count":9,"Score":0.0599281035,"is_accepted":false,"ViewCount":1673,"Q_Id":1534450,"Users Score":3,"Answer":"If you want to apply to Google then Python might be the one to go for, surely MS would like the C# already. If nothing else the competition would not be as fierce as there are much more folk out there with multi years of C++ experience. Also Python gives you a broader language skill and would be a good path to more languages and scripting.\nBut as said and will be said again, choose your tool wisely and see whether it's a nail or a screw you're trying to secure.","Q_Score":2,"Tags":"c#,c++,python","A_Id":1534483,"CreationDate":"2009-10-07T21:52:00.000","Title":"C++ or Python for C# programmer?","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},{"Question":"I am a corporate C# programmer. I found some time to invest into myself and stumbed upon a dilemma. Where to go from now? C#\/.NET is easy to learn, develop for, etc. In future I would want to apply to Microsoft or Google, and want to invest spare time wisely, so what I will learn will flourish in future.\nSo: Python or C++ for a C# programmer? I am a little scared of C++ because developing anything in it takes ages. Python is easy, but I take it as a child-play language, which still need lots of patching to be some mature development tool\/language.\nAny C# developers having same dilemma?","AnswerCount":10,"Available Count":9,"Score":0.0,"is_accepted":false,"ViewCount":1673,"Q_Id":1534450,"Users Score":0,"Answer":"You might be interested in looking at Windows Powershell. It's the latest scripting technology from Microsoft, built on .NET, and can be extended via C#.\nGranted, it's not as portable as C++ or Python, but it would leverage your C#\/.NET experience more readily. Otherwise, I would suggest C++ (and possibly C). Microsoft builds a lot more of its products with C\/C++ than with Python.","Q_Score":2,"Tags":"c#,c++,python","A_Id":1534589,"CreationDate":"2009-10-07T21:52:00.000","Title":"C++ or Python for C# programmer?","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},{"Question":"I am a corporate C# programmer. I found some time to invest into myself and stumbed upon a dilemma. Where to go from now? C#\/.NET is easy to learn, develop for, etc. In future I would want to apply to Microsoft or Google, and want to invest spare time wisely, so what I will learn will flourish in future.\nSo: Python or C++ for a C# programmer? I am a little scared of C++ because developing anything in it takes ages. Python is easy, but I take it as a child-play language, which still need lots of patching to be some mature development tool\/language.\nAny C# developers having same dilemma?","AnswerCount":10,"Available Count":9,"Score":0.0199973338,"is_accepted":false,"ViewCount":1673,"Q_Id":1534450,"Users Score":1,"Answer":"C++ is usually used when speed, and low-level OS access is involved.\nIt's a good skill to have if you want to expand.\nPython allows you to do thing quickly, and it's quite easy to learn, and provides more power than you'd expect from a scripting language, and probably one of the fastest ones out there.\nC++ isn't exactly slow to develop, if you've got an IDE, it's not hard to write per-se, but the syntax is going to get you.","Q_Score":2,"Tags":"c#,c++,python","A_Id":1534645,"CreationDate":"2009-10-07T21:52:00.000","Title":"C++ or Python for C# programmer?","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},{"Question":"I am a corporate C# programmer. I found some time to invest into myself and stumbed upon a dilemma. Where to go from now? C#\/.NET is easy to learn, develop for, etc. In future I would want to apply to Microsoft or Google, and want to invest spare time wisely, so what I will learn will flourish in future.\nSo: Python or C++ for a C# programmer? I am a little scared of C++ because developing anything in it takes ages. Python is easy, but I take it as a child-play language, which still need lots of patching to be some mature development tool\/language.\nAny C# developers having same dilemma?","AnswerCount":10,"Available Count":9,"Score":0.0199973338,"is_accepted":false,"ViewCount":1673,"Q_Id":1534450,"Users Score":1,"Answer":"If you want to apply to Google and\/ or Microsoft then I'd say that of the two you need both!\nGiven more choice, probably C++ and one other language - either dynamic, functional, or both (Scala might be a good choice too).\nIt's not necessarily about whether you'd use the languages themselves but more about the different approaches they require and encourage.\nIf you continue to be \"scared\" by C++ you're probably going to struggle applying as a dev at either of those organisations - unless you are highly specialised elsewhere.","Q_Score":2,"Tags":"c#,c++,python","A_Id":1534651,"CreationDate":"2009-10-07T21:52:00.000","Title":"C++ or Python for C# programmer?","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},{"Question":"I am a corporate C# programmer. I found some time to invest into myself and stumbed upon a dilemma. Where to go from now? C#\/.NET is easy to learn, develop for, etc. In future I would want to apply to Microsoft or Google, and want to invest spare time wisely, so what I will learn will flourish in future.\nSo: Python or C++ for a C# programmer? I am a little scared of C++ because developing anything in it takes ages. Python is easy, but I take it as a child-play language, which still need lots of patching to be some mature development tool\/language.\nAny C# developers having same dilemma?","AnswerCount":10,"Available Count":9,"Score":0.0199973338,"is_accepted":false,"ViewCount":1673,"Q_Id":1534450,"Users Score":1,"Answer":"Why not learn some of each. Studying a language for a week or so won't make you an expert, but it will answer a lot of questions in your head and plant a seed for the future.\nIt's important to not just read through exercises. Find some simple problems that can be programmed in a page or two at most and solve them with each language. That will help you to learn the strengths and weaknesses in the context of the way you think and how you solve problems.","Q_Score":2,"Tags":"c#,c++,python","A_Id":1534556,"CreationDate":"2009-10-07T21:52:00.000","Title":"C++ or Python for C# programmer?","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},{"Question":"I want to write a hit counter script to keep track of hits on images on a website and the originating IPs. Impressions are upwards of hundreds of thousands per day, so the counters will be incremented many times a second. \nI'm looking for a simple, self-hosted method (php, python scripts, etc.). I was thinking of using MySQL to keep track of this, but I'm guessing there's a more efficient way. What are good methods of keeping counters?","AnswerCount":9,"Available Count":4,"Score":0.022218565,"is_accepted":false,"ViewCount":6857,"Q_Id":1535261,"Users Score":1,"Answer":"If accuracy is important, you can do it slightly slower with MySql... create a HEAP \/ Memory table to store your counter values. These a in-memory tables that are blazingly fast. You can write the data into a normal table at intervals. \nBased on the app engine ideas, you could use memcache as a temporary store for your counter. Incrementing a memcache counter is faster than using the MySql heap tables (I think). Once every five or ten seconds, you could read the memcache counter and write that number into your DB.","Q_Score":7,"Tags":"php,python,mysql,tracking","A_Id":1535794,"CreationDate":"2009-10-08T02:12:00.000","Title":"How to write an efficient hit counter for websites","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I want to write a hit counter script to keep track of hits on images on a website and the originating IPs. Impressions are upwards of hundreds of thousands per day, so the counters will be incremented many times a second. \nI'm looking for a simple, self-hosted method (php, python scripts, etc.). I was thinking of using MySQL to keep track of this, but I'm guessing there's a more efficient way. What are good methods of keeping counters?","AnswerCount":9,"Available Count":4,"Score":0.0886555158,"is_accepted":false,"ViewCount":6857,"Q_Id":1535261,"Users Score":4,"Answer":"You could take your webserver's Access log (Apache: access.log) and evaluate it time and again (cronjob) in case you do not need to have the data at hand at the exact moment in time when someone visits your site.\nUsually, the access.log is generated anyway and contains the requested resource as well as time, date and the user's IP. This way you do not have to route all trafic through a php-script. Lean, mean counting machine.","Q_Score":7,"Tags":"php,python,mysql,tracking","A_Id":1536049,"CreationDate":"2009-10-08T02:12:00.000","Title":"How to write an efficient hit counter for websites","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I want to write a hit counter script to keep track of hits on images on a website and the originating IPs. Impressions are upwards of hundreds of thousands per day, so the counters will be incremented many times a second. \nI'm looking for a simple, self-hosted method (php, python scripts, etc.). I was thinking of using MySQL to keep track of this, but I'm guessing there's a more efficient way. What are good methods of keeping counters?","AnswerCount":9,"Available Count":4,"Score":1.0,"is_accepted":false,"ViewCount":6857,"Q_Id":1535261,"Users Score":7,"Answer":"A fascinating subject. Incrementing a counter, simple as it may be, just has to be a transaction... meaning, it can lock out the whole DB for longer than makes sense!-) It can easily be the bottleneck for the whole system.\nIf you need rigorously exact counts but don't need them to be instantly up-to-date, my favorite approach is to append the countable information to a log (switching logs as often as needed for data freshness purposes). Once a log is closed (with thousands of countable events in it), a script can read it and update all that's needed in a single transaction -- maybe not intuitive, but much faster than thousands of single locks.\nThen there's extremely-fast counters that are only statistically accurate -- but since you don't say that such imprecision is acceptable, I'm not going to explain them in more depth.","Q_Score":7,"Tags":"php,python,mysql,tracking","A_Id":1535311,"CreationDate":"2009-10-08T02:12:00.000","Title":"How to write an efficient hit counter for websites","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I want to write a hit counter script to keep track of hits on images on a website and the originating IPs. Impressions are upwards of hundreds of thousands per day, so the counters will be incremented many times a second. \nI'm looking for a simple, self-hosted method (php, python scripts, etc.). I was thinking of using MySQL to keep track of this, but I'm guessing there's a more efficient way. What are good methods of keeping counters?","AnswerCount":9,"Available Count":4,"Score":0.0,"is_accepted":false,"ViewCount":6857,"Q_Id":1535261,"Users Score":0,"Answer":"I've done something very similar, on a similar scale (multiple servers, hundreds of domains, several thousand hits per hour) and log file analysis was definitely the way to go. (It also checked hit rates, weighted them by file type, and blacklisted IP addresses at the firewall if they were making too many requests; its intended purpose was to auto-block bad bots, not to just be a counter, but counting was an essential piece of it.)\nNo performance impact on the web server process itself, since it's not doing any additional work there, and you could easily publish periodically-updated hit counts by injecting them into the site's database every minute\/5 minutes\/100 hits\/whatever without having to lock the relevant row\/table\/database (depending on the locking mechanism in use) on every hit.","Q_Score":7,"Tags":"php,python,mysql,tracking","A_Id":1900337,"CreationDate":"2009-10-08T02:12:00.000","Title":"How to write an efficient hit counter for websites","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I'm starting a new webapp project in Python to get into the Agile mind-set and I'd like to do things \"properly\" with regards to deployment. However, I'm finding the whole virtualenv\/fabric\/zc.buildout\/etc stuff a little confusing - I'm used to just FTP'ing PHP files to a server and pointing a webserver at it.\nAfter deployment the server set-up would look something like:\nNginx --proxy-to--> WSGI Webserver (Spawning) --> WSGI Middleware --> WSGI App (probably MNML or similar)\nwith the python webserver being managed by supervisord.\nWhat sort of deployment set-up\/packages\/apps should I be looking into? And is there a specific directory structure I need to stick to with my app to ease deployment?","AnswerCount":3,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1087,"Q_Id":1537298,"Users Score":2,"Answer":"You already mentioned buildout, and it's all you need. Google for example buildouts for the different parts. Takes a while to set it up the first time, but then you can reuse the setup between different projects too.\nLet supervisord start everything, not just the python server. Then start supervisord at reboot either fron cron or init.d.","Q_Score":2,"Tags":"python,deployment,virtualenv","A_Id":1537585,"CreationDate":"2009-10-08T11:40:00.000","Title":"What do I need to know\/learn for automated python deployment?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I have a server that has to respond to HTTP and XML-RPC requests. Right now I have an instance of SimpleXMLRPCServer, and an instance of BaseHTTPServer.HTTPServer with a custom request handler, running on different ports. I'd like to run both services on a single port. \nI think it should be possible to modify the CGIXMLRPCRequestHandler class to also serve custom HTTP requests on some paths, or alternately, to use multiple request handlers based on what path is requested. I'm not really sure what the cleanest way to do this would be, though.","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":849,"Q_Id":1540011,"Users Score":0,"Answer":"Is there a reason not to run a real webserver out front with url rewrites to the two ports you are usign now? It's going to make life much easier in the long run","Q_Score":0,"Tags":"python,http,xml-rpc","A_Id":1540053,"CreationDate":"2009-10-08T19:45:00.000","Title":"Python HTTP server with XML-RPC","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},{"Question":"I have a server that has to respond to HTTP and XML-RPC requests. Right now I have an instance of SimpleXMLRPCServer, and an instance of BaseHTTPServer.HTTPServer with a custom request handler, running on different ports. I'd like to run both services on a single port. \nI think it should be possible to modify the CGIXMLRPCRequestHandler class to also serve custom HTTP requests on some paths, or alternately, to use multiple request handlers based on what path is requested. I'm not really sure what the cleanest way to do this would be, though.","AnswerCount":3,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":849,"Q_Id":1540011,"Users Score":0,"Answer":"Use SimpleXMLRPCDispatcher class directly from your own request handler.","Q_Score":0,"Tags":"python,http,xml-rpc","A_Id":1543370,"CreationDate":"2009-10-08T19:45:00.000","Title":"Python HTTP server with XML-RPC","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},{"Question":"If yes are there any frameworks\/Tutorials\/tips\/etc recommended? \nN00b at Python but I have tons of PHP experience and wanted to expand my skill set.\nI know Python is great at server side execution, just wanted to know about client side as well.","AnswerCount":8,"Available Count":3,"Score":1.0,"is_accepted":false,"ViewCount":54388,"Q_Id":1540214,"Users Score":7,"Answer":"Silverlight can run IronPython, so you can make Silverlight applications. Which is client-side.","Q_Score":68,"Tags":"python,client-side","A_Id":1540379,"CreationDate":"2009-10-08T20:27:00.000","Title":"Can Python be used for client side web development?","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},{"Question":"If yes are there any frameworks\/Tutorials\/tips\/etc recommended? \nN00b at Python but I have tons of PHP experience and wanted to expand my skill set.\nI know Python is great at server side execution, just wanted to know about client side as well.","AnswerCount":8,"Available Count":3,"Score":-0.024994793,"is_accepted":false,"ViewCount":54388,"Q_Id":1540214,"Users Score":-1,"Answer":"No. Browsers don't run Python.","Q_Score":68,"Tags":"python,client-side","A_Id":1540233,"CreationDate":"2009-10-08T20:27:00.000","Title":"Can Python be used for client side web development?","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},{"Question":"If yes are there any frameworks\/Tutorials\/tips\/etc recommended? \nN00b at Python but I have tons of PHP experience and wanted to expand my skill set.\nI know Python is great at server side execution, just wanted to know about client side as well.","AnswerCount":8,"Available Count":3,"Score":0.0748596907,"is_accepted":false,"ViewCount":54388,"Q_Id":1540214,"Users Score":3,"Answer":"On Windows, any language that registers for the Windows Scripting Host can run in IE. At least the ActiveState version of Python could do that; I seem to recall that has been superseded by a more official version these days.\nBut that solution requires the user to install a python interpreter and run some script or .reg file to put the correct \"magic\" into the registry for the hooks to work.","Q_Score":68,"Tags":"python,client-side","A_Id":7437506,"CreationDate":"2009-10-08T20:27:00.000","Title":"Can Python be used for client side web development?","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},{"Question":"I'm writting a small python script notify me when certain condition met. I used smtplib which does the emailing for me, but I also want the script to call my cell phone as well.\nI can't find a free library for phone callings. Does anyone know any?","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":7113,"Q_Id":1544550,"Users Score":1,"Answer":"I've used Skype4Py very successfully. Keep in mind though it does require Skype to be installed and costs the standard rate for SkypeOut.","Q_Score":8,"Tags":"python,phone-call","A_Id":1545365,"CreationDate":"2009-10-09T15:38:00.000","Title":"Is there a free python library for phone calling?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I need to implement a small test utility which consumes extremely simple SOAP XML (HTTP POST) messages. This is a protocol which I have to support, and it's not my design decision to use SOAP (just trying to prevent those \"why do you use protocol X?\" answers) \nI'd like to use stuff that's already in the basic python 2.6.x installation. What's the easiest way to do that? The sole SOAP message is really simple, I'd rather not use any enterprisey tools like WSDL class generation if possible. \nI already implemented the same functionality earlier in Ruby with just plain HTTPServlet::AbstractServlet and REXML parser. Worked fine.\nI thought I could a similar solution in Python with BaseHTTPServer, BaseHTTPRequestHandler and the elementree parser, but it's not obvious to me how I can read the contents of my incoming SOAP POST message. The documentation is not that great IMHO.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":515,"Q_Id":1547520,"Users Score":1,"Answer":"I wrote something like this in Boo, using a .Net HTTPListener, because I too had to implement someone else's defined WSDL.\nThe WSDL I was given used document\/literal form (you'll need to make some adjustments to this information if your WSDL uses rpc\/encoded). I wrapped the HTTPListener in a class that allowed client code to register callbacks by SOAP action, and then gave that class a Start method that would kick off the HTTPListener. You should be able to do something very similar in Python, with a getPOST() method on BaseHTTPServer to:\n\nextract the SOAP action from the HTTP\nheaders\nuse elementtree to extract the SOAP\nheader and SOAP body from the POST'ed\nHTTP\ncall the defined callback for the\nSOAP action, sending these extracted values\nreturn the response text given by the\ncallback in a corresponding SOAP\nenvelope; if the callback raises an\nexception, catch it and re-wrap it as\na SOAP fault\n\nThen you just implement a callback per SOAP action, which gets the XML content passed to it, parses this with elementtree, performs the desired action (or mock action if this is tester), and constructs the necessary response XML (I was not too proud to just create this explicitly using string interpolation, but you could use elementtree to create this by serializing a Python response object).\nIt will help if you can get some real SOAP sample messages in order to help you not tear out your hair, especially in the part where you create the necessary response XML.","Q_Score":1,"Tags":"python,http,soap","A_Id":1547642,"CreationDate":"2009-10-10T09:49:00.000","Title":"A minimalist, non-enterprisey approach for a SOAP server 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},{"Question":"I have a two websites in php and python.\nWhen a user sends a request to the server I need php\/python to send an HTTP POST request to a remote server. I want to reply to the user immediately without waiting for a response from the remote server.\nIs it possible to continue running a php\/python script after sending a response to the user. In that case I'll first reply to the user and only then send the HTTP POST request to the remote server.\nIs it possible to create a non-blocking HTTP client in php\/python without handling the response at all?\nA solution that will have the same logic in php and python is preferable for me.\nThanks","AnswerCount":6,"Available Count":1,"Score":0.0333209931,"is_accepted":false,"ViewCount":12400,"Q_Id":1555517,"Users Score":1,"Answer":"What you need to do is have the PHP script execute another script that does the server call and then sends the user the request.","Q_Score":14,"Tags":"php,python,nonblocking","A_Id":1555614,"CreationDate":"2009-10-12T16:22:00.000","Title":"sending a non-blocking HTTP POST request","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},{"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},{"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},{"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},{"Question":"Usually I tend to install things via the package manager, for unixy stuff. However, when I programmed a lot of perl, I would use CPAN, newer versions and all that.\nIn general, I used to install system stuff via package manager, and language stuff via it's own package manager ( gem\/easy_install|pip\/cpan)\nNow using python primarily, I am wondering what best practice is?","AnswerCount":2,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":1252,"Q_Id":1559372,"Users Score":17,"Answer":"There are two completely opposing camps: one in favor of system-provided packages, and one in favor of separate installation. I'm personally in the \"system packages\" camp. I'll provide arguments from each side below.\nPro system packages: system packager already cares about dependency, and compliance with overall system policies (such as file layout). System packages provide security updates while still caring about not breaking compatibility - so they sometimes backport security fixes that the upstream authors did not backport. System packages are \"safe\" wrt. system upgrades: after a system upgrade, you probably also have a new Python version, but all your Python modules are still there if they come from a system packager. That's all personal experience with Debian.\nCon system packages: not all software may be provided as a system package, or not in the latest version; installing stuff yourself into the system may break system packages. Upgrades may break your application.\nPro separate installation: Some people (in particular web application developers) argue that you absolutely need a repeatable setup, with just the packages you want, and completely decoupled from system Python. This goes beyond self-installed vs. system packages, since even for self-installed, you might still modify the system python; with the separate installation, you won't. As Lennart discusses, there are now dedicated tool chains to support this setup. People argue that only this approach can guarantee repeatable results.\nCon separate installation: you need to deal with bug fixes yourself, and you need to make sure all your users use the separate installation. In the case of web applications, the latter is typically easy to achieve.","Q_Score":11,"Tags":"python,setuptools,distutils,pip","A_Id":1559521,"CreationDate":"2009-10-13T10:25:00.000","Title":"Which is the most pythonic: installing python modules via a package manager ( macports, apt) or via pip\/easy_install\/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},{"Question":"Right now its a gmail box but sooner or later I want it to scale.\nI want to sync a copy of a live personal mailbox (inbox and outbox) somewhere else, but I don't want to affect the unread state of any unread messages.\nwhat type of access will make this easiest? I can't find any information if IMAP will affect the read state, but it appears I can manually reset a message to unread. Pop by definition doesn't affect unread state but nobody seems to use pop to access their gmail, why?","AnswerCount":6,"Available Count":1,"Score":0.0333209931,"is_accepted":false,"ViewCount":5515,"Q_Id":1564237,"Users Score":1,"Answer":"Nobody uses POP because typically they want the extra functionality of IMAP, such as tracking message state. When that functionality is only getting in your way and needs workarounds, I think using POP's your best bet!-)","Q_Score":4,"Tags":"python,gmail,imap,pop3,imaplib","A_Id":1564294,"CreationDate":"2009-10-14T04:27:00.000","Title":"get email unread content, without affecting unread state","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"Standard libraries (xmlrpclib+SimpleXMLRPCServer in Python 2 and xmlrpc.server in Python 3) report all errors (including usage errors) as python exceptions which is not suitable for public services: exception strings are often not easy understandable without python knowledge and might expose some sensitive information. It's not hard to fix this, but I prefer to avoid reinventing the wheel. Is there a third party library with better error reporting? I'm interested in good fault messages for all usage errors and hiding internals when reporting internal errors (this is better done with logging).\nxmlrpclib already have the constants for such errors: NOT_WELLFORMED_ERROR, UNSUPPORTED_ENCODING, INVALID_ENCODING_CHAR, INVALID_XMLRPC, METHOD_NOT_FOUND, INVALID_METHOD_PARAMS, INTERNAL_ERROR.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":1435,"Q_Id":1571598,"Users Score":1,"Answer":"I don't think you have a library specific problem. When using any library or framework you typically want to trap all errors, log them somewhere, and throw up \"Oops, we're having problems. You may want to contact us at x@x.com with error number 100 and tell us what you did.\" So wrap your failable entry points in try\/catches, create a generic logger and off you go...","Q_Score":1,"Tags":"python,xml-rpc","A_Id":1608160,"CreationDate":"2009-10-15T10:50:00.000","Title":"XML-RPC server with better error 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":0},{"Question":"I'm writing unit tests for a portion of an application that runs as an HTTP server. The approach I have been trying to take is to import the module that contains the HTTP server, start it. Then, the unit tests will use urllib2 to connect, send data, and check the response.\nOur HTTP server is using Twisted. One problem here is that I'm just not that familiar with Twisted :)\nNow, I instantiate our HTTP server and start it in the setUp() method and then I stop it in the tearDown() method.\nProblem is, Twisted doesn't appear to like this, and it will only run one unit test. After the first one, the reactor won't start anymore.\nI've searched and searched and searched, and I just can't seem to find an answer that makes sense.\nAm I taking the wrong approach entirely, or just missing something obvious?","AnswerCount":4,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":5134,"Q_Id":1575966,"Users Score":4,"Answer":"As others mentioned, you should be using Trial for unit tests in Twisted.\nYou also should be unit testing from the bottom up - that's what the \"unit\" in unit testing implies. Test your data and logic before you test your interface. For a HTTP interface, you should be calling processGET, processPOST, etc with a mock request, but you should only be doing this after you've tested what these methods are calling. Each test should assume that the units tested elsewhere are working as designed.\nIf you're speaking HTTP, or you need a running server or other state, you're probably making higher level tests such as functional or integration tests. This isn't a bad thing, but you might want to rephrase your question.","Q_Score":19,"Tags":"python,unit-testing,twisted","A_Id":1580776,"CreationDate":"2009-10-16T01:03:00.000","Title":"Python - Twisted and 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":0},{"Question":"I've got a library written in C++ which I wrap using SWIG and use in python. Generally there is one class with few methods. The problem is that calling these methods may be time consuming - they may hang my application (GIL is not released when calling these methods). So my question is: \nWhat is the simplest way to release GIL for these method calls? \n(I understand that if I used a C library I could wrap this with some additional C code, but here I use C++ and classes)","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":3393,"Q_Id":1576737,"Users Score":0,"Answer":"You can use the same API call as for C. No difference. Include \"python.h\" and call the appoproate function.\nAlso, see if SWIG doesn't have a typemap or something to indicate that the GIL shuold not be held for a specific function.","Q_Score":7,"Tags":"c++,python,swig,gil","A_Id":1576959,"CreationDate":"2009-10-16T08:07:00.000","Title":"Releasing Python GIL while in C++ 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":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am experiencing issues with my SVN post-commit hook and the fact that it is executed with an empty environment. Everything was working fine till about two weeks ago when my systems administrator upgraded a few things on the server.\nMy post-commit hook executes a Python script that uses a SVN module to email information about the commit to me. After the recent upgrades, however, Python cannot find the SVN module when executed via the hook. When executed by hand (ie with all environment variables intact) everything works fine.\nI have tried setting the PYTHONPATH variable in my post-commit hook directly (PYTHONPATH=\/usr\/local\/lib\/svn-python), but that makes no difference.\nHow can I tell Python where the module is located?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":419,"Q_Id":1576784,"Users Score":1,"Answer":"Got it! I missed the export in my post-commit hook script!\nIt should have been:\nexport PYTHONPATH=\/usr\/local\/lib\/svn-python\nProblem solved :)","Q_Score":1,"Tags":"python,svn","A_Id":1593977,"CreationDate":"2009-10-16T08:21:00.000","Title":"SVN hook environment issues with 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},{"Question":"I know a bunch of scripting languages, (python, ruby, lua, php) but I don't know any compiled languages like C\/C++ , I wanted to try and speed up some python code using cython, which is essentially a python -> C compiler, aimed at creating C extensions for python. Basically you code in a stricter version of python which compiles into C -> native code. \nhere's the problem, I don't know C, yet the cython documentation is aimed at people who obviously already know C (nothing is explained, only presented), and is of no help to me, I need to know if there are any good cython tutorials aimed at python programmers, or if I'm gonna have to learn C before I learn Cython.\nbear in mind I'm a competent python programmer, i would much rather learn cython from the perspective of the language I'm already good at, rather than learn a whole new language in order to learn cython.\n1) PLEASE don't recommend psyco \nedit: ANY information that will help understand the oficial cython docs is useful information","AnswerCount":7,"Available Count":4,"Score":0.0,"is_accepted":false,"ViewCount":8650,"Q_Id":1582105,"Users Score":0,"Answer":"Cython does not support threads well at all. It holds the GIL (Global Intrepreter Lock) the entire time! This makes your code thread-safe by (virtually) disabling concurrent execution. So I wouldn't use it for general purpose development.","Q_Score":20,"Tags":"python,c,cython","A_Id":4445452,"CreationDate":"2009-10-17T12:33:00.000","Title":"Noob-Ready Cython Tutorials","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},{"Question":"I know a bunch of scripting languages, (python, ruby, lua, php) but I don't know any compiled languages like C\/C++ , I wanted to try and speed up some python code using cython, which is essentially a python -> C compiler, aimed at creating C extensions for python. Basically you code in a stricter version of python which compiles into C -> native code. \nhere's the problem, I don't know C, yet the cython documentation is aimed at people who obviously already know C (nothing is explained, only presented), and is of no help to me, I need to know if there are any good cython tutorials aimed at python programmers, or if I'm gonna have to learn C before I learn Cython.\nbear in mind I'm a competent python programmer, i would much rather learn cython from the perspective of the language I'm already good at, rather than learn a whole new language in order to learn cython.\n1) PLEASE don't recommend psyco \nedit: ANY information that will help understand the oficial cython docs is useful information","AnswerCount":7,"Available Count":4,"Score":0.0,"is_accepted":false,"ViewCount":8650,"Q_Id":1582105,"Users Score":0,"Answer":"About all the C that you really need to know is:\n\nC types are much faster than Python types (adding to C ints or doubles can be done in a single clock cycle) but less safe (they are not arbitrarily sized and may silently overflow).\nC function (cdef) calls are much faster than Python (def) function calls (but are less flexible). \n\nThis will get you most of the way there. If you want to eke out that last 10-20% speedup for most applications, there's no getting around knowing C, and how modern processes work (pointers, cache, ...).","Q_Score":20,"Tags":"python,c,cython","A_Id":2582450,"CreationDate":"2009-10-17T12:33:00.000","Title":"Noob-Ready Cython Tutorials","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},{"Question":"I know a bunch of scripting languages, (python, ruby, lua, php) but I don't know any compiled languages like C\/C++ , I wanted to try and speed up some python code using cython, which is essentially a python -> C compiler, aimed at creating C extensions for python. Basically you code in a stricter version of python which compiles into C -> native code. \nhere's the problem, I don't know C, yet the cython documentation is aimed at people who obviously already know C (nothing is explained, only presented), and is of no help to me, I need to know if there are any good cython tutorials aimed at python programmers, or if I'm gonna have to learn C before I learn Cython.\nbear in mind I'm a competent python programmer, i would much rather learn cython from the perspective of the language I'm already good at, rather than learn a whole new language in order to learn cython.\n1) PLEASE don't recommend psyco \nedit: ANY information that will help understand the oficial cython docs is useful information","AnswerCount":7,"Available Count":4,"Score":0.0285636566,"is_accepted":false,"ViewCount":8650,"Q_Id":1582105,"Users Score":1,"Answer":"You can do a lot of very useful things with Cython if you can answer the following C quiz...\n(1) What is a double? What is an int?\n(2) What does the word \"compile\" mean?\n(3) What is a header (.h) file?\nTo answer these questions you don't need to read a whole C book! ...maybe chapter 1.\nOnce you can pass that quiz, try again with the tutorial.\nWhat I usually do is start with pure python code, and add Cython elements bit by bit. In that situation, you can learn the Cython features bit by bit. For example I don't understand C strings, because so far I have not tried to cythonize code that involves strings. When I do, I will first look up how strings work in C, and then second look up how strings work in Cython.\nAgain, once you've gotten started with Cython, you will now and then run into some complication that requires learning slightly more C. And of course the more C you know, the more dextrous you will be with taking full advantage of Cython, not to mention troubleshooting if something goes wrong. But that shouldn't make you reluctant to start!","Q_Score":20,"Tags":"python,c,cython","A_Id":11103468,"CreationDate":"2009-10-17T12:33:00.000","Title":"Noob-Ready Cython Tutorials","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},{"Question":"I know a bunch of scripting languages, (python, ruby, lua, php) but I don't know any compiled languages like C\/C++ , I wanted to try and speed up some python code using cython, which is essentially a python -> C compiler, aimed at creating C extensions for python. Basically you code in a stricter version of python which compiles into C -> native code. \nhere's the problem, I don't know C, yet the cython documentation is aimed at people who obviously already know C (nothing is explained, only presented), and is of no help to me, I need to know if there are any good cython tutorials aimed at python programmers, or if I'm gonna have to learn C before I learn Cython.\nbear in mind I'm a competent python programmer, i would much rather learn cython from the perspective of the language I'm already good at, rather than learn a whole new language in order to learn cython.\n1) PLEASE don't recommend psyco \nedit: ANY information that will help understand the oficial cython docs is useful information","AnswerCount":7,"Available Count":4,"Score":0.0285636566,"is_accepted":false,"ViewCount":8650,"Q_Id":1582105,"Users Score":1,"Answer":"Cython does support concurrency (you can use native POSIX threads with c, that can be compiled in extent ion module) , you just need to be careful enough to not to modify any python objects when GIL is released and keep in mind the interpreter itself is not thread safe. You can also use multiprocessing with python to use more cores for parallelism which can in turn use your compiled cython extensions to speed up even more. But all in all you definitely have to know c programming model , static types etc","Q_Score":20,"Tags":"python,c,cython","A_Id":10643399,"CreationDate":"2009-10-17T12:33:00.000","Title":"Noob-Ready Cython Tutorials","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},{"Question":"A popular software development pattern seems to be:\n\nThrash out the logic and algorithms in Python.\nProfile to find out where the slow bits are.\nReplace those with C.\nShip code that is the best trade-off between high-level and speedy.\n\nI say popular simply because I've seen people talk about it as being a great idea.\nBut are there any large projects that have actually used this method? Preferably Free software projects so I can have a look and see how they did it - and maybe learn some best practices.","AnswerCount":4,"Available Count":3,"Score":0.1488850336,"is_accepted":false,"ViewCount":279,"Q_Id":1582718,"Users Score":3,"Answer":"There are lots of different ways that people approach development. \nSometimes people follow your three steps and discover that the slow bits are due to the external environment, therefore rewriting Python into C does not address the problem. That type of slowness can sometimes be solved on the system side, and sometimes it can be solved in Python by applying a different algorithm. For instance you can cache network responses so that you don't have to go to the network every time, or in SQL you can offload work into `stored procedures which run on the server and reduce the size of the result set. Generally, when you do have something that needs to be rewritten in C, the first thing to do is to look for a pre-existing library and just create a Python wrapper, if one does not already exist. Lots of people have been down these paths before you.\nOften step 1 is to thrash out the application architecture, suspect that there may be a performance issue in some area, then choose a C library (perhaps already wrapped for Python) and use that. Then step 2 simply confirms that there are no really big performance issues that need to be addressed.\nI would say that it is better for a team with one or more experienced developers to attempt to predict performance bottlenecks and mitigate them with pre-existing modules right from the beginning. If you are a beginner with python, then your 3-step process is perfectly valid, i.e. get into building and testing code, knowing that there is a profiler and the possibility of fast C modules if you need it. And then there is psyco, and the various tools for freezing an application into a binary executable.\nAn alternative approach to this, if you know that you will need to use some C or C++ modules, is to start from scratch writing the application in C but embedding Python to do most of the work. This works well for experienced C or C++ developers because they have a rough idea of the type of code that is tedious to do in C.","Q_Score":4,"Tags":"python,c,refactoring,profiling","A_Id":1582864,"CreationDate":"2009-10-17T17:24:00.000","Title":"Best practice for the Python-then-profile-then-C design pattern?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"A popular software development pattern seems to be:\n\nThrash out the logic and algorithms in Python.\nProfile to find out where the slow bits are.\nReplace those with C.\nShip code that is the best trade-off between high-level and speedy.\n\nI say popular simply because I've seen people talk about it as being a great idea.\nBut are there any large projects that have actually used this method? Preferably Free software projects so I can have a look and see how they did it - and maybe learn some best practices.","AnswerCount":4,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":279,"Q_Id":1582718,"Users Score":0,"Answer":"Step 3 is wrong. In the modern world, more than half the time \"the slow bits\" are I\/O or network bound, or limited by some other resource outside the process. Rewriting them in anything is only going to introduce bugs.","Q_Score":4,"Tags":"python,c,refactoring,profiling","A_Id":1582784,"CreationDate":"2009-10-17T17:24:00.000","Title":"Best practice for the Python-then-profile-then-C design pattern?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"A popular software development pattern seems to be:\n\nThrash out the logic and algorithms in Python.\nProfile to find out where the slow bits are.\nReplace those with C.\nShip code that is the best trade-off between high-level and speedy.\n\nI say popular simply because I've seen people talk about it as being a great idea.\nBut are there any large projects that have actually used this method? Preferably Free software projects so I can have a look and see how they did it - and maybe learn some best practices.","AnswerCount":4,"Available Count":3,"Score":0.0996679946,"is_accepted":false,"ViewCount":279,"Q_Id":1582718,"Users Score":2,"Answer":"I also thought that way when I started using Python\nI've done step 3 twice (that I can recall) in 12 years. Not often enough to call it a design pattern. Usually it's enough to wrap an existing C library. Usually someone else has already written the wrapper.","Q_Score":4,"Tags":"python,c,refactoring,profiling","A_Id":1583268,"CreationDate":"2009-10-17T17:24:00.000","Title":"Best practice for the Python-then-profile-then-C design pattern?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"We've got a python library that we're developing. During development, I'd like to use some parts of that library in testing the newer versions of it. That is, use the stable code in order to test the development code. Is there any way of doing this in python?\nEdit: To be more specific, we've got a library (LibA) that has many useful things. Also, we've got a testing library that uses LibA in order to provide some testing facilities (LibT). We want to test LibA using LibT, but because LibT depends on LibA, we'd rather it to use a stable version of LibA, while testing LibT (because we will change LibT to work with newer LibA only once tests pass etc.). So, when running unit-tests, LibA-dev tests will use LibT code that depends on LibA-stable. \nOne idea we've come up with is calling the stable code using RPyC on a different process, but it's tricky to implement in an air-tight way (making sure it dies properly etc, and allowing multiple instances to execute at the same time on the same computer etc.).\nThanks","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":680,"Q_Id":1587776,"Users Score":1,"Answer":"\"We want to test LibA using LibT, but because LibT depends on LibA, we'd rather it to use a stable version of LibA, while testing LibT \"\nIt doesn't make sense to use T + A to test A. What does make sense is the following.\nLibA is really two things mashed together: A1 and A2.\nT depends on A1.\nWhat's really happening is that you're upgrading and testing A2, using T and A1. \nIf you decompose LibA into the parts that T requires and the other parts, you may be able to break this circular dependency.","Q_Score":5,"Tags":"python,testing,dependencies,circular-dependency","A_Id":1588192,"CreationDate":"2009-10-19T09:42:00.000","Title":"Using different versions of a python library in the same process","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"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},{"Question":"Right now I'm running 50 PHP (in CLI mode) individual workers (processes) per machine that are waiting to receive their workload (job). For example, the job of resizing an image. In workload they receive the image (binary data) and the desired size. The worker does it's work and returns the resized image back. Then it waits for more jobs (it loops in a smart way). I'm presuming that I have the same executable, libraries and classes loaded and instantiated 50 times. Am I correct? Because this does not sound very effective.\nWhat I'd like to have now is one process that handles all this work and being able to use all available CPU cores while having everything loaded only once (to be more efficient). I presume a new thread would be started for each job and after it finishes, the thread would stop. More jobs would be accepted if there are less than 50 threads doing the work. If all 50 threads are busy, no additional jobs are accepted.\nI am using a lot of libraries (for Memcached, Redis, MogileFS, ...) to have access to all the various components that the system uses and Python is pretty much the only language apart from PHP that has support for all of them.\nCan Python do what I want and will it be faster and more efficient that the current PHP solution?","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":958,"Q_Id":1591555,"Users Score":1,"Answer":"If you are on a sane operating system then shared libraries should only be loaded once and shared among all processes using them. Memory for data structures and connection handles will obviously be duplicated, but the overhead of stopping and starting the systems may be greater than keeping things up while idle. If you are using something like gearman it might make sense to let several workers stay up even if idle and then have a persistent monitoring process that will start new workers if all the current workers are busy up until a threshold such as the number of available CPUs. That process could then kill workers in a LIFO manner after they have been idle for some period of time.","Q_Score":3,"Tags":"php,python,multithreading","A_Id":1591593,"CreationDate":"2009-10-19T22:47:00.000","Title":"From PHP workers to Python threads","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Right now I'm running 50 PHP (in CLI mode) individual workers (processes) per machine that are waiting to receive their workload (job). For example, the job of resizing an image. In workload they receive the image (binary data) and the desired size. The worker does it's work and returns the resized image back. Then it waits for more jobs (it loops in a smart way). I'm presuming that I have the same executable, libraries and classes loaded and instantiated 50 times. Am I correct? Because this does not sound very effective.\nWhat I'd like to have now is one process that handles all this work and being able to use all available CPU cores while having everything loaded only once (to be more efficient). I presume a new thread would be started for each job and after it finishes, the thread would stop. More jobs would be accepted if there are less than 50 threads doing the work. If all 50 threads are busy, no additional jobs are accepted.\nI am using a lot of libraries (for Memcached, Redis, MogileFS, ...) to have access to all the various components that the system uses and Python is pretty much the only language apart from PHP that has support for all of them.\nCan Python do what I want and will it be faster and more efficient that the current PHP solution?","AnswerCount":3,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":958,"Q_Id":1591555,"Users Score":4,"Answer":"Most probably - yes. But don't assume you have to do multithreading. Have a look at the multiprocessing module. It already has an implementation of a Pool included, which is what you could use. And it basically solves the GIL problem (multithreading can run only 1 \"standard python code\" at any time - that's a very simplified explanation).\nIt will still fork a process per job, but in a different way than starting it all over again. All the initialisations done- and libraries loaded before entering the worker process will be inherited in a copy-on-write way. You won't do more initialisations than necessary and you will not waste memory for the same libarary\/class if you didn't actually make it different from the pre-pool state.\nSo yes - looking only at this part, python will be wasting less resources and will use a \"nicer\" worker-pool model. Whether it will really be faster \/ less CPU-abusing, is hard to tell without testing, or at least looking at the code. Try it yourself.\nAdded: If you're worried about memory usage, python may also help you a bit, since it has a \"proper\" garbage collector, while in php GC is a not a priority and not that good (and for a good reason too).","Q_Score":3,"Tags":"php,python,multithreading","A_Id":1591616,"CreationDate":"2009-10-19T22:47:00.000","Title":"From PHP workers to Python threads","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Usually I use shell command time. My purpose is to test if data is small, medium, large or very large set, how much time and memory usage will be.\nAny tools for Linux or just Python to do this?","AnswerCount":12,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":101454,"Q_Id":1593019,"Users Score":12,"Answer":"I usually do a quick time .\/script.py to see how long it takes. That does not show you the memory though, at least not as a default. You can use \/usr\/bin\/time -v .\/script.py to get a lot of information, including memory usage.","Q_Score":105,"Tags":"python,unix,shell,benchmarking","A_Id":5544739,"CreationDate":"2009-10-20T07:40:00.000","Title":"Is there any simple way to benchmark 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},{"Question":"I'm using a config file to get the info for my database. It always gets the hostname and then figures out what database options to use from this config file. I want to be able to tell if I'm inside a unittest here and use the in memory sqlite database instead. Is there a way to tell at that point whether I'm inside a unittest, or will I have to find a different way?","AnswerCount":5,"Available Count":2,"Score":0.0399786803,"is_accepted":false,"ViewCount":108,"Q_Id":1601308,"Users Score":1,"Answer":"Use some sort of database configuration and configure which database to use, and configure the in-memory database during unit tests.","Q_Score":1,"Tags":"python,unit-testing,sqlite","A_Id":1601338,"CreationDate":"2009-10-21T14:43:00.000","Title":"Is there a way to tell whether a function is getting executed in a unittest?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I'm using a config file to get the info for my database. It always gets the hostname and then figures out what database options to use from this config file. I want to be able to tell if I'm inside a unittest here and use the in memory sqlite database instead. Is there a way to tell at that point whether I'm inside a unittest, or will I have to find a different way?","AnswerCount":5,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":108,"Q_Id":1601308,"Users Score":0,"Answer":"This is kind of brute force but it works. Have an environmental variable UNIT_TEST that your code checks, and set it inside your unit test driver.","Q_Score":1,"Tags":"python,unit-testing,sqlite","A_Id":1601336,"CreationDate":"2009-10-21T14:43:00.000","Title":"Is there a way to tell whether a function is getting executed in a unittest?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I have a website that right now, runs by creating static html pages from a cron job that runs nightly. \nI'd like to add some search and filtering features using a CGI type script, but my script will have enough of a startup time (maybe a few seconds?) that I'd like it to stay resident and serve multiple requests.\nThis is a side-project I'm doing for fun, and it's not going to be super complex. I don't mind using something like Pylons, but I don't feel like I need or want an ORM layer.\nWhat would be a reasonable approach here?\nEDIT: I wanted to point out that for the load I'm expecting and processing I need to do on a request, I'm confident that a single python script in a single process could handle all requests without any slowdowns, especially since my dataset would be memory-resident.","AnswerCount":2,"Available Count":1,"Score":-0.0996679946,"is_accepted":false,"ViewCount":602,"Q_Id":1602516,"Users Score":-1,"Answer":"maybe you should direct your search towards inter process commmunication and make a search process that returns the results to the web server. This search process will be running all the time assuming you have your own server.","Q_Score":2,"Tags":"python,frameworks,cgi,pylons","A_Id":1603021,"CreationDate":"2009-10-21T18:03:00.000","Title":"I want to create a \"CGI script\" in python that stays resident in memory and services multiple requests","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I have written a Python script that checks a certain e-mail address and passes new e-mails to an external program. How can I get this script to execute 24\/7, such as turning it into daemon or service in Linux. Would I also need a loop that never ends in the program, or can it be done by just having the code re executed multiple times?","AnswerCount":16,"Available Count":4,"Score":1.0,"is_accepted":false,"ViewCount":365270,"Q_Id":1603109,"Users Score":11,"Answer":"how about using $nohup command on linux?\nI use it for running my commands on my Bluehost server.\nPlease advice if I am wrong.","Q_Score":213,"Tags":"python,linux,scripting,daemons","A_Id":8956634,"CreationDate":"2009-10-21T19:36:00.000","Title":"How to make a Python script run like a service or daemon 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},{"Question":"I have written a Python script that checks a certain e-mail address and passes new e-mails to an external program. How can I get this script to execute 24\/7, such as turning it into daemon or service in Linux. Would I also need a loop that never ends in the program, or can it be done by just having the code re executed multiple times?","AnswerCount":16,"Available Count":4,"Score":1.0,"is_accepted":false,"ViewCount":365270,"Q_Id":1603109,"Users Score":7,"Answer":"If you are using terminal(ssh or something) and you want to keep a long-time script working after you log out from the terminal, you can try this:\nscreen\napt-get install screen\ncreate a virtual terminal inside( namely abc): screen -dmS abc\nnow we connect to abc: screen -r abc\nSo, now we can run python script: python keep_sending_mails.py\nfrom now on, you can directly close your terminal, however, the python script will keep running rather than being shut down\n\nSince this keep_sending_mails.py's PID is a child process of the virtual screen rather than the\n terminal(ssh)\n\nIf you want to go back check your script running status, you can use screen -r abc again","Q_Score":213,"Tags":"python,linux,scripting,daemons","A_Id":35008431,"CreationDate":"2009-10-21T19:36:00.000","Title":"How to make a Python script run like a service or daemon 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},{"Question":"I have written a Python script that checks a certain e-mail address and passes new e-mails to an external program. How can I get this script to execute 24\/7, such as turning it into daemon or service in Linux. Would I also need a loop that never ends in the program, or can it be done by just having the code re executed multiple times?","AnswerCount":16,"Available Count":4,"Score":0.012499349,"is_accepted":false,"ViewCount":365270,"Q_Id":1603109,"Users Score":1,"Answer":"Use whatever service manager your system offers - for example under Ubuntu use upstart. This will handle all the details for you such as start on boot, restart on crash, etc.","Q_Score":213,"Tags":"python,linux,scripting,daemons","A_Id":20908406,"CreationDate":"2009-10-21T19:36:00.000","Title":"How to make a Python script run like a service or daemon 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},{"Question":"I have written a Python script that checks a certain e-mail address and passes new e-mails to an external program. How can I get this script to execute 24\/7, such as turning it into daemon or service in Linux. Would I also need a loop that never ends in the program, or can it be done by just having the code re executed multiple times?","AnswerCount":16,"Available Count":4,"Score":1.0,"is_accepted":false,"ViewCount":365270,"Q_Id":1603109,"Users Score":12,"Answer":"cron is clearly a great choice for many purposes. However it doesn't create a service or daemon as you requested in the OP. cron just runs jobs periodically (meaning the job starts and stops), and no more often than once \/ minute. There are issues with cron -- for example, if a prior instance of your script is still running the next time the cron schedule comes around and launches a new instance, is that OK? cron doesn't handle dependencies; it just tries to start a job when the schedule says to.\nIf you find a situation where you truly need a daemon (a process that never stops running), take a look at supervisord. It provides a simple way to wrapper a normal, non-daemonized script or program and make it operate like a daemon. This is a much better way than creating a native Python daemon.","Q_Score":213,"Tags":"python,linux,scripting,daemons","A_Id":19515492,"CreationDate":"2009-10-21T19:36:00.000","Title":"How to make a Python script run like a service or daemon 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},{"Question":"I've been using Python's built-in cProfile tool with some pretty good success. But I'd like to be able to access more information such as how long I'm waiting for I\/O (and what kind of I\/O I'm waiting on) or how many cache misses I have. Are there any Linux tools to help with this beyond your basic time command?","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":1160,"Q_Id":1607641,"Users Score":2,"Answer":"I'm not sure if python will provide the low level information you are looking for. You might want to look at oprofile and latencytop though.","Q_Score":1,"Tags":"python,linux,profiling","A_Id":1608157,"CreationDate":"2009-10-22T14:29:00.000","Title":"What profiling tools exist for Python on Linux beyond the ones included in the standard 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":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I would like to redirect stderr and stdout to files when run inside of pythonw. How can I determine whether a script is running in pythonw or in python?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1325,"Q_Id":1611543,"Users Score":5,"Answer":"sys.executable -- \"A string giving the name of the executable binary for the Python interpreter, on systems where this makes sense.\"","Q_Score":2,"Tags":"python,pythonw","A_Id":1611558,"CreationDate":"2009-10-23T05:31:00.000","Title":"Determine if a script is running in pythonw?","Data Science and Machine Learning":0,"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},{"Question":"Does anyone know of a automated GUI testing package for that works with PyQT besides Squish? Nothing against Squish I am just looking for other packages. It would be cool if there were an open source package. I am doing my testing under Linux.","AnswerCount":4,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":3768,"Q_Id":1616228,"Users Score":4,"Answer":"It looks like PyQT4 includes a QtTest object that can be used for unit testing.","Q_Score":18,"Tags":"python,testing,pyqt","A_Id":1829332,"CreationDate":"2009-10-23T22:19:00.000","Title":"PyQT GUI Testing","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},{"Question":"I have a C++ app that uses Python to load some scripts. It calls some functions in the scripts, and everything works fine until the app exits and calls Py_Finalize. Then it displays the following: (GetName is a function in one of the scripts)\nException AttributeError: \"'module' object has no attribute 'GetName'\" in 'garbage collection' ignored\nFatal Python error: unexpected exception during garbage collection\nThen the app crashes.\nI'm using Python 3.1 on Windows. Any advice would be appreciated.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1194,"Q_Id":1619908,"Users Score":4,"Answer":"From the docs to Py_Finalize():\n\nBugs and caveats: The destruction of\n modules and objects in modules is done\n in random order; this may cause\n destructors (__del__() methods) to\n fail when they depend on other objects\n (even functions) or modules.\n Dynamically loaded extension modules\n loaded by Python are not unloaded.\n Small amounts of memory allocated by\n the Python interpreter may not be\n freed (if you find a leak, please\n report it). Memory tied up in circular\n references between objects is not\n freed. Some memory allocated by\n extension modules may not be freed.\n Some extensions may not work properly\n if their initialization routine is\n called more than once; this can happen\n if an application calls\n Py_Initialize() and Py_Finalize() more\n than once.\n\nMost likely a __del__ contains a call to .GetName(), but that module has already been destroyed by the time __del__ is called.","Q_Score":2,"Tags":"python,exception,attributes","A_Id":1619944,"CreationDate":"2009-10-25T03:24:00.000","Title":"What is causing this Python exception?","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},{"Question":"I have a Python script that outputs something every second or two, but takes a long while to finish completely. I want to set up a website such that someone can directly invoke the script, and the output is sent to the screen while the script is running. \nI don't want the user to wait until the script finishes completely, because then all the output is displayed at once. I also tried that, and the connection always times out.\nI don't know what this process is called, what terms I'm looking for, and what I need to use. CGI? Ajax? Need some serious guidance here, thanks!\nIf it matters, I plan to use Nginx as the webserver.","AnswerCount":5,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":5553,"Q_Id":1621430,"Users Score":0,"Answer":"As suggested by a few of the others you can use a keep alive connection and instead of \"return\" statements use yield statements and instead of \"print\" statements also use yield statements. This will basically show everything that happens in the python script onto the website page.\nAfter extensive searching and testing I would advise nginx as a reverse proxy with gevent & bottle as the backend which allows for peace of mind as nginx will not serve up the python source file ever.","Q_Score":3,"Tags":"python,ajax,cgi,web-applications,fastcgi","A_Id":11067328,"CreationDate":"2009-10-25T17:10:00.000","Title":"How do I display real-time python script output on a 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},{"Question":"I have an email that I'm reading with the Python email lib that I need to modify the attachments of. The email Message class has the \"attach\" method, but does not have anything like \"detach\". How can I remove an attachment from a multipart message? If possible, I want to do this without recreating the message from scratch.\nEssentially I want to:\n\nLoad the email\nRemove the mime attachments\nAdd a new attachment","AnswerCount":3,"Available Count":1,"Score":0.2605204458,"is_accepted":false,"ViewCount":6827,"Q_Id":1626403,"Users Score":4,"Answer":"The way I've figured out to do it is:\n\nSet the payload to an empty list with set_payload\nCreate the payload, and attach to the message.","Q_Score":5,"Tags":"python,email,mime","A_Id":1626650,"CreationDate":"2009-10-26T18:14:00.000","Title":"Python email lib - How to remove attachment from existing 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},{"Question":"I'm now thinking, is it possible to integrate Python, Perl and C\/C++ and also doing a GUI application with this very nice mix of languages?","AnswerCount":5,"Available Count":3,"Score":0.1973753202,"is_accepted":false,"ViewCount":735,"Q_Id":1628001,"Users Score":5,"Answer":"Anything is \"possible\", but whether it is necessary or beneficial is debatable and highly depends on your requirements. Don't mix if you don't need to. Use the language that best fits the domain or target requirements. \nI can't think of a scenario where one needs to mix Python and Perl as their domain is largely the same.\nUsing C\/C++ can be beneficial in cases where you need hardcore system integration or specialized machine dependent services. Or when you need to extend Python or Perl itself (both are written in C\/C++).\nEDIT: if you want to do a GUI application, it is probably easier to choose a language that fits the OS you want your GUI to run in. I.e. something like (but not limited to) C# for Windows, Objective-C for iPhone or Mac, Qt + C++ for Linux etc.","Q_Score":1,"Tags":"c++,python,c,perl,integration","A_Id":1628011,"CreationDate":"2009-10-27T00:04:00.000","Title":"Python, Perl And C\/C++ With GUI","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},{"Question":"I'm now thinking, is it possible to integrate Python, Perl and C\/C++ and also doing a GUI application with this very nice mix of languages?","AnswerCount":5,"Available Count":3,"Score":0.0399786803,"is_accepted":false,"ViewCount":735,"Q_Id":1628001,"Users Score":1,"Answer":"Everything is possible - but why add two and a half more levels of complexity?","Q_Score":1,"Tags":"c++,python,c,perl,integration","A_Id":1628012,"CreationDate":"2009-10-27T00:04:00.000","Title":"Python, Perl And C\/C++ With GUI","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},{"Question":"I'm now thinking, is it possible to integrate Python, Perl and C\/C++ and also doing a GUI application with this very nice mix of languages?","AnswerCount":5,"Available Count":3,"Score":0.0399786803,"is_accepted":false,"ViewCount":735,"Q_Id":1628001,"Users Score":1,"Answer":"Python & Perl? together?\nI can only think of an editor.","Q_Score":1,"Tags":"c++,python,c,perl,integration","A_Id":1628013,"CreationDate":"2009-10-27T00:04:00.000","Title":"Python, Perl And C\/C++ With GUI","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},{"Question":"Is there any reason to favor Python or Java over the other for developing on Android phones, other than the usual Python v. Java issues?","AnswerCount":3,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":4643,"Q_Id":1640806,"Users Score":11,"Answer":"Java is \"more native\" on the Android platform; Python is coming after and striving to get parity but not quite there yet AFAIK. Roughly the reverse situation wrt App Engine, where Python's been around for a year longer than Java and so is still more mature and complete (even though Java's catching up).\nSo, in any situation where you'd be at all undecided between Java and Python if the deployment was due to happen on some general purpose platform such as Linux, I think the maturity and completeness arguments could sway you towards Python for deployment on App Engine, and towards Java for deployment on Android.","Q_Score":10,"Tags":"java,python,android","A_Id":1641125,"CreationDate":"2009-10-28T23:30:00.000","Title":"Android: Java v. 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},{"Question":"Is there any reason to favor Python or Java over the other for developing on Android phones, other than the usual Python v. Java issues?","AnswerCount":3,"Available Count":2,"Score":0.1325487884,"is_accepted":false,"ViewCount":4643,"Q_Id":1640806,"Users Score":2,"Answer":"On the mobile platform performance and memory usage are much more critical than desktop or server. The JVM that runs on Android is highly optimized for the mobile platform. Based on the links I have seen about Python on Android none of them seem to have an optimized VM for mobile platform.","Q_Score":10,"Tags":"java,python,android","A_Id":1641263,"CreationDate":"2009-10-28T23:30:00.000","Title":"Android: Java v. 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},{"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},{"Question":"I have mod_python installed on a debian box with python 2.4 and 2.6 installed. I want mod_python to use 2.6 but it is finding 2.4. How can set it to use the other version.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":145,"Q_Id":1646017,"Users Score":1,"Answer":"The version of Python used is set when mod_python is compiled. If you need to use a version other than the default, you'll need to recompile it, or you may be able to find a different package from the repository.","Q_Score":1,"Tags":"python,apache,mod-python","A_Id":1646473,"CreationDate":"2009-10-29T19:29:00.000","Title":"Setting mod_python's interperter","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm using Python (under Google App Engine), and I have some RSA private keys that I need to export in PKCS#12 format. Is there anything out there that will assist me with this? I'm using PyCrypto\/KeyCzar, and I've figured out how to import\/export RSA keys in PKCS8 format, but I really need it in PKCS12.\nCan anybody point me in the right direction? If it helps, the reason I need them in PKCS12 format is so that I can import them on the iPhone, which seems to only allow key-import in that format.","AnswerCount":3,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":2305,"Q_Id":1647568,"Users Score":2,"Answer":"If you can handle some ASN.1 generation, you can relatively easily convert a PKCS#8-file into a PKCS#12-file. A PKCS#12-file is basically a wrapper around a PKCS#8 and a certificate, so to make a PKCS#12-file, you just have to add some additional data around your PKCS#8-file and your certificate.\nUsually a PKCS#12-file will contain the certificate(s) in an encrypted structure, but all compliant parsers should be able to read it from an unencrypted structure. Also, PKCS#12-files will usually contain a MacData-structure for integrity-check, but this is optional and a compliant parser should work fine without it.","Q_Score":2,"Tags":"python,google-app-engine,cryptography,rsa,pkcs#12","A_Id":1648617,"CreationDate":"2009-10-30T01:35:00.000","Title":"How to encode an RSA key using PKCS12 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},{"Question":"I am looking for a solution to programmatically return all available serial ports with python.\nAt the moment I am entering ls \/dev\/tty.* or ls \/dev\/cu.* into the terminal to list ports and hardcoding them into the pyserial class.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":2216,"Q_Id":1659283,"Users Score":1,"Answer":"What about just doing the os.listdir \/ glob equivalent of ls to perform the equivalent of that ls? Of course it's not going to be the case that some usable device is connected to each such special file (but, that holds for ls as well;-), but for \"finding all serial ports\", as you ask in your Q's title, I'm not sure how else you might proceed.","Q_Score":3,"Tags":"python,macos,serial-port","A_Id":1659294,"CreationDate":"2009-11-02T03:16:00.000","Title":"MacPython: programmatically finding all serial ports","Data Science and Machine Learning":0,"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},{"Question":"If you have to choose a scripting language, why would you choose Python?","AnswerCount":8,"Available Count":6,"Score":0.0,"is_accepted":false,"ViewCount":11442,"Q_Id":1659559,"Users Score":0,"Answer":"I would try a number of \"scripting\" languages (as well as some languages with good static type inference), and then select the language(s) that best fit the problem.\nThis may be for a number of reasons including, but not limited to: Runtime targets and performance (as dictated by functional requirements), library support (don't re-invent the wheel all the time), existing tool support, existing integration support (if X supports Y, is it real feasible to get X to support Z just to use Z?), and most important to a subjective question: personal choice and zealot fanaticism :)\nThe term \"scripting language\" is absolutely horrid -- unless perhaps you really DO mean SH or MIRC \"script\". The phrase \"dynamically typed language\" is a much better qualifier.","Q_Score":3,"Tags":"python,scripting","A_Id":1659616,"CreationDate":"2009-11-02T05:33:00.000","Title":"What makes Python a good scripting 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},{"Question":"If you have to choose a scripting language, why would you choose Python?","AnswerCount":8,"Available Count":6,"Score":0.049958375,"is_accepted":false,"ViewCount":11442,"Q_Id":1659559,"Users Score":2,"Answer":"I think it depends on your definition of scripting language. There are (at least) two camps. One is that scripting language should be embeddable, so the core should be small (like Lua or Tcl). The second camp is scripting for system administration, and Perl is definitely in this camp. \nPython is a general programming language, not particularly in either camp (but also not unsuitable), probably most useful for writing small or medium sized programs.","Q_Score":3,"Tags":"python,scripting","A_Id":1659629,"CreationDate":"2009-11-02T05:33:00.000","Title":"What makes Python a good scripting 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},{"Question":"If you have to choose a scripting language, why would you choose Python?","AnswerCount":8,"Available Count":6,"Score":0.0,"is_accepted":false,"ViewCount":11442,"Q_Id":1659559,"Users Score":0,"Answer":"I haven't programmed in python before but my guess would be the libraries available and the size of the userbase.","Q_Score":3,"Tags":"python,scripting","A_Id":1659630,"CreationDate":"2009-11-02T05:33:00.000","Title":"What makes Python a good scripting 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},{"Question":"If you have to choose a scripting language, why would you choose Python?","AnswerCount":8,"Available Count":6,"Score":0.0,"is_accepted":false,"ViewCount":11442,"Q_Id":1659559,"Users Score":0,"Answer":"It's very intuitive, has a ton of libraries, helps you whip up a script VERY FAST. You can use it for small projects or big projects and can compile into an EXE for windows, an APP for mac or into a cross platform application.\nI has possibly the cleanest syntax of any language I have seen to date and can do everything from adding numbers to system calls to reading various different types of files. Hell, you can even do web programming with it.\nI see no reason why I would advise against python... ever.","Q_Score":3,"Tags":"python,scripting","A_Id":1698597,"CreationDate":"2009-11-02T05:33:00.000","Title":"What makes Python a good scripting 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},{"Question":"If you have to choose a scripting language, why would you choose Python?","AnswerCount":8,"Available Count":6,"Score":1.0,"is_accepted":false,"ViewCount":11442,"Q_Id":1659559,"Users Score":11,"Answer":"Depends on what you mean by \"scripting language\". If you mean I'm going to be extensively typing it in at a shell prompt, I want the mysterious but utter conciseness of Bash or zsh; if you mean I'm going to have to embed it in 2000 apps in each of which it will typically be used for \"customization\" scripts of 2 or 3 lines, I probably want the minimalist simplicity of Lua (I may not like programming in Lua all that much, but 2-3 lines is indeed \"scripting\" more than \"programming\", and the near-zero cost of embedding Lua in anything will then dominate).\nPython, like Perl or Ruby, is mostly used to write MUCH more substantial \"scripts\" (impossible to distinguish from \"programs\", except maybe by total bigots;-) -- in which case, very different considerations apply wrt \"real\" scripting languages such as bash or zsh, or lua or tcl for a different definition of \"scripting language\". Basically, if what you want is a dynamically (but strongly) typed language, with full capacity to scale up to very large software systems, and yet quite good at \"playing with others\"... then you surely have a particularly weird definition of \"scripting\", my friend!-) But that's the arena where Python, Ruby and Perl mostly play -- and where one could debate one against the other (but any one of them would crush any other popular language I know -- yeah, I've known and loved and used rexx, scheme, Smalltalk, and many many others, but none could hold a candle to the Big Three I just mentioned in this arena!-).\nBut unless you clarify your terminology, \"scripting language\" remains an empty, meaning-free sound, and any debate surrounding it utterly useless and void of significance.","Q_Score":3,"Tags":"python,scripting","A_Id":1659617,"CreationDate":"2009-11-02T05:33:00.000","Title":"What makes Python a good scripting 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},{"Question":"If you have to choose a scripting language, why would you choose Python?","AnswerCount":8,"Available Count":6,"Score":1.2,"is_accepted":true,"ViewCount":11442,"Q_Id":1659559,"Users Score":20,"Answer":"Because it has clean and agile syntax, it's fast, well documented, well connected to C, has a lot of libraries, it's intuitive, and it's not perl.","Q_Score":3,"Tags":"python,scripting","A_Id":1659564,"CreationDate":"2009-11-02T05:33:00.000","Title":"What makes Python a good scripting 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},{"Question":"What is that needs to be coded in Python instead of C\/C++ etc? I know its advantages etc. I want to know why exactly makes Python The language for people in this industry?","AnswerCount":7,"Available Count":4,"Score":0.1137907297,"is_accepted":false,"ViewCount":1359,"Q_Id":1659620,"Users Score":4,"Answer":"A few other points I've not seen in the existing answers:\n\nit's free\nit's fast [enough]\nit runs on every platform I know of (AIX, HPUX, Linux, Mac OS X, Windows..)\nquick to learn\nlarge, powerful libraries \n\n\nnumeric\ngraphical\netc\n\nsimple, consistent syntax\nthe existing user-base is large\nbecause it's easy-to-learn, you don't have to be a \"programmer\" to use it","Q_Score":1,"Tags":"python,oop,animation","A_Id":1659774,"CreationDate":"2009-11-02T05:55:00.000","Title":"Why is Python a favourite among people working in animation industry?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"What is that needs to be coded in Python instead of C\/C++ etc? I know its advantages etc. I want to know why exactly makes Python The language for people in this industry?","AnswerCount":7,"Available Count":4,"Score":0.0855049882,"is_accepted":false,"ViewCount":1359,"Q_Id":1659620,"Users Score":3,"Answer":"Because Python is what Basic should have been ;)\nIts a language designed from the beginning to be used by non-programmers, but with the power to be truly used as a general purpose programming language.","Q_Score":1,"Tags":"python,oop,animation","A_Id":1659654,"CreationDate":"2009-11-02T05:55:00.000","Title":"Why is Python a favourite among people working in animation industry?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"What is that needs to be coded in Python instead of C\/C++ etc? I know its advantages etc. I want to know why exactly makes Python The language for people in this industry?","AnswerCount":7,"Available Count":4,"Score":0.057080742,"is_accepted":false,"ViewCount":1359,"Q_Id":1659620,"Users Score":2,"Answer":"Aside from the fact that it's already in use, the main advantage is that it's quick to use. Java, C, and friends almost all require tedious coding that merely restates what you already know. Python is designed to be quick to write, quick to modify, and as general as possible.\nAs an example, functions in java require you to declare the type of each of the input variables. In python, as long as you pass input variables that work with the function, it's valid. This makes your code extremely flexible. You don't waste time declaring variables as one type or another, you just use them.\nSome people will tell you that java produces code that is \"more correct\", but in animation and graphics, producing code that works in as short a time as possible is usually the goal.","Q_Score":1,"Tags":"python,oop,animation","A_Id":1659703,"CreationDate":"2009-11-02T05:55:00.000","Title":"Why is Python a favourite among people working in animation industry?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"What is that needs to be coded in Python instead of C\/C++ etc? I know its advantages etc. I want to know why exactly makes Python The language for people in this industry?","AnswerCount":7,"Available Count":4,"Score":0.0285636566,"is_accepted":false,"ViewCount":1359,"Q_Id":1659620,"Users Score":1,"Answer":"My guess is that it is the tool for the job because it is easy to prototype extra features.","Q_Score":1,"Tags":"python,oop,animation","A_Id":1659637,"CreationDate":"2009-11-02T05:55:00.000","Title":"Why is Python a favourite among people working in animation industry?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am interested in your opinions on unittesting code that uses Corba to communicate with a server.\nWould you mock the Corba objects? In Python that's sort of a pain in the ass because all the methods of Corba objects are loaded dynamically. So you're basically stuck with \"mock anything\".\nThanks!\nNote:\nI believe I have not made myself clear enough, so I'll try to give a somewhat more concrete example:\nA web application needs to display a page containing data received from the server. It obtains the data by calling server_pagetable.getData() and then formats the data, converts them to the correct python types (because Corba does not have e.g. a date type etc.) and finally creates the HTML code to be displayed.\nAnd this is what I would like to test - the methods that receive the data and do all the transformations and finally create the HTML code.\nI believe the most straightforward decision is to mock the Corba objects as they essentially comprise both the networking and db functionality (which ought not to be tested in unit tests). \nIt's just that this is quite a lot of \"extra work\" to do - mocking all the Corba objects (there is a User object, a server session object, the pagetable object, an admin object etc.). Maybe it's just because I'm stuck with Corba and therefore I have to reflect the object hierarchy dictated by the server with mocks. On the other hand, it could be that there is some cool elegant solution to testing code using Corba that just did not cross my mind.","AnswerCount":3,"Available Count":3,"Score":1.2,"is_accepted":true,"ViewCount":625,"Q_Id":1660049,"Users Score":3,"Answer":"Don't try to unittest Corba. Assume that Corba works. Unittest your own code. This means:\n\nCreate a unit test which checks that you correctly set up Corba and that you can invoke a single method and read a property. If that works, all other methods and properties will work, too.\nAfter that, test that all the exposed objects work correctly. You don't need Corba for this.","Q_Score":2,"Tags":"python,unit-testing,mocking,corba","A_Id":1660185,"CreationDate":"2009-11-02T08:38:00.000","Title":"Unittesting Corba 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},{"Question":"I am interested in your opinions on unittesting code that uses Corba to communicate with a server.\nWould you mock the Corba objects? In Python that's sort of a pain in the ass because all the methods of Corba objects are loaded dynamically. So you're basically stuck with \"mock anything\".\nThanks!\nNote:\nI believe I have not made myself clear enough, so I'll try to give a somewhat more concrete example:\nA web application needs to display a page containing data received from the server. It obtains the data by calling server_pagetable.getData() and then formats the data, converts them to the correct python types (because Corba does not have e.g. a date type etc.) and finally creates the HTML code to be displayed.\nAnd this is what I would like to test - the methods that receive the data and do all the transformations and finally create the HTML code.\nI believe the most straightforward decision is to mock the Corba objects as they essentially comprise both the networking and db functionality (which ought not to be tested in unit tests). \nIt's just that this is quite a lot of \"extra work\" to do - mocking all the Corba objects (there is a User object, a server session object, the pagetable object, an admin object etc.). Maybe it's just because I'm stuck with Corba and therefore I have to reflect the object hierarchy dictated by the server with mocks. On the other hand, it could be that there is some cool elegant solution to testing code using Corba that just did not cross my mind.","AnswerCount":3,"Available Count":3,"Score":0.0665680765,"is_accepted":false,"ViewCount":625,"Q_Id":1660049,"Users Score":1,"Answer":"I would set up a test server, and do live tests on that. Unittesting can be tricky with network stuff, so it's best to keep it as real as possible. Any mocking would be done on the test server, for instance if you need to communicate to three different servers, it could be set up with three different IP addresses to play the role of all three servers.","Q_Score":2,"Tags":"python,unit-testing,mocking,corba","A_Id":1660187,"CreationDate":"2009-11-02T08:38:00.000","Title":"Unittesting Corba 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},{"Question":"I am interested in your opinions on unittesting code that uses Corba to communicate with a server.\nWould you mock the Corba objects? In Python that's sort of a pain in the ass because all the methods of Corba objects are loaded dynamically. So you're basically stuck with \"mock anything\".\nThanks!\nNote:\nI believe I have not made myself clear enough, so I'll try to give a somewhat more concrete example:\nA web application needs to display a page containing data received from the server. It obtains the data by calling server_pagetable.getData() and then formats the data, converts them to the correct python types (because Corba does not have e.g. a date type etc.) and finally creates the HTML code to be displayed.\nAnd this is what I would like to test - the methods that receive the data and do all the transformations and finally create the HTML code.\nI believe the most straightforward decision is to mock the Corba objects as they essentially comprise both the networking and db functionality (which ought not to be tested in unit tests). \nIt's just that this is quite a lot of \"extra work\" to do - mocking all the Corba objects (there is a User object, a server session object, the pagetable object, an admin object etc.). Maybe it's just because I'm stuck with Corba and therefore I have to reflect the object hierarchy dictated by the server with mocks. On the other hand, it could be that there is some cool elegant solution to testing code using Corba that just did not cross my mind.","AnswerCount":3,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":625,"Q_Id":1660049,"Users Score":0,"Answer":"I have got similar work to tackle but I probably will not write a test for implementation of CORBA objects or more specifically COM objects (implementation of CORBA). I have to write tests for work that uses these structures as oppose to the structures themselves (although I could land myself in that role too if I ask too many questions). In the end of the day, unittest is integration on a smaller scale so whenever I write tests I am always thinking of input and outputs rather than actual structures. From the way you have written your problem my concentration would be on the data of server_pagetable.getData() and the output HTML without caring too much about what happens inbetween (because that is the code you are testing, you don't want to define the code in the test but ensure that output is correct). If you want to test individual functions inbetween then I would get mock data (essentially still data, so you can generate mock data rather than mock class if possible). Mocks are only used when you don't have parts of the full code and those functions needs some input from those parts of the code but as you are not interested in them or don't have them you simplify the interaction with them. This is just my opinion.","Q_Score":2,"Tags":"python,unit-testing,mocking,corba","A_Id":51438774,"CreationDate":"2009-11-02T08:38:00.000","Title":"Unittesting Corba 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},{"Question":"I was writing a script to inspect python's version on my system and I've noticed that python -V writes to the error stream, while python -h, for instance, uses the standard output. Is there a good reason for this behavior?","AnswerCount":4,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":340,"Q_Id":1672650,"Users Score":3,"Answer":"The -h option also used to print to stderr because it is not part of the output of your program, i.e. the output is not produced by your Python script but by the Python interpreter itself. \nAs for why they changed the -h to use stdout? Try typing python -h with your terminal window set to the standard 24 lines. It scrolls off the screen.\nNow most people would react by trying python -h |less but that only works if you send the output of -h to the stdout instead of stderr. So there was a good reason for making -h go to stdout, but no good reason for changing -V.","Q_Score":6,"Tags":"python","A_Id":1675051,"CreationDate":"2009-11-04T09:34:00.000","Title":"Why does python -V write to the error stream?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I was writing a script to inspect python's version on my system and I've noticed that python -V writes to the error stream, while python -h, for instance, uses the standard output. Is there a good reason for this behavior?","AnswerCount":4,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":340,"Q_Id":1672650,"Users Score":2,"Answer":"Why?\nBecause it's not the actual output of your actual script.\nThat's the long-standing, standard, common, typical, ordinary use for standard error: everything NOT output from your script.","Q_Score":6,"Tags":"python","A_Id":1673210,"CreationDate":"2009-11-04T09:34:00.000","Title":"Why does python -V write to the error stream?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":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},{"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},{"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},{"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},{"Question":"I hear Python is very good for pentesting. It has got good modules for that. But it's not a good framework, like Metasploit.","AnswerCount":4,"Available Count":3,"Score":0.049958375,"is_accepted":false,"ViewCount":7782,"Q_Id":1675904,"Users Score":1,"Answer":"well i think that c is more powerful than both languages, and is better for pen-testing.","Q_Score":4,"Tags":"python,penetration-tools","A_Id":2305866,"CreationDate":"2009-11-04T19:01:00.000","Title":"Is Python or Ruby good for penetration 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},{"Question":"I hear Python is very good for pentesting. It has got good modules for that. But it's not a good framework, like Metasploit.","AnswerCount":4,"Available Count":3,"Score":0.049958375,"is_accepted":false,"ViewCount":7782,"Q_Id":1675904,"Users Score":1,"Answer":"But C isn't a scriptng language there is many arguments that proof that python\/ruby are better for pen testing . For example with C you can't automate so fast as with python\/ruby , python\/ruby is high-level language and writing programs on them are a lot easier than C . But if you want to deal with pen-testing you should learn Python or any other scripting language and C\/C++ or other languages like PHP depent what are you testing but you should know a least one scripting language they make things a lot easier some times .","Q_Score":4,"Tags":"python,penetration-tools","A_Id":19335182,"CreationDate":"2009-11-04T19:01:00.000","Title":"Is Python or Ruby good for penetration 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},{"Question":"I hear Python is very good for pentesting. It has got good modules for that. But it's not a good framework, like Metasploit.","AnswerCount":4,"Available Count":3,"Score":1.2,"is_accepted":true,"ViewCount":7782,"Q_Id":1675904,"Users Score":4,"Answer":"Any language that has good, easy string handling capabilities is a good match for penetration testing. This is why you see scripting languages as the most used languages in this sort of tasks.\nTo answer your question, they're just as good.","Q_Score":4,"Tags":"python,penetration-tools","A_Id":1675945,"CreationDate":"2009-11-04T19:01:00.000","Title":"Is Python or Ruby good for penetration 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},{"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},{"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},{"Question":"I have made some changes in a python module in my checked out copy of a repository, and need to test them. However, when I try to run a script that uses the module, it keeps importing the module from the trunk of the repository, which is of no use to me. \nI tried setting PYTHONPATH, which did nothing at all. After some searching around, I found that anything in the .pth files under site-packages directory will be put in even before PYTHONPATH (which to me defeats the purpose of having it). I believe this is the cause for my module not being picked.\nAm I correct? If so, what is the way to override this (without modifying the script to have a sys.path.insert(0,path) )?\nEdit: In reply to NicDumz - the original repository was under \/projects\/spam. The python modules were part of this in \/projects\/spam\/sources\/python\/a\/b\/. However, these are 'built' every night using a homegrown make variant which then puts them into \/projects\/spam\/build\/lib\/python\/a\/b\/. The script is using the module under this last path only.\n I have checked out the entire repository to under \/home\/sundar\/spam, and made changes in \/home\/sundar\/spam\/sources\/python\/a\/b\/mymodule.py. I've set my PYTHONPATH to \/home\/sundar\/spam\/sources\/python and tried to import a.b.mymodule with no success.","AnswerCount":4,"Available Count":1,"Score":0.049958375,"is_accepted":false,"ViewCount":4291,"Q_Id":1679673,"Users Score":1,"Answer":"Your current working directory is first in the sys.path. Anything there trumps anything else on the path.\nCopy the \"test version\" to some place closer to the front of the list of directories in sys.path, like your current working directory.","Q_Score":1,"Tags":"python,import,path,module","A_Id":1679860,"CreationDate":"2009-11-05T10:35:00.000","Title":"How do I make Python pick the correct module without manually modifying sys.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":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"There are lots of tutorials\/instructions on how to embed python in an application, but nothing (that I've seen) on overall design for how the embedded interpreter should be used and interact with the application.\nThe only idea I could think of would be to simply give the user a method (menu option, etc) of executing scripts in the program. So certain classes, functions, objects, etc. would be exported to python, some script would do something, then said script could be run from the program.\nWould such a design be \"safe?\" Meaning is it feasible for a malicious\/poorly-written script to \"damage\" the program and\/or computer? I assume its possible depending on the functions available to the script (e.g: it could try to overwrite some important files, etc.) How might one prevent such from happening? (e.g: script certification, program design, etc.)\nThis is implementation specific, but is it possible\/feasible to have the effects of the script stay after its done running? Meaning if a script computes something, will the result be available to the program after execution of the script has finished? I think it is possible to do if the program were setup to interact with a specific script, but the program will be released before most scripts are written; and such a setup seems like a misuse of embedding a scripting language. Is there actually cases where you would want the result of a scripts execution to be available, or is this a contrived situation that doesn't really occur?\nAre there any other designs for embedding python?\nWhat about using python in a way similar to a plugin architecture?\nThanks, \nMatthew A. Todd","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":282,"Q_Id":1682831,"Users Score":1,"Answer":"The only idea I could think of would be to simply give the user a method (menu option, etc) of executing scripts in the program.\nCorrect.\nSo certain classes, functions, objects, etc. would be exported to python, some script would do something, then said script could be run from the program.\nCorrect.\nWould such a design be \"safe?\"\nYes. Unless your users are malicious, psychotic sociopaths. They want to make your program do useful things. They bought\/downloaded the software in the first place. They think it has value.\nThey trusted your software. Why not trust them?\nMeaning if a script computes something, will the result be available to the program after execution of the script has finished?\nPrograms like Apache do this all the time. You screw up the configuration (\"script\"), it crashes. Lesson learned? Don't screw up the configuration.","Q_Score":2,"Tags":"python,embedding","A_Id":1682872,"CreationDate":"2009-11-05T19:03:00.000","Title":"Embedding Python Design","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a lot of APIs\/Classes that I have developed in Ruby and Python that I would like to use in my .NET apps. Is it possible to instantiate a Ruby or Python Object in C# and call its methods?\nIt seems that libraries like IronPython do the opposite of this. Meaning, they allow Python to utilize .NET objects, but not the reciprocal of this which is what I am looking for... Am I missing something here?\nAny ideas?","AnswerCount":4,"Available Count":1,"Score":-0.049958375,"is_accepted":false,"ViewCount":5027,"Q_Id":1684145,"Users Score":-1,"Answer":"I have seen ways to call into Ruby \/ Python from c#. But it's easier the other way around.","Q_Score":8,"Tags":"c#,.net,python,ruby","A_Id":1684168,"CreationDate":"2009-11-05T22:37:00.000","Title":"Call Ruby or Python API in C# .NET","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},{"Question":"I'm a Java programmer and if there's one thing that I dislike about it, it would be speed. Java seems really slow, but a lot of the Python scriptsprograms I have written so far seem really fast. \nSo I was just wondering if Python is faster than Java, or C# and how that compares to C\/C++ (which I figure it'll be slower than)?","AnswerCount":8,"Available Count":4,"Score":1.0,"is_accepted":false,"ViewCount":29026,"Q_Id":1686192,"Users Score":24,"Answer":"This totally depends on the usecase. For long running applications (like servers), Java has proven to be extremely fast - even faster than C. This is possible as the JVM might compile hot bytecode to machine code. While doing this, it may take fully advantage of each and every feature of the CPU. This typically isn't possible for C, at least as soon as you leave your laboratory environment: just assume distributing a dozen of optimized builds to your clients - that simply won't work.\nBut back to your question: it really depends. E.g. if startup time is an issue (which isn't an issue for a server application for instance) Java might not be the best choice. It may also depend on where your hot code areas are: If they are within native libraries with some Python code to simply glue them together, you will be able to get C like performance with Python as well.\nTypically, scripting languages will tend to be slower though - at least most of the time.","Q_Score":12,"Tags":"python,performance","A_Id":1686232,"CreationDate":"2009-11-06T08:27:00.000","Title":"How fast is 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},{"Question":"I'm a Java programmer and if there's one thing that I dislike about it, it would be speed. Java seems really slow, but a lot of the Python scriptsprograms I have written so far seem really fast. \nSo I was just wondering if Python is faster than Java, or C# and how that compares to C\/C++ (which I figure it'll be slower than)?","AnswerCount":8,"Available Count":4,"Score":0.0,"is_accepted":false,"ViewCount":29026,"Q_Id":1686192,"Users Score":0,"Answer":"For the Python, velocity depends also for the interpreter implementations... I saw that pypy is generally faster than cpython.","Q_Score":12,"Tags":"python,performance","A_Id":7529473,"CreationDate":"2009-11-06T08:27:00.000","Title":"How fast is 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},{"Question":"I'm a Java programmer and if there's one thing that I dislike about it, it would be speed. Java seems really slow, but a lot of the Python scriptsprograms I have written so far seem really fast. \nSo I was just wondering if Python is faster than Java, or C# and how that compares to C\/C++ (which I figure it'll be slower than)?","AnswerCount":8,"Available Count":4,"Score":0.049958375,"is_accepted":false,"ViewCount":29026,"Q_Id":1686192,"Users Score":2,"Answer":"It is very hard to make a truly objective and general comparison of the runtime speed of two languages. In comparing any two languages X and Y, one often finds X is faster than Y in some respects while being slower in others. For me, this makes any benchmarks\/comparisons available online largely useless. The best way is to test it yourself and see how fast each language is for the job that you are doing.\nHaving said that, there are certain things one should remember when testing languages like Java and Python. Code in these languages can often be speeded up significantly by using constructions more suited to the language (e.g. list comprehensions in Python, or using char[] and StringBuilder for certain String operations in Java). Moreover, for Python, using psyco can greatly boost the speed of the program. And then there is the whole issue of using appropriate data structures and keeping an eye on the runtime complexity of your code.","Q_Score":12,"Tags":"python,performance","A_Id":1686811,"CreationDate":"2009-11-06T08:27:00.000","Title":"How fast is 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},{"Question":"I'm a Java programmer and if there's one thing that I dislike about it, it would be speed. Java seems really slow, but a lot of the Python scriptsprograms I have written so far seem really fast. \nSo I was just wondering if Python is faster than Java, or C# and how that compares to C\/C++ (which I figure it'll be slower than)?","AnswerCount":8,"Available Count":4,"Score":0.0,"is_accepted":false,"ViewCount":29026,"Q_Id":1686192,"Users Score":0,"Answer":"It's a question you can't answer properly, because it all depends when it has to be fast.\nJava is good for huge servers, it's bad when you have to re-compile and test a lot of times your code (compilation is sooooooo slow). Python doesn't even have to be compiled to test !\nIn production environment, it's totally silly to say Java is faster than C... it's like saying C is faster than assembly.\nAnyway it's not possible to answer precisely : it all depends on what you want \/ need.","Q_Score":12,"Tags":"python,performance","A_Id":1686388,"CreationDate":"2009-11-06T08:27:00.000","Title":"How fast is 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},{"Question":"Python has a flag -O that you can execute the interpreter with. The option will generate \"optimized\" bytecode (written to .pyo files), and given twice, it will discard docstrings. From Python's man page:\n\n-O Turn on basic optimizations. This changes the filename extension \n for compiled (bytecode) files from .pyc to .pyo. Given twice,\n causes docstrings to be discarded.\n\nThis option's two major features as I see it are:\n\nStrip all assert statements. This trades defense against corrupt program state for speed. But don't you need a ton of assert statements for this to make a difference? Do you have any code where this is worthwhile (and sane?)\nStrip all docstrings. In what application is the memory usage so critical, that this is a win? Why not push everything into modules written in C?\n\nWhat is the use of this option?\nDoes it have a real-world value?","AnswerCount":7,"Available Count":2,"Score":1.0,"is_accepted":false,"ViewCount":12397,"Q_Id":1693088,"Users Score":7,"Answer":"I have never encountered a good reason to use -O. I have always assumed its main purpose is in case at some point in the future some meaningful optimization is added.","Q_Score":50,"Tags":"python,optimization,assert,bytecode","A_Id":1693940,"CreationDate":"2009-11-07T13:51:00.000","Title":"What is the use of Python's basic optimizations mode? (python -O)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Python has a flag -O that you can execute the interpreter with. The option will generate \"optimized\" bytecode (written to .pyo files), and given twice, it will discard docstrings. From Python's man page:\n\n-O Turn on basic optimizations. This changes the filename extension \n for compiled (bytecode) files from .pyc to .pyo. Given twice,\n causes docstrings to be discarded.\n\nThis option's two major features as I see it are:\n\nStrip all assert statements. This trades defense against corrupt program state for speed. But don't you need a ton of assert statements for this to make a difference? Do you have any code where this is worthwhile (and sane?)\nStrip all docstrings. In what application is the memory usage so critical, that this is a win? Why not push everything into modules written in C?\n\nWhat is the use of this option?\nDoes it have a real-world value?","AnswerCount":7,"Available Count":2,"Score":0.1137907297,"is_accepted":false,"ViewCount":12397,"Q_Id":1693088,"Users Score":4,"Answer":"You've pretty much figured it out: It does practically nothing at all. You're almost never going to see speed or memory gains, unless you're severely hurting for RAM.","Q_Score":50,"Tags":"python,optimization,assert,bytecode","A_Id":1693128,"CreationDate":"2009-11-07T13:51:00.000","Title":"What is the use of Python's basic optimizations mode? (python -O)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I would like to give sources for what I'm saying but I just dont have them, it's something I heard.\nOnce a programming professor told me that some software benchmarking done to .net vs Python in some particular items it gave a relation of 5:8 in favor of .NET . That was his argument in favor of Python not being so much slower than .NET\nHere it's the thing, I would like to try IronPython since I could combine the web framework I know the most (asp.net) with the language I like the most (Python) and I was wondering about the speed of programs in asp.net in Python vs the speed of programs in ASP.NET with VB.net or C#. Is there any software benchmarking on this? \nAlso, shouldnt the speeds of IronPython compared to other .NET languages be similar, since IronPython unlike Python have to compile to the .NET intermediate code? Can someone enlight me on these issues?\nGreetings","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":6879,"Q_Id":1693205,"Users Score":1,"Answer":"You could enable .net tracing, which outputs timing information at the bottom of the page. Make an app in C#\/.Net and an app using Python and look at the differences in timing. That will give you a definitive answer.\nIn all honesty I think you're better off just using C#, it's \"faster\" to develop since the VS environment is there for you and it's going to run faster since it doesn't have to use the dynamic language runtime.","Q_Score":10,"Tags":".net,python,performance,ironpython","A_Id":1694288,"CreationDate":"2009-11-07T14:27:00.000","Title":"How does ironpython speed compare to other .net 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},{"Question":"I would like to give sources for what I'm saying but I just dont have them, it's something I heard.\nOnce a programming professor told me that some software benchmarking done to .net vs Python in some particular items it gave a relation of 5:8 in favor of .NET . That was his argument in favor of Python not being so much slower than .NET\nHere it's the thing, I would like to try IronPython since I could combine the web framework I know the most (asp.net) with the language I like the most (Python) and I was wondering about the speed of programs in asp.net in Python vs the speed of programs in ASP.NET with VB.net or C#. Is there any software benchmarking on this? \nAlso, shouldnt the speeds of IronPython compared to other .NET languages be similar, since IronPython unlike Python have to compile to the .NET intermediate code? Can someone enlight me on these issues?\nGreetings","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":6879,"Q_Id":1693205,"Users Score":0,"Answer":"IronPython will be considerably slower than C#. You could think of the comparison as very roughly between CPython and C, but with the gap somewhat smaller.","Q_Score":10,"Tags":".net,python,performance,ironpython","A_Id":2617858,"CreationDate":"2009-11-07T14:27:00.000","Title":"How does ironpython speed compare to other .net 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},{"Question":"How do I get started with getting going with XML-RPC with joomla? I've been looking around for documentation and finding nothing...\nI'd like to connect to a joomla server, (after enabling the Core Joomla XML-RPC plugin), and be able to do things like login and add an article, and tweak all the parameters of the article if possible.\nMy xml-rpc client implementation will be in python.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":2670,"Q_Id":1694205,"Users Score":3,"Answer":"the book \"Mastering Joomla 1.5 Extension and Framework Development\" has a nice explanation of that.\nJoomla has a fex XML-RPC plugins that let you do a few things, like the blogger API interface. (plugins\/xmlrpc\/blogger.php)\nYou should create your own XML-RPC plugin to do the custom things you want.","Q_Score":3,"Tags":"python,joomla,xml-rpc","A_Id":1696183,"CreationDate":"2009-11-07T19:53:00.000","Title":"Joomla and XMLRPC","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},{"Question":"currently im making some crawler script,one of problem is \nsometimes if i open webpage with PAMIE,webpage can't open and hang forever.\nare there any method to close PAMIE's IE or win32com's IE ? \nsuch like if webpage didn't response or loading complete less than 10sec or so .\nthanks in advance","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":294,"Q_Id":1698362,"Users Score":0,"Answer":"I think what you are looking for is somewhere to set the timeout on your request. I would suggest looking into the documentation on PAMIE.","Q_Score":0,"Tags":"python,time,multithreading,pamie","A_Id":1698371,"CreationDate":"2009-11-08T23:40:00.000","Title":"win32com and PAMIE web page open timeout","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},{"Question":"currently im making some crawler script,one of problem is \nsometimes if i open webpage with PAMIE,webpage can't open and hang forever.\nare there any method to close PAMIE's IE or win32com's IE ? \nsuch like if webpage didn't response or loading complete less than 10sec or so .\nthanks in advance","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":294,"Q_Id":1698362,"Users Score":2,"Answer":"Just use, to initialize your PAMIE instance, PAMIE(timeOut=100) or whatever. The units of measure for timeOut are \"tenths of a second\" (!); the default is 3000 (300 seconds, i.e., 5 minutes); with 300 as I suggested, you'd time out after 10 seconds as you request.\n(You can pass the timeOut= parameter even when you're initializing with a URL, but in that case the timeout will only be active after the initial navigation).","Q_Score":0,"Tags":"python,time,multithreading,pamie","A_Id":1698422,"CreationDate":"2009-11-08T23:40:00.000","Title":"win32com and PAMIE web page open timeout","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},{"Question":"I want to pass data between a Python and a C# application in Windows (I want the channel to be bi-directional)\nIn fact I wanna pass a struct containing data about a network packet that I've captured with C# (SharpPcap) to the Python app and then send back a modified packet to the C# program.\nWhat do you propose ? (I rather it be a fast method)\nMy searches so far revealed that I can use these technologies, but I don't know which:\n\nJSON-RPC \nUse WCF (run the project\nunder IronPython using Ironclad)\nWCF (use Python for .NET)","AnswerCount":2,"Available Count":2,"Score":0.1973753202,"is_accepted":false,"ViewCount":2195,"Q_Id":1700228,"Users Score":2,"Answer":"Use JSON-RPC because the experience that you gain will have more practical use. JSON is widely used in web applications written in all of the dozen or so most popular languages.","Q_Score":6,"Tags":"c#,python,ipc,rpc,bidirectional","A_Id":1700287,"CreationDate":"2009-11-09T10:33:00.000","Title":"IPC between Python and 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":0,"Web Development":0},{"Question":"I want to pass data between a Python and a C# application in Windows (I want the channel to be bi-directional)\nIn fact I wanna pass a struct containing data about a network packet that I've captured with C# (SharpPcap) to the Python app and then send back a modified packet to the C# program.\nWhat do you propose ? (I rather it be a fast method)\nMy searches so far revealed that I can use these technologies, but I don't know which:\n\nJSON-RPC \nUse WCF (run the project\nunder IronPython using Ironclad)\nWCF (use Python for .NET)","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":2195,"Q_Id":1700228,"Users Score":2,"Answer":"Why not use a simple socket communication, or if you wish you can start a simple http server, and\/or do json-rpc over it.","Q_Score":6,"Tags":"c#,python,ipc,rpc,bidirectional","A_Id":1700631,"CreationDate":"2009-11-09T10:33:00.000","Title":"IPC between Python and 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":0,"Web Development":0},{"Question":"I need an IronPython\\Python example that would show C#\/VB.NET developers how awesome this language really is. \nI'm looking for an easy to understand code snippet or application I can use to demo Python's capabilities.\nAny thoughts?","AnswerCount":13,"Available Count":2,"Score":1.0,"is_accepted":false,"ViewCount":1848,"Q_Id":1708103,"Users Score":10,"Answer":"Rewrite any small C# app in IronPython, and show them how many lines of code it took you. If that's not impressing, I don't know what is.\nI'm referring to one of your internal apps.","Q_Score":10,"Tags":"python,ironpython","A_Id":1708382,"CreationDate":"2009-11-10T13:49:00.000","Title":"How to impress developers with IronPython\/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},{"Question":"I need an IronPython\\Python example that would show C#\/VB.NET developers how awesome this language really is. \nI'm looking for an easy to understand code snippet or application I can use to demo Python's capabilities.\nAny thoughts?","AnswerCount":13,"Available Count":2,"Score":0.0461211021,"is_accepted":false,"ViewCount":1848,"Q_Id":1708103,"Users Score":3,"Answer":"I have to agree Geo. Show a C# or VB app next to the same app written in IronPython. When I've done my IronPython talks, I've had a lot of success morphing C# code into Python. It makes for a very dramatic presentation.\nI'm also a big fan of showing off how duck typing makes your code more testable.","Q_Score":10,"Tags":"python,ironpython","A_Id":1711358,"CreationDate":"2009-11-10T13:49:00.000","Title":"How to impress developers with IronPython\/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},{"Question":"We currently run a small shared hosting service for a couple of hundred small PHP sites on our servers. We'd like to offer Python support too, but from our initial research at least, a server restart seems to be required after each source code change.\nIs this really the case? If so, we're just not going to be able to offer Python hosting support. Giving our clients the ability to upload files is easy, but we can't have them restart the (shared) server process!\nPHP is easy -- you upload a new version of a file, the new version is run.\nI've a lot of respect for the Python language and community, so find it hard to believe that it really requires such a crazy process to update a site's code. Please tell me I'm wrong! :-)","AnswerCount":3,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":1525,"Q_Id":1711483,"Users Score":7,"Answer":"Python is a compiled language; the compiled byte code is cached by the Python process for later use, to improve performance. PHP, by default, is interpreted. It's a tradeoff between usability and speed.\nIf you're using a standard WSGI module, such as Apache's mod_wsgi, then you don't have to restart the server -- just touch the .wsgi file and the code will be reloaded. If you're using some weird server which doesn't support WSGI, you're sort of on your own usability-wise.","Q_Score":6,"Tags":"python,web-hosting","A_Id":1711705,"CreationDate":"2009-11-10T21:50:00.000","Title":"Python web hosting: Why are server restarts necessary?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm a beginner with Pylons and I've mostly developed on my localhost using the built-in web server. I think it's time to start deployment for my personal blog, I have a Debian Lenny server with apache2-mpm-prefork module and mod_wsgi - I've never really used mod_wsgi or fastcgi and I hear either of these are the way to go.\nMy questions:\n\nShould I go with mod_wsgi or fastcgi and why?\nWhere should I be creating my web application? Should I create an entirely new user for it? Should I store it in \/home\/meder\/web-app ? I currently have some php websites being hosted on my server and they live in \/www\/ which is a directory I created. Is there any sorta gotcha with static binary files such as images, as there is with django?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":450,"Q_Id":1712883,"Users Score":2,"Answer":"mod_wsgi. It's more efficient. FastCGI can be troublesome to setup, whereas I've never known anyone to have a problem using mod_wsgi with a supported version of Python (2.5, 2.6, 3.1 included). WSGI exists for Python (by Python, &c.) and so it makes for a more \"Pythonic\" experience. Prior to WSGI I used to serve small Pylons apps via paste behind mod_proxy (due to massive issues with fastcgi).\nAnywhere is fine, any user is fine. If you're worried about security, you may wish to add another user. You could create a home folder in \/www\/ if you were so inclined :) Static binary files, images, etc., should be served separately if you can, but Pylons had (actually, I believe still does have) a method of serving these (this should be the 'public' folder). I would still use a separate mount as Apache is more efficient at serving these than passing them through Pylons.","Q_Score":0,"Tags":"python,apache,deployment,apache2,pylons","A_Id":1712913,"CreationDate":"2009-11-11T03:50:00.000","Title":"Pylons deployment questions","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"Are there database testing tools for python (like sqlunit)? I want to test the DAL that is built using sqlalchemy","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":601,"Q_Id":1719279,"Users Score":4,"Answer":"Follow the design pattern that Django uses.\n\nCreate a disposable copy of the database. Use SQLite3 in-memory, for example.\nCreate the database using the SQLAlchemy table and index definitions. This should be a fairly trivial exercise.\nLoad the test data fixture into the database. \nRun your unit test case in a database with a known, defined state.\nDispose of the database.\n\nIf you use SQLite3 in-memory, this procedure can be reasonably fast.","Q_Score":4,"Tags":"python,database,testing,sqlalchemy","A_Id":1719347,"CreationDate":"2009-11-12T01:27:00.000","Title":"Are there database testing tools for python (like sqlunit)?","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},{"Question":"I am developing a twisted server. I need to control the memory usage. It is not a good idea to modify code, insert some memory logging command and restart the server. I think it is better to use a \"remote console\", so that I can type heapy command and see the response from the server directly. All I need is a remote console, I can build one by myself, but I don't like to rebuild a wheel. My question is: is there already any remote console for twisted?\nThanks.","AnswerCount":2,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":1027,"Q_Id":1721699,"Users Score":6,"Answer":"Take a look at twisted.manhole","Q_Score":5,"Tags":"python,console,twisted","A_Id":1721715,"CreationDate":"2009-11-12T11:55:00.000","Title":"Is there any \"remote console\" for twisted 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":1,"Web Development":0},{"Question":"I need to load large models and other structured binary data on an older CD-based game console as efficiently as possible. What's the best way to do it? The data will be exported from a Python application. This is a pretty elaborate hobby project.\nRequierements:\n\nno reliance on fully standard compliant STL - i might use uSTL though.\nas little overhead as possible. Aim for a solution so good. that it could be used on the original Playstation, and yet as modern and elegant as possible.\nno backward\/forward compatibility necessary.\nno copying of large chunks around - preferably files get loaded into RAM in background, and all large chunks accessed directly from there later.\nshould not rely on the target having the same endianness and alignment, i.e. a C plugin in Python which dumps its structs to disc would not be a very good idea.\nshould allow to move the loaded data around, as with individual files 1\/3 the RAM size, fragmentation might be an issue. No MMU to abuse.\nrobustness is a great bonus, as my attention span is very short, i.e. i'd change saving part of the code and forget the loading one or vice versa, so at least a dumb safeguard would be nice.\nexchangeability between loaded data and runtime-generated data without runtime overhead and without severe memory management issues would be a nice bonus.\n\nI kind of have a semi-plan of parsing in Python trivial, limited-syntax C headers which would use structs with offsets instead of pointers, and convenience wrapper structs\/classes in the main app with getters which would convert offsets to properly typed pointers\/references, but i'd like to hear your suggestions.\nClarification: the request is primarily about data loading framework and memory management issues.","AnswerCount":4,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":270,"Q_Id":1727594,"Users Score":0,"Answer":"Consider storing your data as BLOBs in a SQLite DB. SQLite is extremely portable and lighweight, ANSI C, has both C++ and Python interfaces. This will take care of large files, no fragmentation, variable-length records with fast access, and so on. The rest is just serialization of structs to these BLOBs.","Q_Score":3,"Tags":"c++,python,embedded,playstation","A_Id":1727732,"CreationDate":"2009-11-13T06:56:00.000","Title":"Optimal datafile format loading on a game console","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},{"Question":"I need to load large models and other structured binary data on an older CD-based game console as efficiently as possible. What's the best way to do it? The data will be exported from a Python application. This is a pretty elaborate hobby project.\nRequierements:\n\nno reliance on fully standard compliant STL - i might use uSTL though.\nas little overhead as possible. Aim for a solution so good. that it could be used on the original Playstation, and yet as modern and elegant as possible.\nno backward\/forward compatibility necessary.\nno copying of large chunks around - preferably files get loaded into RAM in background, and all large chunks accessed directly from there later.\nshould not rely on the target having the same endianness and alignment, i.e. a C plugin in Python which dumps its structs to disc would not be a very good idea.\nshould allow to move the loaded data around, as with individual files 1\/3 the RAM size, fragmentation might be an issue. No MMU to abuse.\nrobustness is a great bonus, as my attention span is very short, i.e. i'd change saving part of the code and forget the loading one or vice versa, so at least a dumb safeguard would be nice.\nexchangeability between loaded data and runtime-generated data without runtime overhead and without severe memory management issues would be a nice bonus.\n\nI kind of have a semi-plan of parsing in Python trivial, limited-syntax C headers which would use structs with offsets instead of pointers, and convenience wrapper structs\/classes in the main app with getters which would convert offsets to properly typed pointers\/references, but i'd like to hear your suggestions.\nClarification: the request is primarily about data loading framework and memory management issues.","AnswerCount":4,"Available Count":3,"Score":0.1488850336,"is_accepted":false,"ViewCount":270,"Q_Id":1727594,"Users Score":3,"Answer":"I note that nowhere in your description do you ask for \"ease of programming\". :-)\nThus, here's what comes to mind for me as a way of creating this:\n\nThe data should be in the same on-disk format as it would be in the target's memory, such that it can simply pull blobs from disk into memory with no reformatting it. Depending on how much freedom you want in putting things into memory, the \"blobs\" could be the whole file, or could be smaller bits within it; I don't understand your data well enough to suggest how to subdivide it but presumably you can. Because we can't rely on the same endianness and alignment on the host, you'll need to be somewhat clever about translating things when writing the files on the host-side, but at least this way you only need the cleverness on one side of the transfer rather than on both.\nIn order to provide a bit of assurance that the target-side and host-side code matches, you should write this in a form where you provide a single data description and have some generation code that will generate both the target-side C code and the host-side Python code from it. You could even have your generator generate a small random \"version\" number in the process, and have the host-side code write this into the file header and the target-side check it, and give you an error if they don't match. (The point of using a random value is that the only information bit you care about is whether they match, and you don't want to have to increment it manually.)","Q_Score":3,"Tags":"c++,python,embedded,playstation","A_Id":1728074,"CreationDate":"2009-11-13T06:56:00.000","Title":"Optimal datafile format loading on a game console","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},{"Question":"I need to load large models and other structured binary data on an older CD-based game console as efficiently as possible. What's the best way to do it? The data will be exported from a Python application. This is a pretty elaborate hobby project.\nRequierements:\n\nno reliance on fully standard compliant STL - i might use uSTL though.\nas little overhead as possible. Aim for a solution so good. that it could be used on the original Playstation, and yet as modern and elegant as possible.\nno backward\/forward compatibility necessary.\nno copying of large chunks around - preferably files get loaded into RAM in background, and all large chunks accessed directly from there later.\nshould not rely on the target having the same endianness and alignment, i.e. a C plugin in Python which dumps its structs to disc would not be a very good idea.\nshould allow to move the loaded data around, as with individual files 1\/3 the RAM size, fragmentation might be an issue. No MMU to abuse.\nrobustness is a great bonus, as my attention span is very short, i.e. i'd change saving part of the code and forget the loading one or vice versa, so at least a dumb safeguard would be nice.\nexchangeability between loaded data and runtime-generated data without runtime overhead and without severe memory management issues would be a nice bonus.\n\nI kind of have a semi-plan of parsing in Python trivial, limited-syntax C headers which would use structs with offsets instead of pointers, and convenience wrapper structs\/classes in the main app with getters which would convert offsets to properly typed pointers\/references, but i'd like to hear your suggestions.\nClarification: the request is primarily about data loading framework and memory management issues.","AnswerCount":4,"Available Count":3,"Score":0.1973753202,"is_accepted":false,"ViewCount":270,"Q_Id":1727594,"Users Score":4,"Answer":"On platforms like the Nintendo GameCube and DS, 3D models are usually stored in a very simple custom format:\n\nA brief header, containing a magic number identifying the file, the number of vertices, normals, etc., and optionally a checksum of the data following the header (Adler-32, CRC-16, etc).\nA possibly compressed list of 32-bit floating-point 3-tuples for each vector and normal.\nA possibly compressed list of edges or faces.\nAll of the data is in the native endian format of the target platform.\nThe compression format is often trivial (Huffman), simple (Arithmetic), or standard (gzip). All of these require very little memory or computational power.\n\nYou could take formats like that as a cue: it's quite a compact representation.\nMy suggestion is to use a format most similar to your in-memory data structures, to minimize post-processing and copying. If that means you create the format yourself, so be it. You have extreme needs, so extreme measures are needed.","Q_Score":3,"Tags":"c++,python,embedded,playstation","A_Id":1728071,"CreationDate":"2009-11-13T06:56:00.000","Title":"Optimal datafile format loading on a game console","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},{"Question":"Unit tests have different requirements than production code. For example, unit tests may not have to be as performant as the production code.\nPerhaps it sometimes makes sense to write your unit tests in a language that is better suited to writing unit tests? The specific example I have in mind is writing an application in C# but using IronRuby or IronPython to write the tests.\nAs I see it, using IronPython and IronRuby have several advantages over C# code as a testing language:\n\nMocking can be simpler in dynamically typed languages\nIronPython has less verbose type annotations that are not needed in unit tests\nExperimental invocation of tests without recompilation by typing commands at the interpreter\n\nWhat are the tradeoffs in using two different languages for tests and production code?","AnswerCount":10,"Available Count":9,"Score":0.0199973338,"is_accepted":false,"ViewCount":1494,"Q_Id":1729791,"Users Score":1,"Answer":"I agree with the other answers that there are disadvantages, but I'm surprised that so few have talked about advantages.\n\nTDD'ing across languages is a great way to learn new languages: write the tests in a language you know well, and the implementation in the language you are learning. As you are learning, you will discover better ways of writing the code than you first did, but refactoring is easy because you have a test suite.\nHaving to master multiple languages keeps you (and your team) sharp.\nYou get better verification that your API is interoperable across languages.","Q_Score":10,"Tags":"c#,.net,unit-testing,ironpython","A_Id":1731244,"CreationDate":"2009-11-13T15:09:00.000","Title":"What are the (dis)advantages of writing unit tests in a different language to 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},{"Question":"Unit tests have different requirements than production code. For example, unit tests may not have to be as performant as the production code.\nPerhaps it sometimes makes sense to write your unit tests in a language that is better suited to writing unit tests? The specific example I have in mind is writing an application in C# but using IronRuby or IronPython to write the tests.\nAs I see it, using IronPython and IronRuby have several advantages over C# code as a testing language:\n\nMocking can be simpler in dynamically typed languages\nIronPython has less verbose type annotations that are not needed in unit tests\nExperimental invocation of tests without recompilation by typing commands at the interpreter\n\nWhat are the tradeoffs in using two different languages for tests and production code?","AnswerCount":10,"Available Count":9,"Score":0.0399786803,"is_accepted":false,"ViewCount":1494,"Q_Id":1729791,"Users Score":2,"Answer":"I think that this is an excellent question and an idea worthy of consideration - particularly in an environment like Visual Studio\/.NET where this is easily supported\nThe plus side - as you suggest - is that you can choose to use a language\/tool to create tests that is more suited to creating tests than perhaps the code you are using to create code and for this reason alone its worth a thought.\nThe down side is, as suggested, that your developers - those creating the tests (and we must remember not to confuse Unit Testing with Test Driven Design) probably ought to be fluent in more than one language (I'd suggest that the ability to be so is fairly important to a good developer but I'm biased!) - and more importantly that you may have to worry about structural differences between the two (though again, if you're talking about .NET languages that should be covered for you).\nIt gets even more interesting if you go beyond \"unit\" tests to tests at all levels where the specific capabilities of particular languages may give advantages in building up a test case.\nThe ultimate question is whether the advantages outweigh the disadvantages... and that's probably somewhat case specific.","Q_Score":10,"Tags":"c#,.net,unit-testing,ironpython","A_Id":1730103,"CreationDate":"2009-11-13T15:09:00.000","Title":"What are the (dis)advantages of writing unit tests in a different language to 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},{"Question":"Unit tests have different requirements than production code. For example, unit tests may not have to be as performant as the production code.\nPerhaps it sometimes makes sense to write your unit tests in a language that is better suited to writing unit tests? The specific example I have in mind is writing an application in C# but using IronRuby or IronPython to write the tests.\nAs I see it, using IronPython and IronRuby have several advantages over C# code as a testing language:\n\nMocking can be simpler in dynamically typed languages\nIronPython has less verbose type annotations that are not needed in unit tests\nExperimental invocation of tests without recompilation by typing commands at the interpreter\n\nWhat are the tradeoffs in using two different languages for tests and production code?","AnswerCount":10,"Available Count":9,"Score":0.0199973338,"is_accepted":false,"ViewCount":1494,"Q_Id":1729791,"Users Score":1,"Answer":"The biggest disadvantage is that you are also testing compiler dependencies in your unit tests. In a sense, this also makes them integration tests. That might make them preferable if you expect your code to be usable from multiple languages, but it's adding one level of complexity that you may not need if your code will only be used in production with the language that it's developed in.\nOne advantage that I can see is that it further isolates that code being developed from the test itself. By separating the act of writing the test even further from the actual code under development, it forces you to really consider how the code should be written to pass the test rather than simply moving the initial development of the code into the test itself.","Q_Score":10,"Tags":"c#,.net,unit-testing,ironpython","A_Id":1729896,"CreationDate":"2009-11-13T15:09:00.000","Title":"What are the (dis)advantages of writing unit tests in a different language to 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},{"Question":"Unit tests have different requirements than production code. For example, unit tests may not have to be as performant as the production code.\nPerhaps it sometimes makes sense to write your unit tests in a language that is better suited to writing unit tests? The specific example I have in mind is writing an application in C# but using IronRuby or IronPython to write the tests.\nAs I see it, using IronPython and IronRuby have several advantages over C# code as a testing language:\n\nMocking can be simpler in dynamically typed languages\nIronPython has less verbose type annotations that are not needed in unit tests\nExperimental invocation of tests without recompilation by typing commands at the interpreter\n\nWhat are the tradeoffs in using two different languages for tests and production code?","AnswerCount":10,"Available Count":9,"Score":0.0199973338,"is_accepted":false,"ViewCount":1494,"Q_Id":1729791,"Users Score":1,"Answer":"When building an API or library, I often deliver unit tests as a form of documentation on how best to use the API or library. Most of the time I build a C# library, I'm delivering to a client who will be writing C# code to use the library.\nFor documentation sake, at least some of my tests will always be written in the target language.","Q_Score":10,"Tags":"c#,.net,unit-testing,ironpython","A_Id":1729874,"CreationDate":"2009-11-13T15:09:00.000","Title":"What are the (dis)advantages of writing unit tests in a different language to 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},{"Question":"Unit tests have different requirements than production code. For example, unit tests may not have to be as performant as the production code.\nPerhaps it sometimes makes sense to write your unit tests in a language that is better suited to writing unit tests? The specific example I have in mind is writing an application in C# but using IronRuby or IronPython to write the tests.\nAs I see it, using IronPython and IronRuby have several advantages over C# code as a testing language:\n\nMocking can be simpler in dynamically typed languages\nIronPython has less verbose type annotations that are not needed in unit tests\nExperimental invocation of tests without recompilation by typing commands at the interpreter\n\nWhat are the tradeoffs in using two different languages for tests and production code?","AnswerCount":10,"Available Count":9,"Score":0.0199973338,"is_accepted":false,"ViewCount":1494,"Q_Id":1729791,"Users Score":1,"Answer":"The biggest tradeoff would be if someone was looking at using Unit Tests to figure out how a certain action may be performed, writing it in a different language would make it harder to use. Also you would have to make your C# code CLS compliant.","Q_Score":10,"Tags":"c#,.net,unit-testing,ironpython","A_Id":1729838,"CreationDate":"2009-11-13T15:09:00.000","Title":"What are the (dis)advantages of writing unit tests in a different language to 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},{"Question":"Unit tests have different requirements than production code. For example, unit tests may not have to be as performant as the production code.\nPerhaps it sometimes makes sense to write your unit tests in a language that is better suited to writing unit tests? The specific example I have in mind is writing an application in C# but using IronRuby or IronPython to write the tests.\nAs I see it, using IronPython and IronRuby have several advantages over C# code as a testing language:\n\nMocking can be simpler in dynamically typed languages\nIronPython has less verbose type annotations that are not needed in unit tests\nExperimental invocation of tests without recompilation by typing commands at the interpreter\n\nWhat are the tradeoffs in using two different languages for tests and production code?","AnswerCount":10,"Available Count":9,"Score":0.0,"is_accepted":false,"ViewCount":1494,"Q_Id":1729791,"Users Score":0,"Answer":"Experience 1\nIn the past year I worked on a project that had two main pieces:\n\nA Grails web application\nand a Java Swing application\n\nwe wrote our Java unit tests using Groovy and it worked out well. Unit testing with groovy took a lot less time verbosity wise and also made it possible to fake static methods and so forth. Although there were a couple places where we ran into unexpected results due to Groovy's dynamic typing, on the whole it was a positive experience.\nExperience 2\nAnother recent project I worked on was a C# ASP.NET MVC 3 web application where I wrote all the unit tests with F#. I chose C# for the web app because I felt it worked better with MVC 3. I chose F# for unit tests because it is my favorite language. The only issues I ran into were minor annoyances with types like null vs. option.\nConclusion\nWhen we have two languages targeting the same runtime (well, C# \/ F# and Java \/ Groovy on CLR and JRE respectively) where one is used for production code and one for unit tests, there isn't too much to worry about regarding compatibility at least. Then I think it's really a questions of whether you and your team feel comfortable enough in both languages (and I suppose you might be kind enough to consider future maintainers as well). Indeed, I think the times you'd be compelled to use a different language for unit testing is when the unit testing language is actually your language of comfort or choice over your production language.\nThere are some exceptions I'd admit to this liberal attitude. If you're are designing a library to be consumed by language X then it may be a smart idea to write your unit tests in language X (some at least). But for application code, I've never found writing unit tests in the same language as your production code particularly advantageous.","Q_Score":10,"Tags":"c#,.net,unit-testing,ironpython","A_Id":9560983,"CreationDate":"2009-11-13T15:09:00.000","Title":"What are the (dis)advantages of writing unit tests in a different language to 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},{"Question":"Unit tests have different requirements than production code. For example, unit tests may not have to be as performant as the production code.\nPerhaps it sometimes makes sense to write your unit tests in a language that is better suited to writing unit tests? The specific example I have in mind is writing an application in C# but using IronRuby or IronPython to write the tests.\nAs I see it, using IronPython and IronRuby have several advantages over C# code as a testing language:\n\nMocking can be simpler in dynamically typed languages\nIronPython has less verbose type annotations that are not needed in unit tests\nExperimental invocation of tests without recompilation by typing commands at the interpreter\n\nWhat are the tradeoffs in using two different languages for tests and production code?","AnswerCount":10,"Available Count":9,"Score":1.0,"is_accepted":false,"ViewCount":1494,"Q_Id":1729791,"Users Score":7,"Answer":"One obvious potential problem is a confusing debugging experience. I haven't personally tried to debug across languages in .NET - what happens if you step into C# code from IronPython?\nThe other problem is that anyone wanting to develop on your code base has to know both languages.","Q_Score":10,"Tags":"c#,.net,unit-testing,ironpython","A_Id":1729848,"CreationDate":"2009-11-13T15:09:00.000","Title":"What are the (dis)advantages of writing unit tests in a different language to 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},{"Question":"Unit tests have different requirements than production code. For example, unit tests may not have to be as performant as the production code.\nPerhaps it sometimes makes sense to write your unit tests in a language that is better suited to writing unit tests? The specific example I have in mind is writing an application in C# but using IronRuby or IronPython to write the tests.\nAs I see it, using IronPython and IronRuby have several advantages over C# code as a testing language:\n\nMocking can be simpler in dynamically typed languages\nIronPython has less verbose type annotations that are not needed in unit tests\nExperimental invocation of tests without recompilation by typing commands at the interpreter\n\nWhat are the tradeoffs in using two different languages for tests and production code?","AnswerCount":10,"Available Count":9,"Score":1.2,"is_accepted":true,"ViewCount":1494,"Q_Id":1729791,"Users Score":11,"Answer":"Disadvantages that come to my mind:\n\nDepending on the language, you need another development environment (additional dependency of the project, additional effort to setup a development machine, additional licenses, additional training ...)\nRefactoring is sometimes supported by the IDE - but most probably not for this other language. So you have to refactor them manually.\nUnit tests can also be used as programming examples. Tests show how the tested classes are intended to be used. This does not work so well if the tests are written in a different language.","Q_Score":10,"Tags":"c#,.net,unit-testing,ironpython","A_Id":1729849,"CreationDate":"2009-11-13T15:09:00.000","Title":"What are the (dis)advantages of writing unit tests in a different language to 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},{"Question":"Unit tests have different requirements than production code. For example, unit tests may not have to be as performant as the production code.\nPerhaps it sometimes makes sense to write your unit tests in a language that is better suited to writing unit tests? The specific example I have in mind is writing an application in C# but using IronRuby or IronPython to write the tests.\nAs I see it, using IronPython and IronRuby have several advantages over C# code as a testing language:\n\nMocking can be simpler in dynamically typed languages\nIronPython has less verbose type annotations that are not needed in unit tests\nExperimental invocation of tests without recompilation by typing commands at the interpreter\n\nWhat are the tradeoffs in using two different languages for tests and production code?","AnswerCount":10,"Available Count":9,"Score":0.0399786803,"is_accepted":false,"ViewCount":1494,"Q_Id":1729791,"Users Score":2,"Answer":"Main disadvantage as I see it is maintainablity. If you code in C#, your development team are competent in that language, as will new hires be. You need a multi-functional dev team.\nI think that it's also worth noting that you probably don't want people writing their tests in a language that is maybe not their strongest. Your test code needs to be robust.\nYou also need to be switching between syntaxes whilst writing codes\/tests - this is a bit of a nuisance.","Q_Score":10,"Tags":"c#,.net,unit-testing,ironpython","A_Id":1729845,"CreationDate":"2009-11-13T15:09:00.000","Title":"What are the (dis)advantages of writing unit tests in a different language to 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},{"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},{"Question":"Can anyone suggest a good Python 3 Library for sending \/ receiving reatime MIDI?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":618,"Q_Id":1742382,"Users Score":1,"Answer":"Why Python 3? It generally doesn't have many libraries yet. Generally you want to look into high-level C-libraries with Python wrappers. I doubt many of these work under Python 3 at the moment.","Q_Score":4,"Tags":"python,python-3.x,midi","A_Id":2089977,"CreationDate":"2009-11-16T14:06:00.000","Title":"Python 3 Library for Realtime Midi 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},{"Question":"From the web I've gleaned that WSGI is a CGI for python web development\/frameworks. FCGI seems to be a more generalised gateway for a variety of languages. Don't know the performance difference between the two in reference to the languages python and C\/++.","AnswerCount":2,"Available Count":2,"Score":1.0,"is_accepted":false,"ViewCount":25057,"Q_Id":1747266,"Users Score":27,"Answer":"They are two different things. WSGI is a Python specific interface for writing web applications. There are wrappers for about any web server protocol to provide the WSGI interface. FastCGI (FCGI) is one of such web server protocols. So, WSGI is an abstraction layer, while CGI \/ FastCGI \/ mod_python are how the actual web servers talk to the application. Some code has to translate the native interface to WSGI (there is a CGI module in wsgiref, there is flup for FastCGI, etc.). There is also mod_wsgi for Apache, which does the translation directly in an Apache module, so you don't need any Python wrapper.","Q_Score":39,"Tags":"python,wsgi,fastcgi","A_Id":1747336,"CreationDate":"2009-11-17T07:59:00.000","Title":"Is there a speed difference between WSGI and FCGI?","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},{"Question":"From the web I've gleaned that WSGI is a CGI for python web development\/frameworks. FCGI seems to be a more generalised gateway for a variety of languages. Don't know the performance difference between the two in reference to the languages python and C\/++.","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":25057,"Q_Id":1747266,"Users Score":80,"Answer":"Correct, WSGI is a Python programmatic API definition and FASTCGI is a language agnostic socket wire protocol definition. Effectively they are at different layers with WSGI being a higher layer. In other words, one can implement WSGI on top of something that so happened to use FASTCGI to communicate with a web server, but not the other way around.\nIn general, FASTCGI being a socket wire protocol means that you always need some type of programmatic interface on top to use it. For Python one such option is WSGI. As FASTCGI is just a means to an end, one can't really compare its performance to WSGI in that case because WSGI isn't a comparable socket wire protocol, but a user of FASTCGI itself.\nOne could try and compare performance of different language interfaces on top of FASTCGI, but in general that is quite meaningless in itself as the lower network layer and server request handling aren't the bottleneck. Instead your application code and database will be.","Q_Score":39,"Tags":"python,wsgi,fastcgi","A_Id":1748161,"CreationDate":"2009-11-17T07:59:00.000","Title":"Is there a speed difference between WSGI and FCGI?","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},{"Question":"I want to do full integration testing for a web application. I want to test many things like AJAX, positioning and presence of certain phrases and HTML elements using several browsers. I'm seeking a tool to do such automated testing.\nOn the other hand; this is my first time using integration testing. Are there any specific recommendations when doing such testing? Any tutorial as well?\n(As a note: My backend code is done using Perl, Python and Django.)\nThanks!","AnswerCount":9,"Available Count":1,"Score":0.022218565,"is_accepted":false,"ViewCount":5279,"Q_Id":1747772,"Users Score":1,"Answer":"I would also recommend Selenium. It got a really nice Firefox Plugin, that you can use to create your integration tests.","Q_Score":10,"Tags":"python,ruby,perl,automated-tests,integration-testing","A_Id":1747828,"CreationDate":"2009-11-17T09:59:00.000","Title":"Integration Testing for a Web 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":0,"Web Development":1},{"Question":"What's are some ways of testing complex data types such as video, images, music, etc. I'm using TDD and wonder are there alternatives to \"gold file\" testing for rendering algorithms. I understand that there's ways to test other parts of the program that don't render and using those results you can infer. However, I'm particularly interested in rendering algorithms specifically image\/video testing. \nThe question came up while I was using OpenCV\/Python to do some basic facial recognition and want to verify its correctness. \nEven if there's nothing definitive any suggestion will help.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":229,"Q_Id":1761663,"Users Score":0,"Answer":"What's wrong with the \"gold file\" technique? It's part of your test fixture. Every test has a data fixture that's the equivalent to the \"gold file\" in a media-intensive application.\nWhen doing ordinary TDD of ordinary business applications, one often has a golden database fixture that must be used.\nEven when testing simple functions and core classes of an application, the setUp method creates a kind of \"gold file\" fixture for that class or function.\nWhat's wrong with that technique? Please update your question with the specific problems you're having.","Q_Score":2,"Tags":"python,image,testing,opencv","A_Id":1762591,"CreationDate":"2009-11-19T08:05:00.000","Title":"Testing complex datatypes?","Data Science and Machine Learning":0,"Database and SQL":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},{"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},{"Question":"For someone who\u2019s been happily programming in C# for quite some time now and planning to learn a new language I find the Python community more closely knit than many others. \nPersonally dynamic typing puts me off, but I am fascinated by the way the Python community rallies around it. There are a lot of other things I expect I would miss in Python (LINQ, expression trees, etc.) \nWhat are the good things about Python that developers love? Stuff that\u2019ll excite me more than C#.","AnswerCount":13,"Available Count":10,"Score":0.0,"is_accepted":false,"ViewCount":3108,"Q_Id":1773063,"Users Score":0,"Answer":"Don't get me wrong, I am and will always be a devoted fan of C#.\nBut sometimes there are things I can't do in C#. lthough C# keeps reducing those gaps, Python is still the language I go to to fill them.\nIt's dynamic, flexible, powerful, and clean. Lovely language. Whenever I need to script or build dynamic or functional (as in functional programming) software, I go Python.","Q_Score":20,"Tags":"c#,python,programming-languages","A_Id":1773322,"CreationDate":"2009-11-20T20:30:00.000","Title":"What Python features will excite the interest of a C# developer?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"For someone who\u2019s been happily programming in C# for quite some time now and planning to learn a new language I find the Python community more closely knit than many others. \nPersonally dynamic typing puts me off, but I am fascinated by the way the Python community rallies around it. There are a lot of other things I expect I would miss in Python (LINQ, expression trees, etc.) \nWhat are the good things about Python that developers love? Stuff that\u2019ll excite me more than C#.","AnswerCount":13,"Available Count":10,"Score":0.0153834017,"is_accepted":false,"ViewCount":3108,"Q_Id":1773063,"Users Score":1,"Answer":"Like any programming language, it is just a tool in the box or a brush by which you may paint your creation. Any creative endeavour requires that the artist loves the tools he uses; otherwise, the outcome suffers. Some people like Python for the same reason others love Perl. Incidentally, I have found that most Python lovers loathe Perl's flexible and expressive syntax. As a Perl lover, I don't hate Python, but consider it to be overly structured and restrictive.\nIf you ask me, all of these throngs of people who seem to love Python were silently suffering under the tool choices before Python came into being. Some suffered under Perl, others under something else. In other words, I believe that when Python came along, it found a large group of silent sufferers longing for a tool like Python. \nI can't program in Python because I can't \"think\" in Python. I can \"think\" in Perl, therefore, it is the tool I prefer. The silently suffering mass of, now, Python users seem to have found some long lost salvation. Now if they could only keep their evangelism to themselves :).","Q_Score":20,"Tags":"c#,python,programming-languages","A_Id":1773317,"CreationDate":"2009-11-20T20:30:00.000","Title":"What Python features will excite the interest of a C# developer?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"For someone who\u2019s been happily programming in C# for quite some time now and planning to learn a new language I find the Python community more closely knit than many others. \nPersonally dynamic typing puts me off, but I am fascinated by the way the Python community rallies around it. There are a lot of other things I expect I would miss in Python (LINQ, expression trees, etc.) \nWhat are the good things about Python that developers love? Stuff that\u2019ll excite me more than C#.","AnswerCount":13,"Available Count":10,"Score":1.0,"is_accepted":false,"ViewCount":3108,"Q_Id":1773063,"Users Score":11,"Answer":"I'm a very heavy user of both C# and Python; I've built very complicated applications in both languages, and I've also embedded Python scripting in my major C# application. I'm not using either to do much in the way of web work right now, but other than that I feel like I'm pretty qualified to answer the question.\nThe things about Python that excite me, in particular:\n\nThe deep integration of generators into the language. This was the first thing that made me realize that I needed to take a long, serious look at Python. My appreciation for this has deepened considerably since I've become conversant with the itertools module, which looks like a nifty set of tools but is in fact a new way of life.\nThe coupling of dynamic typing and the fact that everything's an object makes pretty sophisticated techniques extremely simple to implement. It's so easy to replace logic with tables in Python (e.g. o = class_map[k]() instead of if k='foo': o = Foo()) that it becomes a basic technique. It's so normal in Python to write methods that take methods as parameters that you don't raise an eyebrow when you see d = defaultdict(list).\nzip, and the methods that are designed with it in mind. It takes a while before you can intuitively grasp what dict(zip(k, v)) and d.update(zip(k, v)) are doing, but it's a paradigm-shifting moment when you get there. An entire universe of uninteresting and potentially error-laden code eliminated, just by using one function. Then you start designing functions and classes with the expectation that they'll be used in conjunction with zip, and suddenly your code gets simpler and easier. (Protip: Or itertools.izip. Or itertools.izip_longest.)\nSpeaking of dictionaries, the way that they're deeply integrated into the language. Understanding what a line of code like self.__dict__.update(**kwargs) does is another one of those paradigm-shifting moments.\nList comprehensions and generator expressions, of course.\nInexpensive exceptions.\nAn interactive intepreter.\nFunction decorators.\nIronPython, which is so much simpler to use than we have any right to expect.\n\nAnd that's without even getting into the remarkable array of functionality in the standard modules, or the ridiculous bounty of third-party tools like BeautifulSoup or SQL Alchemy or Pylons.\nOne of the most direct benefits that I've gotten from getting deeply into Python is that it has greatly improved my C# code. I could generally understand code that had a variable of type Dictionary> in it, but it didn't seem natural to write it. (I use static dictionaries to replace hard-coded logic far more frequently today than I did a year ago.) I have no difficulty understanding what LINQ is doing now, or how IEnumerable and return yield work.\nSo what don't I like about Python?\n\nDynamic typing really limits what you can do with static code analysis. Not only isn't there a tool like Resharper for Python, in a language where it's possible to write getattr(x, y)() there really can't be.\nIt has a bunch of inelegant conventions. How I would love to be able to go back in time and try to talk GVR out of the idea that lambda expressions should be introduced with the word lambda - it's pretty damning that something as fundamental as lambda expressions should be more concise in C# than they are in Python. The leading and trailing double-underscore convention is horrible, and the fact that people mutely acquiesce to it is testimony to Dostoevsky's observation that man is the animal who can get used to anything. And don't get me started on the fact that a module with the name of StringIO was allowed to get out the door.\nSome of the features that make Python work on multiple platforms also make it kind of baffling. It's easy to use import, but it's really not easy to understand what the hell it's actually doing. (Where is it looking? What does __init__.py do? Etc.)\nThe amazingly rich library of standard modules is so amazingly rich that it's hard to know what's in it. It's often easier to write a function than it is to find out whether or not there's something in the standard library that does the same thing - I'm looking at you, itertools.chain.","Q_Score":20,"Tags":"c#,python,programming-languages","A_Id":1773987,"CreationDate":"2009-11-20T20:30:00.000","Title":"What Python features will excite the interest of a C# developer?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"For someone who\u2019s been happily programming in C# for quite some time now and planning to learn a new language I find the Python community more closely knit than many others. \nPersonally dynamic typing puts me off, but I am fascinated by the way the Python community rallies around it. There are a lot of other things I expect I would miss in Python (LINQ, expression trees, etc.) \nWhat are the good things about Python that developers love? Stuff that\u2019ll excite me more than C#.","AnswerCount":13,"Available Count":10,"Score":1.0,"is_accepted":false,"ViewCount":3108,"Q_Id":1773063,"Users Score":10,"Answer":"Your question is kind of like a plumber asking why carpenters are always going on and on about hammers. After all the plumber doesn't have a hammer and has never missed it. Python (even IronPython) and C# target different types of developers and different types of programs. I am very comfortable in Python and enjoy the freedom to focus on the business rules without being distracted by the syntax requirements of the language. On the other hand I have written some fairly substantial code in C# and would be very concerned about the lack of type safety had I taken on the same task in Python. This is not to say that Python is a \"toy\" language. You can (and people have) write a complete medium or large application in Python. You have the freedom of dynamic typing, but you also have the responsibility to keep it all straight (frameworks help here). Similarly you can write a small application in C#, but you will bring along some overhead you do not likely need.\nSo if the problem is a nail use a hammer, if the problem is a screw use a screw driver. In other words spend some time to learn Python, get to know it's streangths (text processing, quick coding cycles, simple clean code, etc) and then when you are looking at tackling a new problem ask whether you would be better off in Python or C#. One thing is certain. So long as C# is the only programming language you know, it is the only one you will ever use.\nPat O","Q_Score":20,"Tags":"c#,python,programming-languages","A_Id":1773278,"CreationDate":"2009-11-20T20:30:00.000","Title":"What Python features will excite the interest of a C# developer?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"For someone who\u2019s been happily programming in C# for quite some time now and planning to learn a new language I find the Python community more closely knit than many others. \nPersonally dynamic typing puts me off, but I am fascinated by the way the Python community rallies around it. There are a lot of other things I expect I would miss in Python (LINQ, expression trees, etc.) \nWhat are the good things about Python that developers love? Stuff that\u2019ll excite me more than C#.","AnswerCount":13,"Available Count":10,"Score":0.0307595242,"is_accepted":false,"ViewCount":3108,"Q_Id":1773063,"Users Score":2,"Answer":"I'm an asymmetrical user of both languages, in a sense that I use C# mostly professionally and Python for all my \"fun\" projects (not that work is never fun, but... you know...)\nThis difference of context may skew my perspective, including my opinion that they are two distinct types (pun intended) of languages for, generally, distinct purposes.\nThis said, it may not be a coincidence that Python is, at this point in time, [one of?] the languages of choice for all kinds of cutting edge, somewhat scholarly, technology\/science oriented projects. (And BTW, this \"scholarly\" keyword here doesNOT imply, that Python is a university toy, plenty of \"serious\" applications in plenty of domains\/industry are proof to the contrary). This may be due to several factors:\n(I don't develop most points, readily well expressed in other responses)\n\nthe openness and quasi universal availability of Python (unlike C# !)\nthe lightweight \/ ease of use \/ low learning curve\nthe extensive, high quality, \"standard\" library and the extensiver (and occasionally bum quality, but on the whole available, open-sourced, etc.) additional library.\nthe wide array of open source projects in Python language\nthe relative ease to bind with C\/C++ for reusing legacy code, but also for placing performance-critical portions of a project\nthe generally higher level of abstraction of may constructs of the language\nthe multi-paradigms (imperative, object oriented and functional)\nthe availability of practitioners in so many domain of science and technology\n\nand, yes, the\n\n\"herd mentality effect\" mentioned in a remark, possibly in a [self?] deriding way. The fact that a language attracts a broad, \"closely knit\" community, makes it attractive too, beyond the superficial (\"look cool\" and such) traits of herd mentality. Put in broader context, sometimes the best technology\/language to use is not measured on the its intrinsic merits but on the overall \"picture\", including the user community.","Q_Score":20,"Tags":"c#,python,programming-languages","A_Id":1773315,"CreationDate":"2009-11-20T20:30:00.000","Title":"What Python features will excite the interest of a C# developer?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"For someone who\u2019s been happily programming in C# for quite some time now and planning to learn a new language I find the Python community more closely knit than many others. \nPersonally dynamic typing puts me off, but I am fascinated by the way the Python community rallies around it. There are a lot of other things I expect I would miss in Python (LINQ, expression trees, etc.) \nWhat are the good things about Python that developers love? Stuff that\u2019ll excite me more than C#.","AnswerCount":13,"Available Count":10,"Score":1.0,"is_accepted":false,"ViewCount":3108,"Q_Id":1773063,"Users Score":18,"Answer":"For me its the flexibility and elegance, but there are a handful of things I wish could be pulled in from other languages though (better threading, more robust expressions).\nIn typical I can write a little bit of code in python and do a lot more than the same amount of lines in many other languages. Also, in python code form is of utmost importance and the syntax lends its self to highly readable, clean looking code. That of course helps out with maintenance. \nI love having a command line interpreter that I can quickly prototype an algorithm in rather than having to start up a new project, code, compile, test, repeat. Not to mention the fact I can use it to help me automate my server maintenance as well (I double as a SA for my company).\nThe last thing that comes to mind immediately is the vast amounts of libraries. There are a lot of things already solved out there, the built-in library has a lot to offer, and the third party ones are many times very good (not always though).","Q_Score":20,"Tags":"c#,python,programming-languages","A_Id":1773087,"CreationDate":"2009-11-20T20:30:00.000","Title":"What Python features will excite the interest of a C# developer?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"For someone who\u2019s been happily programming in C# for quite some time now and planning to learn a new language I find the Python community more closely knit than many others. \nPersonally dynamic typing puts me off, but I am fascinated by the way the Python community rallies around it. There are a lot of other things I expect I would miss in Python (LINQ, expression trees, etc.) \nWhat are the good things about Python that developers love? Stuff that\u2019ll excite me more than C#.","AnswerCount":13,"Available Count":10,"Score":1.0,"is_accepted":false,"ViewCount":3108,"Q_Id":1773063,"Users Score":15,"Answer":"Being able to type in some code and get the result back immediately.\n(Disclaimer: I use both C# and Python regularly, and I think both have their good and bad points.)","Q_Score":20,"Tags":"c#,python,programming-languages","A_Id":1773082,"CreationDate":"2009-11-20T20:30:00.000","Title":"What Python features will excite the interest of a C# developer?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"For someone who\u2019s been happily programming in C# for quite some time now and planning to learn a new language I find the Python community more closely knit than many others. \nPersonally dynamic typing puts me off, but I am fascinated by the way the Python community rallies around it. There are a lot of other things I expect I would miss in Python (LINQ, expression trees, etc.) \nWhat are the good things about Python that developers love? Stuff that\u2019ll excite me more than C#.","AnswerCount":13,"Available Count":10,"Score":1.2,"is_accepted":true,"ViewCount":3108,"Q_Id":1773063,"Users Score":11,"Answer":"I'm primarily .NET developer and using Python for me personal projects.\n\nWhat are the good things about python that developers love?\n\nI can say for myself - Python is like a breath of fresh air. \n1) It's simple to learn, took about a week for me in the evenings. I'm saying about Python + Django. Python syntax is quite simple.\n2) It's simple to use. No troubles installing Python + Django on Windows at all.\n3) It can be run on Windows and UNIX.\n4) I need it for web, so I get cheaper hosting than ASP.NET.\n5) All the advantages of Python language over C#. Like tuples - so useful!\nThe only thing I don't like is that my favorite IDE Visual Studio doesn't support it (I know about IronPython, don't you worry).","Q_Score":20,"Tags":"c#,python,programming-languages","A_Id":1773224,"CreationDate":"2009-11-20T20:30:00.000","Title":"What Python features will excite the interest of a C# developer?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"For someone who\u2019s been happily programming in C# for quite some time now and planning to learn a new language I find the Python community more closely knit than many others. \nPersonally dynamic typing puts me off, but I am fascinated by the way the Python community rallies around it. There are a lot of other things I expect I would miss in Python (LINQ, expression trees, etc.) \nWhat are the good things about Python that developers love? Stuff that\u2019ll excite me more than C#.","AnswerCount":13,"Available Count":10,"Score":0.0153834017,"is_accepted":false,"ViewCount":3108,"Q_Id":1773063,"Users Score":1,"Answer":"I like all stuff with [] and {}. Selectors like this [-1:1]. Possibility to write less code, but more something meaningfull, that gives to write Models and other declarative things very DRY.","Q_Score":20,"Tags":"c#,python,programming-languages","A_Id":1773215,"CreationDate":"2009-11-20T20:30:00.000","Title":"What Python features will excite the interest of a C# developer?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"For someone who\u2019s been happily programming in C# for quite some time now and planning to learn a new language I find the Python community more closely knit than many others. \nPersonally dynamic typing puts me off, but I am fascinated by the way the Python community rallies around it. There are a lot of other things I expect I would miss in Python (LINQ, expression trees, etc.) \nWhat are the good things about Python that developers love? Stuff that\u2019ll excite me more than C#.","AnswerCount":13,"Available Count":10,"Score":0.0,"is_accepted":false,"ViewCount":3108,"Q_Id":1773063,"Users Score":0,"Answer":"The main thing I like about Python is its very concise, readable syntax. Though using indentation as a block delimiter can seem strange at first, once you begin to code a lot in the language I find it begins to make sense. Though the core language is quite simple, its more advanced features, e.g. list comprehension, decorators and generators, are rather useful too. \nIn addition, the Python standard library is just fantastic; its documentation is very well written, and it contains a lot of very useful packages. I also find that there are plenty of good bindings for C libraries, such as PyGTK, Webkit and Qt, to name but a few.\nOne caveat is that Python, like most dynamic languages, is quite slow in comparison with compiled, statically-typed languages. However, you can easily extend it with C, allowing you to write code requiring better performance in C and the rest in Python.\nIt's a great language overall, and (for me at least) makes coding more productive and enjoyable.","Q_Score":20,"Tags":"c#,python,programming-languages","A_Id":1773312,"CreationDate":"2009-11-20T20:30:00.000","Title":"What Python features will excite the interest of a C# developer?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":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},{"Question":"How can I import contacts of given email id\/pwd from \n\ngmail\nyahoo\nhotmail \netc\n\nusing python\/django application. Please suggest?","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":2955,"Q_Id":1774915,"Users Score":1,"Answer":"Amir Hussain,\nYahoo mail using captcha, so it will not works for any scripts or service unless they have managed service with the help of a third party for captcha decoder. So u have to contact a service provider who provide managed service. \nAs far as I know, Improsys is the first Address Grabber marketer and they have managed service. They have this tool available for Classic ASP, ASP.Net, .Net, Ruby on Rails, PHP, Cold Fusion, JAVA, JSP and Perl. Microsoft Outlook and Outlook Express. \nActually I am using their service. Their service is satisfactory but the cost is too high.","Q_Score":5,"Tags":"python,django","A_Id":11819696,"CreationDate":"2009-11-21T08:12:00.000","Title":"how to import contacts from various services like gmail or yahoo using 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},{"Question":"TextMate seems to use the built-in Python version I assume (sys.path doesn't work). How do you configure it to use 3.1 instead? I've already installed the 3.1 package and I can use IDLE for interactive sessions, but I need to use TextMate now.\nThanks","AnswerCount":4,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":17177,"Q_Id":1775954,"Users Score":4,"Answer":"the shebang is the best solution, to see where python 3 is installed type in terminal:\n\nwhich python3\n\nyou will get something like this:\n\n\/usr\/local\/bin\/python3\n\nif nothing shows up first install python3\nand at the top of your script insert:\n\n #!\/usr\/local\/bin\/python3","Q_Score":28,"Tags":"python,macos,python-3.x,textmate","A_Id":7792338,"CreationDate":"2009-11-21T16:34:00.000","Title":"Using Python 3.1 with TextMate","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Can you delete emails with imaplib? If so how?","AnswerCount":3,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":23123,"Q_Id":1777264,"Users Score":19,"Answer":"Deleting an email over IMAP is performed in two phases:\n\nmark one or more items for deletion: imap.store(msg_no, '+FLAGS', '\\\\Deleted')\nexpunge the mailbox: imap.expunge()\n\n(imap is your IMAP4 object)","Q_Score":14,"Tags":"python,email,imap","A_Id":1777290,"CreationDate":"2009-11-22T00:13:00.000","Title":"Using python imaplib to \"delete\" an email from Gmail?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"One of my Python scripts runs in interactive mode but fails when run from the command line. The difference is that when run from the command line, it imports modules from a bad .egg file, and when run interactively it uses my fixed (unzipped) version in the current directory.\nMy question is two-fold: a) why does Python load modules differently when run from these locations, and b) what are my options to work around it?","AnswerCount":4,"Available Count":3,"Score":1.2,"is_accepted":true,"ViewCount":2052,"Q_Id":1777671,"Users Score":2,"Answer":"I don't understand what do you mean by running script in interactive mode, so I can't say exactly. But the first place to look for modules (sys.path[0]) in interactive mode is current directory (even calling os.chdir() will affect imports), while for script it's directory where the script is located (derived from sys.argv[0]). Note that they are effectively the same when script is run from directory where it's located, but could be different in other cases. Hope this helps.","Q_Score":5,"Tags":"python,interactive,egg,non-interactive","A_Id":1777968,"CreationDate":"2009-11-22T02:51:00.000","Title":"Python importing modules differently when run interactively\/non-interactively","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"One of my Python scripts runs in interactive mode but fails when run from the command line. The difference is that when run from the command line, it imports modules from a bad .egg file, and when run interactively it uses my fixed (unzipped) version in the current directory.\nMy question is two-fold: a) why does Python load modules differently when run from these locations, and b) what are my options to work around it?","AnswerCount":4,"Available Count":3,"Score":0.0996679946,"is_accepted":false,"ViewCount":2052,"Q_Id":1777671,"Users Score":2,"Answer":"On UNIX systems and Mac OS-X:\n\nDo you have a ~\/.python-eggs directory?\n\nOS independent:\n\nAre you sure that you use the same Python instance in both cases?\nCan you print sys.path in each cases and see which package directory comes first on your module search path?","Q_Score":5,"Tags":"python,interactive,egg,non-interactive","A_Id":1777700,"CreationDate":"2009-11-22T02:51:00.000","Title":"Python importing modules differently when run interactively\/non-interactively","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"One of my Python scripts runs in interactive mode but fails when run from the command line. The difference is that when run from the command line, it imports modules from a bad .egg file, and when run interactively it uses my fixed (unzipped) version in the current directory.\nMy question is two-fold: a) why does Python load modules differently when run from these locations, and b) what are my options to work around it?","AnswerCount":4,"Available Count":3,"Score":0.049958375,"is_accepted":false,"ViewCount":2052,"Q_Id":1777671,"Users Score":1,"Answer":"a) why does Python load modules differently when run from these locations \nb) what are my options to work around it?\nCheck your environment variable PYTHONPATH. When python imports module, it searches those directories. One way to get around your problem is to add your local folder \"the (unzipped) version in the current directory\" to the beginning of PYTHONPATH so that python will find it first.","Q_Score":5,"Tags":"python,interactive,egg,non-interactive","A_Id":1778097,"CreationDate":"2009-11-22T02:51:00.000","Title":"Python importing modules differently when run interactively\/non-interactively","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Just curious. If you had the time and inclination to create a programming language, what characteristics would it have?\nOne language I would like to see would borrow as much from the syntax of Python as possible but compile to machine code that runs as fast as C or C++.","AnswerCount":5,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":340,"Q_Id":1778278,"Users Score":0,"Answer":"It should be fast and lightweight (not like the .NET Framework), but you should still be able to create fully functional and flexible GUI apps.","Q_Score":0,"Tags":"python,c++","A_Id":1778322,"CreationDate":"2009-11-22T09:39:00.000","Title":"If you had the time and inclination to create a programming language, what characteristics would it have?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"What are the main differences between Python metaclasses and class decorators? Is there something I can do with one but not with the other?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":8667,"Q_Id":1779372,"Users Score":47,"Answer":"Decorators are much, much simpler and more limited -- and therefore should be preferred whenever the desired effect can be achieved with either a metaclass or a class decorator.\nAnything you can do with a class decorator, you can of course do with a custom metaclass (just apply the functionality of the \"decorator function\", i.e., the one that takes a class object and modifies it, in the course of the metaclass's __new__ or __init__ that make the class object!-).\nThere are many things you can do in a custom metaclass but not in a decorator (unless the decorator internally generates and applies a custom metaclass, of course -- but that's cheating;-)... and even then, in Python 3, there are things you can only do with a custom metaclass, not after the fact... but that's a pretty advanced sub-niche of your question, so let me give simpler examples).\nFor example, suppose you want to make a class object X such that print X (or in Python 3 print(X) of course;-) displays peekaboo!. You cannot possibly do that without a custom metaclass, because the metaclass's override of __str__ is the crucial actor here, i.e., you need a def __str__(cls): return \"peekaboo!\" in the custom metaclass of class X.\nThe same applies to all magic methods, i.e., to all kinds of operations as applied to the class object itself (as opposed to, ones applied to its instances, which use magic methods as defined in the class -- operations on the class object itself use magic methods as defined in the metaclass).","Q_Score":43,"Tags":"python,decorator,metaclass","A_Id":1779404,"CreationDate":"2009-11-22T17:39:00.000","Title":"Python metaclasses vs class decorators","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"First, a disclaimer. I'm not a CS grad nor a math major, so simplicity is important. \nI have a four-character string (e.g. \"isoy\") that I need to pass as a single 32-bit integer field. Of course at the other end, I need to decode it back to a string. The string will only contain A-Z, and case is not important, if that helps.\nThe funny part is that I'm starting with PowerShell on the sending end and Linux at the receiving end. I can use Perl or Python there, with a preference for Python. I don't actually need answers in each language, I'm most interested in a PowerShell (C# also good) example for going both ways.","AnswerCount":6,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":3087,"Q_Id":1780922,"Users Score":2,"Answer":"Please take a look at the struct standard library module in Python's Manual. It has two functions for this: struct.pack and struct.unpack. You can use the 'L' (unsigned long) format character for this.","Q_Score":2,"Tags":"c#,python,algorithm,powershell","A_Id":1780938,"CreationDate":"2009-11-23T03:09:00.000","Title":"How do I encode a 4-byte string as a single 32-bit integer?","Data Science and Machine Learning":0,"Database and SQL":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},{"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},{"Question":"I spent a few days reading about C++ and Python and I found that Python is so much simpler and easy to learn. \nSo I wonder does it really worth spending time learning it? Or should I invest that time learning C++ instead?\nWhat can C++ do and Python can't ?","AnswerCount":11,"Available Count":8,"Score":1.2,"is_accepted":true,"ViewCount":10696,"Q_Id":1792360,"Users Score":41,"Answer":"Some Python limits :\n- Python is slow. It can be improved in many ways (see other answers) but the bare bone cPython is 100 times slower that C\/C++. \nThis problem is getter more and more mitigated. With Numpy, Pypy and asyncio, most performance problems are not covered, and only very specific use cases are a bottleneck in Python anymore.\n- Python is opened to anything. It's really hard to protect \/ obfuscate \/ limit Python code. \n- Python is not hype. Unlike Ruby, there is no \"cool wave\" around Python, and it's still much harder to find a experienced Python coder, than, let's say, a Java or a PHP pro.\n- After using Python, a lot of languages seems to be a pain to use. You'd think it's good, but believe me, not always. When you have to go Javascript after a Python project, your eyes are in tears for at least 3 days. Really hard to get started.\n- It's harder to find web hosting than for popular solutions, such as PHP.\n- As a dynamic language, you don't have the very handy refactoring tools you could get with Java and Eclipse or C# and VS. \n- For the same reason, you can't rely on type checking as a safety net. This is why pythonistas tend to follow best practice and write unit tests more often than others. \n- It seems I just can't find an IDE with a decent code completion. PyDev, Gedit, Komodo, SPE, etc. just don't do it as good as it could be.\nWith Python 3 types hints and tools like PyCharm or Sublime Text+Anaconda, the situation has changed a lot.\n- The best docs are still in English only. Some people don't deal well with it.\n- You have to get use to the syntax. Not only you get spaces and line breaks instead of bracets, but you can forget about long lambdas, --i, and ternary operation.\nNow, to me, these are not reasons to not learn a tool that will make you produce more while having more fun. But maybe it's just me :-)\nHonestly, given that :\n\nC++ much harder to learn;\nYou can do pretty much any thing you want with Python;\nYou will get quicker result with Python in your projects.\n\nUnless you have professional issues involving C++, you'd better learn Python first, it's more motivating. You still can learn C++ later, it's a useful language for system programming, embedded devices and such.\nDon't try to learn both at the same times, multitasking rarely ends well.","Q_Score":12,"Tags":"c++,python","A_Id":1793767,"CreationDate":"2009-11-24T19:26:00.000","Title":"What are the limits 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":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I spent a few days reading about C++ and Python and I found that Python is so much simpler and easy to learn. \nSo I wonder does it really worth spending time learning it? Or should I invest that time learning C++ instead?\nWhat can C++ do and Python can't ?","AnswerCount":11,"Available Count":8,"Score":1.0,"is_accepted":false,"ViewCount":10696,"Q_Id":1792360,"Users Score":32,"Answer":"Here's why it's worth learning Python:\nA comparatively small number of problems are constrained by the speed of the algorithm. A comparatively large number of problems are bounded by the speed of the developer.","Q_Score":12,"Tags":"c++,python","A_Id":1794560,"CreationDate":"2009-11-24T19:26:00.000","Title":"What are the limits 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":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I spent a few days reading about C++ and Python and I found that Python is so much simpler and easy to learn. \nSo I wonder does it really worth spending time learning it? Or should I invest that time learning C++ instead?\nWhat can C++ do and Python can't ?","AnswerCount":11,"Available Count":8,"Score":0.0,"is_accepted":false,"ViewCount":10696,"Q_Id":1792360,"Users Score":0,"Answer":"One significant difference not so far mentioned is the difference between a language like C++ that builds to native code, and a language like Python which by default puts a VM between you and the hardware. For doing low-level work, like coding against the OS kernel, the native language will be the preferred option.\nIn practise, though, when you're working in that context it usually means dropping all the way down C (in its role as portable assembler) rather than being able to use C++ (and its runtime libraries), for much if not all of the code.","Q_Score":12,"Tags":"c++,python","A_Id":1795473,"CreationDate":"2009-11-24T19:26:00.000","Title":"What are the limits 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":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I spent a few days reading about C++ and Python and I found that Python is so much simpler and easy to learn. \nSo I wonder does it really worth spending time learning it? Or should I invest that time learning C++ instead?\nWhat can C++ do and Python can't ?","AnswerCount":11,"Available Count":8,"Score":0.0,"is_accepted":false,"ViewCount":10696,"Q_Id":1792360,"Users Score":0,"Answer":"One thing that people often use C for, and never (to my knowledge) Python, is low-level code such as operating-system kernels and embedded software.\nC has a lot of of constructs that make it very easy to, for example, convert an arbitrary machine address into a pointer and dereference it, or tell the compiler that an address used for memory-mapped I\/O might change even though this program doesn\u2019t change it, or to specify the exact layout of an object in memory. It\u2019s designed to run as fast as possible, with as little wasted memory, rather than be safe.\nThat\u2019s what the comments about \u201cletting you shoot yourself in the foot\u201d are mostly referring to.","Q_Score":12,"Tags":"c++,python","A_Id":53662323,"CreationDate":"2009-11-24T19:26:00.000","Title":"What are the limits 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":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I spent a few days reading about C++ and Python and I found that Python is so much simpler and easy to learn. \nSo I wonder does it really worth spending time learning it? Or should I invest that time learning C++ instead?\nWhat can C++ do and Python can't ?","AnswerCount":11,"Available Count":8,"Score":0.0,"is_accepted":false,"ViewCount":10696,"Q_Id":1792360,"Users Score":0,"Answer":"As others have suggested: learn Python to study algorithms and higher level concepts and use it for prototyping and for places where you can. Learn C\/C++ and\/or Java for the job market and for cases where you must use it.\nPython's vastly easier syntax and high level libraries allow you to focus on interfaces and abstractions while still having a functional prototype.","Q_Score":12,"Tags":"c++,python","A_Id":1795061,"CreationDate":"2009-11-24T19:26:00.000","Title":"What are the limits 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":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I spent a few days reading about C++ and Python and I found that Python is so much simpler and easy to learn. \nSo I wonder does it really worth spending time learning it? Or should I invest that time learning C++ instead?\nWhat can C++ do and Python can't ?","AnswerCount":11,"Available Count":8,"Score":0.0181798149,"is_accepted":false,"ViewCount":10696,"Q_Id":1792360,"Users Score":1,"Answer":"From what I've been told, 1% of learning C++ is learning C. 1% is learning the extra basic features. 98% is learning to use the features in a safe, maintainable way, and coping with the dark hairy corners of the language.\nLearning python will teach you to write code that is safe, and maintainable. I think that if you learn python then go back to C++, then you will be able to write good C++ code. Of course, that won't mean you will understand bad C++, or C++ code that was written in a non-pythonic way.\nLimits to python?\n\nIt's interpreted, so you have to ship the source and the interpreter; and processes will take much longer to start up. \nIt's not C++, so it won't play with existing C++ code. \nIt's a bit slower (even if you wrap the hot loops in C).*\nIt encourages you to be \"pythonic\", and some problems are easier if you are not \"pythonic\".\n\n*Python might be faster:\n\nAutomatic GC. C++ is only faster if it doesn't leak too much.\nDictionaries. Lots of code runs in O(N plus a bit), rather than O(N^2) if you use a dictionary. Sure, you can use a hash table in C++, but not everbody does.\nMemory management - the python interpreter caches some of the basic data structures' memory, then reallocates them, rather than hitting the system for new memory. This reduces system calls, which is a very good thing.\nProfiling new algorithms is waaaay easier on python. In lots of problems, a better algorithm is more important than a linear speedup (which is what C++ gives you).\nIf you are making a program that \"only runs once\" (scientific analysis, data migration, etc), then the compile-build-test cycle should be faster in python. That's what really counts ;)","Q_Score":12,"Tags":"c++,python","A_Id":1794856,"CreationDate":"2009-11-24T19:26:00.000","Title":"What are the limits 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":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I spent a few days reading about C++ and Python and I found that Python is so much simpler and easy to learn. \nSo I wonder does it really worth spending time learning it? Or should I invest that time learning C++ instead?\nWhat can C++ do and Python can't ?","AnswerCount":11,"Available Count":8,"Score":0.0,"is_accepted":false,"ViewCount":10696,"Q_Id":1792360,"Users Score":0,"Answer":"Learn a statically typed language and a scripting language. \nYou can do whatever you want in either language. A well-written C++ code base is easier to maintain\/debug than a Python code base written with the same level of competency.\nIf your goal is to do web stuff or scripting, Python is for you. Anything more advanced will require C++.\nThat being said, go for Python.","Q_Score":12,"Tags":"c++,python","A_Id":1793871,"CreationDate":"2009-11-24T19:26:00.000","Title":"What are the limits 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":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I spent a few days reading about C++ and Python and I found that Python is so much simpler and easy to learn. \nSo I wonder does it really worth spending time learning it? Or should I invest that time learning C++ instead?\nWhat can C++ do and Python can't ?","AnswerCount":11,"Available Count":8,"Score":0.0544914242,"is_accepted":false,"ViewCount":10696,"Q_Id":1792360,"Users Score":3,"Answer":"if you are trying to find out whether you are still going to be employed some\ntime later using C++ or Python, don't concern yourself with a single language's longevity.\nLearn to program. Don't learn to program in .\nHere is an analogy: If your car is running fine (gets you where you're\ngoing, has good mileage, cheap to maintain, relatively safe), there is\nno logical reason to trade it in for another one. None. Whatsoever.\nDrive it to the ground before you even consider what make or model to\nget next. But if you are already looking around thinking what car to\nget, just go get it, stop asking everybody you know whether you should\ndo it. If you need to ask, you need to change it. It's as simple as\nthat.","Q_Score":12,"Tags":"c++,python","A_Id":1792387,"CreationDate":"2009-11-24T19:26:00.000","Title":"What are the limits 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":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Inside my python scrip, I get some string back from a function which I didn't write. The encoding of it varies. I need to convert it to ascii format. Is there some fool-proof way of doing this? I don't mind replacing the non-ascii chars with blanks or something else...","AnswerCount":5,"Available Count":2,"Score":0.0798297691,"is_accepted":false,"ViewCount":11358,"Q_Id":1792602,"Users Score":2,"Answer":"What's meant by \"foolproof\" is that the function does not fail with even the most obscure, impossible input -- meaning, you could feed the function random binary data and IT WOULD NEVER FAIL, NO MATTER WHAT. That's what \"foolproof\" means.\nThe function should then proceed do its best to convert to the destination encoding. If it has to throw away all the trash it does not understand, then that is perfectly fine and is in fact the most desirable result. Why try to salvage all the junk? Just discard the junk. Tell the user he's not merely a moron for using Microsoft anything, but a non-standard moron for using non-standard Microsoft anything...or for attempting to send in binary data!\nI have just precisely this same need (though my need is in PHP), and I also have users who are at least as moronic as I am, sometimes moreso; however, they are definitely nicer and no doubt more patient.\nThe best, bottom-line thing I've found so far is (in PHP 5.3):\n$fixed_string = iconv( 'ISO-8859-1', 'UTF-8\/\/IGNORE\/\/TRANSLATE', $in_string );\nThis attempts to translate whatever it can and simply throws away all the junk, resulting in a legal UTF-8 string output. I've also not been able to break it or cause it to fail or reject any incoming text or data, even by feeding it gobs of binary junk data.\nFinding the iconv() and getting it to work is easy; what's so maddening and wasteful is reading through all the total garbage and bend-over-backwards idiocy that so many programmers seem to espouse when dealing with this encoding fiasco. What's become of the enviable (and respectable) \"Flail and Burn The Idiots\" mentality of old school programming? Let's get back to basics. Use iconv() and throw away their garbage, and don't be bashful when telling them you threw away their garbage -- in short, don't fail to flail the morons who feed you garbage. And you can tell them I told you so.","Q_Score":5,"Tags":"python,utf-8,ascii,decode","A_Id":5642048,"CreationDate":"2009-11-24T20:08:00.000","Title":"What is the fool proof way to convert some string (utf-8 or else) to a simple ASCII string 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},{"Question":"Inside my python scrip, I get some string back from a function which I didn't write. The encoding of it varies. I need to convert it to ascii format. Is there some fool-proof way of doing this? I don't mind replacing the non-ascii chars with blanks or something else...","AnswerCount":5,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":11358,"Q_Id":1792602,"Users Score":9,"Answer":"If you want an ASCII string that unambiguously represents what you have got, without losing any information, the answer is simple:\nDon't muck about with encode\/decode, use the repr() function (Python 2.X) or the ascii() function (Python 3.x).","Q_Score":5,"Tags":"python,utf-8,ascii,decode","A_Id":1793902,"CreationDate":"2009-11-24T20:08:00.000","Title":"What is the fool proof way to convert some string (utf-8 or else) to a simple ASCII string 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},{"Question":"Would it be possible to translate the Ruby on Rails code base to Python?\nI think many people like Python more than Ruby, but find Ruby on Rails features better (as a whole) than the ones in Python web frameworks.\nSo that, would it be possible? Or does Ruby on Rails utilize language-specific features that would be difficult to translate to Python?","AnswerCount":4,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":23732,"Q_Id":1794179,"Users Score":14,"Answer":"I think one of the things that people like about RoR is the domain-specific language (DSL) style of programming. This is something that Ruby is much better at than Python.","Q_Score":23,"Tags":"python,ruby-on-rails,metaprogramming,code-translation","A_Id":1794205,"CreationDate":"2009-11-25T01:56:00.000","Title":"Python on Rails?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"Is smtplib pure python or implemented in C?","AnswerCount":3,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":355,"Q_Id":1801271,"Users Score":4,"Answer":"smtplib itself is implemented in python but socket is based on C, so its means both.","Q_Score":5,"Tags":"python,c,smtplib","A_Id":1801277,"CreationDate":"2009-11-26T02:40:00.000","Title":"Is smtplib pure python or implemented 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":0,"Web Development":0},{"Question":"Is smtplib pure python or implemented in C?","AnswerCount":3,"Available Count":2,"Score":0.1325487884,"is_accepted":false,"ViewCount":355,"Q_Id":1801271,"Users Score":2,"Answer":"Basically pure Python (as the underlying implementation if you go down far enough is C). You can find the source under the Lib\\ directory in your Python root.","Q_Score":5,"Tags":"python,c,smtplib","A_Id":1801281,"CreationDate":"2009-11-26T02:40:00.000","Title":"Is smtplib pure python or implemented 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":0,"Web Development":0},{"Question":"I come from a background where I normally create one file per class. I organize common classes under directories as well. This practice is intuitive to me and it has been proven to be effective in C++, PHP, JavaSript, etc. \nI am having trouble bringing this metaphor into Python: files are not just files anymore, but they are formal modules. It doesn't seem right to just have one class in a module --- most classes are useless by themselves. If I have a automobile.py and an Automobile class, it seems silly to always reference it as automobile.Automobile as well.\nBut, at the same time, it doesn't seem right to throw a ton of code into one file and call it a day. Obviously, a very complex application should have more than 5 files.\nWhat is the correct---or pythonic---way? (Or if there is no correct way, what is your preferred way and why?) How much code should I be throwing in a Python module?","AnswerCount":5,"Available Count":3,"Score":1.2,"is_accepted":true,"ViewCount":22658,"Q_Id":1801878,"Users Score":39,"Answer":"Think in terms of a \"logical unit of packaging\" -- which may be a single class, but more often will be a set of classes that closely cooperate. Classes (or module-level functions -- don't \"do Java in Python\" by always using static methods when module-level functions are also available as a choice!-) can be grouped based on this criterion. Basically, if most users of A also need B and vice versa, A and B should probably be in the same module; but if many users will only need one of them and not the other, then they should probably be in distinct modules (perhaps in the same package, i.e., directory with an __init__.py file in it).\nThe standard Python library, while far from perfect, tends to reflect (mostly) reasonably good practices -- so you can mostly learn from it by example. E.g., the threading module of course defines a Thread class... but it also holds the synchronization-primitive classes such as locks, events, conditions, and semaphores, and an exception-class that can be raised by threading operations (and a few more things). It's at the upper bound of reasonable size (800 lines including whitespace and docstrings), and some crucial thread-related functionality such as Queue has been placed in a separate module, nevertheless it's a good example of what maximum amount of functionality it still makes sense to pack into a single module.","Q_Score":47,"Tags":"python,module,package,project-organization","A_Id":1801992,"CreationDate":"2009-11-26T06:28:00.000","Title":"The Pythonic way of organizing modules and 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":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I come from a background where I normally create one file per class. I organize common classes under directories as well. This practice is intuitive to me and it has been proven to be effective in C++, PHP, JavaSript, etc. \nI am having trouble bringing this metaphor into Python: files are not just files anymore, but they are formal modules. It doesn't seem right to just have one class in a module --- most classes are useless by themselves. If I have a automobile.py and an Automobile class, it seems silly to always reference it as automobile.Automobile as well.\nBut, at the same time, it doesn't seem right to throw a ton of code into one file and call it a day. Obviously, a very complex application should have more than 5 files.\nWhat is the correct---or pythonic---way? (Or if there is no correct way, what is your preferred way and why?) How much code should I be throwing in a Python module?","AnswerCount":5,"Available Count":3,"Score":1.0,"is_accepted":false,"ViewCount":22658,"Q_Id":1801878,"Users Score":7,"Answer":"If you are coming from a c++ point of view, you could view python modules akin to a .so or .dll. Yeah they look like source files, because python is scripted, but they are actually loadable libraries of specific functionality. \nAnother metaphor that may help is you might look python modules as namespaces.","Q_Score":47,"Tags":"python,module,package,project-organization","A_Id":1802001,"CreationDate":"2009-11-26T06:28:00.000","Title":"The Pythonic way of organizing modules and 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":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I come from a background where I normally create one file per class. I organize common classes under directories as well. This practice is intuitive to me and it has been proven to be effective in C++, PHP, JavaSript, etc. \nI am having trouble bringing this metaphor into Python: files are not just files anymore, but they are formal modules. It doesn't seem right to just have one class in a module --- most classes are useless by themselves. If I have a automobile.py and an Automobile class, it seems silly to always reference it as automobile.Automobile as well.\nBut, at the same time, it doesn't seem right to throw a ton of code into one file and call it a day. Obviously, a very complex application should have more than 5 files.\nWhat is the correct---or pythonic---way? (Or if there is no correct way, what is your preferred way and why?) How much code should I be throwing in a Python module?","AnswerCount":5,"Available Count":3,"Score":0.1586485043,"is_accepted":false,"ViewCount":22658,"Q_Id":1801878,"Users Score":4,"Answer":"In a mid-sized project, I found myself with several sets of closely related classes. Several of those sets are now grouped into files; for example, the low-level network classes are all in a single network module. However, a few of the largest classes have been split out into their own file.\nPerhaps the best way to start down that path from a one-class-per-file history is to take the classes that you would normally place in the same directory, and instead keep them in the same file. If that file starts looking too large, split it.","Q_Score":47,"Tags":"python,module,package,project-organization","A_Id":1801981,"CreationDate":"2009-11-26T06:28:00.000","Title":"The Pythonic way of organizing modules and 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":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to understand what paste script and paster are. The website is far from clear.\nI used paster to generate pre-made layouts for projects, but I don't get the big picture. \nAs far as I understand, and from the wikipedia entry, it says it's a framework for web frameworks, but that seems reductive. paster create seems to be able to create pre-made layouts for setuptools\/distutils enabled packages.\nWhat is the problem (or set of problems) it's trying to solve?","AnswerCount":2,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":6425,"Q_Id":1802282,"Users Score":4,"Answer":"PasteScript (and its companion PasteDeploy) are tools for running Python code using 'entry points'. Basically, a python library can specify in metadata that it knows how to create a certain kind of Python project, or perform certain operations on those projects. paster is a commandline tool that looks up the appropriate code for the operation you requested. It's a very general kind of problem; if you're familiar with Ruby at all, the equivalent might be 'rake'.\nIn particular, PasteDeploy is a configuration format to serve Python webapps using paster. Both PasteScript and PasteDeploy are important for the Pylons web framework.","Q_Score":21,"Tags":"python,paste,paster","A_Id":1802443,"CreationDate":"2009-11-26T08:26:00.000","Title":"What is paste 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},{"Question":"What are the technical reasons why languages like Python and Ruby are interpreted (out of the box) instead of compiled? It seems to me like it should not be too hard for people knowledgeable in this domain to make these languages not be interpreted like they are today, and we would see significant performance gains. So certainly I am missing something.","AnswerCount":12,"Available Count":7,"Score":0.0166651236,"is_accepted":false,"ViewCount":2514,"Q_Id":1805148,"Users Score":1,"Answer":"By design. \nThe authors wanted something where they can write scripts into.\nPython gets compiled the first time it is executed though","Q_Score":18,"Tags":"python,ruby,compiler-construction","A_Id":1805155,"CreationDate":"2009-11-26T18:47:00.000","Title":"Why is (python|ruby) interpreted?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"What are the technical reasons why languages like Python and Ruby are interpreted (out of the box) instead of compiled? It seems to me like it should not be too hard for people knowledgeable in this domain to make these languages not be interpreted like they are today, and we would see significant performance gains. So certainly I am missing something.","AnswerCount":12,"Available Count":7,"Score":0.0333209931,"is_accepted":false,"ViewCount":2514,"Q_Id":1805148,"Users Score":2,"Answer":"In a compiled language, the loop you get into when making software is\n\nMake a change\nCompile changes\nTest changes\ngoto 1\n\nInterpreted languages tend to be faster to make stuff in because you get to cut out step two of that process (and when you're dealing with a large system where compile times can be upwards of two minutes, step two can add a significant amount of time).\nThis isn't necessarily the reason python|ruby designers thought of, but keep in mind that \"How efficiently does the machine run this?\" is only half the software development problem.\nIt also seems like it would be easier to compile code in a language that's interpreted naturally than it would be to add an interpreter to a language that's compiled by default.","Q_Score":18,"Tags":"python,ruby,compiler-construction","A_Id":1805169,"CreationDate":"2009-11-26T18:47:00.000","Title":"Why is (python|ruby) interpreted?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"What are the technical reasons why languages like Python and Ruby are interpreted (out of the box) instead of compiled? It seems to me like it should not be too hard for people knowledgeable in this domain to make these languages not be interpreted like they are today, and we would see significant performance gains. So certainly I am missing something.","AnswerCount":12,"Available Count":7,"Score":0.0166651236,"is_accepted":false,"ViewCount":2514,"Q_Id":1805148,"Users Score":1,"Answer":"Raw compute performance is probably not a goal of most interpreted languages. Interpreted languages are typically more concerned about programmer productivity than raw speed. In most cases these languages are plenty fast enough for the tasks the languages were designed to tackle. \nGiven that, and that just about the only advantages of a compiler are type checking (difficult to do in a dynamic language) and speed, there's not much incentive to write compilers for most interpreted languages.","Q_Score":18,"Tags":"python,ruby,compiler-construction","A_Id":1928816,"CreationDate":"2009-11-26T18:47:00.000","Title":"Why is (python|ruby) interpreted?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"What are the technical reasons why languages like Python and Ruby are interpreted (out of the box) instead of compiled? It seems to me like it should not be too hard for people knowledgeable in this domain to make these languages not be interpreted like they are today, and we would see significant performance gains. So certainly I am missing something.","AnswerCount":12,"Available Count":7,"Score":0.0333209931,"is_accepted":false,"ViewCount":2514,"Q_Id":1805148,"Users Score":2,"Answer":"Well, isn't one of the strengths of these languages that they are so easily scriptable? They wouldn't be if they were compiled. And on the other hand, dynamic languages are easier to intereprete than to compile.","Q_Score":18,"Tags":"python,ruby,compiler-construction","A_Id":1805157,"CreationDate":"2009-11-26T18:47:00.000","Title":"Why is (python|ruby) interpreted?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"What are the technical reasons why languages like Python and Ruby are interpreted (out of the box) instead of compiled? It seems to me like it should not be too hard for people knowledgeable in this domain to make these languages not be interpreted like they are today, and we would see significant performance gains. So certainly I am missing something.","AnswerCount":12,"Available Count":7,"Score":1.0,"is_accepted":false,"ViewCount":2514,"Q_Id":1805148,"Users Score":32,"Answer":"Several reasons:\n\nfaster development loop, write-test vs write-compile-link-test\neasier to arrange for dynamic behavior (reflection, metaprogramming)\nmakes the whole system portable (just recompile the underlying C code and you are good to go on a new platform)\n\nThink of what would happen if the system was not interpreted. Say you used translation-to-C as the mechanism. The compiled code would periodically have to check if it had been superseded by metaprogramming. A similar situation arises with eval()-type functions. In those cases, it would have to run the compiler again, an outrageously slow process, or it would have to also have the interpreter around at run-time anyway. \nThe only alternative here is a JIT compiler. These systems are highly complex and sophisticated and have even bigger run-time footprints than all the other alternatives. They start up very slowly, making them impractical for scripting. Ever seen a Java script? I haven't.\nSo, you have two choices:\n\nall the disadvantages of both a compiler and an interpreter\njust the disadvantages of an interpreter\n\nIt's not surprising that generally the primary implementation just goes with the second choice. It's quite possible that some day we may see secondary implementations like compilers appearing. Ruby 1.9 and Python have bytecode VM's; those are \u00bd-way there. A compiler might target just non-dynamic code, or it might have various levels of language support declarable as options. But since such a thing can't be the primary implementation, it represents a lot of work for a very marginal benefit. Ruby already has 200,000 lines of C in it...\nI suppose I should add that one can always add a compiled C (or, with some effort, any other language) extension. So, say you have a slow numerical operation. If you add, say Array#newOp with a C implementation then you get the speedup, the program stays in Ruby (or whatever) and your environment gets a new instance method. Everybody wins! So this reduces the need for a problematic secondary implementation.","Q_Score":18,"Tags":"python,ruby,compiler-construction","A_Id":1805172,"CreationDate":"2009-11-26T18:47:00.000","Title":"Why is (python|ruby) interpreted?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"What are the technical reasons why languages like Python and Ruby are interpreted (out of the box) instead of compiled? It seems to me like it should not be too hard for people knowledgeable in this domain to make these languages not be interpreted like they are today, and we would see significant performance gains. So certainly I am missing something.","AnswerCount":12,"Available Count":7,"Score":1.0,"is_accepted":false,"ViewCount":2514,"Q_Id":1805148,"Users Score":8,"Answer":"Merely replacing an interpreter with a compiler won't give you as big a performance boost as you might think for a language like Python. When most time is actually spend doing symbolic lookups of object members in dictionaries, it doesn't really matter if the call to the function performing such lookup is interpreted, or is native machine code - the difference, while not quite negligible, will be dwarfed by lookup overhead.\nTo really improve performance, you need optimizing compilers. And optimization techniques here are very different from what you have with C++, or even Java JIT - an optimizing compiler for a dynamically typed \/ duck typed language such as Python needs to do some very creative type inference (including probabilistic - i.e. \"90% chance of it being T\" and then generating efficient machine code for that case with a check\/branch before it) and escape analysis. This is hard.","Q_Score":18,"Tags":"python,ruby,compiler-construction","A_Id":1805899,"CreationDate":"2009-11-26T18:47:00.000","Title":"Why is (python|ruby) interpreted?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"What are the technical reasons why languages like Python and Ruby are interpreted (out of the box) instead of compiled? It seems to me like it should not be too hard for people knowledgeable in this domain to make these languages not be interpreted like they are today, and we would see significant performance gains. So certainly I am missing something.","AnswerCount":12,"Available Count":7,"Score":1.0,"is_accepted":false,"ViewCount":2514,"Q_Id":1805148,"Users Score":6,"Answer":"I think the biggest reason for the languages being interpreted is portability. As a programmer you can write code that will run in an interpreter not a specific OS. So your programs behave more uniformly across platforms (more so than compiled languages). Another advantage I can think of is it's easier to have a dynamic type system in an interpreted language. I think the creators of the language were thinking having a language where programmers can be more productive due to automatic memory management, dynamic type system and meta programming wins over any performance loss due to the language being interpreted. If you are concerned about performance you can always compile the language to native machine code employing a technique like JIT compilation.","Q_Score":18,"Tags":"python,ruby,compiler-construction","A_Id":1805158,"CreationDate":"2009-11-26T18:47:00.000","Title":"Why is (python|ruby) interpreted?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Been using mod_python for a while, I read more and more articles about how good WSGI is, without really understanding why.\nSo why should I switch to it? What are the benefits? Is it hard, and is the learning curve worth it?","AnswerCount":6,"Available Count":4,"Score":1.2,"is_accepted":true,"ViewCount":10494,"Q_Id":1813394,"Users Score":13,"Answer":"mod_wsgi vs. mod_python:\n\nmod_wsgi is a little faster (internally there's more C, less Python)\nmod_wsgi processes can be isolated from Apache, which improves security\/stability with lower memory use[1]\nmod_python gives you access to some of Apache's internals\n\nWSGI in general:\n\nlots of reusable middleware (authentication\/authorisation, session stuff, caching, filtering)\nease of deployment on non-Apache webservers either via native WSGI support or flup\n\n[1] - compared to a preforking Apache, which maintains a separate Python interpreter in each process","Q_Score":23,"Tags":"python,wsgi","A_Id":1813471,"CreationDate":"2009-11-28T18:54:00.000","Title":"Why should I use 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":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Been using mod_python for a while, I read more and more articles about how good WSGI is, without really understanding why.\nSo why should I switch to it? What are the benefits? Is it hard, and is the learning curve worth it?","AnswerCount":6,"Available Count":4,"Score":0.0333209931,"is_accepted":false,"ViewCount":10494,"Q_Id":1813394,"Users Score":1,"Answer":"You shouldn't have to relearn much, since the difference from a developer perspective is just a small wrapper and some server configuration.\nFrom a deployment perspective, the difference is that your python code lives in a separate process from the web browser, which means\na) The python process can be running as another user than the web server. This can be valuable for security, if used right.\nb) The web server processes does not need to contain the python runtime. This can be a major boost for performance if the server runs a lot of \"other\" requests (static files, etc) and some heavy python requests.","Q_Score":23,"Tags":"python,wsgi","A_Id":1813431,"CreationDate":"2009-11-28T18:54:00.000","Title":"Why should I use 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":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Been using mod_python for a while, I read more and more articles about how good WSGI is, without really understanding why.\nSo why should I switch to it? What are the benefits? Is it hard, and is the learning curve worth it?","AnswerCount":6,"Available Count":4,"Score":0.0665680765,"is_accepted":false,"ViewCount":10494,"Q_Id":1813394,"Users Score":2,"Answer":"Most Python frameworks implement wsgi. There is mod_wsgi for apache and a SCGI\/FastCGI\/AJP module + Flup for the others. That way you can have all the advantages of a separate Python process, without being tied to one webserver.","Q_Score":23,"Tags":"python,wsgi","A_Id":1813462,"CreationDate":"2009-11-28T18:54:00.000","Title":"Why should I use 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":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Been using mod_python for a while, I read more and more articles about how good WSGI is, without really understanding why.\nSo why should I switch to it? What are the benefits? Is it hard, and is the learning curve worth it?","AnswerCount":6,"Available Count":4,"Score":1.0,"is_accepted":false,"ViewCount":10494,"Q_Id":1813394,"Users Score":15,"Answer":"For developing sophisticated web applications in Python, you would probably use a more comprehensive web development framework like DJango, Zope, Turbogears etc. As an application developer, you don't have to worry about WSGI much. All you have to be aware about is that these frameworks support WSGI. The WSGI allows separation of web server and web application code and a system administrator can change the web server as long as the web application is WSGI compliant. If you are developing in one of these frameworks, you would anyway be satisfying this condition. \nIf you are a web framework developer (that is developing DJango or Zope itself), then you have to understand WSGI in more depth.","Q_Score":23,"Tags":"python,wsgi","A_Id":1813470,"CreationDate":"2009-11-28T18:54:00.000","Title":"Why should I use 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":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to work on some problems and algorithms. I know C++ but a friend told me that it would be better if done with Python.As it would be much faster to develop and less time is spent in programming details which does not actually earn anything solution wise.\nEDIT 2: I plan to use python-graph lib from Google-codes, Please provide example codes if you have used it.\nEDIT 1: faster - less time && less work to code the solution\nThank you all for your help !","AnswerCount":13,"Available Count":11,"Score":0.0307595242,"is_accepted":false,"ViewCount":1482,"Q_Id":1823431,"Users Score":2,"Answer":"I also vote for python. When do algorithm, we tend to work on the algorithm itself rather than language, low level details. Basically, we works on abstraction level. And using python, we're less likely to be side-tracked. \nBut if you're very familiar and comfortable with C++ and can use it freely to express your idea, just use it.","Q_Score":4,"Tags":"c++,python,algorithm,graph","A_Id":1823545,"CreationDate":"2009-12-01T01:08:00.000","Title":"which is a better language (C++ or Python) for complex problem solving exercises (ex. Graphs)?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to work on some problems and algorithms. I know C++ but a friend told me that it would be better if done with Python.As it would be much faster to develop and less time is spent in programming details which does not actually earn anything solution wise.\nEDIT 2: I plan to use python-graph lib from Google-codes, Please provide example codes if you have used it.\nEDIT 1: faster - less time && less work to code the solution\nThank you all for your help !","AnswerCount":13,"Available Count":11,"Score":0.0153834017,"is_accepted":false,"ViewCount":1482,"Q_Id":1823431,"Users Score":1,"Answer":"If using C++ means that STL is fair game, I'd say that it deserves serious consideration. STL is a fantastic library, combining structures, iterators, and algorithms. I love the Python recommendations, but if I could use STL I'd reconsider C++.","Q_Score":4,"Tags":"c++,python,algorithm,graph","A_Id":1823577,"CreationDate":"2009-12-01T01:08:00.000","Title":"which is a better language (C++ or Python) for complex problem solving exercises (ex. Graphs)?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to work on some problems and algorithms. I know C++ but a friend told me that it would be better if done with Python.As it would be much faster to develop and less time is spent in programming details which does not actually earn anything solution wise.\nEDIT 2: I plan to use python-graph lib from Google-codes, Please provide example codes if you have used it.\nEDIT 1: faster - less time && less work to code the solution\nThank you all for your help !","AnswerCount":13,"Available Count":11,"Score":0.0307595242,"is_accepted":false,"ViewCount":1482,"Q_Id":1823431,"Users Score":2,"Answer":"With C++, you'd sometimes be concentrating more on the language issues than the problem itself, so Python. I'd even be recommending you do it in a higher-level language like Matlab (although the language itself can be a bit ugly).","Q_Score":4,"Tags":"c++,python,algorithm,graph","A_Id":1823589,"CreationDate":"2009-12-01T01:08:00.000","Title":"which is a better language (C++ or Python) for complex problem solving exercises (ex. Graphs)?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to work on some problems and algorithms. I know C++ but a friend told me that it would be better if done with Python.As it would be much faster to develop and less time is spent in programming details which does not actually earn anything solution wise.\nEDIT 2: I plan to use python-graph lib from Google-codes, Please provide example codes if you have used it.\nEDIT 1: faster - less time && less work to code the solution\nThank you all for your help !","AnswerCount":13,"Available Count":11,"Score":0.0,"is_accepted":false,"ViewCount":1482,"Q_Id":1823431,"Users Score":0,"Answer":"Remember that Python is compiled to bytecode and then interpreted in a VM. So, in performance isn't better (faster) than C++.","Q_Score":4,"Tags":"c++,python,algorithm,graph","A_Id":1823580,"CreationDate":"2009-12-01T01:08:00.000","Title":"which is a better language (C++ or Python) for complex problem solving exercises (ex. Graphs)?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to work on some problems and algorithms. I know C++ but a friend told me that it would be better if done with Python.As it would be much faster to develop and less time is spent in programming details which does not actually earn anything solution wise.\nEDIT 2: I plan to use python-graph lib from Google-codes, Please provide example codes if you have used it.\nEDIT 1: faster - less time && less work to code the solution\nThank you all for your help !","AnswerCount":13,"Available Count":11,"Score":0.0461211021,"is_accepted":false,"ViewCount":1482,"Q_Id":1823431,"Users Score":3,"Answer":"Algorithms are fine in Python (allthough you can only fly one OS scheduled python thread due to the global lock); however, when it comes to data structures + algorithms you need fixed complexity guarantees, and this case you mix Python with C.\nI suppose what I have said applies more to long running computations. You can emulate data structures on-top of the python hashmap primitive.","Q_Score":4,"Tags":"c++,python,algorithm,graph","A_Id":1823479,"CreationDate":"2009-12-01T01:08:00.000","Title":"which is a better language (C++ or Python) for complex problem solving exercises (ex. Graphs)?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to work on some problems and algorithms. I know C++ but a friend told me that it would be better if done with Python.As it would be much faster to develop and less time is spent in programming details which does not actually earn anything solution wise.\nEDIT 2: I plan to use python-graph lib from Google-codes, Please provide example codes if you have used it.\nEDIT 1: faster - less time && less work to code the solution\nThank you all for your help !","AnswerCount":13,"Available Count":11,"Score":0.0614608973,"is_accepted":false,"ViewCount":1482,"Q_Id":1823431,"Users Score":4,"Answer":"I would go for python. And if you really need the performance, then you can always write C\/C++ extensions and use them in python.","Q_Score":4,"Tags":"c++,python,algorithm,graph","A_Id":1823473,"CreationDate":"2009-12-01T01:08:00.000","Title":"which is a better language (C++ or Python) for complex problem solving exercises (ex. Graphs)?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to work on some problems and algorithms. I know C++ but a friend told me that it would be better if done with Python.As it would be much faster to develop and less time is spent in programming details which does not actually earn anything solution wise.\nEDIT 2: I plan to use python-graph lib from Google-codes, Please provide example codes if you have used it.\nEDIT 1: faster - less time && less work to code the solution\nThank you all for your help !","AnswerCount":13,"Available Count":11,"Score":1.0,"is_accepted":false,"ViewCount":1482,"Q_Id":1823431,"Users Score":8,"Answer":"A bit subjective, but I'd vote for python because it has good libraries and abstracts a lot of the low level 'detail' that you'd have to consider when using c++...","Q_Score":4,"Tags":"c++,python,algorithm,graph","A_Id":1823434,"CreationDate":"2009-12-01T01:08:00.000","Title":"which is a better language (C++ or Python) for complex problem solving exercises (ex. Graphs)?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to work on some problems and algorithms. I know C++ but a friend told me that it would be better if done with Python.As it would be much faster to develop and less time is spent in programming details which does not actually earn anything solution wise.\nEDIT 2: I plan to use python-graph lib from Google-codes, Please provide example codes if you have used it.\nEDIT 1: faster - less time && less work to code the solution\nThank you all for your help !","AnswerCount":13,"Available Count":11,"Score":1.0,"is_accepted":false,"ViewCount":1482,"Q_Id":1823431,"Users Score":6,"Answer":"I did all my algorithms work in college in C++ because I knew it.\nIf I'd had to learn a language at the same time, I would have picked Python most likely.","Q_Score":4,"Tags":"c++,python,algorithm,graph","A_Id":1823440,"CreationDate":"2009-12-01T01:08:00.000","Title":"which is a better language (C++ or Python) for complex problem solving exercises (ex. Graphs)?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to work on some problems and algorithms. I know C++ but a friend told me that it would be better if done with Python.As it would be much faster to develop and less time is spent in programming details which does not actually earn anything solution wise.\nEDIT 2: I plan to use python-graph lib from Google-codes, Please provide example codes if you have used it.\nEDIT 1: faster - less time && less work to code the solution\nThank you all for your help !","AnswerCount":13,"Available Count":11,"Score":1.0,"is_accepted":false,"ViewCount":1482,"Q_Id":1823431,"Users Score":6,"Answer":"I am under the impression that it really depends from what you mean by faster.\nFaster to develop: go python.\nFaster to run: go C++.\nHowever python can use a lot of external C libraries, so the difference in processing time might not be that relevant, depending on the type of implementation.","Q_Score":4,"Tags":"c++,python,algorithm,graph","A_Id":1823447,"CreationDate":"2009-12-01T01:08:00.000","Title":"which is a better language (C++ or Python) for complex problem solving exercises (ex. Graphs)?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to work on some problems and algorithms. I know C++ but a friend told me that it would be better if done with Python.As it would be much faster to develop and less time is spent in programming details which does not actually earn anything solution wise.\nEDIT 2: I plan to use python-graph lib from Google-codes, Please provide example codes if you have used it.\nEDIT 1: faster - less time && less work to code the solution\nThank you all for your help !","AnswerCount":13,"Available Count":11,"Score":0.0767717131,"is_accepted":false,"ViewCount":1482,"Q_Id":1823431,"Users Score":5,"Answer":"At my university the 500 students in the \"Algorithms and Datastructures\" class get to choose the language they want.\nPython is by far the most popular choice there, and personally I'm happy I also chose that, even though I already knew C++.","Q_Score":4,"Tags":"c++,python,algorithm,graph","A_Id":1823457,"CreationDate":"2009-12-01T01:08:00.000","Title":"which is a better language (C++ or Python) for complex problem solving exercises (ex. Graphs)?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to work on some problems and algorithms. I know C++ but a friend told me that it would be better if done with Python.As it would be much faster to develop and less time is spent in programming details which does not actually earn anything solution wise.\nEDIT 2: I plan to use python-graph lib from Google-codes, Please provide example codes if you have used it.\nEDIT 1: faster - less time && less work to code the solution\nThank you all for your help !","AnswerCount":13,"Available Count":11,"Score":1.2,"is_accepted":true,"ViewCount":1482,"Q_Id":1823431,"Users Score":23,"Answer":"I think you're looking for Python, because you can:\n\nFocus on the algorithms themselves and not have to worry about other detail like memory management. \nDo more with less code\nThe syntax is almost like working with pseudo code.\nThere is great built in language support for lists, tuples, list comprehensions, etc...\n\nBut more specifically...\n\nIf by better you mean speed of development, then chose Python.\nIf by better you mean sheer execution speed, then chose C++.","Q_Score":4,"Tags":"c++,python,algorithm,graph","A_Id":1823475,"CreationDate":"2009-12-01T01:08:00.000","Title":"which is a better language (C++ or Python) for complex problem solving exercises (ex. Graphs)?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have been using python's native bignums for an algorithm and decided to try and speed it up by converting it to C++. When I used long longs, the C++ was about 100x faster than the python, but when I used GMP bindings in C++, it was only 10x faster than the python (for the same cases that fit in long longs).\nIs there a better bignum implementation for doing a large number of small additions? For example, we have a big number N we'll be adding a lot of little +1, +21, +1, etc. and every once and a while adds another big number M?","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1568,"Q_Id":1831212,"Users Score":0,"Answer":"Did you do profiling ? Of Python and C++ whole applications. So that you know that you really need that additional speed.\nTry Python 3k it now have any-length integers implemented!","Q_Score":5,"Tags":"c++,python,bignum,gmp,arbitrary-precision","A_Id":1831277,"CreationDate":"2009-12-02T07:33:00.000","Title":"Bignum implementation that has efficient addition of small integers","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I have been working with Ruby on Rails for over a year now and have been offered some development work with Python. I would like know if development with Python is as enjoyable as Ruby in terms of the clarity and ease of use. And how well is Python suited for Web development. I've heard of Pylons being a direct port of the Rails framework but does it provide the same level of comfort and features. Are there any popular websites built using Python and a framework that offers the same level of flexibilty as Rails.\nBecause Rails doesn't seem like work.","AnswerCount":5,"Available Count":1,"Score":0.0399786803,"is_accepted":false,"ViewCount":1541,"Q_Id":1834829,"Users Score":1,"Answer":"Clarity and ease of use are some of Pythons biggest selling points. In saying that, the different Python web frameworks cover almost the entire spectrum from small and simple all the way up to large and complex with everything in between.\nYou should find that most Python web frameworks have less 'magic' than Rails - ie they are a bit more explicit which is arguably better from the clarity point of view.\nIn my opinion, even if you enjoy Rails and don't ever plan on leaving, you should still try out other languages and frameworks occasionally to give you a broader perspective.\nPersonally I like Turbogears2, but I think Django would make a good starting point for a Rails developer that wanted to try out something else.","Q_Score":2,"Tags":"python,ruby-on-rails,pylons","A_Id":1864605,"CreationDate":"2009-12-02T18:22:00.000","Title":"Python after Ruby on Rails","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"What are the advantages of Python, PowerShell, and other scripting environments? We would like to standardize our scripting and are currently using bat and cmd files as the standard. I think Python would be a better option than these, but am also researching PowerShell and other scripting tools.\nThe scripts would be used to trigger processes such as wget etc to call web services, or other applications\/tools that need to run in a specific order with specific parameters.\nWe primarily work with the Windows stack, but there is a good chance we will need to support Unix in the future.","AnswerCount":8,"Available Count":6,"Score":1.0,"is_accepted":false,"ViewCount":44901,"Q_Id":1834850,"Users Score":46,"Answer":"Python works as a great, all-purpose tool if you're looking to replace CMD and BAT scripts on your Windows boxes, and can also be written to run scripts on your (L)inux boxes, too. It's a great, flexible language and can handle many tasks you throw at it.\nThat being said, PowerShell is an amazingly versatile tool for administering all manner of Windows boxes; it has all the power of .NET, with many more interfaces into MS products such as Exchange and Active Directory, which are a timesaver. Depending on your situation, you may get more use of of PS than other scripting languages just because of the interfaces available to MS products, and I know MS seems to have made a commitment to providing those APIs in a lot of products. PowerShell comes installed on all current versions of Windows (Windows 7+, Windows Server 2008+), and is fairly easily installed on older versions.\nTo address your edit that your scripts will be used to launch other processes, I think in that case either of the tools fit the bill. I would recommend PS if you plan on adding any admin-ish tasks to the scripts rather than just service calls, but if you stick to what you described, Python is good.","Q_Score":32,"Tags":"python,powershell,scripting","A_Id":1835086,"CreationDate":"2009-12-02T18:26:00.000","Title":"Python, PowerShell, or Other?","Data Science and Machine Learning":0,"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},{"Question":"What are the advantages of Python, PowerShell, and other scripting environments? We would like to standardize our scripting and are currently using bat and cmd files as the standard. I think Python would be a better option than these, but am also researching PowerShell and other scripting tools.\nThe scripts would be used to trigger processes such as wget etc to call web services, or other applications\/tools that need to run in a specific order with specific parameters.\nWe primarily work with the Windows stack, but there is a good chance we will need to support Unix in the future.","AnswerCount":8,"Available Count":6,"Score":0.0748596907,"is_accepted":false,"ViewCount":44901,"Q_Id":1834850,"Users Score":3,"Answer":"If all you do is spawning a lot of system specific programs with no or little programming logic behind then OS specific shell might be a better choice than a full general purpose programming language.","Q_Score":32,"Tags":"python,powershell,scripting","A_Id":1836471,"CreationDate":"2009-12-02T18:26:00.000","Title":"Python, PowerShell, or Other?","Data Science and Machine Learning":0,"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},{"Question":"What are the advantages of Python, PowerShell, and other scripting environments? We would like to standardize our scripting and are currently using bat and cmd files as the standard. I think Python would be a better option than these, but am also researching PowerShell and other scripting tools.\nThe scripts would be used to trigger processes such as wget etc to call web services, or other applications\/tools that need to run in a specific order with specific parameters.\nWe primarily work with the Windows stack, but there is a good chance we will need to support Unix in the future.","AnswerCount":8,"Available Count":6,"Score":0.049958375,"is_accepted":false,"ViewCount":44901,"Q_Id":1834850,"Users Score":2,"Answer":"I find it sad no one yet mentioend good ol' Perl.","Q_Score":32,"Tags":"python,powershell,scripting","A_Id":1835112,"CreationDate":"2009-12-02T18:26:00.000","Title":"Python, PowerShell, or Other?","Data Science and Machine Learning":0,"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},{"Question":"What are the advantages of Python, PowerShell, and other scripting environments? We would like to standardize our scripting and are currently using bat and cmd files as the standard. I think Python would be a better option than these, but am also researching PowerShell and other scripting tools.\nThe scripts would be used to trigger processes such as wget etc to call web services, or other applications\/tools that need to run in a specific order with specific parameters.\nWe primarily work with the Windows stack, but there is a good chance we will need to support Unix in the future.","AnswerCount":8,"Available Count":6,"Score":0.049958375,"is_accepted":false,"ViewCount":44901,"Q_Id":1834850,"Users Score":2,"Answer":"The questions is kind of vague, but Python is much more portable than PowerShell; however, Python isn't that prevalent on Windows. But on the other hand, I don't believe PowerShell scripts will work on a Windows machine that doesn't have PowerShell. Meaning they may not work in the old fashioned cmd shell. I think you'll find more documentation and libraries for Python as well.\nPowerShell is more like Bash than it is a programming language like Python.\nMaybe you could explain what you want to do with your scripts and you'll probably get better answers.","Q_Score":32,"Tags":"python,powershell,scripting","A_Id":1834895,"CreationDate":"2009-12-02T18:26:00.000","Title":"Python, PowerShell, or Other?","Data Science and Machine Learning":0,"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},{"Question":"What are the advantages of Python, PowerShell, and other scripting environments? We would like to standardize our scripting and are currently using bat and cmd files as the standard. I think Python would be a better option than these, but am also researching PowerShell and other scripting tools.\nThe scripts would be used to trigger processes such as wget etc to call web services, or other applications\/tools that need to run in a specific order with specific parameters.\nWe primarily work with the Windows stack, but there is a good chance we will need to support Unix in the future.","AnswerCount":8,"Available Count":6,"Score":1.0,"is_accepted":false,"ViewCount":44901,"Q_Id":1834850,"Users Score":20,"Answer":"We would like to standardize our scripting and are currently using bat and cmd files as the standard.\n\nIt sounds like Windows is your predominate environment.\nIf so, PowerShell would be much better than Python. \n\nPowerShell is included with Windows\nServer 2008. No need to\ndeploy\/install Python runtime on\nevery new server that rolls in.\nThe entire Microsoft server related software (Exchange, Systems Center, etc) is transitioning to PowerShell cmdlets for functionality and extensions\n3rd party vendors (e.g. SCOM plugins) will also use PowerShell scripts\/cmdlets to expose functionality\n\nI have more experience with Python than PowerShell but the writing is on the wall as far as the Microsoft ecosystem is concerned: go with PowerShell. Otherwise, you'll just be going against the grain and constantly interop-ing between Python and everyone else's cmdlets.\nJust because you can code import win32com.client in Python does not put it on equal footing with PowerShell in the Windows environment.","Q_Score":32,"Tags":"python,powershell,scripting","A_Id":1836342,"CreationDate":"2009-12-02T18:26:00.000","Title":"Python, PowerShell, or Other?","Data Science and Machine Learning":0,"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},{"Question":"What are the advantages of Python, PowerShell, and other scripting environments? We would like to standardize our scripting and are currently using bat and cmd files as the standard. I think Python would be a better option than these, but am also researching PowerShell and other scripting tools.\nThe scripts would be used to trigger processes such as wget etc to call web services, or other applications\/tools that need to run in a specific order with specific parameters.\nWe primarily work with the Windows stack, but there is a good chance we will need to support Unix in the future.","AnswerCount":8,"Available Count":6,"Score":0.049958375,"is_accepted":false,"ViewCount":44901,"Q_Id":1834850,"Users Score":2,"Answer":"One advantage to Python is the availability of third-party libraries and an extensive built-in standard library. You can do a lot of powerful operations quickly and easily with Python on a variety of operating systems and environments. That's one reason we use Python here at the office not only as a scripting language but for all of our database backend applications as well.\nWe also use it for XML and HTML scraping, using ElementTree and BeautifulSoup, which are very powerful and flexible Python-specific libraries for this sort of work.","Q_Score":32,"Tags":"python,powershell,scripting","A_Id":1834979,"CreationDate":"2009-12-02T18:26:00.000","Title":"Python, PowerShell, or Other?","Data Science and Machine Learning":0,"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},{"Question":"I need to render wikitext (pulled from the database of a mediawiki of it's relevant) and display in some other format (ultimately to be rendered as a PDF, but basically any other format will do).\nI can definately hack together something that does the job but ultimately I'll be writing it as I go along, and I can see that the overhead of implementing new tags as people in my team use them will eat up a lot of my time.\nIs there a project to do this?\nI saw TiddlyWiki which is written in python, which I will look into borrowing their library, but in the meantime I figured there may be a project that's a bit more niche that someone knows?\nCheers","AnswerCount":3,"Available Count":1,"Score":-0.0665680765,"is_accepted":false,"ViewCount":2209,"Q_Id":1836884,"Users Score":-1,"Answer":"pywikipedia i have found to be best","Q_Score":1,"Tags":"python,mediawiki,wikitext","A_Id":2321542,"CreationDate":"2009-12-03T00:29:00.000","Title":"Render wikitext with 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":0,"Web Development":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},{"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},{"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},{"Question":"I'm writing a web app using python with web.py, and I want to implement my own logging system. I'd like to log detailed information about each request that come to python (static files are handled by web servers).\nCurrently I'm thinking about writing the logs to a pipe. On the other side, there should be cronolog.\nMy main concern is that will the performance be good? How is the time\/resource consumed in piping the logs compared to the normal processing of a request (less than 5 database queries, and page generation from templates)?\nOr are there other better approaches? I don't want to write the log file in python because tens of processes will be started by fastcgi.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":514,"Q_Id":1839348,"Users Score":1,"Answer":"Pipes are one of the fastest I\/O mechanisms available. It's just a shared buffer. Nothing more. If the receiving end of your pipe is totally overwhelmed, you may have an issue. But you have no evidence of that right now.\nIf you have 10's of processes started by FastCGI, each can have their own independent log file. That's the ideal situation: use Python logging -- make each process have a unique log file.\nIn the rare event that you need to examine all log files, cat them together for analysis.","Q_Score":0,"Tags":"python,logging,pipe","A_Id":1839366,"CreationDate":"2009-12-03T11:28:00.000","Title":"python web app logging through pipe? (performance concerned)","Data Science and Machine Learning":0,"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},{"Question":"Problem Specification:\nGiven a directory, I want to iterate through the directory and its non-hidden sub-directories,\n\u00a0and add a whirlpool hash into the non-hidden\nfile's names.\nIf the script is re-run it would would replace an old hash with a new one.\n\n.\u00a0\u00a0\u00a0==>\u00a0\u00a0..\n..\u00a0\u00a0\u00a0==>\u00a0\u00a0..\n\n\n\n\nQuestion:\na) How would you do this?\nb) Out of the all methods available to you, what makes your method most suitable?\n\n\n\nVerdict:\nThanks all, I have chosen SeigeX's answer for it's speed and portability.\nIt is emprically quicker than the other bash variants,\n\u00a0and it worked without alteration on my Mac OS X machine.","AnswerCount":13,"Available Count":1,"Score":0.0153834017,"is_accepted":false,"ViewCount":4430,"Q_Id":1841737,"Users Score":1,"Answer":"Hm, interesting problem.\nTry the following (the mktest function is just for testing -- TDD for bash! :)\nEdit:\n\nAdded support for whirlpool hashes.\ncode cleanup\nbetter quoting of filenames\nchanged array-syntax for test part-- should now work with most korn-like shells. Note that pdksh does not support :-based parameter expansion (or rather\nit means something else)\n\nNote also that when in md5-mode it fails for filenames with whirlpool-like hashes, and\npossibly vice-versa.\n\n\n#!\/usr\/bin\/env bash\n\n#Tested with:\n# GNU bash, version 4.0.28(1)-release (x86_64-pc-linux-gnu)\n# ksh (AT&T Research) 93s+ 2008-01-31\n# mksh @(#)MIRBSD KSH R39 2009\/08\/01 Debian 39.1-4\n# Does not work with pdksh, dash\n\nDEFAULT_SUM=\"md5\"\n\n#Takes a parameter, as root path\n# as well as an optional parameter, the hash function to use (md5 or wp for whirlpool).\nmain()\n{\n case $2 in\n \"wp\")\n export SUM=\"wp\"\n ;;\n \"md5\")\n export SUM=\"md5\"\n ;;\n *)\n export SUM=$DEFAULT_SUM\n ;;\n esac\n\n # For all visible files in all visible subfolders, move the file\n # to a name including the correct hash:\n find $1 -type f -not -regex '.*\/\\..*' -exec $0 hashmove '{}' \\;\n}\n\n# Given a file named in $1 with full path, calculate it's hash.\n# Output the filname, with the hash inserted before the extention\n# (if any) -- or: replace an existing hash with the new one,\n# if a hash already exist.\nhashname_md5()\n{\n pathname=\"$1\"\n full_hash=`md5sum \"$pathname\"`\n hash=${full_hash:0:32}\n filename=`basename \"$pathname\"`\n prefix=${filename%%.*}\n suffix=${filename#$prefix}\n\n #If the suffix starts with something that looks like an md5sum,\n #remove it:\n suffix=`echo $suffix|sed -r 's\/\\.[a-z0-9]{32}\/\/'`\n\n echo \"$prefix.$hash$suffix\"\n}\n\n# Same as hashname_md5 -- but uses whirlpool hash.\nhashname_wp()\n{\n pathname=\"$1\"\n hash=`whirlpool \"$pathname\"`\n filename=`basename \"$pathname\"`\n prefix=${filename%%.*}\n suffix=${filename#$prefix}\n\n #If the suffix starts with something that looks like an md5sum,\n #remove it:\n suffix=`echo $suffix|sed -r 's\/\\.[a-z0-9]{128}\/\/'`\n\n echo \"$prefix.$hash$suffix\"\n}\n\n\n#Given a filepath $1, move\/rename it to a name including the filehash.\n# Try to replace an existing hash, an not move a file if no update is\n# needed.\nhashmove()\n{\n pathname=\"$1\"\n filename=`basename \"$pathname\"`\n path=\"${pathname%%\/$filename}\"\n\n case $SUM in\n \"wp\")\n hashname=`hashname_wp \"$pathname\"`\n ;;\n \"md5\")\n hashname=`hashname_md5 \"$pathname\"`\n ;;\n *)\n echo \"Unknown hash requested\"\n exit 1\n ;;\n esac\n\n if [[ \"$filename\" != \"$hashname\" ]]\n then\n echo \"renaming: $pathname => $path\/$hashname\"\n mv \"$pathname\" \"$path\/$hashname\"\n else\n echo \"$pathname up to date\"\n fi\n}\n\n# Create som testdata under \/tmp\nmktest()\n{\n root_dir=$(tempfile)\n rm \"$root_dir\"\n mkdir \"$root_dir\"\n i=0\n test_files[$((i++))]='test'\n test_files[$((i++))]='testfile, no extention or spaces'\n\n test_files[$((i++))]='.hidden'\n test_files[$((i++))]='a hidden file'\n\n test_files[$((i++))]='test space'\n test_files[$((i++))]='testfile, no extention, spaces in name'\n\n test_files[$((i++))]='test.txt'\n test_files[$((i++))]='testfile, extention, no spaces in name'\n\n test_files[$((i++))]='test.ab8e460eac3599549cfaa23a848635aa.txt'\n test_files[$((i++))]='testfile, With (wrong) md5sum, no spaces in name'\n\n test_files[$((i++))]='test spaced.ab8e460eac3599549cfaa23a848635aa.txt'\n test_files[$((i++))]='testfile, With (wrong) md5sum, spaces in name'\n\n test_files[$((i++))]='test.8072ec03e95a26bb07d6e163c93593283fee032db7265a29e2430004eefda22ce096be3fa189e8988c6ad77a3154af76f582d7e84e3f319b798d369352a63c3d.txt'\n test_files[$((i++))]='testfile, With (wrong) whirlpoolhash, no spaces in name'\n\n test_files[$((i++))]='test spaced.8072ec03e95a26bb07d6e163c93593283fee032db7265a29e2430004eefda22ce096be3fa189e8988c6ad77a3154af76f582d7e84e3f319b798d369352a63c3d.txt']\n test_files[$((i++))]='testfile, With (wrong) whirlpoolhash, spaces in name'\n\n test_files[$((i++))]='test space.txt'\n test_files[$((i++))]='testfile, extention, spaces in name'\n\n test_files[$((i++))]='test multi-space .txt'\n test_files[$((i++))]='testfile, extention, multiple consequtive spaces in name'\n\n test_files[$((i++))]='test space.h'\n test_files[$((i++))]='testfile, short extention, spaces in name'\n\n test_files[$((i++))]='test space.reallylong'\n test_files[$((i++))]='testfile, long extention, spaces in name'\n\n test_files[$((i++))]='test space.reallyreallyreallylong.tst'\n test_files[$((i++))]='testfile, long extention, double extention,\n might look like hash, spaces in name'\n\n test_files[$((i++))]='utf8test1 - \u00e6eia\u00e6\u00e5.txt'\n test_files[$((i++))]='testfile, extention, utf8 characters, spaces in name'\n\n test_files[$((i++))]='utf8test1 - \u6f22\u5b57.txt'\n test_files[$((i++))]='testfile, extention, Japanese utf8 characters, spaces in name'\n\n for s in . sub1 sub2 sub1\/sub3 .hidden_dir\n do\n\n #note -p not needed as we create dirs top-down\n #fails for \".\" -- but the hack allows us to use a single loop\n #for creating testdata in all dirs\n mkdir $root_dir\/$s\n dir=$root_dir\/$s\n\n i=0\n while [[ $i -lt ${#test_files[*]} ]]\n do\n filename=${test_files[$((i++))]}\n echo ${test_files[$((i++))]} > \"$dir\/$filename\"\n done\n done\n\n echo \"$root_dir\"\n}\n\n# Run test, given a hash-type as first argument\nruntest()\n{\n sum=$1\n\n root_dir=$(mktest)\n\n echo \"created dir: $root_dir\"\n echo \"Running first test with hashtype $sum:\"\n echo\n main $root_dir $sum\n echo\n echo \"Running second test:\"\n echo\n main $root_dir $sum\n echo \"Updating all files:\"\n\n find $root_dir -type f | while read f\n do\n echo \"more content\" >> \"$f\"\n done\n\n echo\n echo \"Running final test:\"\n echo\n main $root_dir $sum\n #cleanup:\n rm -r $root_dir\n}\n\n# Test md5 and whirlpool hashes on generated data.\nruntests()\n{\n runtest md5\n runtest wp\n}\n\n#For in order to be able to call the script recursively, without splitting off\n# functions to separate files:\ncase \"$1\" in\n 'test')\n runtests\n ;;\n 'hashname')\n hashname \"$2\"\n ;;\n 'hashmove')\n hashmove \"$2\"\n ;;\n 'run')\n main \"$2\" \"$3\"\n ;;\n *)\n echo \"Use with: $0 test - or if you just want to try it on a folder:\"\n echo \" $0 run path (implies md5)\"\n echo \" $0 run md5 path\"\n echo \" $0 run wp path\"\n ;;\nesac","Q_Score":3,"Tags":"python,perl,bash,hash,batch-processing","A_Id":1847365,"CreationDate":"2009-12-03T18:00:00.000","Title":"Hashing Multiple 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},{"Question":"I've never used python before. I've used php for about 5 years now. I plan to learn python, but I'm not sure what for yet. If I can think of a project that might be better to do in python, I'll use that to learn it.\nEdit: just to add this as an important note, I do mean strictly for linux, not multi-platform.\nEdit 2: I'm hoping for objective answers, like a specific project, not a general field of projects, etc.","AnswerCount":8,"Available Count":5,"Score":0.024994793,"is_accepted":false,"ViewCount":640,"Q_Id":1842208,"Users Score":1,"Answer":"If you're doing any multi threading development, pick Python over PHP.","Q_Score":3,"Tags":"php,python,linux,theory","A_Id":1847687,"CreationDate":"2009-12-03T19:13:00.000","Title":"From a coder's perspective, what kind of project should I choose python over php for where both could do the 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":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've never used python before. I've used php for about 5 years now. I plan to learn python, but I'm not sure what for yet. If I can think of a project that might be better to do in python, I'll use that to learn it.\nEdit: just to add this as an important note, I do mean strictly for linux, not multi-platform.\nEdit 2: I'm hoping for objective answers, like a specific project, not a general field of projects, etc.","AnswerCount":8,"Available Count":5,"Score":0.024994793,"is_accepted":false,"ViewCount":640,"Q_Id":1842208,"Users Score":1,"Answer":"My company was contracted to build a web application last year, and the client specified that it should be done in Flex. Now, this application should have been a web application, but we had a unique opportunity to try something new.\nWe had absolutely no idea what we were doing at the time, but it was a great learning experience. My advice would be to try something new when you get the chance, make mistakes, and continue to learn.\nMight be harder if you want to learn Python casually... Try getting someone to pay you for using it.","Q_Score":3,"Tags":"php,python,linux,theory","A_Id":1845431,"CreationDate":"2009-12-03T19:13:00.000","Title":"From a coder's perspective, what kind of project should I choose python over php for where both could do the 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":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've never used python before. I've used php for about 5 years now. I plan to learn python, but I'm not sure what for yet. If I can think of a project that might be better to do in python, I'll use that to learn it.\nEdit: just to add this as an important note, I do mean strictly for linux, not multi-platform.\nEdit 2: I'm hoping for objective answers, like a specific project, not a general field of projects, etc.","AnswerCount":8,"Available Count":5,"Score":0.0748596907,"is_accepted":false,"ViewCount":640,"Q_Id":1842208,"Users Score":3,"Answer":"A project you want to maintain over any length of time.\nI've had to maintain PHP code and there is something about the fact that you can mix HTML and code that makes PHP stuff a nightmare.\nPython has a much higher level of abstraction and makes more maintainable code much easier to write and much more importantly for maintenance - read.\nAll IMHO of course as this is a rather subjective question.","Q_Score":3,"Tags":"php,python,linux,theory","A_Id":1842248,"CreationDate":"2009-12-03T19:13:00.000","Title":"From a coder's perspective, what kind of project should I choose python over php for where both could do the 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":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've never used python before. I've used php for about 5 years now. I plan to learn python, but I'm not sure what for yet. If I can think of a project that might be better to do in python, I'll use that to learn it.\nEdit: just to add this as an important note, I do mean strictly for linux, not multi-platform.\nEdit 2: I'm hoping for objective answers, like a specific project, not a general field of projects, etc.","AnswerCount":8,"Available Count":5,"Score":0.024994793,"is_accepted":false,"ViewCount":640,"Q_Id":1842208,"Users Score":1,"Answer":"Anything that requires background processing or any significant amount of code that doesn't just show a user a page. Python is really good as a scripting language, and writing a command line Python script is commonplace; writing a PHP script to do command line work is rare.","Q_Score":3,"Tags":"php,python,linux,theory","A_Id":1842267,"CreationDate":"2009-12-03T19:13:00.000","Title":"From a coder's perspective, what kind of project should I choose python over php for where both could do the 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":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've never used python before. I've used php for about 5 years now. I plan to learn python, but I'm not sure what for yet. If I can think of a project that might be better to do in python, I'll use that to learn it.\nEdit: just to add this as an important note, I do mean strictly for linux, not multi-platform.\nEdit 2: I'm hoping for objective answers, like a specific project, not a general field of projects, etc.","AnswerCount":8,"Available Count":5,"Score":0.1243530018,"is_accepted":false,"ViewCount":640,"Q_Id":1842208,"Users Score":5,"Answer":"PHP for websites. Python for pretty much anything else, such as commandline tools, long-running scripts, daemons, etcetera. If you're writing a PHP script and you're reaching for functions in the posix extenstion, shared memory or other low-level stuff then that's generally a sign that Python would be better suited. It's not that PHP can't do it, but Python just does it better and less buggy.\nEspecially when you're venturing into background daemons for your website you'll want to look at Python. PHP has some garbage collection problems in long running processes such as daemons. Also, some functionality is much easier and clearer in Python (e.g. redirecting STDIN, STDOUT and STDERR. PHP misses posix_dup2()). Also, Python has threads :-)\nThe only time when I now use PHP background daemons for my websites is when they can re-use significant amounts of code (such as with MVC frameworks like CakePHP).\nOne more advantage of Python is that there are many, many libraries for it, because it's rather easy to create a Python wrapper for a C library. So, Python has libraries that PHP doesn't have (OpenGL, multimedia, etcetera). So if you're into those areas Python becomes the obvious choice.","Q_Score":3,"Tags":"php,python,linux,theory","A_Id":1843790,"CreationDate":"2009-12-03T19:13:00.000","Title":"From a coder's perspective, what kind of project should I choose python over php for where both could do the 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":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Ruby uses require, Python uses import. They're substantially different models, and while I'm more used to the require model, I can see a few places where I think I like import more. I'm curious what things people find particularly easy \u2014 or more interestingly, harder than they should be \u2014 with each of these models.\nIn particular, if you were writing a new programming language, how would you design a code-loading mechanism? Which \"pros\" and \"cons\" would weigh most heavily on your design choice?","AnswerCount":4,"Available Count":2,"Score":0.049958375,"is_accepted":false,"ViewCount":6271,"Q_Id":1849376,"Users Score":1,"Answer":"Python's import provides a very explicit kind of namespace: the namespace is the path, you don't have to look into files to know what namespace they do their definitions in, and your file is not cluttered with namespace definitions. This makes the namespace scheme of an application simple and fast to understand (just look at the source tree), and avoids simple mistakes like mistyping a namespace declaration.\nA nice side effect is every file has its own private namespace, so you don't have to worry about conflicts when naming things.\nSometimes namespaces can get annoying too, having things like some.module.far.far.away.TheClass() everywhere can quickly make your code very long and boring to type. In these cases you can import ... from ... and inject bits of another namespace in the current one. If the injection causes a conflict with the module you are importing in, you can simply rename the thing you imported: from some.other.module import Bar as BarFromOtherModule.\nPython is still vulnerable to problems like circular imports, but it's the application design more than the language that has to be blamed in these cases.\nSo python took C++ namespace and #include and largely extended on it. On the other hand I don't see in which way ruby's module and require add anything new to these, and you have the exact same horrible problems like global namespace cluttering.","Q_Score":9,"Tags":"python,ruby,programming-languages,language-features,language-design","A_Id":1871126,"CreationDate":"2009-12-04T20:12:00.000","Title":"What are the advantages and disadvantages of the require vs. import methods of loading 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},{"Question":"Ruby uses require, Python uses import. They're substantially different models, and while I'm more used to the require model, I can see a few places where I think I like import more. I'm curious what things people find particularly easy \u2014 or more interestingly, harder than they should be \u2014 with each of these models.\nIn particular, if you were writing a new programming language, how would you design a code-loading mechanism? Which \"pros\" and \"cons\" would weigh most heavily on your design choice?","AnswerCount":4,"Available Count":2,"Score":0.1973753202,"is_accepted":false,"ViewCount":6271,"Q_Id":1849376,"Users Score":4,"Answer":"A nice property of require is that it is actually a method defined in Kernel. Thus you can override it and implement your own packaging system for Ruby, which is what e.g. Rubygems does!\nPS: I am not selling monkey patching here, but the fact that Ruby's package system can be rewritten by the user (even to work like python's system). When you write a new programming language, you cannot get everything right. Thus if your import mechanism is fully extensible (into totally all directions) from within the language, you do your future users the best service. A language that is not fully extensible from within itself is an evolutionary dead-end. I'd say this is one of the things Matz got right with Ruby.","Q_Score":9,"Tags":"python,ruby,programming-languages,language-features,language-design","A_Id":1870801,"CreationDate":"2009-12-04T20:12:00.000","Title":"What are the advantages and disadvantages of the require vs. import methods of loading 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},{"Question":"Is there a blog\/forum\/listserv that is equivalent to RubyQuiz.com for the Python language?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":463,"Q_Id":1851396,"Users Score":1,"Answer":"At the risk of stating the obvious, why not just do the rubyquiz examples in python. Those exercises as well as others aren't tied to a language - you're just as well off just doing projecteuler problems in python rather than searching for python-specific puzzles. A puzzle is a puzzle a language is just a tool to solve it.","Q_Score":2,"Tags":"python","A_Id":1852706,"CreationDate":"2009-12-05T06:52:00.000","Title":"Ruby Quiz 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":1},{"Question":"I know that IronPython is a dynamically typed language so what I am asking sounds pretty stupid, but is it possible to do something with an IronPython script to make sure the changing of the CLR libraries it references will not result in a runtime error when the script is executed?\nThe reason I ask is that I have written a library referenced by IronPython scripts in C#, and I want a way to know if I've broken any of the interfaces used by the IronPhon scripts when I change the C# library. This is easy to do with another C# project by just compiling the code and seeing compile errors, but this doesn't seem to work when compiling the IronPython scripts.\nAny ideas?","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":244,"Q_Id":1852897,"Users Score":2,"Answer":"No, there is no way to statically verify at compile time that the interface changes have not broken your IronPython code. This is the nature of dynamic languages. Such errors are instead presented at runtime","Q_Score":4,"Tags":"ironpython,dynamic-language-runtime","A_Id":1852956,"CreationDate":"2009-12-05T17:51:00.000","Title":"IronPython compile-time checks against CLR libraries?","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},{"Question":"I know that IronPython is a dynamically typed language so what I am asking sounds pretty stupid, but is it possible to do something with an IronPython script to make sure the changing of the CLR libraries it references will not result in a runtime error when the script is executed?\nThe reason I ask is that I have written a library referenced by IronPython scripts in C#, and I want a way to know if I've broken any of the interfaces used by the IronPhon scripts when I change the C# library. This is easy to do with another C# project by just compiling the code and seeing compile errors, but this doesn't seem to work when compiling the IronPython scripts.\nAny ideas?","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":244,"Q_Id":1852897,"Users Score":1,"Answer":"A good set of fast running unit tests would be a good alternative to compile time checking.","Q_Score":4,"Tags":"ironpython,dynamic-language-runtime","A_Id":1866436,"CreationDate":"2009-12-05T17:51:00.000","Title":"IronPython compile-time checks against CLR libraries?","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},{"Question":"I've been researching this on and off for a number of months now, but I am incapable of finding clear direction. \nMy goal is to have a page which has a form on it and a graph on it. The form can be filled out and then sent to the CGI Python script (yeah, I'll move to WSGI or fast_cgi later, I'm starting simple!) I'd like the form to be able to send multiple times, so the user can update the graph, but I don't want the page to reload every time it doe that. I have a form and a graph now, but they're on separate pages and work as a conventional script.\nI'd like to avoid ALL frameworks except JQuery (as I love it, don't like dealing with the quirks of different browsers, etc). \nA nudge in the right direction(s) is all I'm asking for here, or be as specific as you care to. \n(I've found similar guides to doing this in PHP, I believe, but for some reason, they didn't serve my purpose.)\nEDIT: The graph is generated using Flot (a JQuery plugin) using points generated from the form input and processed in the Python script. The Python script prints the Javascript which produces the graph in the end. It could all be done in Javascript, but I want the heavier stuff to be handled server-side, hence the Python.\nThanks!","AnswerCount":4,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1212,"Q_Id":1855748,"Users Score":0,"Answer":"Update img.src attribute in onsubmit() handler.\n\nimg.src url points to your Python script that should generate an image in response.\nonsubmit() for your form could be registered and written using JQuery.","Q_Score":2,"Tags":"javascript,python,ajax","A_Id":1855787,"CreationDate":"2009-12-06T15:59:00.000","Title":"Dynamically Refreshed Pages produced by 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},{"Question":"I thought it would be a good idea to compile a list of things to watch out for when making a Python app portable. There are a lot of subtle 'gotchas' in portability that are only discovered through experience and thorough testing; there needs to be some sort of list addressing the more common ones.\nPlease post one gotcha (with its fix) per comment.","AnswerCount":7,"Available Count":4,"Score":0.1137907297,"is_accepted":false,"ViewCount":2875,"Q_Id":1883118,"Users Score":4,"Answer":"If you deal with binary file formats in Python, note that the struct and array modules uses machine dependent size and endianness. struct can be used portably by always using < or > in the format string. array can't. It will probably be portable for arrays of bytes, but the documentation makes no such guarantee.","Q_Score":4,"Tags":"python,portability","A_Id":1883501,"CreationDate":"2009-12-10T18:41:00.000","Title":"Big List Of Portability 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},{"Question":"I thought it would be a good idea to compile a list of things to watch out for when making a Python app portable. There are a lot of subtle 'gotchas' in portability that are only discovered through experience and thorough testing; there needs to be some sort of list addressing the more common ones.\nPlease post one gotcha (with its fix) per comment.","AnswerCount":7,"Available Count":4,"Score":0.057080742,"is_accepted":false,"ViewCount":2875,"Q_Id":1883118,"Users Score":2,"Answer":"Getting away from the syntax side of things, I think the biggest thing to watch out for is that typically when people think of python, they might not think of all the libraries it is composed of. \nMany python packages depend on C libraries which may or may not be cross platform compatible. In addition, Python runs under Java through Jython, and .Net through IronPython. Unless libraries are written in pure python, they will not, in many cases, work on anything other than the C based version of python.","Q_Score":4,"Tags":"python,portability","A_Id":1883350,"CreationDate":"2009-12-10T18:41:00.000","Title":"Big List Of Portability 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},{"Question":"I thought it would be a good idea to compile a list of things to watch out for when making a Python app portable. There are a lot of subtle 'gotchas' in portability that are only discovered through experience and thorough testing; there needs to be some sort of list addressing the more common ones.\nPlease post one gotcha (with its fix) per comment.","AnswerCount":7,"Available Count":4,"Score":0.0285636566,"is_accepted":false,"ViewCount":2875,"Q_Id":1883118,"Users Score":1,"Answer":"I'll start off:\nWindows uses backslashes for path separators --> '\\'\nUnix uses forward slashes for path separators --> '\/'\nThe os module comes with os.sep, which contains the path separator for the current platform that the script is being run on. Use os.sep instead of forward or back slashes. os.path.join will join two or more path components this way.","Q_Score":4,"Tags":"python,portability","A_Id":1883137,"CreationDate":"2009-12-10T18:41:00.000","Title":"Big List Of Portability 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},{"Question":"I thought it would be a good idea to compile a list of things to watch out for when making a Python app portable. There are a lot of subtle 'gotchas' in portability that are only discovered through experience and thorough testing; there needs to be some sort of list addressing the more common ones.\nPlease post one gotcha (with its fix) per comment.","AnswerCount":7,"Available Count":4,"Score":0.057080742,"is_accepted":false,"ViewCount":2875,"Q_Id":1883118,"Users Score":2,"Answer":"Some modules are not cross-platform. Two that come to mind are both curses (Linux) and msvcrt (Windows). The fix to this simple problem is simply not to use them but find an alternative instead.","Q_Score":4,"Tags":"python,portability","A_Id":1883817,"CreationDate":"2009-12-10T18:41:00.000","Title":"Big List Of Portability 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},{"Question":"I have been programming in Python for a while now, and I'd like to learn a more \"hireable\" language like Java or the C\/C++\/C# family. I'm acquainted with (though not necessarily good at) all of them. I'm leaning towards Java because it runs just about everywhere, and I'd like to start developing for the Android. \nComing from a dynamic language, what is the best way for me to learn Java? Or should I learn a C based language instead?","AnswerCount":9,"Available Count":5,"Score":1.0,"is_accepted":false,"ViewCount":18209,"Q_Id":1883455,"Users Score":8,"Answer":"Java and C# will be less of a step away from Python than would C or C++ because Java, C#, and Python all have automatic memory management. A good Java book is Thinking in Java by Bruce Eckel. It starts at an introductory level, but also has a lot of depth.\nThe big difference with the language coming from Python is the fact that all variables are typed. The other hard thing with Java has to do with the bewildering array of Java APIs out there. The fact that you are interested in Android is an advantage here. After becoming comfortable with the core language, I suggest you start learning the Android API and focus on becoming an Android expert. I think Android will be a growing market for a while.\nGood luck!","Q_Score":20,"Tags":"java,python","A_Id":1883690,"CreationDate":"2009-12-10T19:41:00.000","Title":"Learn Java from Python background","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},{"Question":"I have been programming in Python for a while now, and I'd like to learn a more \"hireable\" language like Java or the C\/C++\/C# family. I'm acquainted with (though not necessarily good at) all of them. I'm leaning towards Java because it runs just about everywhere, and I'd like to start developing for the Android. \nComing from a dynamic language, what is the best way for me to learn Java? Or should I learn a C based language instead?","AnswerCount":9,"Available Count":5,"Score":0.0,"is_accepted":false,"ViewCount":18209,"Q_Id":1883455,"Users Score":0,"Answer":"I don't think you should use a special way to learn Java because you know Python. Just start with HelloWorld.java and move on step by step. Your basic skills in programming will help you.","Q_Score":20,"Tags":"java,python","A_Id":1883538,"CreationDate":"2009-12-10T19:41:00.000","Title":"Learn Java from Python background","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},{"Question":"I have been programming in Python for a while now, and I'd like to learn a more \"hireable\" language like Java or the C\/C++\/C# family. I'm acquainted with (though not necessarily good at) all of them. I'm leaning towards Java because it runs just about everywhere, and I'd like to start developing for the Android. \nComing from a dynamic language, what is the best way for me to learn Java? Or should I learn a C based language instead?","AnswerCount":9,"Available Count":5,"Score":0.0,"is_accepted":false,"ViewCount":18209,"Q_Id":1883455,"Users Score":0,"Answer":"I suppose one could ease his\/her way into .NET and Java by starting with IronPython and Jython respectively. This will not teach you the new language syntax but open up respective libraries so you can explore what is \"out there\", learn development tools, build process etc. Syntax is by far the easiest to switch but the know-how and best practices in each language are not.","Q_Score":20,"Tags":"java,python","A_Id":1884743,"CreationDate":"2009-12-10T19:41:00.000","Title":"Learn Java from Python background","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},{"Question":"I have been programming in Python for a while now, and I'd like to learn a more \"hireable\" language like Java or the C\/C++\/C# family. I'm acquainted with (though not necessarily good at) all of them. I'm leaning towards Java because it runs just about everywhere, and I'd like to start developing for the Android. \nComing from a dynamic language, what is the best way for me to learn Java? Or should I learn a C based language instead?","AnswerCount":9,"Available Count":5,"Score":0.0,"is_accepted":false,"ViewCount":18209,"Q_Id":1883455,"Users Score":0,"Answer":"1) It depends what you would do with an \"hireable\" language. For instance, if you were interested in programming web applications and distributed\/client\/server app, Java would be a good choice. \nC# is maybe a bit less client \/ server oriented, and maybe more valuable for small non IT companies and for most retail software companies.\nC and C++ are still great languages, but are more \"system\", embeded and \"critical apps\" oriented. And they are not suitable to be runned on differents mobile phones.\n2) The best way to learn java, according to me, is firstable to learn the basics, then look for more specialized stuff like J2ME and Android software framework.","Q_Score":20,"Tags":"java,python","A_Id":1883705,"CreationDate":"2009-12-10T19:41:00.000","Title":"Learn Java from Python background","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},{"Question":"I have been programming in Python for a while now, and I'd like to learn a more \"hireable\" language like Java or the C\/C++\/C# family. I'm acquainted with (though not necessarily good at) all of them. I'm leaning towards Java because it runs just about everywhere, and I'd like to start developing for the Android. \nComing from a dynamic language, what is the best way for me to learn Java? Or should I learn a C based language instead?","AnswerCount":9,"Available Count":5,"Score":1.0,"is_accepted":false,"ViewCount":18209,"Q_Id":1883455,"Users Score":9,"Answer":"I would take a project you've implemented in Python and try converting it to Java. Since you already know basic programming fundamentals, it'll probably be easier if you take things you know how to do and figure out how you'd do the same sort of operations in Java (or whatever new language you want to learn).\nIn the end, the only way to learn to write code, is to write more code.","Q_Score":20,"Tags":"java,python","A_Id":1883585,"CreationDate":"2009-12-10T19:41:00.000","Title":"Learn Java from Python background","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},{"Question":"I'm learning about Pylons and I've read a few tutorials, but none of them have addressed collaboration practices. Starting on a practice project. I'd like to keep my code in a revision-control system (Git, specifically) as if it were an open-source project with multiple developers, in order to practice that aspect of Pylons development as well.\nI'm wondering what I should do with the development.ini file that was generated by Paster as part of my new application. On one hand, it contains lots of settings that other develpers wouldn't want to have to recreate by hand, so it seems like it ought to be stored in my Git repository so that other developers can access it. On the other hand, some of the settings, such as the database connection URL, are specific to one person's development environment and wouldn't make sense to share with others.\nWhat do real-world Pylons applications do with this file?","AnswerCount":4,"Available Count":4,"Score":0.0,"is_accepted":false,"ViewCount":358,"Q_Id":1886192,"Users Score":0,"Answer":"You should check in development.ini. Most developers are smart enough to realize that if they want to run your application they need to make some tweaks. The development.ini will serve as a template. A file that has the database configured incorrectly is still useful since I can see that the system is trying to connect to the database and failing.\nLater on you will be making files such as development.ini, staging.ini, and production.ini. This will help when you move environments.","Q_Score":1,"Tags":"python,pylons","A_Id":1894559,"CreationDate":"2009-12-11T06:29:00.000","Title":"Should Pylons' development.ini be checked 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":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm learning about Pylons and I've read a few tutorials, but none of them have addressed collaboration practices. Starting on a practice project. I'd like to keep my code in a revision-control system (Git, specifically) as if it were an open-source project with multiple developers, in order to practice that aspect of Pylons development as well.\nI'm wondering what I should do with the development.ini file that was generated by Paster as part of my new application. On one hand, it contains lots of settings that other develpers wouldn't want to have to recreate by hand, so it seems like it ought to be stored in my Git repository so that other developers can access it. On the other hand, some of the settings, such as the database connection URL, are specific to one person's development environment and wouldn't make sense to share with others.\nWhat do real-world Pylons applications do with this file?","AnswerCount":4,"Available Count":4,"Score":0.0996679946,"is_accepted":false,"ViewCount":358,"Q_Id":1886192,"Users Score":2,"Answer":"On a team development, we make an effort to ensure everyone has a common development environment, or we make adjustments to things (like database URLs) to allow people on different environments (we do Mac, Windows, and Linux) to share all files.\nAnd our Pylons development.ini files are committed to subversion, just like everything else.","Q_Score":1,"Tags":"python,pylons","A_Id":1891883,"CreationDate":"2009-12-11T06:29:00.000","Title":"Should Pylons' development.ini be checked 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":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm learning about Pylons and I've read a few tutorials, but none of them have addressed collaboration practices. Starting on a practice project. I'd like to keep my code in a revision-control system (Git, specifically) as if it were an open-source project with multiple developers, in order to practice that aspect of Pylons development as well.\nI'm wondering what I should do with the development.ini file that was generated by Paster as part of my new application. On one hand, it contains lots of settings that other develpers wouldn't want to have to recreate by hand, so it seems like it ought to be stored in my Git repository so that other developers can access it. On the other hand, some of the settings, such as the database connection URL, are specific to one person's development environment and wouldn't make sense to share with others.\nWhat do real-world Pylons applications do with this file?","AnswerCount":4,"Available Count":4,"Score":1.2,"is_accepted":true,"ViewCount":358,"Q_Id":1886192,"Users Score":2,"Answer":"You could check it in as sample.ini for example so that everyone can copy to their own development.ini and modify as needed","Q_Score":1,"Tags":"python,pylons","A_Id":1886486,"CreationDate":"2009-12-11T06:29:00.000","Title":"Should Pylons' development.ini be checked 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":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm learning about Pylons and I've read a few tutorials, but none of them have addressed collaboration practices. Starting on a practice project. I'd like to keep my code in a revision-control system (Git, specifically) as if it were an open-source project with multiple developers, in order to practice that aspect of Pylons development as well.\nI'm wondering what I should do with the development.ini file that was generated by Paster as part of my new application. On one hand, it contains lots of settings that other develpers wouldn't want to have to recreate by hand, so it seems like it ought to be stored in my Git repository so that other developers can access it. On the other hand, some of the settings, such as the database connection URL, are specific to one person's development environment and wouldn't make sense to share with others.\nWhat do real-world Pylons applications do with this file?","AnswerCount":4,"Available Count":4,"Score":0.0,"is_accepted":false,"ViewCount":358,"Q_Id":1886192,"Users Score":0,"Answer":"The most important aspect of collaboration is communicating with your teammates. See if you can come to a quick consensus on how to handle the situation.\nMy suggestion though, would be to pass around your completed ini file for the other devs to modify for their own purposes. If there are a lot of hand tuned settings that they won't want (or need) to change, then they shouldn't have to do the work. At the end of the day though, they'll need to write the settings somehow.","Q_Score":1,"Tags":"python,pylons","A_Id":1886225,"CreationDate":"2009-12-11T06:29:00.000","Title":"Should Pylons' development.ini be checked 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":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am developing a library and an application that uses the library in Python 2.6. I've placed a \"mylib.pth\" file in \"site-packages\" so that I can import mylib from within my application. \nI am using a DVCS so when I want to fix a bug or add a feature to the library I make a branch of the repository and work within that branch. To test my application with the changes I am making to the library I edit the path in \"mylib.pth\" to point to the new development branch.\nThis gets a little tedious if I have a few parallel branches of my library going on at one. I have to keep editing the \"mylib.pth\" file before testing to ensure I am testing against the correct version of my library. Is there a way to use the current path (i.e. the development branch of the library that I am current in) to set the library path when I invoke my application instead of using the \"mylib.pth\" in the global \"site-packages\" directory?","AnswerCount":6,"Available Count":2,"Score":0.0333209931,"is_accepted":false,"ViewCount":683,"Q_Id":1889967,"Users Score":1,"Answer":"Sure, you can alter sys.path to add the current directory (or a subdirectory of it) to the search path. site.addsitedir is a good way to do it. Since you'd be doing this from Python you can have any sort of logic you like for deciding which directory to add; you could base it on os.path.normpath\u200bing the current directory if it looks like a branch, or looking for the newest branch on-disc, or something else.\nYou could put this code in the sitecustomize.py module or other startup-triggered location.","Q_Score":3,"Tags":"python","A_Id":1890161,"CreationDate":"2009-12-11T18:25:00.000","Title":"Setting Python path while developing library 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},{"Question":"I am developing a library and an application that uses the library in Python 2.6. I've placed a \"mylib.pth\" file in \"site-packages\" so that I can import mylib from within my application. \nI am using a DVCS so when I want to fix a bug or add a feature to the library I make a branch of the repository and work within that branch. To test my application with the changes I am making to the library I edit the path in \"mylib.pth\" to point to the new development branch.\nThis gets a little tedious if I have a few parallel branches of my library going on at one. I have to keep editing the \"mylib.pth\" file before testing to ensure I am testing against the correct version of my library. Is there a way to use the current path (i.e. the development branch of the library that I am current in) to set the library path when I invoke my application instead of using the \"mylib.pth\" in the global \"site-packages\" directory?","AnswerCount":6,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":683,"Q_Id":1889967,"Users Score":2,"Answer":"If you use setuptools, then you can say setup.py develop in your working tree, and it will do the .pth file manipulation for you.","Q_Score":3,"Tags":"python","A_Id":1890000,"CreationDate":"2009-12-11T18:25:00.000","Title":"Setting Python path while developing library 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},{"Question":"I am looking for a few pointers, I got pointed to this site.\nMy primary interest is network programming. I have done quite a bit of reading and experimenting and am familiar with mechanisms of most protocols. Now I want to start writing code. I read introductory stuff on python and grasped it well too. I had just started playing with the python modules, when I met somebody(with a tall reputation) at the local lug meeting who told me that I could always learn python very easily later but C was the language I must know, specially given my interest on network programming. I did some research and thought maybe the guy is right. So I've been with a k&r for 4 weeks now. It didn't intimidate me but I am progressing very very slowly and maybe that's why also slacking a bit. I am posting this because I'm at the stage where it's even worrying me now. I'm always thinking that in python i could be building stuff right now. I know python won't teach me low level things like memory management etc, but my progress is pain-stakingly slow in C.\nQuestion: Should I continue battling with C like i'm now and write some working code in it or switch to python where i'll be at a bit more ease? Will a high level language spoil me too much to come back to C later?","AnswerCount":9,"Available Count":7,"Score":1.0,"is_accepted":false,"ViewCount":8819,"Q_Id":1891551,"Users Score":17,"Answer":"Just use Python. You'll have access to the same low-level socket APIs as in C, without having to learn about indirection and memory management at the same time.\nLater, if you find that Python is too slow for your purposes, you can rewrite some parts in C. But don't do it to begin with.","Q_Score":6,"Tags":"python,c,networking","A_Id":1891560,"CreationDate":"2009-12-11T23:32:00.000","Title":"Network programming: Python vs. C for a complete beginner","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I am looking for a few pointers, I got pointed to this site.\nMy primary interest is network programming. I have done quite a bit of reading and experimenting and am familiar with mechanisms of most protocols. Now I want to start writing code. I read introductory stuff on python and grasped it well too. I had just started playing with the python modules, when I met somebody(with a tall reputation) at the local lug meeting who told me that I could always learn python very easily later but C was the language I must know, specially given my interest on network programming. I did some research and thought maybe the guy is right. So I've been with a k&r for 4 weeks now. It didn't intimidate me but I am progressing very very slowly and maybe that's why also slacking a bit. I am posting this because I'm at the stage where it's even worrying me now. I'm always thinking that in python i could be building stuff right now. I know python won't teach me low level things like memory management etc, but my progress is pain-stakingly slow in C.\nQuestion: Should I continue battling with C like i'm now and write some working code in it or switch to python where i'll be at a bit more ease? Will a high level language spoil me too much to come back to C later?","AnswerCount":9,"Available Count":7,"Score":0.1106561105,"is_accepted":false,"ViewCount":8819,"Q_Id":1891551,"Users Score":5,"Answer":"Depending on what level(s) of the networking stack you want to work, C may be indispensable, useful, or hardly relevant. But if trying to tackle C first is wearing down your motivation, by all means go back to Python and get some success and therefore incentive -- you can come back to C later. Learning an easier language first, a harder one later, is a perfectly natural progression! MIT, for example, uses Python for some \"programming 101\" courses -- and yet, most definitely, that doesn't turn students off harder languages such as C (or even C++, which is harder yet!) in later courses.","Q_Score":6,"Tags":"python,c,networking","A_Id":1891571,"CreationDate":"2009-12-11T23:32:00.000","Title":"Network programming: Python vs. C for a complete beginner","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I am looking for a few pointers, I got pointed to this site.\nMy primary interest is network programming. I have done quite a bit of reading and experimenting and am familiar with mechanisms of most protocols. Now I want to start writing code. I read introductory stuff on python and grasped it well too. I had just started playing with the python modules, when I met somebody(with a tall reputation) at the local lug meeting who told me that I could always learn python very easily later but C was the language I must know, specially given my interest on network programming. I did some research and thought maybe the guy is right. So I've been with a k&r for 4 weeks now. It didn't intimidate me but I am progressing very very slowly and maybe that's why also slacking a bit. I am posting this because I'm at the stage where it's even worrying me now. I'm always thinking that in python i could be building stuff right now. I know python won't teach me low level things like memory management etc, but my progress is pain-stakingly slow in C.\nQuestion: Should I continue battling with C like i'm now and write some working code in it or switch to python where i'll be at a bit more ease? Will a high level language spoil me too much to come back to C later?","AnswerCount":9,"Available Count":7,"Score":0.1106561105,"is_accepted":false,"ViewCount":8819,"Q_Id":1891551,"Users Score":5,"Answer":"Twenty years ago, even ten, you couldn't live without it.\nNow many do.\nIt's possible (probable, actually) that more than half the programmers in the world don't know C. It's completely unnecessary for Web work and for most app work. I'm being gracious with this--if you really were to include web, hobby, overseas consultants and the like, the percent who have used C is probably pretty low at this point.\nEmbedded often uses C, but I've worked on 2 embedded platforms (a waveform analyzer and cable box) where I've done nothing but Java work.\nHonestly a basic understanding of C is nice for writing drivers and understanding pointers, but these days you can easily get through an entire career without ever needing C. I personally would completely skip C++, although it's used quite a bit, I don't see any big advantages to learning it now.","Q_Score":6,"Tags":"python,c,networking","A_Id":1891586,"CreationDate":"2009-12-11T23:32:00.000","Title":"Network programming: Python vs. C for a complete beginner","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I am looking for a few pointers, I got pointed to this site.\nMy primary interest is network programming. I have done quite a bit of reading and experimenting and am familiar with mechanisms of most protocols. Now I want to start writing code. I read introductory stuff on python and grasped it well too. I had just started playing with the python modules, when I met somebody(with a tall reputation) at the local lug meeting who told me that I could always learn python very easily later but C was the language I must know, specially given my interest on network programming. I did some research and thought maybe the guy is right. So I've been with a k&r for 4 weeks now. It didn't intimidate me but I am progressing very very slowly and maybe that's why also slacking a bit. I am posting this because I'm at the stage where it's even worrying me now. I'm always thinking that in python i could be building stuff right now. I know python won't teach me low level things like memory management etc, but my progress is pain-stakingly slow in C.\nQuestion: Should I continue battling with C like i'm now and write some working code in it or switch to python where i'll be at a bit more ease? Will a high level language spoil me too much to come back to C later?","AnswerCount":9,"Available Count":7,"Score":0.022218565,"is_accepted":false,"ViewCount":8819,"Q_Id":1891551,"Users Score":1,"Answer":"As a python programmer, I would give you the opposite advice. Learn python first. At least until you learn the limitations and possibilities it has compared to what you can do in C. Then use C for those far out problems you can't fix in Python. :)","Q_Score":6,"Tags":"python,c,networking","A_Id":1891569,"CreationDate":"2009-12-11T23:32:00.000","Title":"Network programming: Python vs. C for a complete beginner","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I am looking for a few pointers, I got pointed to this site.\nMy primary interest is network programming. I have done quite a bit of reading and experimenting and am familiar with mechanisms of most protocols. Now I want to start writing code. I read introductory stuff on python and grasped it well too. I had just started playing with the python modules, when I met somebody(with a tall reputation) at the local lug meeting who told me that I could always learn python very easily later but C was the language I must know, specially given my interest on network programming. I did some research and thought maybe the guy is right. So I've been with a k&r for 4 weeks now. It didn't intimidate me but I am progressing very very slowly and maybe that's why also slacking a bit. I am posting this because I'm at the stage where it's even worrying me now. I'm always thinking that in python i could be building stuff right now. I know python won't teach me low level things like memory management etc, but my progress is pain-stakingly slow in C.\nQuestion: Should I continue battling with C like i'm now and write some working code in it or switch to python where i'll be at a bit more ease? Will a high level language spoil me too much to come back to C later?","AnswerCount":9,"Available Count":7,"Score":0.022218565,"is_accepted":false,"ViewCount":8819,"Q_Id":1891551,"Users Score":1,"Answer":"I would recommend starting with Python, unless you absolutely need the speed. It's often said that programming languages are just tools in your toolbox, and certain ones are going to be able to accomplish a given task better than others. If you don't need the speed, Python is going to accomplish the task you're looking to accomplish with less code and will be easier to learn.\nI am entirely self-taught and went from Apple II BASIC to assembly language to scripting languages (Perl, PHP, Ruby) and now am using mostly C. C is a relatively small language, but I believe that had I started out with C, I probably would've lost my motivation. Start out with Python - you'll learn the gist of programming, then if you have the need or the want to learn C later, it will be easier to pick up.","Q_Score":6,"Tags":"python,c,networking","A_Id":1891955,"CreationDate":"2009-12-11T23:32:00.000","Title":"Network programming: Python vs. C for a complete beginner","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I am looking for a few pointers, I got pointed to this site.\nMy primary interest is network programming. I have done quite a bit of reading and experimenting and am familiar with mechanisms of most protocols. Now I want to start writing code. I read introductory stuff on python and grasped it well too. I had just started playing with the python modules, when I met somebody(with a tall reputation) at the local lug meeting who told me that I could always learn python very easily later but C was the language I must know, specially given my interest on network programming. I did some research and thought maybe the guy is right. So I've been with a k&r for 4 weeks now. It didn't intimidate me but I am progressing very very slowly and maybe that's why also slacking a bit. I am posting this because I'm at the stage where it's even worrying me now. I'm always thinking that in python i could be building stuff right now. I know python won't teach me low level things like memory management etc, but my progress is pain-stakingly slow in C.\nQuestion: Should I continue battling with C like i'm now and write some working code in it or switch to python where i'll be at a bit more ease? Will a high level language spoil me too much to come back to C later?","AnswerCount":9,"Available Count":7,"Score":0.0444152037,"is_accepted":false,"ViewCount":8819,"Q_Id":1891551,"Users Score":2,"Answer":"I would recommend using Python. Because it is a higher level language than C, you can concentrate more on the \"what\" rather than the \"how\". This means that you can avoid the level of detail required by C in order to achieve what you need to get done right now.\nThis isn't to say that a low level of detail is never required. It certainly is, but at this time I'd recommend you ignore it and pick it up in the future, should you need to.","Q_Score":6,"Tags":"python,c,networking","A_Id":1891967,"CreationDate":"2009-12-11T23:32:00.000","Title":"Network programming: Python vs. C for a complete beginner","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I am looking for a few pointers, I got pointed to this site.\nMy primary interest is network programming. I have done quite a bit of reading and experimenting and am familiar with mechanisms of most protocols. Now I want to start writing code. I read introductory stuff on python and grasped it well too. I had just started playing with the python modules, when I met somebody(with a tall reputation) at the local lug meeting who told me that I could always learn python very easily later but C was the language I must know, specially given my interest on network programming. I did some research and thought maybe the guy is right. So I've been with a k&r for 4 weeks now. It didn't intimidate me but I am progressing very very slowly and maybe that's why also slacking a bit. I am posting this because I'm at the stage where it's even worrying me now. I'm always thinking that in python i could be building stuff right now. I know python won't teach me low level things like memory management etc, but my progress is pain-stakingly slow in C.\nQuestion: Should I continue battling with C like i'm now and write some working code in it or switch to python where i'll be at a bit more ease? Will a high level language spoil me too much to come back to C later?","AnswerCount":9,"Available Count":7,"Score":0.0,"is_accepted":false,"ViewCount":8819,"Q_Id":1891551,"Users Score":0,"Answer":"learn lisp, its performance is almost that of C and its easy to learn and you can do more in lisp than you can in python and its not hard to learn. You can also do natural language programming to solve problems. go lisp.","Q_Score":6,"Tags":"python,c,networking","A_Id":14009100,"CreationDate":"2009-12-11T23:32:00.000","Title":"Network programming: Python vs. C for a complete beginner","Data Science and Machine Learning":0,"Database and SQL":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},{"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},{"Question":"We have a common python installation for all of our systems in order to ensure every system has the same python installation and to ease configuration issues. This installation is located on a shared drive. We also have multiple platforms that share this installation. We get around conflicting platform-specific files by setting the --exec-prefix configure option when compiling python.\nMy issue is that I now want to install an egg using easy_install (or otherwise) that is platform-dependent. easy_install puts the egg in the site-packages directory of the platform-independent part of the install. The name of the egg has the platform in it so there should be no conflict. But python will only load the first one it finds. (So, on Solaris it might try to load the Linux egg). Modifying the easy-install.pth file can change which one it finds, but that's pretty useless.\nI can move the .egg files into a platform-depended packages directory and then use pkg_resources.require() to load them (or manually adjust the path). But it seems as though I shouldn't have to since the platform is in the name of the egg.\nIs there any more generic way I can ensure that python will load the egg for the correct platform?","AnswerCount":4,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1197,"Q_Id":1903653,"Users Score":0,"Answer":"Use \"easy_install -m\" to install all the platform-specific packages, so that there is no default version on sys.path. That way, version resolution takes place at runtime, and platform information will be taken into consideration.","Q_Score":6,"Tags":"python,easy-install,pkg-resources","A_Id":2164148,"CreationDate":"2009-12-14T21:33:00.000","Title":"How can I deal with python eggs for multiple platforms in one 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":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have a python script on a linux server that I can SSH into and I want to run the script on the linux server( and pass it parameters entered by the user) and get the output on an ASP.net webpage running on IIS. How would I be able to do that?\nWould it be easier if I was running a wamp server?\nEdit: The servers are in the same internal intranet.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1105,"Q_Id":1904320,"Users Score":0,"Answer":"Probably the best approach is the least coupled one. If you can determine a protocol that you're comfortable with the two (asp\/python) talking in, it will go a long way to reducing headaches.\nLet's say you pick XML.\nSetup the python script to run as a WSGI application with either cherrypy or apache (or whatever). The script formats it's response in XML and passes that to WSGI which returns the XML over HTTP.\nOn the ASP.NET side of things, whenever you want to \"run the script\" you simply query the URL with the WebRequest class, then parse the results with LINQ-to-XML (which on a side note is a really cool technology).\nHere's where this becomes relevant: Later on if either the ASP.NET implementation or the python implementation changes you don't have to re-code\/refactor the other. Later if you realize that the ASP.NET app and some desktop app need to be able to do that, you've standardized on a protocol and implementing it should be easy and well supported.","Q_Score":1,"Tags":"asp.net,python,remote-execution","A_Id":1904344,"CreationDate":"2009-12-14T23:40:00.000","Title":"Run a remote python script from ASP.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":1,"Web Development":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},{"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},{"Question":"I started with c++ but as we all know, c++ is a monster. I still have to take it and I do like C++ (it takes programming a step further) \nHowever, currently I have been working with python for a while. I see how you guys can turn some long algorithm into simple one.\nI know programming is a progress, and can take up to years of experience.\nI also know myself - I am not a natural programmer, and software engineering is not my first choice anyway. However, I would like to do heavy programming on my own, and create projects.\nHow can I become a better python programmer?","AnswerCount":5,"Available Count":2,"Score":0.1586485043,"is_accepted":false,"ViewCount":8219,"Q_Id":1908250,"Users Score":4,"Answer":"One suggestion is to find an open-source project in Python, and start contributing. You may ask \"how can I contribute, if I'm a beginner?\". One answer is \"write tests\". Almost any project will welcome you as a tester. Another answer is \"documentation\", though that is less likely to give immediate benefits.","Q_Score":10,"Tags":"python","A_Id":1908528,"CreationDate":"2009-12-15T15:37:00.000","Title":"How to become a good Python coder?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I started with c++ but as we all know, c++ is a monster. I still have to take it and I do like C++ (it takes programming a step further) \nHowever, currently I have been working with python for a while. I see how you guys can turn some long algorithm into simple one.\nI know programming is a progress, and can take up to years of experience.\nI also know myself - I am not a natural programmer, and software engineering is not my first choice anyway. However, I would like to do heavy programming on my own, and create projects.\nHow can I become a better python programmer?","AnswerCount":5,"Available Count":2,"Score":0.1194272985,"is_accepted":false,"ViewCount":8219,"Q_Id":1908250,"Users Score":3,"Answer":"The already-posted answers are great.\nIn addition, whenever you're coding something in Python and you start doing something that feels clumsy, take a step back and think. If you can't think of a more elegant way to do it, post it as a question on Stack Overflow. I can't count the number of times that I've seen someone reduce ten lines of Python into one (which is still perfectly easy to read and understand).","Q_Score":10,"Tags":"python","A_Id":1908456,"CreationDate":"2009-12-15T15:37:00.000","Title":"How to become a good Python coder?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"my question simply relates to the difference in performance between a socket in C and in Python. Since my Python build is CPython, I assume it's similar, but I'm curious if someone actually has \"real\" benchmarks, or at least an opinion that's evidence based. \nMy logics is as such:\n\nC socket much faster? then write a C\nextension. \nnot\/barely a difference?\nkeep writing in Python and figure out\nhow to obtain packet level control\n(scapy? dpkt?)\n\nI'm sure someone will want to know for either context or curiosity. I plan to build a sort of proxy for myself (not for internet browsing, anonymity, etc) and will bind the application I want to use with it to a specific port. Then, all packets on said port will be queued, address header modified, and then sent, etc, etc.\nThanks in advance.","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":4477,"Q_Id":1909471,"Users Score":1,"Answer":"i would think C would be faster, but python would be a lot easier to manage and use.\nthe difference would be so small, you wouldn't need it unless you were trying to send masses amount of data (something stupid like 1 million gb\/second lol)\njoe","Q_Score":10,"Tags":"python,c,sockets,scapy","A_Id":1909504,"CreationDate":"2009-12-15T18:39:00.000","Title":"C\/Python Socket 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":0},{"Question":"my question simply relates to the difference in performance between a socket in C and in Python. Since my Python build is CPython, I assume it's similar, but I'm curious if someone actually has \"real\" benchmarks, or at least an opinion that's evidence based. \nMy logics is as such:\n\nC socket much faster? then write a C\nextension. \nnot\/barely a difference?\nkeep writing in Python and figure out\nhow to obtain packet level control\n(scapy? dpkt?)\n\nI'm sure someone will want to know for either context or curiosity. I plan to build a sort of proxy for myself (not for internet browsing, anonymity, etc) and will bind the application I want to use with it to a specific port. Then, all packets on said port will be queued, address header modified, and then sent, etc, etc.\nThanks in advance.","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":4477,"Q_Id":1909471,"Users Score":13,"Answer":"In general, sockets in Python perform just fine. For example, the reference implementation of the BitTorrent tracker server is written in Python.\nWhen doing networking operations, the speed of the network is usually the limiting factor. That is, any possible tiny difference in speed between C and Python's socket code is completely overshadowed by the fact that you're doing networking of some kind.\nHowever, your description of what you want to do indicates that you want to inspect and modify individual IP packets. This is beyond the capabilities of Python's standard networking libraries, and is in any case a very OS-dependent operation. Rather than asking \"which is faster?\" you will need to first ask \"is this possible?\"","Q_Score":10,"Tags":"python,c,sockets,scapy","A_Id":1909511,"CreationDate":"2009-12-15T18:39:00.000","Title":"C\/Python Socket 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":0},{"Question":"What is Python used for and what is it designed for?","AnswerCount":2,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":155982,"Q_Id":1909512,"Users Score":134,"Answer":"Python is a dynamic, strongly typed, object oriented, multipurpose programming language, designed to be quick (to learn, to use, and to understand), and to enforce a clean and uniform syntax.\n\nPython is dynamically typed: it means that you don't declare a type (e.g. 'integer') for a variable name, and then assign something of that type (and only that type). Instead, you have variable names, and you bind them to entities whose type stays with the entity itself. a = 5 makes the variable name a to refer to the integer 5. Later, a = \"hello\" makes the variable name a to refer to a string containing \"hello\". Static typed languages would have you declare int a and then a = 5, but assigning a = \"hello\" would have been a compile time error. On one hand, this makes everything more unpredictable (you don't know what a refers to). On the other hand, it makes very easy to achieve some results a static typed languages makes very difficult.\nPython is strongly typed. It means that if a = \"5\" (the string whose value is '5') will remain a string, and never coerced to a number if the context requires so. Every type conversion in python must be done explicitly. This is different from, for example, Perl or Javascript, where you have weak typing, and can write things like \"hello\" + 5 to get \"hello5\".\nPython is object oriented, with class-based inheritance. Everything is an object (including classes, functions, modules, etc), in the sense that they can be passed around as arguments, have methods and attributes, and so on.\nPython is multipurpose: it is not specialised to a specific target of users (like R for statistics, or PHP for web programming). It is extended through modules and libraries, that hook very easily into the C programming language.\nPython enforces correct indentation of the code by making the indentation part of the syntax. There are no control braces in Python. Blocks of code are identified by the level of indentation. Although a big turn off for many programmers not used to this, it is precious as it gives a very uniform style and results in code that is visually pleasant to read.\nThe code is compiled into byte code and then executed in a virtual machine. This means that precompiled code is portable between platforms.\n\nPython can be used for any programming task, from GUI programming to web programming with everything else in between. It's quite efficient, as much of its activity is done at the C level. Python is just a layer on top of C. There are libraries for everything you can think of: game programming and openGL, GUI interfaces, web frameworks, semantic web, scientific computing...","Q_Score":105,"Tags":"python","A_Id":1923081,"CreationDate":"2009-12-15T18:46:00.000","Title":"What is Python used for?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am learning IronPython along wiht Python. I'm curious what kinds of tasks you tend to use IronPython to tackle more often than standard .NET languages. \nThanks for any example.","AnswerCount":6,"Available Count":4,"Score":0.0,"is_accepted":false,"ViewCount":797,"Q_Id":1912971,"Users Score":0,"Answer":"We use it a lot for small administrative tools against SharePoint. In particular it is fantastic for exploring the API against real data (with all its real life quirks). Development iterations are faster and you can't always install Visual Studio on production servers.","Q_Score":8,"Tags":"python,ironpython","A_Id":10440546,"CreationDate":"2009-12-16T07:36:00.000","Title":"IronPython: What kind of jobs you ever done with IronPython instead of standard .NET languages (e.g., 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},{"Question":"I am learning IronPython along wiht Python. I'm curious what kinds of tasks you tend to use IronPython to tackle more often than standard .NET languages. \nThanks for any example.","AnswerCount":6,"Available Count":4,"Score":0.0,"is_accepted":false,"ViewCount":797,"Q_Id":1912971,"Users Score":0,"Answer":"I use IronPython for a few different purposes:\n\nAn alternative to Powershell when I need to script something and invoke a .NET library, or when the script is complicated enough to warrant a real programming language.\nEmbedding in a .NET app for scriptable plugins.\nPrototyping and testing .NET libs in immediate mode. This is way easier than making a test project in C#","Q_Score":8,"Tags":"python,ironpython","A_Id":10438778,"CreationDate":"2009-12-16T07:36:00.000","Title":"IronPython: What kind of jobs you ever done with IronPython instead of standard .NET languages (e.g., 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},{"Question":"I am learning IronPython along wiht Python. I'm curious what kinds of tasks you tend to use IronPython to tackle more often than standard .NET languages. \nThanks for any example.","AnswerCount":6,"Available Count":4,"Score":0.0996679946,"is_accepted":false,"ViewCount":797,"Q_Id":1912971,"Users Score":3,"Answer":"In the day job, it's my standard language for those little bits of build process that are too much for .bat files and not heavyweight enough to demand a separate executable; this includes anything that could use a little bit of XML processing or reflection -- generating Wix files with systematic handling of 32 and 64 bit installs, for example. It beats out PowerShell in this role because IronPython is an XCOPY install onto build machines.\nIt's also very useful for prototyping fragments of code against unfamiliar or complex APIs (WMI and Active Directory being the usual ones for me), or diagnosing problems in code using those APIs (like sniffing out the oddities that happen when you're on the domain controller, rather than elsewhere).","Q_Score":8,"Tags":"python,ironpython","A_Id":1913029,"CreationDate":"2009-12-16T07:36:00.000","Title":"IronPython: What kind of jobs you ever done with IronPython instead of standard .NET languages (e.g., 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},{"Question":"I am learning IronPython along wiht Python. I'm curious what kinds of tasks you tend to use IronPython to tackle more often than standard .NET languages. \nThanks for any example.","AnswerCount":6,"Available Count":4,"Score":0.0,"is_accepted":false,"ViewCount":797,"Q_Id":1912971,"Users Score":0,"Answer":"Created a load tool for a MS Group Chat Server plugin. The GC API is in C#. I wrapped that into a dll and had FePy load it. The main application, configuration scripts etc are all in FePy.","Q_Score":8,"Tags":"python,ironpython","A_Id":1913220,"CreationDate":"2009-12-16T07:36:00.000","Title":"IronPython: What kind of jobs you ever done with IronPython instead of standard .NET languages (e.g., 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},{"Question":"I have a GSM date\/time stamp from a PDU encoded SMS it is formatted as so\n\\x90,\\x21,\\x51,\\x91,\\x40,\\x33\nformat yy,mm,dd,hh,mm,ss\nI have read them from a binary file into a byte array. I want to convert them to a string but without doing any decoding I want to end up with a string that contains 902151914033. I then need to reverse each 2 characters in the string.\nCan anyone give me some pointers?\nMany Thanks","AnswerCount":5,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":10490,"Q_Id":1916928,"Users Score":5,"Answer":"To convert to hex:\nhexdata = ''.join('%02x' % ord(byte) for byte in bindata)\nTo reverse every other hex character (if I'm understanding correctly):\nhexdata = ''.join(('%02x' % ord(byte))[::-1] for byte in bindata)","Q_Score":0,"Tags":"python,bytearray,decode","A_Id":1917086,"CreationDate":"2009-12-16T19:10:00.000","Title":"convert byte array to string without interpreting the bytes?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I have two related Python 'import' questions. They are easily testable, but I want answers that are language-defined and not implementation-specific, and I'm also interested in style\/convention, so I'm asking here instead.\n1)\nIf module A imports module B, and module B imports module C, can code in module A reference module C without an explicit import? If so, am I correct in assuming this is bad practice?\n2)\nIf I import module A.B.C, does that import modules A and A.B as well? If so, is it by convention better to explicitly import A; import A.B; import A.B.C?","AnswerCount":2,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":3559,"Q_Id":1917958,"Users Score":11,"Answer":"Alan's given a great answer, but I wanted to add that for your question 1 it depends on what you mean by 'imports'.\nIf you use the from C import x syntax, then x becomes available in the namespace of B. If in A you then do import B, you will have access to x from A as B.x.\nIt's not so much bad practice as potentially confusing, and will make debugging etc harder as you won't necessarily know where the objects have come from.","Q_Score":13,"Tags":"python,coding-style,import,module,conventions","A_Id":1918234,"CreationDate":"2009-12-16T21:41:00.000","Title":"Python import mechanics","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have built an XML-RPC interface in Python and I need to enforce some stricter typing. For example, passing string '10' instead of int 10. I can clean this up with some type casting and a little exception handling, but I am wondering if there is any other way of forcing type integrity such as something XML-RPC specific, a decorator, or something else.","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":220,"Q_Id":1925487,"Users Score":1,"Answer":"It's always going to be converted to a string anyway, so why do you care what's being passed in? If you use \"%s\" % number or even just str(number), then it doesn't matter whether number is a string or an int.","Q_Score":2,"Tags":"python,django","A_Id":1925617,"CreationDate":"2009-12-18T00:12:00.000","Title":"XML-RPC method parameter data typing 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},{"Question":"We have a web service which serves small, arbitrary segments of a fixed inventory of larger MP3 files. The MP3 files are generated on-the-fly by a python application. The model is, make a GET request to a URL specifying which segments you want, get an audio\/mpeg stream in response. This is an expensive process. \nWe're using Nginx as the front-end request handler. Nginx takes care of caching responses for common requests.\nWe initially tried using Tornado on the back-end to handle requests from Nginx. As you would expect, the blocking MP3 operation kept Tornado from doing its thing (asynchronous I\/O). So, we went multithreaded, which solved the blocking problem, and performed quite well. However, it introduced a subtle race condition (under real world load) that we haven't been able to diagnose or reproduce yet. The race condition corrupts our MP3 output.\nSo we decided to set our application up as a simple WSGI handler behind Apache\/mod_wsgi (still w\/ Nginx up front). This eliminates the blocking issue and the race condition, but creates a cascading load (i.e. Apache creates too many processses) on the server under real world conditions. We're working on tuning Apache\/mod_wsgi right now, but still at a trial-and-error phase. (Update: we've switched back to Tornado. See below.)\nFinally, the question: are we missing anything? Is there a better way to serve CPU-expensive resources over HTTP?\nUpdate: Thanks to Graham's informed article, I'm pretty sure this is an Apache tuning problem. In the mean-time, we've gone back to using Tornado and are trying to resolve the data-corruption issue. \nFor those who were so quick to throw more iron at the problem, Tornado and a bit of multi-threading (despite the data integrity problem introduced by threading) handles the load acceptably on a small (single core) Amazon EC2 instance.","AnswerCount":5,"Available Count":3,"Score":0.0399786803,"is_accepted":false,"ViewCount":495,"Q_Id":1929681,"Users Score":1,"Answer":"You might consider a queuing system with AJAX notification methods.\nWhenever there is a request for your expensive resource, and that resource needs to be generated, add that request to the queue (if it's not already there). That queuing operation should return an ID of an object that you can query to get its status.\nNext you have to write a background service that spins up worker threads. These workers simply dequeue the request, generate the data, then saves the data's location in the request object.\nThe webpage can make AJAX calls to your server to find out the progress of the generation and to give a link to the file once it's available.\nThis is how LARGE media sites work - those that have to deal with video in particular. It might be overkill for your MP3 work however.\nAlternatively, look into running a couple machines to distribute the load. Your threads on Apache will still block, but atleast you won't consume resources on the web server.","Q_Score":5,"Tags":"python,http,mod-wsgi,tornado","A_Id":1929711,"CreationDate":"2009-12-18T17:39:00.000","Title":"Is there a better way to serve the results of an expensive, blocking python process over HTTP?","Data Science and Machine Learning":0,"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},{"Question":"We have a web service which serves small, arbitrary segments of a fixed inventory of larger MP3 files. The MP3 files are generated on-the-fly by a python application. The model is, make a GET request to a URL specifying which segments you want, get an audio\/mpeg stream in response. This is an expensive process. \nWe're using Nginx as the front-end request handler. Nginx takes care of caching responses for common requests.\nWe initially tried using Tornado on the back-end to handle requests from Nginx. As you would expect, the blocking MP3 operation kept Tornado from doing its thing (asynchronous I\/O). So, we went multithreaded, which solved the blocking problem, and performed quite well. However, it introduced a subtle race condition (under real world load) that we haven't been able to diagnose or reproduce yet. The race condition corrupts our MP3 output.\nSo we decided to set our application up as a simple WSGI handler behind Apache\/mod_wsgi (still w\/ Nginx up front). This eliminates the blocking issue and the race condition, but creates a cascading load (i.e. Apache creates too many processses) on the server under real world conditions. We're working on tuning Apache\/mod_wsgi right now, but still at a trial-and-error phase. (Update: we've switched back to Tornado. See below.)\nFinally, the question: are we missing anything? Is there a better way to serve CPU-expensive resources over HTTP?\nUpdate: Thanks to Graham's informed article, I'm pretty sure this is an Apache tuning problem. In the mean-time, we've gone back to using Tornado and are trying to resolve the data-corruption issue. \nFor those who were so quick to throw more iron at the problem, Tornado and a bit of multi-threading (despite the data integrity problem introduced by threading) handles the load acceptably on a small (single core) Amazon EC2 instance.","AnswerCount":5,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":495,"Q_Id":1929681,"Users Score":0,"Answer":"It looks like you are doing things right -- just lacking CPU power: can you determine what is the CPU loading in the process of generating these MP3?\nI think the next thing you have to do there is to add more hardware to render the MP3's on other machines. Or that or find a way to deliver pre-rendered MP3 (maybe you can cahce some of your media?)\nBTW, scaling for the web was the theme of a Keynote lecture by Jacob Kaplan-Moss on PyCon Brasil this year, and it is far from being a closed problem. The stack of technologies one needs to handle is quite impressible - (I could not find an online copy o f the presentation, though - -sorry for that)","Q_Score":5,"Tags":"python,http,mod-wsgi,tornado","A_Id":1929738,"CreationDate":"2009-12-18T17:39:00.000","Title":"Is there a better way to serve the results of an expensive, blocking python process over HTTP?","Data Science and Machine Learning":0,"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},{"Question":"We have a web service which serves small, arbitrary segments of a fixed inventory of larger MP3 files. The MP3 files are generated on-the-fly by a python application. The model is, make a GET request to a URL specifying which segments you want, get an audio\/mpeg stream in response. This is an expensive process. \nWe're using Nginx as the front-end request handler. Nginx takes care of caching responses for common requests.\nWe initially tried using Tornado on the back-end to handle requests from Nginx. As you would expect, the blocking MP3 operation kept Tornado from doing its thing (asynchronous I\/O). So, we went multithreaded, which solved the blocking problem, and performed quite well. However, it introduced a subtle race condition (under real world load) that we haven't been able to diagnose or reproduce yet. The race condition corrupts our MP3 output.\nSo we decided to set our application up as a simple WSGI handler behind Apache\/mod_wsgi (still w\/ Nginx up front). This eliminates the blocking issue and the race condition, but creates a cascading load (i.e. Apache creates too many processses) on the server under real world conditions. We're working on tuning Apache\/mod_wsgi right now, but still at a trial-and-error phase. (Update: we've switched back to Tornado. See below.)\nFinally, the question: are we missing anything? Is there a better way to serve CPU-expensive resources over HTTP?\nUpdate: Thanks to Graham's informed article, I'm pretty sure this is an Apache tuning problem. In the mean-time, we've gone back to using Tornado and are trying to resolve the data-corruption issue. \nFor those who were so quick to throw more iron at the problem, Tornado and a bit of multi-threading (despite the data integrity problem introduced by threading) handles the load acceptably on a small (single core) Amazon EC2 instance.","AnswerCount":5,"Available Count":3,"Score":0.0399786803,"is_accepted":false,"ViewCount":495,"Q_Id":1929681,"Users Score":1,"Answer":"Please define \"cascading load\", as it has no common meaning.\nYour most likely problem is going to be if you're running too many Apache processes.\nFor a load like this, make sure you're using the prefork mpm, and make sure you're limiting yourself to an appropriate number of processes (no less than one per CPU, no more than two).","Q_Score":5,"Tags":"python,http,mod-wsgi,tornado","A_Id":1937378,"CreationDate":"2009-12-18T17:39:00.000","Title":"Is there a better way to serve the results of an expensive, blocking python process over HTTP?","Data Science and Machine Learning":0,"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},{"Question":"I have an object which defines a __deepcopy__ method. I would like a function that will deepcopy it not by the method given by it, but in the default way that objects of the class object are copied.\nHow could I do that? I think I could try to code it but there are probably many \"gotchas\" I won't be thinking of.\nThe reason I'm doing it is because I have an object class which implements a __deepcopy__ method, and that method checks for some condition, and in some cases it will deepcopy the object in a certain way, and in other cases it will deepcopy in the default object way.","AnswerCount":1,"Available Count":1,"Score":0.6640367703,"is_accepted":false,"ViewCount":807,"Q_Id":1933621,"Users Score":4,"Answer":"You basically need to override the existing __deepcopy__ method, which means temporarily setting the object's class to something different -- whether that's acceptable essentially depends on whether the \"__deepcopy__ override\" needs to affect only one, \"top-level\" object (in which case the kludge's probably OK), or if there are many objects of that class in the graph you're copying, in which case it's quite a mess. Which case obtains?","Q_Score":1,"Tags":"python,deep-copy","A_Id":1933642,"CreationDate":"2009-12-19T17:44:00.000","Title":"Deepcopy a simple Python 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},{"Question":"I know PHP a little. But Python is totally new for me. I only know it's something \"similar\", right? Or wrong? What are the differences I should know?","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":26274,"Q_Id":1936085,"Users Score":1,"Answer":"One main difference is, that code formatting (indentation) influences your codes behaviour in Python. PHP is not interested in how you format your code.\nFurthermore PHP may be able to produce applications outside of webservers and CLIs but is definitely aimed at those two environments while Python is more \"all purpose\".","Q_Score":4,"Tags":"php,python","A_Id":1936148,"CreationDate":"2009-12-20T15:07:00.000","Title":"What are the major differences between Python and 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":0},{"Question":"I know PHP a little. But Python is totally new for me. I only know it's something \"similar\", right? Or wrong? What are the differences I should know?","AnswerCount":3,"Available Count":2,"Score":1.0,"is_accepted":false,"ViewCount":26274,"Q_Id":1936085,"Users Score":16,"Answer":"PHP is a language that's made for the web. You can make GTK and CLI applications with PHP, but it's mainly used for websites. Python is used for a lot of stuff like websites, webservers, game frameworks, desktop and CLI application, IDEs and a lot more.\nThere's also a huge difference in the syntax. PHP has a syntax that's like C with curly braces for loops and whitespace is ignored. Python doesn't have curly braces, instead the level of indention of blocks of code are important.\nBoth languages are easy to learn. It just depends on what you want to do.","Q_Score":4,"Tags":"php,python","A_Id":1936138,"CreationDate":"2009-12-20T15:07:00.000","Title":"What are the major differences between Python and 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":0},{"Question":"I've import contacts from gmail by using gdata api, \nand is there any apis like that for hotmail\/live\/Aol ?","AnswerCount":3,"Available Count":1,"Score":0.1325487884,"is_accepted":false,"ViewCount":637,"Q_Id":1938945,"Users Score":2,"Answer":"There is Windows Live Contact API for Hotmail\/Live mail.\nYahoo Contact API for Yahoo also exists, but to this date, no AOL contact api. \nI would suggest you try openinviter (openinviter.com) to import contacts. Unfortunately, you will not have OAuth capabilities, but it is the best class out there and works with 90+ different email providers. \nNote: it is written in php, but creating a wrapper won't be too hard.","Q_Score":0,"Tags":"python,api","A_Id":1939043,"CreationDate":"2009-12-21T08:50:00.000","Title":"Is there any libraries could import contacts from hotmail\/live\/aol account?","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},{"Question":"Is there any way to use xbmc plugins in .net? im thinking about those plugins that provide access to media content like GameTrailers and stuff like that..","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":318,"Q_Id":1940150,"Users Score":1,"Answer":"I believe the plugin system is based on Python. You may be able to use IronPython to run some of the plugins in XBMC, although it may not be 100% compatible. You could also take the Python code and create a COM server object in which you could use .NET interop to interface with it.","Q_Score":2,"Tags":".net,python,xbmc","A_Id":1940200,"CreationDate":"2009-12-21T13:40:00.000","Title":"Run XBMC plugins in a .net 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},{"Question":"So I'm trying to do more web development in python, and I've picked cherrypy, hosted by lighttpd w\/ fastcgi. But my question is a very basic one: why do I need to restart lighttpd (or apache) every time I change my application code, or the code for an underlying library?\nI realize this question extends from a basic mis(i.e. poor)understanding of the fastcgi model, so I'm open to any schooling here, but I'm used to just changing a PHP file and it showing up, versus having to bounce the web server.\nAny elucidation\/useful mockery appreciated.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2035,"Q_Id":1947344,"Users Score":0,"Answer":"From a system-software-writer's pointer of view: This all depends on how the meta-data about the server process is organized within your daemon (lighttpd or fcgi). Some programs are designed for one time only initialization -- MOSTLY this allows a much simpler and better performing internal programming model.\nOften it is very hard to program a server process reload config data in a easy way. You might have to introduce locks and external event objects (signals in UNIX). When you can synchronize the data structures by design -- i.e., only initializing once .... why complicate things by making the data model modifiable multiple times ?","Q_Score":5,"Tags":"python,fastcgi,lighttpd,cherrypy","A_Id":1947457,"CreationDate":"2009-12-22T16:09:00.000","Title":"fastcgi, cherrypy, 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":1},{"Question":"I am pretty sure that python scripts will work in all three, but I want to make sure. I have read here and there about editors that can write CPython, Jython, IronPython and I am hoping that I am looking to much into the distinction.\nMy situation is I have 3 different api's that I want to test. Each api performs the same functionality code wise, but they are different in implementation. I am writing wrappers around each language's apis. Each wrapper should expose the exact same functionality and implementation to python using Boost::python, Jython, and IronPython. \nMy question is, would a python script written using these exposed methods (that are common for each language) work in all three \"flavors\" of Python?\nLike I said I am pretty sure the answer is 'Of course,' but I need to make sure before I spend too much time working on this.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1142,"Q_Id":1953989,"Users Score":10,"Answer":"The short answer is: Sometimes.\nSome projects built on top of IronPython may not work with CPython, and some CPython modules that are written in C (e.g. NumPy) will not work with IronPython.\nOn a similar note, while Jython implements the language specification, it has several incompatibilities with CPython (for instance, it lacks a few parts of the CPython standard library, and it can import Java standard library packages and classes, like Swing)\nSo, yes, as long as you avoid the incompatibilities.","Q_Score":7,"Tags":"python,testing,ironpython,jython,boost-python","A_Id":1954037,"CreationDate":"2009-12-23T16:56:00.000","Title":"Are CPython, IronPython, Jython scripts compatible with each other?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am new to the Python programming language. I was wondering if it is possible to compile a program to written in Python.\nIs it possible to convert Python scripts to some lower level programming languages which then can be compiled to binary code?\nA developer who is considering to code in Python might want to keep the possibility open to be able to go for binary distribution later.","AnswerCount":7,"Available Count":2,"Score":1.0,"is_accepted":false,"ViewCount":159831,"Q_Id":1957054,"Users Score":26,"Answer":"Python, as a dynamic language, cannot be \"compiled\" into machine code statically, like C or COBOL can. You'll always need an interpreter to execute the code, which, by definition in the language, is a dynamic operation.\nYou can \"translate\" source code in bytecode, which is just an intermediate process that the interpreter does to speed up the load of the code, It converts text files, with comments, blank spaces, words like 'if', 'def', 'in', etc in binary code, but the operations behind are exactly the same, in Python, not in machine code or any other language. This is what it's stored in .pyc files and it's also portable between architectures.\nProbably what you need it's not \"compile\" the code (which it's not possible) but to \"embed\" an interpreter (in the right architecture) with the code to allow running the code without an external installation of the interpreter. To do that, you can use all those tools like py2exe or cx_Freeze.\nMaybe I'm being a little pedantic on this :-P","Q_Score":72,"Tags":"python,compilation","A_Id":1957814,"CreationDate":"2009-12-24T06:36:00.000","Title":"Is it possible to compile a program written 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},{"Question":"I am new to the Python programming language. I was wondering if it is possible to compile a program to written in Python.\nIs it possible to convert Python scripts to some lower level programming languages which then can be compiled to binary code?\nA developer who is considering to code in Python might want to keep the possibility open to be able to go for binary distribution later.","AnswerCount":7,"Available Count":2,"Score":-0.0855049882,"is_accepted":false,"ViewCount":159831,"Q_Id":1957054,"Users Score":-3,"Answer":"python compile on the fly when you run it.\nRun a .py file by(linux): python abc.py","Q_Score":72,"Tags":"python,compilation","A_Id":1957072,"CreationDate":"2009-12-24T06:36:00.000","Title":"Is it possible to compile a program written 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},{"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},{"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},{"Question":"I'm trying to extend Python interpreter by a few C functions I wrote. From reading docs, to expose those function the user has to import the module encompassing the functions.\nIs it possible to load pre-load or pre-import via C API the module so that the user doesn't have to type import ? Or even better, from import ?\nEdit: I can do PyRun_SimpleString(\"from mymodule import myfunction\") just after Py_Initialize(); - I was just wondering if there is another way of doing this..?\nEdit 2: In other words, I have an application written in C which embeds a Python interpreter. That application provides some functionality which I want to expose to the users so they can write simple Python scripts for the app. All I want is to remove the need of writing from mymodule import myfunction1, myfunction2 because, since it is very specialized app and the script wont work without the app anyway, it doesn't make sense to require to import ... all the time.","AnswerCount":5,"Available Count":2,"Score":0.1194272985,"is_accepted":false,"ViewCount":697,"Q_Id":1963453,"Users Score":3,"Answer":"Even if you implement a module in Python, the user would have to import it. This is the way Python works, and it's actually a good thing - it's one of the great pluses of Python - the namespace\/module system is robust, easy to use and simple to understand.\nFor academic exercises only, you could of course add your new functionality to Python itself, by creating a custom interpreter. You could even create new keywords this way. But for any practical purpose, this isn't recommended.","Q_Score":1,"Tags":"python,c,import,python-c-api,python-embedding","A_Id":1963510,"CreationDate":"2009-12-26T14:05:00.000","Title":"Extending Python: pre-load my C module","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},{"Question":"I'm trying to extend Python interpreter by a few C functions I wrote. From reading docs, to expose those function the user has to import the module encompassing the functions.\nIs it possible to load pre-load or pre-import via C API the module so that the user doesn't have to type import ? Or even better, from import ?\nEdit: I can do PyRun_SimpleString(\"from mymodule import myfunction\") just after Py_Initialize(); - I was just wondering if there is another way of doing this..?\nEdit 2: In other words, I have an application written in C which embeds a Python interpreter. That application provides some functionality which I want to expose to the users so they can write simple Python scripts for the app. All I want is to remove the need of writing from mymodule import myfunction1, myfunction2 because, since it is very specialized app and the script wont work without the app anyway, it doesn't make sense to require to import ... all the time.","AnswerCount":5,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":697,"Q_Id":1963453,"Users Score":0,"Answer":"Nope. You could add it to the Python interpreter itself, but that would mean creating a custom Python version, which, I guess, is not what you want.\nThat import is not just for loading the module, it's also for making this module visible in the (main|current) namespace. Being able to do that, w\/o hacking the actual Python interpreter, would run against \"Explicit is better than implicit\" very strongly.","Q_Score":1,"Tags":"python,c,import,python-c-api,python-embedding","A_Id":1963505,"CreationDate":"2009-12-26T14:05:00.000","Title":"Extending Python: pre-load my C module","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},{"Question":"We're aiming to implement a scripting mechanism, using DLR's Microsoft.Scripting and hosting assembly.\nNow, someone knows about any performance difference between IronRuby 1.0 and IronPython 2.6?\nTo my understanding they have different compilers, but IronPython seems more mature and tested, but if anyone has documentation or knowledge on this issue, that would be appreciated.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":753,"Q_Id":1969472,"Users Score":6,"Answer":"IronPython has had more time to focus on performance improvements, but IronRuby has made significant performance improvements as of late. However, we rarely pin IronRuby up against IronPython. While people may comment here that one or the other is faster, and certain special cases\/examples may even be uses to prove this, there is no exhaustive comparison available today.","Q_Score":4,"Tags":".net,performance,ironpython,ironruby","A_Id":1972630,"CreationDate":"2009-12-28T13:30:00.000","Title":"Performance comparison between IronRuby and 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":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm looking at existing python code that heavily uses Paramiko to do SSH and FTP. I need to allow the same code to work with some hosts that do not support a secure connection and over which I have no control. \nIs there a quick and easy way to do it via Paramiko, or do I need to step back, create some abstraction that supports both paramiko and Python's FTP libraries, and refactor the code to use this abstraction?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":7051,"Q_Id":1977571,"Users Score":7,"Answer":"No, paramiko has no support for telnet or ftp -- you're indeed better off using a higher-level abstraction and implementing it twice, with paramiko and without it (with the ftplib and telnetlib modules of the Python standard library).","Q_Score":6,"Tags":"python,paramiko","A_Id":1978007,"CreationDate":"2009-12-29T23:30:00.000","Title":"Does Paramiko support non-secure telnet and ftp instead of just SSH and SFTP?","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},{"Question":"Are their any ways to optimize Jython without resorting to profiling or significantly changing the code?\nSpecifically are there any flags that can be passed to the compiler, or code hints in tight loops.","AnswerCount":3,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":707,"Q_Id":1978139,"Users Score":0,"Answer":"I know this is an old question, but I'm just putting this for completeness.\nYou can use:-J-server flag to launch Jython in the Java server mode, which can help speed up the hot loops. (JVM will look to aggressively optimize, but might slow up the start up time)","Q_Score":2,"Tags":"java,python,optimization,jython","A_Id":6481974,"CreationDate":"2009-12-30T02:44:00.000","Title":"Jython Optimizations","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Are their any ways to optimize Jython without resorting to profiling or significantly changing the code?\nSpecifically are there any flags that can be passed to the compiler, or code hints in tight loops.","AnswerCount":3,"Available Count":3,"Score":1.2,"is_accepted":true,"ViewCount":707,"Q_Id":1978139,"Users Score":1,"Answer":"Jython compiler does not offer lots of optimization choices. However, since the Java virtual machine (java) and perhaps compiler (javac) are getting invoked in the back end or at runtime, you should take a look at them.\nJava has different runtime switches to use depending on whether you are going to launch it as a server process, client process, etc. You can also tell how much memory to allocate too.","Q_Score":2,"Tags":"java,python,optimization,jython","A_Id":1990415,"CreationDate":"2009-12-30T02:44:00.000","Title":"Jython Optimizations","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Are their any ways to optimize Jython without resorting to profiling or significantly changing the code?\nSpecifically are there any flags that can be passed to the compiler, or code hints in tight loops.","AnswerCount":3,"Available Count":3,"Score":1.0,"is_accepted":false,"ViewCount":707,"Q_Id":1978139,"Users Score":6,"Answer":"No flags, no code hints. You can optimize by tweaking your code much as you would for any other Python implementation (hoisting, etc), but profiling helps by telling you where it's worth your while to expend such effort -- so, sure, you can optimize \"without resorting to profiling\" (and the code changes to do so may well be deemed to be not significant), but you're unlikely to guess right about where your time and energy are best spent, while profiling helps you determine exactly that.","Q_Score":2,"Tags":"java,python,optimization,jython","A_Id":1978207,"CreationDate":"2009-12-30T02:44:00.000","Title":"Jython Optimizations","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"A friend was \"burned\" when starting to learn Python, and now sees the language as perhaps fatally flawed.\nHe was using a library and changed the value of an object's attribute (the class being in the library), but he used the wrong abbreviation for the attribute name. It took him \"forever\" to figure out what was wrong. His objection to Python is thus that it allows one to accidentally add attributes to an object.\nUnit tests don't provide a solution to this. One doesn't write unit tests against an API being used. One may have a mock for the class, but the mock could have the same typo or incorrect assumption about the attribute name.\nIt's possible to use __setattr__() to guard against this, but (as far as I know), no one does.\nThe only thing I've been able to tell my friend is that after several years of writing Python code full-time, I don't recall ever being burned by this. What else can I tell him?","AnswerCount":8,"Available Count":5,"Score":0.024994793,"is_accepted":false,"ViewCount":521,"Q_Id":1981208,"Users Score":1,"Answer":"I think your friend has misplaced his frustration in the language. His real problem is lack of debugging techniques. teach him how to break down a program into small pieces to examine the output. like a manual unit test, this way any inconsistency is found and any assumptions are proven or discarded.","Q_Score":4,"Tags":"python,attributes","A_Id":1981378,"CreationDate":"2009-12-30T16:59:00.000","Title":"Protection from accidentally misnaming object attributes 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},{"Question":"A friend was \"burned\" when starting to learn Python, and now sees the language as perhaps fatally flawed.\nHe was using a library and changed the value of an object's attribute (the class being in the library), but he used the wrong abbreviation for the attribute name. It took him \"forever\" to figure out what was wrong. His objection to Python is thus that it allows one to accidentally add attributes to an object.\nUnit tests don't provide a solution to this. One doesn't write unit tests against an API being used. One may have a mock for the class, but the mock could have the same typo or incorrect assumption about the attribute name.\nIt's possible to use __setattr__() to guard against this, but (as far as I know), no one does.\nThe only thing I've been able to tell my friend is that after several years of writing Python code full-time, I don't recall ever being burned by this. What else can I tell him?","AnswerCount":8,"Available Count":5,"Score":0.0,"is_accepted":false,"ViewCount":521,"Q_Id":1981208,"Users Score":0,"Answer":"I had a similar bad experience with Python when I first started ... took me 3 months to get over it. Having a tool which warns would be nice back then ...","Q_Score":4,"Tags":"python,attributes","A_Id":1981269,"CreationDate":"2009-12-30T16:59:00.000","Title":"Protection from accidentally misnaming object attributes 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},{"Question":"A friend was \"burned\" when starting to learn Python, and now sees the language as perhaps fatally flawed.\nHe was using a library and changed the value of an object's attribute (the class being in the library), but he used the wrong abbreviation for the attribute name. It took him \"forever\" to figure out what was wrong. His objection to Python is thus that it allows one to accidentally add attributes to an object.\nUnit tests don't provide a solution to this. One doesn't write unit tests against an API being used. One may have a mock for the class, but the mock could have the same typo or incorrect assumption about the attribute name.\nIt's possible to use __setattr__() to guard against this, but (as far as I know), no one does.\nThe only thing I've been able to tell my friend is that after several years of writing Python code full-time, I don't recall ever being burned by this. What else can I tell him?","AnswerCount":8,"Available Count":5,"Score":0.1243530018,"is_accepted":false,"ViewCount":521,"Q_Id":1981208,"Users Score":5,"Answer":"If the possibility to make mistakes is enough for him to consider a language \"fatally flawed\", I don't think you can convince him otherwise. The more you can do with a language, the more you can do wrong with the language. It's a caveat of flexibility\u2014but that's true for any language.","Q_Score":4,"Tags":"python,attributes","A_Id":1981255,"CreationDate":"2009-12-30T16:59:00.000","Title":"Protection from accidentally misnaming object attributes 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},{"Question":"A friend was \"burned\" when starting to learn Python, and now sees the language as perhaps fatally flawed.\nHe was using a library and changed the value of an object's attribute (the class being in the library), but he used the wrong abbreviation for the attribute name. It took him \"forever\" to figure out what was wrong. His objection to Python is thus that it allows one to accidentally add attributes to an object.\nUnit tests don't provide a solution to this. One doesn't write unit tests against an API being used. One may have a mock for the class, but the mock could have the same typo or incorrect assumption about the attribute name.\nIt's possible to use __setattr__() to guard against this, but (as far as I know), no one does.\nThe only thing I've been able to tell my friend is that after several years of writing Python code full-time, I don't recall ever being burned by this. What else can I tell him?","AnswerCount":8,"Available Count":5,"Score":1.2,"is_accepted":true,"ViewCount":521,"Q_Id":1981208,"Users Score":12,"Answer":"\"changed the value of an object's attribute\" Can lead to problems. This is pretty well known. You know it, now, also. That doesn't indict the language. It simply says that you've learned an important lesson in dynamic language programming.\n\nUnit testing absolutely discovers this. You are not forced to mock all library classes. Some folks say it's only a unit test when it's tested in complete isolation. This is silly. You have to trust the library modules -- it's a feature of your architecture. Rather than mock them, just use them. (It is important to write mocks for your own newly-developed libraries. It's also important to mock libraries that make expensive API calls.)\nIn most cases, you can (and should) test your classes with the real library modules. This will find the misspelled attribute name.\nAlso, now that you know that attributes are dynamic, it's really easy to verify that the attribute exists. How?\nUse interactive Python to explore the classes before writing too much code.\nRemember, Python is not Java and it's not C. You can execute Python interactively and determine immediately if you've spelled something wrong. Writing a lot of code without doing any interactive confirmation is -- simply -- the wrong way to use Python.\nA little interactive exploration will find misspelled attribute names.\nFinally -- for your own classes -- you can wrap updatable attributes as properties. This makes it easier to debug any misspelled attribute names. Again, you know to check for this. You can use interactive development to confirm the attribute names.\n\nFussing around with __setattr__ creates problems. In some cases, we actually need to add attributes to an object. Why? It's simpler than creating a whole subclass for one special case where we have to maintain more state information.\n\nOther things you can say:\nI was burned by a C program that absolutely could not be made to work because of ______. [Insert any known C-language problem you want here. No array bounds checking, for example] Does that make C fatally flawed?\nI was burned by a DBA who changed a column name and all the SQL broke. It's painful to unit test all of it. Does that make the relational database fatally flawed? \nI was burned by a sys admin who changed a directory's permissions and my application broke. It was nearly impossible to find. Does that make the OS fatally flawed? \nI was burned by a COBOL program where someone changed the copybook, forgot to recompile the program, and we couldn't debug it because the source looked perfect. COBOL, however, actually is fatally flawed, so this isn't a good example.","Q_Score":4,"Tags":"python,attributes","A_Id":1981279,"CreationDate":"2009-12-30T16:59:00.000","Title":"Protection from accidentally misnaming object attributes 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},{"Question":"A friend was \"burned\" when starting to learn Python, and now sees the language as perhaps fatally flawed.\nHe was using a library and changed the value of an object's attribute (the class being in the library), but he used the wrong abbreviation for the attribute name. It took him \"forever\" to figure out what was wrong. His objection to Python is thus that it allows one to accidentally add attributes to an object.\nUnit tests don't provide a solution to this. One doesn't write unit tests against an API being used. One may have a mock for the class, but the mock could have the same typo or incorrect assumption about the attribute name.\nIt's possible to use __setattr__() to guard against this, but (as far as I know), no one does.\nThe only thing I've been able to tell my friend is that after several years of writing Python code full-time, I don't recall ever being burned by this. What else can I tell him?","AnswerCount":8,"Available Count":5,"Score":0.024994793,"is_accepted":false,"ViewCount":521,"Q_Id":1981208,"Users Score":1,"Answer":"He's effectively ruling out an entire class of programming languages -- dynamically-typed languages -- because of one hard lesson learned. He can use only statically-typed languages if he wishes and still have a very productive career as a programmer, but he is certainly going to have deep frustrations with them as well. Will he then conclude that they are fatally-flawed?","Q_Score":4,"Tags":"python,attributes","A_Id":1981288,"CreationDate":"2009-12-30T16:59:00.000","Title":"Protection from accidentally misnaming object attributes 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},{"Question":"Is there any way of writing pexpect like small program which can launch a process and pass the password to that process?\nI don't want to install and use pexpect python library but want to know the logic behind it so that using linux system apis I can build something similar.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":639,"Q_Id":1982788,"Users Score":2,"Answer":"You could just use \"expect\". It is very light weight and is made to do what youre describing.","Q_Score":0,"Tags":"c++,python,linux,pexpect","A_Id":1982873,"CreationDate":"2009-12-30T22:06:00.000","Title":"writing pexpect like program in c++ 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},{"Question":"Are Python docstrings and comments stored in memory when a module is loaded?\n\nI've wondered if this is true, because I usually document my code well; may this affect memory usage?\nUsually every Python object has a __doc__ method. Are those docstrings read from the file, or processed otherwise?\nI've done searches here in the forums, Google and Mailing-Lists, but I haven't found any relevant information. \nDo you know better?","AnswerCount":5,"Available Count":3,"Score":0.1973753202,"is_accepted":false,"ViewCount":3713,"Q_Id":1983177,"Users Score":5,"Answer":"They are getting read from the file (when the file is compiled to pyc or when the pyc is loaded -- they must be available under object.__doc__) but no --> this will not significantly impact performance under any reasonable circumstances, or are you really writing multi-megabyte doc-strings?","Q_Score":15,"Tags":"python,comments,memory-management,docstring","A_Id":1983193,"CreationDate":"2009-12-30T23:55:00.000","Title":"Are Python docstrings and comments stored in memory when a module is loaded?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Are Python docstrings and comments stored in memory when a module is loaded?\n\nI've wondered if this is true, because I usually document my code well; may this affect memory usage?\nUsually every Python object has a __doc__ method. Are those docstrings read from the file, or processed otherwise?\nI've done searches here in the forums, Google and Mailing-Lists, but I haven't found any relevant information. \nDo you know better?","AnswerCount":5,"Available Count":3,"Score":1.0,"is_accepted":false,"ViewCount":3713,"Q_Id":1983177,"Users Score":12,"Answer":"Yes the docstrings are read from the file, but that shouldn't stop you writing them. Never ever compromise readability of code for performance until you have done a performance test and found that the thing you are worried about is in fact the bottleneck in your program that is causing a problem. I would think that it is extremely unlikely that a docstring will cause any measurable performance impact in any real world situation.","Q_Score":15,"Tags":"python,comments,memory-management,docstring","A_Id":1983203,"CreationDate":"2009-12-30T23:55:00.000","Title":"Are Python docstrings and comments stored in memory when a module is loaded?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Are Python docstrings and comments stored in memory when a module is loaded?\n\nI've wondered if this is true, because I usually document my code well; may this affect memory usage?\nUsually every Python object has a __doc__ method. Are those docstrings read from the file, or processed otherwise?\nI've done searches here in the forums, Google and Mailing-Lists, but I haven't found any relevant information. \nDo you know better?","AnswerCount":5,"Available Count":3,"Score":0.0399786803,"is_accepted":false,"ViewCount":3713,"Q_Id":1983177,"Users Score":1,"Answer":"Do Python docstrings and comments are\n stored in memory when module is\n loaded?\n\nDocstrings are compiled into the .pyc file, and are loaded into memory. Comments are discarded during compilation and have no impact on anything except the insignificant extra time taken to ignore them during compilation (which happens once only after any change to a .py file, except for the main script which is re-compiled every time it is run).\nAlso note that these strings are preserved only if they are the first thing in the module, class definition, or function definition. You can include additional strings pretty much anywhere, but they will be discarded during compilation just as comments are.","Q_Score":15,"Tags":"python,comments,memory-management,docstring","A_Id":1983288,"CreationDate":"2009-12-30T23:55:00.000","Title":"Are Python docstrings and comments stored in memory when a module is loaded?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"All the books I've read on data structures so far seem to use C\/C++, and make heavy use of the \"manual\" pointer control that they offer. Since Python hides that sort of memory management and garbage collection from the user is it even possible to implement efficient data structures in this language, and is there any reason to do so instead of using the built-ins?","AnswerCount":6,"Available Count":4,"Score":1.0,"is_accepted":false,"ViewCount":22283,"Q_Id":1986712,"Users Score":14,"Answer":"For some simple data structures (eg. a stack), you can just use the builtin list to get your job done. With more complex structures (eg. a bloom filter), you'll have to implement them yourself using the primitives the language supports. \nYou should use the builtins if they serve your purpose really since they're debugged and optimised by a horde of people for a long time. Doing it from scratch by yourself will probably produce an inferior data structure. \nIf however, you need something that's not available as a primitive or if the primitive doesn't perform well enough, you'll have to implement your own type.\nThe details like pointer management etc. are just implementation talk and don't really limit the capabilities of the language itself.","Q_Score":16,"Tags":"python,data-structures","A_Id":1986739,"CreationDate":"2009-12-31T19:10:00.000","Title":"Data Structures 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},{"Question":"All the books I've read on data structures so far seem to use C\/C++, and make heavy use of the \"manual\" pointer control that they offer. Since Python hides that sort of memory management and garbage collection from the user is it even possible to implement efficient data structures in this language, and is there any reason to do so instead of using the built-ins?","AnswerCount":6,"Available Count":4,"Score":0.0665680765,"is_accepted":false,"ViewCount":22283,"Q_Id":1986712,"Users Score":2,"Answer":"With Python you have access to a vast assortment of library modules written and debugged by other people. Odds are very good that somewhere out there, there is a module that does at least part of what you want, and odds are even good that it might be implemented in C for performance.\nFor example, if you need to do matrix math, you can use NumPy, which was written in C and Fortran.\nPython is slow enough that you won't be happy if you try to write some sort of really compute-intensive code (example, a Fast Fourier Transform) in native Python. On the other hand, you can get a C-coded Fourier Transform as part of SciPy, and just use it.\nI have never had a situation where I wanted to solve a problem in Python and said \"darn, I just can't express the data structure I need.\"\nIf you are a pioneer, and you are doing something in Python for which there just isn't any library module out there, then you can try writing it in pure Python. If it is fast enough, you are done. If it is too slow, you can profile it, figure out where the slow parts are, and rewrite them in C using the Python C API. I have never needed to do this yet.","Q_Score":16,"Tags":"python,data-structures","A_Id":1987211,"CreationDate":"2009-12-31T19:10:00.000","Title":"Data Structures 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},{"Question":"All the books I've read on data structures so far seem to use C\/C++, and make heavy use of the \"manual\" pointer control that they offer. Since Python hides that sort of memory management and garbage collection from the user is it even possible to implement efficient data structures in this language, and is there any reason to do so instead of using the built-ins?","AnswerCount":6,"Available Count":4,"Score":0.0,"is_accepted":false,"ViewCount":22283,"Q_Id":1986712,"Users Score":0,"Answer":"It's not possible to implement something like a C++ vector in Python, since you don't have array primitives the way C\/C++ do. However, anything more complicated can be implemented (efficiently) on top of it, including, but not limited to: linked lists, hash tables, multisets, bloom filters, etc.","Q_Score":16,"Tags":"python,data-structures","A_Id":1986761,"CreationDate":"2009-12-31T19:10:00.000","Title":"Data Structures 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},{"Question":"All the books I've read on data structures so far seem to use C\/C++, and make heavy use of the \"manual\" pointer control that they offer. Since Python hides that sort of memory management and garbage collection from the user is it even possible to implement efficient data structures in this language, and is there any reason to do so instead of using the built-ins?","AnswerCount":6,"Available Count":4,"Score":1.0,"is_accepted":false,"ViewCount":22283,"Q_Id":1986712,"Users Score":10,"Answer":"C\/C++ data structure books are only attempting to teach you the underlying principles behind the various structures - they are generally not advising you to actually go out and re-invent the wheel by building your own library of stacks and lists.\nWhether you're using Python, C++, C#, Java, whatever, you should always look to the built in data structures first. They will generally be implemented using the same system primitives you would have to use doing it yourself, but with the advantage of having been tried and tested.\nOnly when the provided data structures do not allow you to accomplish what you need, and there isn't an alternative and reliable library available to you, should you be looking at building something from scratch (or extending what's provided).","Q_Score":16,"Tags":"python,data-structures","A_Id":1986749,"CreationDate":"2009-12-31T19:10:00.000","Title":"Data Structures 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},{"Question":"Please bear with me experts i'm a newbie in web dev.\nWith html,css can take care of webpages..\njavascript,ajax for some dynamic content..\nphp for server side scripting,accessing databases,sending emails,doing all other stuf...\nWhat role do these programming languages play?\nCan they do any other important task which cannot be done by PHP?","AnswerCount":4,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":719,"Q_Id":1991065,"Users Score":10,"Answer":"All languages can all do basically any task any other one of them can do, as they are all Turing complete.\nPHP works as a server-side scripting language, but you can also use Perl, Python, Ruby, Haskell, Lisp, Java, C, C++, assembly, or pretty much any other language that can access standard input and standard output for CGI communication with web content.\nPHP is widely used because a) it's easy to learn a little and go, and b) the rather tedious CGI protocols are skipped, as the language handles them for you, so you can just plug your PHP script into an HTML page and not have to know how your program reads the information at all. This makes web programming easier for PHP, but the PHP interpreter is written in C, which does all the heavy lifting, so logically if PHP can do server-side scripting, so can C. Since most other languages are written in C, they too can do server-side scripting. (And since C compiles down to assembly, assembly can do it too, and so can any language that compiles down to assembly. Which is all of them not already covered.)","Q_Score":0,"Tags":"c++,python,c,perl","A_Id":1991076,"CreationDate":"2010-01-02T09:14:00.000","Title":"Role of C,C++,python,perl in Web 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":1},{"Question":"I have a simple setup with my python libraries in \/domains\/somedomain.com\/libs\/ and all my tests run fine. I start WSGI with DJANGO_SETTINGS_MODULE to \"somedomain.settings\" where somedomain is a package in libs\/\nSuddenly, when adding pywapi.py into libs\/ I can't import it when hitting the site. But, if I add 'import pywapi' to my wsgi script, it fails when hit by Apache, but succeeds if I just write it. the WSGI itself is actually adding libs\/ to the path, so I know it should be there when running. The path is absolute, too, so any change in CWD shouldn't be causing this.\nI can't think of anything else and I've been tinkering with it half of my otherwise productive morning.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":927,"Q_Id":1991743,"Users Score":2,"Answer":"I think the problem is related with the permissions of that file. Check that the user running wsgi (apache user, usually) is capable of reading and writing the everything in the libs folder and specially capable of reading the file pywapi.py.","Q_Score":1,"Tags":"python,django,apache,mod-wsgi","A_Id":1991778,"CreationDate":"2010-01-02T14:29:00.000","Title":"How does Django + mod_wsgi affect the python 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":0,"Web Development":1},{"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},{"Question":"Python seems to have functions for copying files (e.g. shutil.copy) and functions for copying directories (e.g. shutil.copytree) but I haven't found any function that handles both. Sure, it's trivial to check whether you want to copy a file or a directory, but it seems like a strange omission.\nIs there really no standard function that works like the unix cp -r command, i.e. supports both directories and files and copies recursively? What would be the most elegant way to work around this problem in Python?","AnswerCount":6,"Available Count":1,"Score":0.1651404129,"is_accepted":false,"ViewCount":192392,"Q_Id":1994488,"Users Score":5,"Answer":"shutil.copy and shutil.copy2 are copying files.\nshutil.copytree copies a folder with all the files and all subfolders. shutil.copytree is using shutil.copy2 to copy the files.\nSo the analog to cp -r you are saying is the shutil.copytree because cp -r targets and copies a folder and its files\/subfolders like shutil.copytree. Without the -r cp copies files like shutil.copy and shutil.copy2 do.","Q_Score":143,"Tags":"python","A_Id":42249637,"CreationDate":"2010-01-03T10:06:00.000","Title":"Copy file or directories recursively 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},{"Question":"Is it possible for a python script to execute at a low run level? \nEdit: \nTo clarify, is it possible for a python script to run in the background, kind of like a daemon.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":523,"Q_Id":1995102,"Users Score":0,"Answer":"Yes. The scripts that control daemons are (normally) plain old bash scripts and can run whatever a bash script can run. The only difference is that in a low runlevel, lots of other system services will not be running, so if the program tries to do something that depends on another daemon, that may fail.","Q_Score":1,"Tags":"python,runlevel","A_Id":1996354,"CreationDate":"2010-01-03T14:21:00.000","Title":"Python 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":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"Just about everyone uses them, but many, including me simply take it for granted that they just work.\nI am looking for high-quality material. Languages I use are: Java, C, C#, Python, C++, so these are of most interest to me.\nNow, C++ is probably a good place to start since you can throw anything in that language. \nAlso, C is close to assembly. How would one emulate exceptions using pure C constructs and no assembly?\nFinally, I heard a rumor that Google employees do not use exceptions for some projects due to speed considerations. Is this just a rumor? How can anything substantial be accomplished without them?\nThank you.","AnswerCount":10,"Available Count":4,"Score":0.0798297691,"is_accepted":false,"ViewCount":9676,"Q_Id":1995734,"Users Score":4,"Answer":"The key thing an exception implementation needs to handle is how to return to the exception handler once an exception has been thrown. Since you may have made an arbitrary number of nested function calls since the try statement in C++, it must unwind the call stack searching for the handler. However implemented, this must incur the code size cost of maintaining sufficient information in order to perform this operation (and generally means a table of data for calls that can take exceptions). It also means that the dynamic code execution path will be longer than simply returning from functions calls (which is a fairly inexpensive operation on most platforms). There may be other costs as well depending on the implementation.\nThe relative cost will vary depending on the language used. The higher-level language used, the less likely the code size cost will matter, and the information may be retained regardless of whether exceptions are used.\nAn application where the use of exceptions (and C++ in general) is often avoided for good reasons is embedded firmware. In typical small bare metal or RTOS platforms, you might have 1MB of code space, or 64K, or even smaller. Some platforms are so small, even C is not practical to use. In this kind of environment, the size impact is relevant because of the cost mentioned above. It also impacts the standard library itself. Embedded toolchain vendors will often produce a library without exception capability, which has a huge impact on code size. Highly optimizing compilers may also analyze the callgraph and optimize away needed call frame information for the unwind operation for considerable space reduction. Exceptions also make it more difficult to analyze hard real-time requirements.\nIn more typical environments, the code size cost is almost certainly irrelevant and the performance factor is likely key. Whether you use them will depend on your performance requirements and how you want to use them. Using exceptions in non-exceptional cases can make an elegant design, but at a performance cost that may be unacceptable for high performance systems. Implementations and relative cost will vary by platform and compiler, so the best way to truly understand if exceptions are a problem is to analyze your own code's performance.","Q_Score":71,"Tags":"c++,python,c,exception","A_Id":1996011,"CreationDate":"2010-01-03T18:06:00.000","Title":"How are exceptions implemented under the hood?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Just about everyone uses them, but many, including me simply take it for granted that they just work.\nI am looking for high-quality material. Languages I use are: Java, C, C#, Python, C++, so these are of most interest to me.\nNow, C++ is probably a good place to start since you can throw anything in that language. \nAlso, C is close to assembly. How would one emulate exceptions using pure C constructs and no assembly?\nFinally, I heard a rumor that Google employees do not use exceptions for some projects due to speed considerations. Is this just a rumor? How can anything substantial be accomplished without them?\nThank you.","AnswerCount":10,"Available Count":4,"Score":1.2,"is_accepted":true,"ViewCount":9676,"Q_Id":1995734,"Users Score":49,"Answer":"Exceptions are just a specific example of a more general case of advanced non-local flow control constructs. Other examples are:\n\nnotifications (a generalization of exceptions, originally from some old Lisp object system, now implemented in e.g. CommonLisp and Ioke), \ncontinuations (a more structured form of GOTO, popular in high-level, higher-order languages), \ncoroutines (a generalization of subroutines, popular especially in Lua), \ngenerators \u00e0 la Python (essentially a restricted form of coroutines), \nfibers (cooperative light-weight threads) and of course the already mentioned \nGOTO.\n\n(I'm sure there's many others I missed.)\nAn interesting property of these constructs is that they are all roughly equivalent in expressive power: if you have one, you can pretty easily build all the others.\nSo, how you best implement exceptions depends on what other constructs you have available: \n\nEvery CPU has GOTO, therefore you can always fall back to that, if you must.\nC has setjmp\/longjmp which are basically MacGyver continuations (built out of duct-tape and toothpicks, not quite the real thing, but will at least get you out of the immediate trouble if you don't have something better available). \nThe JVM and CLI have exceptions of their own, which means that if the exception semantics of your language match Java's\/C#'s, you are home free (but if not, then you are screwed). \nThe Parrot VM as both exceptions and continuations. \nWindows has its own framework for exception handling, which language implementors can use to build their own exceptions on top.\n\nA very interesting use case, both of the usage of exceptions and the implementation of exceptions is Microsoft Live Lab's Volta Project. (Now defunct.) The goal of Volta was to provide architectural refactoring for Web applications at the push of a button. So, you could turn your one-tier web application into a two- or three-tier application just by putting some [Browser] or [DB] attributes on your .NET code and the code would then automagically run on the client or in the DB. In order to do that, the .NET code had to be translated to JavaScript source code, obviously.\nNow, you could just write an entire VM in JavaScript and run the bytecode unmodified. (Basically, port the CLR from C++ to JavaScript.) There are actually projects that do this (e.g. the HotRuby VM), but this is both inefficient and not very interoperable with other JavaScript code.\nSo, instead, they wrote a compiler which compiles CIL bytecode to JavaScript sourcecode. However, JavaScript lacks certain features that .NET has (generators, threads, also the two exception models aren't 100% compatible), and more importantly it lacks certain features that compiler writers love (either GOTO or continuations) and that could be used to implement the above-mentioned missing features.\nHowever, JavaScript does have exceptions. So, they used JavaScript Exceptions to implement Volta Continuations and then they used Volta Continuations to implement .NET Exceptions, .NET Generators and even .NET Managed Threads(!!!)\nSo, to answer your original question:\n\nHow are exceptions implemented under the hood?\n\nWith Exceptions, ironically! At least in this very specific case, anyway.\nAnother great example is some of the exception proposals on the Go mailing list, which implement exceptions using Goroutines (something like a mixture of concurrent coroutines ans CSP processes). Yet another example is Haskell, which uses Monads, lazy evaluation, tail call optimization and higher-order functions to implement exceptions. Some modern CPUs also support basic building blocks for exceptions (for example the Vega-3 CPUs that were specifically designed for the Azul Systems Java Compute Accelerators).","Q_Score":71,"Tags":"c++,python,c,exception","A_Id":1995979,"CreationDate":"2010-01-03T18:06:00.000","Title":"How are exceptions implemented under the hood?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Just about everyone uses them, but many, including me simply take it for granted that they just work.\nI am looking for high-quality material. Languages I use are: Java, C, C#, Python, C++, so these are of most interest to me.\nNow, C++ is probably a good place to start since you can throw anything in that language. \nAlso, C is close to assembly. How would one emulate exceptions using pure C constructs and no assembly?\nFinally, I heard a rumor that Google employees do not use exceptions for some projects due to speed considerations. Is this just a rumor? How can anything substantial be accomplished without them?\nThank you.","AnswerCount":10,"Available Count":4,"Score":0.0199973338,"is_accepted":false,"ViewCount":9676,"Q_Id":1995734,"Users Score":1,"Answer":"Regarding performance - sparse use of exceptions will probably have negligible effects, but do not abuse them.\nI have personally seen Java code which performed two orders of magnitude worse than it could have (took about x100 the time) because exceptions were used in an important loop instead of more standard if\/returns.","Q_Score":71,"Tags":"c++,python,c,exception","A_Id":1995769,"CreationDate":"2010-01-03T18:06:00.000","Title":"How are exceptions implemented under the hood?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Just about everyone uses them, but many, including me simply take it for granted that they just work.\nI am looking for high-quality material. Languages I use are: Java, C, C#, Python, C++, so these are of most interest to me.\nNow, C++ is probably a good place to start since you can throw anything in that language. \nAlso, C is close to assembly. How would one emulate exceptions using pure C constructs and no assembly?\nFinally, I heard a rumor that Google employees do not use exceptions for some projects due to speed considerations. Is this just a rumor? How can anything substantial be accomplished without them?\nThank you.","AnswerCount":10,"Available Count":4,"Score":0.0996679946,"is_accepted":false,"ViewCount":9676,"Q_Id":1995734,"Users Score":5,"Answer":"setjmp() and longjmp() usually.\nException catching does have a non-trivial cost, but for most purposes it's not a big deal.","Q_Score":71,"Tags":"c++,python,c,exception","A_Id":1995737,"CreationDate":"2010-01-03T18:06:00.000","Title":"How are exceptions implemented under the hood?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"What's an easy way of finding all the python modules from a particular package that are being used in an application?","AnswerCount":4,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":20841,"Q_Id":1997449,"Users Score":0,"Answer":"A real simple method is to delete all .pyc files from the package or folder, and then run the application. Once you've played a bit, do a directory listing and see which files have .pyc files now. Those are modules which were imported by the application.\n(Note: the __main__ module, whichever one you invoke as the \"main\" script, never gets compiled, so you should not expect to see a .pyc file for it unless something imported it from within the application. This is often a sign of a problem if it does happen.)","Q_Score":44,"Tags":"python,package","A_Id":1997473,"CreationDate":"2010-01-04T04:01:00.000","Title":"Find which python modules are being imported","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"So the state I'm in released a bunch of data in PDF form, but to make matters worse, most (all?) of the PDFs appear to be letters typed in Office, printed\/fax, and then scanned (our government at its best eh?). At first I thought I was crazy, but then I started seeing numerous pdfs that are 'tilted', like someone didn't get them on the scanner properly. So, I figured the next best thing to getting the actual text out of them, would be to turn each page into an image.\nObviously this needs to be automated, and I'd prefer to stick with Python if possible. If Ruby or Perl have some form of implementation that's just too awesome to pass up, I can go that route. I've tried pyPDF for text extraction, that obviously didn't do me much good. I've tried swftools, but the images I'm getting from that are just shy of completely unusable. It just seems like the fonts get ruined in the conversion. I also don't even really care about the image format on the way out, just as long as they're relatively lightweight, and readable.","AnswerCount":6,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":70011,"Q_Id":2002055,"Users Score":9,"Answer":"You could call e.g. pdftoppm from the command-line (or using Python's subprocess module) and then convert the resulting PPM files to the desired format using e.g. ImageMagick (again, using subprocess or some bindings if they exist).","Q_Score":34,"Tags":"python,pdf,image","A_Id":2002436,"CreationDate":"2010-01-04T20:33:00.000","Title":"Converting PDF to images 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},{"Question":"I have a Python CGI handling a payment transaction. When the user submits the form, the CGI is called. After submission, the CGI takes a while to perform the credit card transaction. During that time, a user might hit the ESC or refresh button. Doing that will not \"kill\" the CGI, meaning, the script will keep running completing the transaction but the CGI's HTML output will never reach the client. This means the user will not know the transaction was completed. How can I solve this problem?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":262,"Q_Id":2002180,"Users Score":3,"Answer":"Same as you should do with every POST: don't send output, but put the output in a session variable and redirect to a pure-GET request. This one looks in the session for messages, and clears+displays those.","Q_Score":1,"Tags":"python,cgi","A_Id":2002206,"CreationDate":"2010-01-04T20:57:00.000","Title":"Python CGI transaction","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I'm working on a c++ project, and we recently needed to include a small part of boost in it. The boost part is really minimal (Boost::Python), thus, using bjam to build everything looks like an overkill (besides, everyone working on the project feels comfortable with make, and has no knowloedge of jam).\nI made quite some tests already, but I cant find a way to include the formerly mentioned library in my makefile and make the build succesful.\nAll your help is deeply apreciated. :)","AnswerCount":4,"Available Count":1,"Score":0.049958375,"is_accepted":false,"ViewCount":2460,"Q_Id":2003506,"Users Score":1,"Answer":"Run bjam from the makefile, just for building that part","Q_Score":8,"Tags":"c++,boost,build-process,makefile,boost-python","A_Id":2003592,"CreationDate":"2010-01-05T01:12:00.000","Title":"How to build a boost dependent project using regular makefiles?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I want to remove as much complexity as I can from administering Python in on Amazon EC2 following some truly awful experiences with hosting providers who claim support for Python. I am looking for some guidance on which AMI to choose so that I have a stable and easily managed environment which already included Python and ideally an Apache web server and a database. \nI am agnostic to Python version, web server, DB and OS as I am still early enough in my development cycle that I can influence those choices. Cost is not a consideration (within bounds) so Windows will work fine if it means easy administration.\nAnyone have any practical experience or recommendations they can share?","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":2510,"Q_Id":2008055,"Users Score":2,"Answer":"If you can get by with using the Amazon provided ones, I'd recommend it. I tend to use ami-84db39ed.\nHonestly though, if you plan on leaving this running all the time, you would probably save a bit of money by just going with a VPS. Amazon tends to be cheaper if you are turning the service on and off over time.","Q_Score":4,"Tags":"python,amazon-ec2","A_Id":2008170,"CreationDate":"2010-01-05T18:01:00.000","Title":"Can you recommend an Amazon AMI 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},{"Question":"I have a need to display some basic info about a facebook group on a website i am building. All i am really looking to show is the total number of members, and maybe a list of the few most recent people who joined. \nI would like to not have to login to FB to accomplish this, is there an API for groups that allows anonymous access? or do i have to go the screen scraping route?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":342,"Q_Id":2008816,"Users Score":1,"Answer":"Use the Python Facebook module on Google Code.","Q_Score":1,"Tags":"python,django,facebook","A_Id":2012448,"CreationDate":"2010-01-05T20:23:00.000","Title":"Python + Facebook, getting info about a group easily","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},{"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},{"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},{"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},{"Question":"How do I get the MAC address of a remote host on my LAN? I'm using Python and Linux.","AnswerCount":7,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":22526,"Q_Id":2010816,"Users Score":0,"Answer":"Many years ago, I was tasked with gathering various machine info from all machines on a corporate campus. One desired piece of info was the MAC address, which is difficult to get on a network that spanned multiple subnets. At the time, I used the Windows built-in \"nbtstat\" command.\nToday there is a Unix utility called \"nbtscan\" that provides similar info. If you do not wish to use an external tool, maybe there are NetBIOS libraries for python that could be used to gather the info for you?","Q_Score":6,"Tags":"python,linux,networking,mac-address","A_Id":2010975,"CreationDate":"2010-01-06T03:40:00.000","Title":"Get remote MAC address using Python and 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":1,"Web Development":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},{"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},{"Question":"i'm stress testing 2 different projects: one is proxsmtpd - smtp proxy written in C\nAnd the other one, smtp_proxy.py, which i developed under 1 hour, with use of asyncore and smtpd python modules.\nI stressed both projects under heavy load,\nand found out that proxsmtpd is able to hold 400 smtp sessions \/ sec,\nwhile my python program, is able to do only 160 smtp sessions \/sec.\nSo, my question is, does it because there are some performance limitations in asyncore,\nor C programs are just faster? Or maybe it's me, using asyncore in inefficient way?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":694,"Q_Id":2022211,"Users Score":2,"Answer":"I think it's a fair assumption that given a good C version and a good Python version, the C version will be faster and more scalable but in your case, you might want to run a profiler and see why and where your program is not scaling up as much as the C version. Perhaps you can uncover the tight spots and optimise it to squeeze some more performance out of your code. Also, I don't know much about asyncore but the first Python library people seem to gravitate towards when they want to do async stuff is twisted. So, perhaps there is a performance improvement there.","Q_Score":2,"Tags":"python,proxy,smtp,asyncore,smtpd","A_Id":2022273,"CreationDate":"2010-01-07T17:25:00.000","Title":"Python asyncore vs plain old 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":0,"Web Development":0},{"Question":"I'm trying to write a simple command line audio player using the Python Gstreamer bindings.\nIs there a function in the gstreamer API that determines in advance whether or not a particular file (URI) can be decoded and played by the currently installed set of codecs?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":208,"Q_Id":2025964,"Users Score":0,"Answer":"I guess you can try to play it and see if that raises any error - in fact, there's no way to know the set of codecs necessary without opening the file. Some distributions even have hooks in place that ask the user to download the right codec when you start playing something.","Q_Score":1,"Tags":"python,uri,decode,gstreamer,codec","A_Id":2026830,"CreationDate":"2010-01-08T06:49:00.000","Title":"How do you ask gstreamer if a file can be played?","Data Science and Machine Learning":0,"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},{"Question":"If you were looking to hire a web developer who would primarily be working with TurboGears\/Python - what sort of questions should you ask them?","AnswerCount":4,"Available Count":2,"Score":0.049958375,"is_accepted":false,"ViewCount":2484,"Q_Id":2034128,"Users Score":1,"Answer":"Don't quiz. Get some real (possibly broken) code from you vcs. Get them to tell you how they would fix it \/ add a feature.\nIf they can, ask them to bring some samples of previous work.","Q_Score":7,"Tags":"python,turbogears","A_Id":2035944,"CreationDate":"2010-01-09T17:07:00.000","Title":"Good interview questions for a Python\/TurboGears web developer?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"If you were looking to hire a web developer who would primarily be working with TurboGears\/Python - what sort of questions should you ask them?","AnswerCount":4,"Available Count":2,"Score":0.049958375,"is_accepted":false,"ViewCount":2484,"Q_Id":2034128,"Users Score":1,"Answer":"Ask him for:\n\nInstrospection\nModel-View-Control design\nDocumenting tools\n\nIf he know a lot about that, surely know a lot about other issues.","Q_Score":7,"Tags":"python,turbogears","A_Id":2034217,"CreationDate":"2010-01-09T17:07:00.000","Title":"Good interview questions for a Python\/TurboGears web developer?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"Is there any web-based IDE that I can use to run quick tests? There're a dozen for PHP and some for even Java but I haven't found yet that runs Python. If there's an open-source IDE available that I can host and run myself, that'd be better.\nThanks","AnswerCount":15,"Available Count":2,"Score":0.0266603475,"is_accepted":false,"ViewCount":30513,"Q_Id":2036987,"Users Score":2,"Answer":"Repl.it has a python interpreter and terminal among others. It may not be a full-fledged IDE. I'm not sure how you define that.","Q_Score":30,"Tags":"python,testing,ide","A_Id":10032718,"CreationDate":"2010-01-10T12:25:00.000","Title":"Online IDE 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},{"Question":"Is there any web-based IDE that I can use to run quick tests? There're a dozen for PHP and some for even Java but I haven't found yet that runs Python. If there's an open-source IDE available that I can host and run myself, that'd be better.\nThanks","AnswerCount":15,"Available Count":2,"Score":0.0133325433,"is_accepted":false,"ViewCount":30513,"Q_Id":2036987,"Users Score":1,"Answer":"I'm pretty sure that IDE's are the last kind of programs that will ever go web based, because a good IDE needs to be so extremely interactive if it wants to be good.\nI really don't see a reason for this and others seem to agree because there isn't any.\nAnd no, an interactive web shell or compiler has nothing to do with an IDE.","Q_Score":30,"Tags":"python,testing,ide","A_Id":2037081,"CreationDate":"2010-01-10T12:25:00.000","Title":"Online IDE 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},{"Question":"Often times I want to automate http queries. I currently use Java(and commons http client), but would probably prefer a scripting based approach. Something really quick and simple. Where I can set a header, go to a page and not worry about setting up the entire OO lifecycle, setting each header, calling up an html parser... I am looking for a solution in ANY language, preferable scripting","AnswerCount":12,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":4483,"Q_Id":2043058,"Users Score":0,"Answer":"What about using PHP+Curl, or just bash?","Q_Score":8,"Tags":"python,ruby,perl,http,scripting","A_Id":2043069,"CreationDate":"2010-01-11T16:15:00.000","Title":"Scripting HTTP more effeciently","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},{"Question":"I have a sign up process that is in a legacy framework and we are trying to switch to a new framework...in fact a different language. So let's say that there are 3 steps in the sign up process and each of those 3 steps has it's own file(step1.php, step2.php, step3.php).\nNow if I want to change page2.php to a python file I will still need the session information from page1.php. How can I transfer this information between the two pages while maintaining a valid session and obviously security.\nWe want to integrate this language switch in the same repository as the original one and doing releases of the new changes. So that's the agile part. (I'm still not sold that this is the best way to do it but I'm more curious)","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":575,"Q_Id":2045131,"Users Score":2,"Answer":"In PHP, store the session information in a database, encoded in JSON. In Python, pull the session ID from the cookie and look up the session information in the database.","Q_Score":2,"Tags":"php,python,session","A_Id":2045154,"CreationDate":"2010-01-11T21:36:00.000","Title":"Pass session information from php to python securely? (in agile)","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"How do I build up an atomic file write operation? The file is to be written by a Java service and read by python scripts.\nFor the record, reads are far greater than writes. But the write happens in batches and tend to be long. The file size amounts to mega bytes. \nRight now my approach is:\n\nWrite file contents to a temp file in\nsame directory\nDelete old file\nRename temp file to old filename.\n\nIs this the right approach? How can avoid conditions where the old file is deleted but the new filename is yet to be renamed? \nDo these programming languages (python and java) offer constructs to lock and avoid this situation?","AnswerCount":7,"Available Count":6,"Score":0.057080742,"is_accepted":false,"ViewCount":15100,"Q_Id":2049247,"Users Score":2,"Answer":"In Linux, Solaris, Unix this is easy. Just use rename() from your program or mv. The files need to be on the same filesystem.\nOn Windows, this is possible if you can control both programs. LockFileEx. For reads, open a shared lock on the lockfile. For writes, open an exclusive lock on the lockfile. Locking is weird in Windows, so I recommend using a separate lock file for this.","Q_Score":31,"Tags":"java,python,file,file-io","A_Id":4406823,"CreationDate":"2010-01-12T13:36:00.000","Title":"Atomic file write operations (cross 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":1,"Web Development":0},{"Question":"How do I build up an atomic file write operation? The file is to be written by a Java service and read by python scripts.\nFor the record, reads are far greater than writes. But the write happens in batches and tend to be long. The file size amounts to mega bytes. \nRight now my approach is:\n\nWrite file contents to a temp file in\nsame directory\nDelete old file\nRename temp file to old filename.\n\nIs this the right approach? How can avoid conditions where the old file is deleted but the new filename is yet to be renamed? \nDo these programming languages (python and java) offer constructs to lock and avoid this situation?","AnswerCount":7,"Available Count":6,"Score":1.2,"is_accepted":true,"ViewCount":15100,"Q_Id":2049247,"Users Score":13,"Answer":"AFAIK no. \nAnd the reason is that for such an atomic operation to be possible, there has to be OS support in the form of a transactional file system. And none of the mainstream operating system offer a transactional file system.\nEDIT - I'm wrong for POSIX-compliant systems at least. The POSIX rename syscall performs an atomic replace if a file with the target name already exists ... as pointed out by @janneb. That should be sufficient to do the OP's operation atomically.\nHowever, the fact remains that the Java File.renameTo() method is explicitly not guaranteed to be atomic, so it does not provide a cross-platform solution to the OP's problem.\nEDIT 2 - With Java 7 you can use java.nio.file.Files.move(Path source, Path target, CopyOption... options) with copyOptions and ATOMIC_MOVE. If this is not supported (by the OS \/ file system) you should get an exception.","Q_Score":31,"Tags":"java,python,file,file-io","A_Id":2049282,"CreationDate":"2010-01-12T13:36:00.000","Title":"Atomic file write operations (cross 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":1,"Web Development":0},{"Question":"How do I build up an atomic file write operation? The file is to be written by a Java service and read by python scripts.\nFor the record, reads are far greater than writes. But the write happens in batches and tend to be long. The file size amounts to mega bytes. \nRight now my approach is:\n\nWrite file contents to a temp file in\nsame directory\nDelete old file\nRename temp file to old filename.\n\nIs this the right approach? How can avoid conditions where the old file is deleted but the new filename is yet to be renamed? \nDo these programming languages (python and java) offer constructs to lock and avoid this situation?","AnswerCount":7,"Available Count":6,"Score":1.0,"is_accepted":false,"ViewCount":15100,"Q_Id":2049247,"Users Score":6,"Answer":"At least on POSIX platforms, leave out step 3 (delete old file). In POSIX, rename within a filesystem is guaranteed to be atomic, and renaming on top of an existing file replaces it atomically.","Q_Score":31,"Tags":"java,python,file,file-io","A_Id":2049334,"CreationDate":"2010-01-12T13:36:00.000","Title":"Atomic file write operations (cross 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":1,"Web Development":0},{"Question":"How do I build up an atomic file write operation? The file is to be written by a Java service and read by python scripts.\nFor the record, reads are far greater than writes. But the write happens in batches and tend to be long. The file size amounts to mega bytes. \nRight now my approach is:\n\nWrite file contents to a temp file in\nsame directory\nDelete old file\nRename temp file to old filename.\n\nIs this the right approach? How can avoid conditions where the old file is deleted but the new filename is yet to be renamed? \nDo these programming languages (python and java) offer constructs to lock and avoid this situation?","AnswerCount":7,"Available Count":6,"Score":0.0285636566,"is_accepted":false,"ViewCount":15100,"Q_Id":2049247,"Users Score":1,"Answer":"You could try and use an extra file to act as a lock, but I'm not sure if that will work out ok. (It would force you to create lock-checking and retry logic at both sides, java and python)\nAnother solution might be to not create files at all, maybe you could make your java process listen on a port and serve data from there rather than from a file?","Q_Score":31,"Tags":"java,python,file,file-io","A_Id":2049333,"CreationDate":"2010-01-12T13:36:00.000","Title":"Atomic file write operations (cross 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":1,"Web Development":0},{"Question":"How do I build up an atomic file write operation? The file is to be written by a Java service and read by python scripts.\nFor the record, reads are far greater than writes. But the write happens in batches and tend to be long. The file size amounts to mega bytes. \nRight now my approach is:\n\nWrite file contents to a temp file in\nsame directory\nDelete old file\nRename temp file to old filename.\n\nIs this the right approach? How can avoid conditions where the old file is deleted but the new filename is yet to be renamed? \nDo these programming languages (python and java) offer constructs to lock and avoid this situation?","AnswerCount":7,"Available Count":6,"Score":0.0855049882,"is_accepted":false,"ViewCount":15100,"Q_Id":2049247,"Users Score":3,"Answer":"It's a classic producer\/consumer problem. You should be able to solve this by using file renaming, which is atomic on POSIX systems.","Q_Score":31,"Tags":"java,python,file,file-io","A_Id":2049395,"CreationDate":"2010-01-12T13:36:00.000","Title":"Atomic file write operations (cross 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":1,"Web Development":0},{"Question":"How do I build up an atomic file write operation? The file is to be written by a Java service and read by python scripts.\nFor the record, reads are far greater than writes. But the write happens in batches and tend to be long. The file size amounts to mega bytes. \nRight now my approach is:\n\nWrite file contents to a temp file in\nsame directory\nDelete old file\nRename temp file to old filename.\n\nIs this the right approach? How can avoid conditions where the old file is deleted but the new filename is yet to be renamed? \nDo these programming languages (python and java) offer constructs to lock and avoid this situation?","AnswerCount":7,"Available Count":6,"Score":0.0285636566,"is_accepted":false,"ViewCount":15100,"Q_Id":2049247,"Users Score":1,"Answer":"Have the python scripts request permission from the service. While the service is writing it would place a lock on the file. If the lock exists, the service would reject the python request.","Q_Score":31,"Tags":"java,python,file,file-io","A_Id":2049386,"CreationDate":"2010-01-12T13:36:00.000","Title":"Atomic file write operations (cross 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":1,"Web Development":0},{"Question":"I'm writing a curses application in Python under UNIX. I want to enable the user to use C-Y to yank from a kill ring a la Emacs.\nThe trouble is, of course, that C-Y is caught by my shell which then sends SIGTSTP to my process. In addition, C-Z also results in SIGTSTP being sent, so catching the signal means that C-Y and C-Z are not distinguishable (though even without this the only solutions I can think of are extremely hackish).\nI know what I'm asking is possible (in C if not in Python), since Emacs does it. How can I disable the shell's special handling of certain control characters sent from the keyboard and have the characters in question appear on the process' stdin?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":543,"Q_Id":2054626,"Users Score":2,"Answer":"See the termios module, and the termios(3) man page.","Q_Score":3,"Tags":"python,unix,signals,curses","A_Id":2054648,"CreationDate":"2010-01-13T05:21:00.000","Title":"How to disable shell interception of control characters?","Data Science and Machine Learning":0,"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},{"Question":"Is it possible to distribute only the bytecode version (.pyc file) of a Python script instead of the original .py file? My app embeds the Python interpreter and calls PyImport_Import to load a script. How can I tell it to look for a .pyc file and import that?","AnswerCount":5,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":15521,"Q_Id":2055355,"Users Score":5,"Answer":"I did it by creating .py library and simple .py program that uses that library. Then I compiled library to .pyc and distributed: program as .py source and library as compiled .pyc.","Q_Score":10,"Tags":"python,c,compilation,bytecode","A_Id":2055381,"CreationDate":"2010-01-13T08:30:00.000","Title":"How to protect Python source 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},{"Question":"Is it possible to distribute only the bytecode version (.pyc file) of a Python script instead of the original .py file? My app embeds the Python interpreter and calls PyImport_Import to load a script. How can I tell it to look for a .pyc file and import that?","AnswerCount":5,"Available Count":2,"Score":0.1973753202,"is_accepted":false,"ViewCount":15521,"Q_Id":2055355,"Users Score":5,"Answer":"Since you are writing your main program in C++, you can do whatever you want to protect your Python files. You could encrypt them for distribution, then decrypt them just in time to import them into the Python interpreter, for example.\nSince you are using PyImport_Import, you can write your own __import__ hook to import the modules not from a file but from a memory buffer, so your transformation to .pyc file can happen all in memory, with no understandable Python code on disk at all.","Q_Score":10,"Tags":"python,c,compilation,bytecode","A_Id":2056647,"CreationDate":"2010-01-13T08:30:00.000","Title":"How to protect Python source 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},{"Question":"I'm new to Java, and I'd like to create some class variables that are dynamically calculated when accessed, as you can do in Python by using the property() method. However, I'm not really sure how to describe this, so Googling shows me lots about the Java \"Property\" class, but this doesn't appear to be the same thing. What is the Java equivalent of Python's property()?","AnswerCount":6,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":3624,"Q_Id":2056752,"Users Score":0,"Answer":"Do you want to create new fields\/getters\/setters in the class? If you want to do this in runtime, you have to create completely new class with your fields and methods, and load it into the JVM. To create new class you can use library like ASM or CGLib, but if you're new to Java, this isn't something you want to start with.","Q_Score":10,"Tags":"java,python,properties","A_Id":2056762,"CreationDate":"2010-01-13T13:03:00.000","Title":"What is the Java Equivalent of Python's property()?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I'm new to Java, and I'd like to create some class variables that are dynamically calculated when accessed, as you can do in Python by using the property() method. However, I'm not really sure how to describe this, so Googling shows me lots about the Java \"Property\" class, but this doesn't appear to be the same thing. What is the Java equivalent of Python's property()?","AnswerCount":6,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":3624,"Q_Id":2056752,"Users Score":2,"Answer":"They don't really exist. In Java it's common practice to declare members as private or protected and only allow access to them via methods. Often this leads to lots of small getFoo() and setFoo(newFoo) methods. Python doesn't really have private and protected and it's more common to allow direct access to members.","Q_Score":10,"Tags":"java,python,properties","A_Id":2056814,"CreationDate":"2010-01-13T13:03:00.000","Title":"What is the Java Equivalent of Python's property()?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I am purely a windows programmer and spend all my time hacking VC++. \nRecently I have been heading several web based applications and myself built applications with python (\/pylons framework) and doing projects on rails. All the web projects are hosted on ubuntu linux.\nThe RELEASE procedures and check list we followed for building and releasing VC++ windows application are merely no more useful when it comes to script based language.\nSo we don't built any binaries now. I copied asp\/php files into IIS folder through ftp server when using open source cms applications.\nSo FTP is the one of the way to host the files to the web server. Now we feel lazy or not so passionate to copy files via ftp instead we use the SVN checkout and we simply do svn update to get the latest copy.\nIs SVN checkout and svn update are the right methods to update the latest build files into the server? Are there any downside in using svn update? Any better method to release the script\/web based scripts into the production server? \nPS: I have used ssh server at some extension on linux platform.","AnswerCount":4,"Available Count":3,"Score":1.2,"is_accepted":true,"ViewCount":242,"Q_Id":2059337,"Users Score":3,"Answer":"I would create a branch in SVN for every release of web application and when the release is ready there, I would check it out on the server and set to be run or move it into the place of the old version.","Q_Score":1,"Tags":"python,ruby,linux,scripting,release","A_Id":2059364,"CreationDate":"2010-01-13T18:52:00.000","Title":"Practices while releasing the python\/ruby\/script based web applications on 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":1,"Web Development":1},{"Question":"I am purely a windows programmer and spend all my time hacking VC++. \nRecently I have been heading several web based applications and myself built applications with python (\/pylons framework) and doing projects on rails. All the web projects are hosted on ubuntu linux.\nThe RELEASE procedures and check list we followed for building and releasing VC++ windows application are merely no more useful when it comes to script based language.\nSo we don't built any binaries now. I copied asp\/php files into IIS folder through ftp server when using open source cms applications.\nSo FTP is the one of the way to host the files to the web server. Now we feel lazy or not so passionate to copy files via ftp instead we use the SVN checkout and we simply do svn update to get the latest copy.\nIs SVN checkout and svn update are the right methods to update the latest build files into the server? Are there any downside in using svn update? Any better method to release the script\/web based scripts into the production server? \nPS: I have used ssh server at some extension on linux platform.","AnswerCount":4,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":242,"Q_Id":2059337,"Users Score":0,"Answer":"One downside of doing an svn update: though you can go back in time, to what revision do you go back to? You have to look it up. svn update pseudo-deployments work much cleaner if you use tags - in that case you'd be doing an svn switch to a different tag, not an svn update on the same branch or the trunk.\nYou want to tag your software with the version number something like 1.1.4 , and then have a simple script to zip it up application-1.1.4,zip, and deploy it - then you have automated repeatable releases and rollbacks as well as greater visibility into what is changing between releases.","Q_Score":1,"Tags":"python,ruby,linux,scripting,release","A_Id":4454448,"CreationDate":"2010-01-13T18:52:00.000","Title":"Practices while releasing the python\/ruby\/script based web applications on 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":1,"Web Development":1},{"Question":"I am purely a windows programmer and spend all my time hacking VC++. \nRecently I have been heading several web based applications and myself built applications with python (\/pylons framework) and doing projects on rails. All the web projects are hosted on ubuntu linux.\nThe RELEASE procedures and check list we followed for building and releasing VC++ windows application are merely no more useful when it comes to script based language.\nSo we don't built any binaries now. I copied asp\/php files into IIS folder through ftp server when using open source cms applications.\nSo FTP is the one of the way to host the files to the web server. Now we feel lazy or not so passionate to copy files via ftp instead we use the SVN checkout and we simply do svn update to get the latest copy.\nIs SVN checkout and svn update are the right methods to update the latest build files into the server? Are there any downside in using svn update? Any better method to release the script\/web based scripts into the production server? \nPS: I have used ssh server at some extension on linux platform.","AnswerCount":4,"Available Count":3,"Score":0.0996679946,"is_accepted":false,"ViewCount":242,"Q_Id":2059337,"Users Score":2,"Answer":"Is SVN checkout and svn update are the right methods to update the latest build files into the server? \nVery, very good methods. You know what you got. You can go backwards at any time.\nAre there any downside in using svn update? None.\nAny better method to release the script\/web based scripts into the production server?\nWhat we do.\nWe do not run out of the SVN checkout directories. The SVN checkout directory is \"raw\" source sitting on the server.\nWe use Python's setup.py install to create the application in \/opt\/app\/app-x.y directory tree. Each tagged SVN branch is also a branch in the final installation.\nRuby has gems and other installation tools that are probably similar to Python's.\nOur web site's Apache and mod_wsgi configurations refer to a specific \/opt\/app\/app-x.y version. We can then stage a version, do testing, do things like migrate data from production to the next release, and generally get ready.\nThen we adjust our Apache and mod_wsgi configuration to use the next version. \nPrevious versions are all in place. And left in place. We'll delete them some day when they confuse us.","Q_Score":1,"Tags":"python,ruby,linux,scripting,release","A_Id":2059406,"CreationDate":"2010-01-13T18:52:00.000","Title":"Practices while releasing the python\/ruby\/script based web applications on 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":1,"Web Development":1},{"Question":"How can individual unit tests be temporarily disabled when using the unittest module in Python?","AnswerCount":7,"Available Count":2,"Score":1.0,"is_accepted":false,"ViewCount":78791,"Q_Id":2066508,"Users Score":15,"Answer":"Simply placing @unittest.SkipTest decorator above the test is enough.","Q_Score":159,"Tags":"python,python-unittest","A_Id":42430138,"CreationDate":"2010-01-14T18:26:00.000","Title":"Disable individual Python unit tests temporarily","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"How can individual unit tests be temporarily disabled when using the unittest module in Python?","AnswerCount":7,"Available Count":2,"Score":0.1418931938,"is_accepted":false,"ViewCount":78791,"Q_Id":2066508,"Users Score":5,"Answer":"I just rename a test case method with an underscore: test_myfunc becomes _test_myfunc.","Q_Score":159,"Tags":"python,python-unittest","A_Id":2066777,"CreationDate":"2010-01-14T18:26:00.000","Title":"Disable individual Python unit tests temporarily","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"What is the most efficient method to store a Python dictionary on the disk? The only methods I know of right now are plain-text and the pickle module.\nEdit: Sorry for not being very clear. By efficient I meant fastest execution speed. The dictionary will contain mutable objects that will hold information to be parsed and modified.","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":5666,"Q_Id":2067749,"Users Score":2,"Answer":"JSON and YAML work well, also. \nDepends on what you mean by \"efficient\"? Size of file? Time required? Amount of code you need to write?\nYou have the timeit module available to determine what meets your specific criteria for \"efficient\".","Q_Score":5,"Tags":"python,dictionary,disk,pickle","A_Id":2068000,"CreationDate":"2010-01-14T21:35:00.000","Title":"Efficient method to store Python dictionary on disk?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"So I'm aware of the big ammount of general-purpose scripting languages like Ruby, Python, Perl, maybe even PHP, etc. that actually claim being usable for creating desktop applications too.\nI think my question can be answered clearly\n\nAre there actually companies using a special scripting language only to create their applications?\nAre there any real advantages on creating a product in a language like Python only?\nI'm not talking about the viability of those languages for web-development!\nShould I stick with C(++) for desktop apps?\n\nbest regards,\nlamas","AnswerCount":7,"Available Count":4,"Score":1.2,"is_accepted":true,"ViewCount":464,"Q_Id":2067907,"Users Score":3,"Answer":"Python (combined with PyQt) is a very solid combination for GUI desktop applications (note that while QT is LGPL, PyQt (the Python bindings) is dual licensed: GPL or commercial).\nIt offers the same (GUI library-wise) as Qt on C++ but with Python's specific strenghts. I'll list some of the more obvious ones:\n\nrapid prototyping\nextremely readable (hence maintainable) code\n\nShould I stick with C(++) for desktop apps? \nIn general: no, unless you want to \/ need to (for a specific reason).","Q_Score":3,"Tags":"python,ruby,perl,scripting","A_Id":2067929,"CreationDate":"2010-01-14T22:03:00.000","Title":"\"Real\" and non-embedded use of Ruby, Python and their friends","Data Science and Machine Learning":0,"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},{"Question":"So I'm aware of the big ammount of general-purpose scripting languages like Ruby, Python, Perl, maybe even PHP, etc. that actually claim being usable for creating desktop applications too.\nI think my question can be answered clearly\n\nAre there actually companies using a special scripting language only to create their applications?\nAre there any real advantages on creating a product in a language like Python only?\nI'm not talking about the viability of those languages for web-development!\nShould I stick with C(++) for desktop apps?\n\nbest regards,\nlamas","AnswerCount":7,"Available Count":4,"Score":1.0,"is_accepted":false,"ViewCount":464,"Q_Id":2067907,"Users Score":6,"Answer":"The company I work for uses Perl and Tk with PerlApp to build executable packages to produce or major software application.\nPerl beats C and C++ for simplicity of code. You can do things in one line of Perl that take 20 lines of C.\nWe've used WxPerl for a few smaller projects. We'd like to move fully to WxPerl, but existing code works, so the move has a low priority until Wx can give us something we need that Tk can't.\nPython is popular for building GUI apps, too. You may have heard about Chandler. That's a big Python app. There are many others as well.\nRuby is also a suitable choice.\nPHP is breaking into the world of command line apps. I am not sure about the power or flexibility of its GUI toolkits.","Q_Score":3,"Tags":"python,ruby,perl,scripting","A_Id":2068161,"CreationDate":"2010-01-14T22:03:00.000","Title":"\"Real\" and non-embedded use of Ruby, Python and their friends","Data Science and Machine Learning":0,"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},{"Question":"So I'm aware of the big ammount of general-purpose scripting languages like Ruby, Python, Perl, maybe even PHP, etc. that actually claim being usable for creating desktop applications too.\nI think my question can be answered clearly\n\nAre there actually companies using a special scripting language only to create their applications?\nAre there any real advantages on creating a product in a language like Python only?\nI'm not talking about the viability of those languages for web-development!\nShould I stick with C(++) for desktop apps?\n\nbest regards,\nlamas","AnswerCount":7,"Available Count":4,"Score":0.057080742,"is_accepted":false,"ViewCount":464,"Q_Id":2067907,"Users Score":2,"Answer":"I would recommend you not try to look for a language that is best for GUI apps but instead look for the language that you like the most and then use that to write your app.\nRuby, Python, Perl all have GUI tool kits available to them. Most of them have access to the same often used tool kits like TK, GTK, and Wx. The look and feel of a an app will be dependent more on the GUI tool kit than on the language, and performance wise your likely to see more impact for how you write your app than language choice.\nIf your comfortable with C++ then you should also look at C# or Java as options. While not scripting languages they have many of the same benefits like memory management and more sane string implementations.","Q_Score":3,"Tags":"python,ruby,perl,scripting","A_Id":2072473,"CreationDate":"2010-01-14T22:03:00.000","Title":"\"Real\" and non-embedded use of Ruby, Python and their friends","Data Science and Machine Learning":0,"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},{"Question":"So I'm aware of the big ammount of general-purpose scripting languages like Ruby, Python, Perl, maybe even PHP, etc. that actually claim being usable for creating desktop applications too.\nI think my question can be answered clearly\n\nAre there actually companies using a special scripting language only to create their applications?\nAre there any real advantages on creating a product in a language like Python only?\nI'm not talking about the viability of those languages for web-development!\nShould I stick with C(++) for desktop apps?\n\nbest regards,\nlamas","AnswerCount":7,"Available Count":4,"Score":0.0285636566,"is_accepted":false,"ViewCount":464,"Q_Id":2067907,"Users Score":1,"Answer":"I have used a number of programs that were developed using scripted languages. Several embedded device vendors ship my group Windows-based configuration and debugging utilities written in TCL. Google's drawing program SketchUp has a lot of Ruby inside it (and users can create add-ons using Ruby). I have seen many Linux applications written in Python. There are many more examples out there, but often times finished applications are bundled up to the point where you can't really tell what's powering it on the inside.\nYes, there can be advantages to working with scripted languages. Some scripted languages make it easier to do specific tasks; for example, text processing is much easier (IMO) in a language like Ruby that has regular expression support and a robust String class than it is in plain old C. Generating a UI using a scripted language may make it easier to support multiple platforms, as all the platform-specific code is taken care of inside the language interpreter or pre-compiled libraries. For example, our suppliers who build TCL-based apps claim they can build the UI for an app using TCL in a fraction of the time it would take them to build it in C++ or VB, and then they can port it to Linux almost effortlessly.\nOn the other hand there are a few things that scripted languages typically aren't suited for, such as writing drivers or doing anything that requires low-level hardware access.\nMost importantly, however, is this: modern languages have become quite powerful to the point where choice of language doesn't make as big of a difference as it used to be. Use the language you are most comfortable with. The learning curve associated with learning a new language will usually have a much larger impact on your project.","Q_Score":3,"Tags":"python,ruby,perl,scripting","A_Id":2068564,"CreationDate":"2010-01-14T22:03:00.000","Title":"\"Real\" and non-embedded use of Ruby, Python and their friends","Data Science and Machine Learning":0,"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},{"Question":"There're tons of apps\/widgets for PHP function reference and even for Ruby but I'm shocked to find there is nothing available for a popular language like Python (besides the official online documentation ofcourse). \nIs there really not a single handy reference widget\/app available for Python? I have 'Pocket Reference' book, but a dashboard widget would be so handy!","AnswerCount":4,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":657,"Q_Id":2068486,"Users Score":1,"Answer":"Python libraries have (or should have) built in documentation through docstrings. Also, python code is (mostly) very readable, and reading the source (.py or even .c) is actually the preferred way for many developers to get the information they're looking for, especially since some corner cases may not even be documented.\nI've caught myself looking through the source now and then, as if it's a natural step in looking up functionality, either because I'm curious how they solve the problem, or because I reckon it's faster than googling obscure problems and reading SO questions.","Q_Score":3,"Tags":"python,macos,documentation,reference,widget","A_Id":2068830,"CreationDate":"2010-01-15T00:06:00.000","Title":"Python Function Reference","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"There're tons of apps\/widgets for PHP function reference and even for Ruby but I'm shocked to find there is nothing available for a popular language like Python (besides the official online documentation ofcourse). \nIs there really not a single handy reference widget\/app available for Python? I have 'Pocket Reference' book, but a dashboard widget would be so handy!","AnswerCount":4,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":657,"Q_Id":2068486,"Users Score":0,"Answer":"The interactive interpreter is a fantastic reference tool. dir() gives you help about same.\npydoc at the command line is another great tool. It does for Python what man gives you for commands, plus it even includes a web server you can start up to see the documentation in your browser.","Q_Score":3,"Tags":"python,macos,documentation,reference,widget","A_Id":2069084,"CreationDate":"2010-01-15T00:06:00.000","Title":"Python Function Reference","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a third-party Python script (foo.py) in a folder that is in my system path (but not the Python sys.path). foo.py is not part of any Python module.\nI am writing another script (bar.py) in which I'd like to call a function located in foo.py. Is this possible? Can it be done without explicitly naming the folder of foo.py?\nThanks.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":197,"Q_Id":2074071,"Users Score":2,"Answer":"You can include the path of foo.py in the PYTHONPATH environment variable. The interpreter will look also the directories contained there, so you can make the import just like it was on the same directory.","Q_Score":0,"Tags":"python,import","A_Id":2074086,"CreationDate":"2010-01-15T19:07:00.000","Title":"Use function from Python script in OS 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":1,"System Administration and DevOps":0,"Web Development":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},{"Question":"How can we export C# methods?\nI have a dll and I want to use its methods in the Python language with the ctypes module.\nBecause I need to use the ctypes module, I need to export the C# methods for them to be visible in Python.\nSo, how can I export the C# methods (like they do in C++)?","AnswerCount":4,"Available Count":1,"Score":0.049958375,"is_accepted":false,"ViewCount":8012,"Q_Id":2082159,"Users Score":1,"Answer":"(This may no longer be relevant since SLaks has found that ingenious link, but I'll leave an edited version for reference...)\nThe \"normal\" way of exposing .NET\/C# objects to unmanaged code (like Python) is to create a COM-callable wrapper for the C# DLL (.NET assembly), and call that using Python's COM\/OLE support. To create the COM-callable wrapper, use the tlbexp and\/or regasm command-line utilities.\nObviously, however, this does not provide the C\/DLL-style API that SLaks' link does.","Q_Score":15,"Tags":"c#,python,methods,export,python.net","A_Id":2082198,"CreationDate":"2010-01-17T18:49:00.000","Title":"How to export C# methods?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Does any standard \"comes with batteries\" method exist to clear the terminal screen from a Python script, or do I have to go curses (the libraries, not the words)?","AnswerCount":27,"Available Count":4,"Score":0.0148137311,"is_accepted":false,"ViewCount":516293,"Q_Id":2084508,"Users Score":2,"Answer":"You could tear through the terminfo database, but the functions for doing so are in curses anyway.","Q_Score":241,"Tags":"python,terminal","A_Id":2084517,"CreationDate":"2010-01-18T07:34:00.000","Title":"Clear 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},{"Question":"Does any standard \"comes with batteries\" method exist to clear the terminal screen from a Python script, or do I have to go curses (the libraries, not the words)?","AnswerCount":27,"Available Count":4,"Score":0.0,"is_accepted":false,"ViewCount":516293,"Q_Id":2084508,"Users Score":0,"Answer":"If all you need is to clear the screen, this is probably good enough. The problem is there's not even a 100% cross platform way of doing this across linux versions. The problem is the implementations of the terminal all support slightly different things. I'm fairly sure that \"clear\" will work everywhere. But the more \"complete\" answer is to use the xterm control characters to move the cursor, but that requires xterm in and of itself.\nWithout knowing more of your problem, your solution seems good enough.","Q_Score":241,"Tags":"python,terminal","A_Id":4808001,"CreationDate":"2010-01-18T07:34:00.000","Title":"Clear 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},{"Question":"Does any standard \"comes with batteries\" method exist to clear the terminal screen from a Python script, or do I have to go curses (the libraries, not the words)?","AnswerCount":27,"Available Count":4,"Score":0.0148137311,"is_accepted":false,"ViewCount":516293,"Q_Id":2084508,"Users Score":2,"Answer":"python -c \"from os import system; system('clear')\"","Q_Score":241,"Tags":"python,terminal","A_Id":2084525,"CreationDate":"2010-01-18T07:34:00.000","Title":"Clear 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},{"Question":"Does any standard \"comes with batteries\" method exist to clear the terminal screen from a Python script, or do I have to go curses (the libraries, not the words)?","AnswerCount":27,"Available Count":4,"Score":1.0,"is_accepted":false,"ViewCount":516293,"Q_Id":2084508,"Users Score":108,"Answer":"Why hasn't anyone talked about just simply doing Ctrl+L in Windows or Cmd+L in Mac.\nSurely the simplest way of clearing screen.","Q_Score":241,"Tags":"python,terminal","A_Id":26639250,"CreationDate":"2010-01-18T07:34:00.000","Title":"Clear 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},{"Question":"I have a set of binary assets (swf files) each about 150Kb in size. I am developing them locally on my home computer and I want to periodically deploy them for review. My current strategy is:\n\nCopy the .swf's into a transfer directory that is also a hg (mercurial) repo.\nhg push the changes to my slicehost VPN\nssh onto my slicehost VPN\n\n\ncd to my transfer directory and hg up\nsu www and cp the changed files into my public folder for viewing.\n\n\nI would like to automate the process. Best case scenario is something close to:\n\nCopy the .swf's into a \"quick deploy\" directory\nRun a single local script to do all of the above.\n\nI am interested in:\n\nadvice on where to put passwords since I need to su www to transfer files into the public web directories. \nhow the division of responsibility between local machine and server is handled.\n\nI think using rsync is a better tool than hg since I don't really need a revision history of these types of changes. I can write this as a python script, a shell script or however is considered a best practice. \nEventually I would like to build this into a system that can handle my modest deployment needs. Perhaps there is an open-source deployment system that handles this and other types of situations? I'll probably roll-my-own for this current need but long term I'd like something relatively flexible.\nNote: My home development computer is OS X and the target server is some recent flavour of Ubuntu. I'd prefer a python based solution but if this is best handled from the shell I have no problems putting it together that way.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":349,"Q_Id":2084969,"Users Score":1,"Answer":"to avoid su www I see two easy choices.\n\nmake a folder writable to you and readable by www's group in some path that the web-server will be able to serve, then you can rsync to that folder from somewhere on your local machine.\nput your public ssh key in www's authorized_keys and rsync to the www user (a bit less security in some setups perhaps, but not much, and usually more convenient).\n\nworking around su www by putting your or its password in some file would seem far less secure.\nA script to invoke \"rsync -avz --partial \/some\/path www@server:some\/other\/path\" should be quick to write in python (although I do not python well).","Q_Score":0,"Tags":"python,macos,deployment,ubuntu,rsync","A_Id":2085042,"CreationDate":"2010-01-18T09:25:00.000","Title":"How to deploy highly iterative updates","Data Science and Machine Learning":0,"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},{"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},{"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},{"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},{"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},{"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},{"Question":"I've encountered the following error while scripting in Python.\nERROR Tue 19. Jan 14:51:21 2010 C:\\Python24\\Lib\\site-packages\\win32com\\client\\util.py:0: Script Error\ncom_error: (-2147217385, 'OLE error 0x80041017', None, None)\nUnfortunately, I don't know what it means, or even what other information I might need to find out. Does anyone have any insight into this?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1265,"Q_Id":2090950,"Users Score":0,"Answer":"When doing python COM programming, I sometimes use VBA (in Excel) to test code that gives errors.\nThat way, I can see if the problem is in the Python-COM layer, or if I get the same error when using VBA. I have sometimes seen that the error messages in VBA have descriptions that the Python exception lacks.\nVBA is quite nice for doing COM programming. You have tab completion\/intellisense in the editor.","Q_Score":1,"Tags":"python,com","A_Id":2091963,"CreationDate":"2010-01-19T03:56:00.000","Title":"unidentified com_error 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},{"Question":"I have installed Py-Appscript on my machine and it can be used with the Python installation at \/Library\/Frameworks\/Python.framework\/Versions\/Current\/bin\/python.\nI am trying to use this installation of Py-Appscript with an Automator service. To do this, I use the Run Shell Script action and then set the Shell to usr\/bin\/python (which is my only choice for Python, unfortunately).\nThe usr\/bin\/python does not appear to have access to my third-party modules and crashes on the line:\nfrom appscript import *\nIs there a way for me to give usr\/bin\/python access to my third-party modules?\nOR\nIs there a way to tell Automator to use \/Library\/Frameworks\/Python.framework\/Versions\/Current\/bin\/python instead?\nI need Automator to run the Python directly from the Run Shell Script action. Any action that calls Python scripts that are external to Automator (via bin\/bash, for example) does not perform quickly enough to be useful.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2403,"Q_Id":2093837,"Users Score":0,"Answer":"When you install modules, you typically install them per Python instance. So in this case you have installed them for the Python in \/Library\/Frameworks\/Python.framework\/Versions\/Current\/bin\/python, and it will then be available only for that Python. \/usr\/bin\/python is then apparently another Python installation (I'm not an OS X expert).\nTo make it available for the \/usr\/bin\/python installation, install it for \/usr\/bin\/python.","Q_Score":2,"Tags":"python,automator","A_Id":2094638,"CreationDate":"2010-01-19T13:40:00.000","Title":"Using Third-Party Modules with Python in an Automator Service","Data Science and Machine Learning":0,"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},{"Question":"In a game that I am writing, I use a 2D vector class which I have written to handle the speeds of the objects. This is called a large number of times every frame as there are a lot of objects on the screen, so any increase I can make in its speed will be useful.\nIt is pretty simple, consisting mostly of wrappers to the related math functions. It would be quite trivial to rewrite in C, but I am not sure whether doing so will make any significant difference as all it really does is call the underlying math functions, add, multiply or divide.\nSo, my question is under what circumstances does it make sense to rewrite in C? Where will you see a significant speed boost, and where can you see a reasonable speed boost without rewriting an extensive amount of the program?","AnswerCount":5,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":429,"Q_Id":2096334,"Users Score":9,"Answer":"First measure then optimize","Q_Score":4,"Tags":"python,c,optimization","A_Id":2096358,"CreationDate":"2010-01-19T19:19:00.000","Title":"When Does It Make Sense To Rewrite A Python Module 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},{"Question":"I'm making an application that analyses one or more series of data using several different algorithms (agents). I came to the idea that each of these agents could be implemented as separate Python scripts which I run using either the Python C API or Boost.Python in my app.\nI'm a little worried about runtime overhead TBH, as I'm doing some pretty heavy duty data processing and I don't want to have to wait several minutes for each simulation. I will typically be making hundreds of thousands, if not millions, of iterations in which I invoke the external \"agents\"; am I better of just hardcoding everything in the app, or will the performance drop be tolerable? \nAlso, are there any other interpreted languages I can use other than Python?","AnswerCount":7,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":2474,"Q_Id":2103728,"Users Score":0,"Answer":"you could probably create an embedded language using C++ templates and operator overloading, see for example ublas or ftensor matrix languages. i do not think python or other interpreted languages of is suitable for having numbercrunching\/data processing.","Q_Score":7,"Tags":"c++,python,perl,performance,lua","A_Id":2103784,"CreationDate":"2010-01-20T18:04:00.000","Title":"Selecting An Embedded Language","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},{"Question":"I'm making an application that analyses one or more series of data using several different algorithms (agents). I came to the idea that each of these agents could be implemented as separate Python scripts which I run using either the Python C API or Boost.Python in my app.\nI'm a little worried about runtime overhead TBH, as I'm doing some pretty heavy duty data processing and I don't want to have to wait several minutes for each simulation. I will typically be making hundreds of thousands, if not millions, of iterations in which I invoke the external \"agents\"; am I better of just hardcoding everything in the app, or will the performance drop be tolerable? \nAlso, are there any other interpreted languages I can use other than Python?","AnswerCount":7,"Available Count":3,"Score":0.0285636566,"is_accepted":false,"ViewCount":2474,"Q_Id":2103728,"Users Score":1,"Answer":"For millions of calls (from I'm assuming c++, because you mentioned boost) into python, yes: you will notice a performance hit. This may or may not be significant - perhaps the speed gain of trying out new 'agents' would be greater than the hit. Python does have fast numerical libraries (such as numpy) that might help, but you'll still incur overhead of marshalling data, calling into python, the gil, etc.\nYes, you can embed many other languages: check out lua. Also, check out swig.org, which can connect to many other languages besides python.","Q_Score":7,"Tags":"c++,python,perl,performance,lua","A_Id":2103831,"CreationDate":"2010-01-20T18:04:00.000","Title":"Selecting An Embedded Language","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},{"Question":"I'm making an application that analyses one or more series of data using several different algorithms (agents). I came to the idea that each of these agents could be implemented as separate Python scripts which I run using either the Python C API or Boost.Python in my app.\nI'm a little worried about runtime overhead TBH, as I'm doing some pretty heavy duty data processing and I don't want to have to wait several minutes for each simulation. I will typically be making hundreds of thousands, if not millions, of iterations in which I invoke the external \"agents\"; am I better of just hardcoding everything in the app, or will the performance drop be tolerable? \nAlso, are there any other interpreted languages I can use other than Python?","AnswerCount":7,"Available Count":3,"Score":0.1418931938,"is_accepted":false,"ViewCount":2474,"Q_Id":2103728,"Users Score":5,"Answer":"Tcl was designed from the ground up to be an embedded language.","Q_Score":7,"Tags":"c++,python,perl,performance,lua","A_Id":2104152,"CreationDate":"2010-01-20T18:04:00.000","Title":"Selecting An Embedded Language","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},{"Question":"I'm writing an application working with plugins. There are two types of plugins: Engine and Model. Engine objects have an update() method that call the Model.velocity() method.\nFor performance reasons these methods are allowed to be written in C. This means that sometimes they will be written in Python and sometimes written in C.\nThe problem is that this forces to do an expensive Python function call of Model.velocity() in Engine.update() (and also reacquiring the GIL). I thought about adding something like Model.get_velocity_c_func() to the API, that would allow Model implementations to return a pointer to the C version of their velocity() method if available, making possible for Engine to do a faster C function call.\nWhat data type should I use to pass the function pointer ? And is this a good design at all, maybe there is an easier way ?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":366,"Q_Id":2106324,"Users Score":1,"Answer":"The CObject (PyCOBject) data type exists for this purpose. It holds a void*, but you can store any data you wish. You do have to be careful not to pass the wrong CObject to the wrong functions, as some other library's CObjects will look just like your own.\nIf you want more type security, you could easily roll your own PyType for this; all it has to do, after all, is contain a pointer of the right type.","Q_Score":0,"Tags":"python,c,function-pointers","A_Id":2106391,"CreationDate":"2010-01-21T01:29:00.000","Title":"Passing C function pointers between two python modules","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},{"Question":"I have a string that I would like to encrypt in Python, store it as a cookie, then in a PHP file I'd like to retrieve that cookie, and decrypt it in PHP. How would I go about doing this?\n\nI appreciate the fast responses.\nAll cookie talk aside, lets just say I want to encrypt a string in Python and then decrypt a string in PHP.\nAre there any examples you can point me to?","AnswerCount":5,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":7880,"Q_Id":2112274,"Users Score":0,"Answer":"Well, my first thought would be to use a web server that uses SSL and set the cookie's secure property to true, meaning that it will only be served over SSL connections.\nHowever, I'm aware that this probably isn't what you're looking for.","Q_Score":4,"Tags":"php,python","A_Id":2112306,"CreationDate":"2010-01-21T19:38:00.000","Title":"How to encrypt a string in Python and decrypt that same string 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":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a string that I would like to encrypt in Python, store it as a cookie, then in a PHP file I'd like to retrieve that cookie, and decrypt it in PHP. How would I go about doing this?\n\nI appreciate the fast responses.\nAll cookie talk aside, lets just say I want to encrypt a string in Python and then decrypt a string in PHP.\nAre there any examples you can point me to?","AnswerCount":5,"Available Count":2,"Score":0.0399786803,"is_accepted":false,"ViewCount":7880,"Q_Id":2112274,"Users Score":1,"Answer":"If you're not talking about encryption but encoding to make sure the contents make it through safely regardless of quoting issues, special characters, and line breaks, I think base64 encoding is your best bet. PHP has base64_encode \/ decode() out of the box, and I'm sure Python has, too.\nNote that base64 encoding obviously does nothing to encrypt your data (i.e. to make it unreadable to outsiders), and base64 encoded data grows by 33%.","Q_Score":4,"Tags":"php,python","A_Id":2112331,"CreationDate":"2010-01-21T19:38:00.000","Title":"How to encrypt a string in Python and decrypt that same string 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":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm a PhD student and use Python to write the code I use for my research. My workflow often consists of making a small change to the code, running the program, seeing whether the results improved, and repeating the process. Because of this, I find myself spending more time waiting for my program to run than I do actually working on it (a common experience, I know). I'm currently using the most recent version of Python 2 on my system, so my question is whether switching to Python 3 is going to give me any speed boost or not. At this point, I don't really have a compelling reason to move to Python 3, so if the execution speeds are similar, I'll probably just stick with 2.x. I know I'm going to have to modify my code a bit to get it working in Python 3, so it's not trivial to just test it on both versions to see which runs faster. I'd need to be reasonably confident I will get a speed improvement before I spend the time updating my code to Python 3.","AnswerCount":5,"Available Count":3,"Score":0.1194272985,"is_accepted":false,"ViewCount":14827,"Q_Id":2112298,"Users Score":3,"Answer":"Try refining the algorithms or changing the data structures used. That's usually the best way to get an increase in performance.","Q_Score":35,"Tags":"python,performance","A_Id":2115650,"CreationDate":"2010-01-21T19:43:00.000","Title":"Python 2.x vs 3.x Speed","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm a PhD student and use Python to write the code I use for my research. My workflow often consists of making a small change to the code, running the program, seeing whether the results improved, and repeating the process. Because of this, I find myself spending more time waiting for my program to run than I do actually working on it (a common experience, I know). I'm currently using the most recent version of Python 2 on my system, so my question is whether switching to Python 3 is going to give me any speed boost or not. At this point, I don't really have a compelling reason to move to Python 3, so if the execution speeds are similar, I'll probably just stick with 2.x. I know I'm going to have to modify my code a bit to get it working in Python 3, so it's not trivial to just test it on both versions to see which runs faster. I'd need to be reasonably confident I will get a speed improvement before I spend the time updating my code to Python 3.","AnswerCount":5,"Available Count":3,"Score":0.0798297691,"is_accepted":false,"ViewCount":14827,"Q_Id":2112298,"Users Score":2,"Answer":"I have phylogenetics analysis that takes a long time to run, and uses about a half-dozen python scripts as well as other bioinformatics software (muscle, clustal, blast, even R!). I use temp files to save intermediate results and a master script with the subprocess module to glue all the pieces together. It's easy to change the master to run only the modified parts that I want to test. But, if the changes are being made to early steps, and you only know how good it is at the end of the whole process, then this strategy wouldn't help much.","Q_Score":35,"Tags":"python,performance","A_Id":2112852,"CreationDate":"2010-01-21T19:43:00.000","Title":"Python 2.x vs 3.x Speed","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm a PhD student and use Python to write the code I use for my research. My workflow often consists of making a small change to the code, running the program, seeing whether the results improved, and repeating the process. Because of this, I find myself spending more time waiting for my program to run than I do actually working on it (a common experience, I know). I'm currently using the most recent version of Python 2 on my system, so my question is whether switching to Python 3 is going to give me any speed boost or not. At this point, I don't really have a compelling reason to move to Python 3, so if the execution speeds are similar, I'll probably just stick with 2.x. I know I'm going to have to modify my code a bit to get it working in Python 3, so it's not trivial to just test it on both versions to see which runs faster. I'd need to be reasonably confident I will get a speed improvement before I spend the time updating my code to Python 3.","AnswerCount":5,"Available Count":3,"Score":0.0798297691,"is_accepted":false,"ViewCount":14827,"Q_Id":2112298,"Users Score":2,"Answer":"I can't answer the root of your question, but if you read anything regarding the sluggish performance of the io module please disregard it. The were definitely performance issues in Python 3.0, but they were largely resolved in Python 3.1.","Q_Score":35,"Tags":"python,performance","A_Id":2112332,"CreationDate":"2010-01-21T19:43:00.000","Title":"Python 2.x vs 3.x Speed","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"What would be the best way in Python to determine whether a directory is writeable for the user executing the script? Since this will likely involve using the os module I should mention I'm running it under a *nix environment.","AnswerCount":10,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":85042,"Q_Id":2113427,"Users Score":78,"Answer":"It may seem strange to suggest this, but a common Python idiom is \n\nIt's easier to ask for forgiveness\n than for permission\n\nFollowing that idiom, one might say:\nTry writing to the directory in question, and catch the error if you don't have the permission to do so.","Q_Score":120,"Tags":"python,file,permissions,directory,operating-system","A_Id":2113457,"CreationDate":"2010-01-21T22:24:00.000","Title":"Determining Whether a Directory is Writeable","Data Science and Machine Learning":0,"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},{"Question":"In the 'old days' when there was just cpython, most extensions were written in c (as platform independent as possible) and compiled into pyd's (think PyCrypto for example). Now there is Jython, IronPython and PyPy and the pyd\u2019s do not work with any of them (Ironclad aside). It seems they all support ctypes and that the best approach MIGHT be to create a platform independent dll or shared library and then use ctypes to interface to it.\nBut I think this approach will be a bit slower than the old fashion pyd approach. You could also program a pyd for cpython, a similar c# dll for IronPython and a java class or jar for Jython (I'm not sure about PyPy. But while this approach will appeal to platform purists it is very labor intensive. So what is the best route to take today?","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":501,"Q_Id":2114627,"Users Score":1,"Answer":"If you're wrapping an existing native library, the ctypes is absolutely the way to go.\nIf you're trying to speed up the hot spots in a Python extension, then making a custom extension for each interpreter (and a pure-Python fallback) is tractable because the bulk of the code is pure Python that can be shared, but undesirable and labour-intensive, as you said. You could use ctypes in this case as well.","Q_Score":4,"Tags":"python,ironpython,jython","A_Id":2119710,"CreationDate":"2010-01-22T02:44:00.000","Title":"Python extensions that can be used in all varieties of python (jython \/ IronPython \/ etc.)","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},{"Question":"In the 'old days' when there was just cpython, most extensions were written in c (as platform independent as possible) and compiled into pyd's (think PyCrypto for example). Now there is Jython, IronPython and PyPy and the pyd\u2019s do not work with any of them (Ironclad aside). It seems they all support ctypes and that the best approach MIGHT be to create a platform independent dll or shared library and then use ctypes to interface to it.\nBut I think this approach will be a bit slower than the old fashion pyd approach. You could also program a pyd for cpython, a similar c# dll for IronPython and a java class or jar for Jython (I'm not sure about PyPy. But while this approach will appeal to platform purists it is very labor intensive. So what is the best route to take today?","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":501,"Q_Id":2114627,"Users Score":2,"Answer":"Currently, it seems the ctypes is indeed the best approach. It works today, and it's so convenient that it's gonna conquer (most of) the world.\nFor performance-critical APIs (such as numpy), ctypes is indeed problematic. The cleanest approach would probably be to port Cython to produce native IronPython \/ Jython \/ PyPy extensions.\nI recall that PyPy had plans to compile ctypes code to efficient wrappers, but as far as I google, there is nothing like that yet...","Q_Score":4,"Tags":"python,ironpython,jython","A_Id":2116557,"CreationDate":"2010-01-22T02:44:00.000","Title":"Python extensions that can be used in all varieties of python (jython \/ IronPython \/ etc.)","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},{"Question":"Well aware that DLR is here!! I have recently reading up on all of these and was wondering if there were any specific benefits of using one language over another?\nFor example performance benefits! and available functionality through standard libaries!!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":638,"Q_Id":2116310,"Users Score":1,"Answer":"The answer is \"depends\".\nF# is great if you need to functional programming is used extensively by Academics that need its pure computing power to get something done.\nIronPython and IronRuby is great for being able to create applications that run on the CLR because they give you the .NET goodness with the speed of writing Python or Ruby. I don't think that any of these is more preferable to another without it being in a proper context","Q_Score":0,"Tags":"f#,ironpython,ironruby","A_Id":2116333,"CreationDate":"2010-01-22T09:41:00.000","Title":"What are the benefits of using IronPython over IronRuby or F#?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have extensive experience with PHP cURL but for the last few months I've been coding primarily in Java, utilizing the HttpClient library.\nMy new project requires me to use Python, once again putting me at the crossroads of seemingly comparable libraries: pycurl and urllib2.\nPutting aside my previous experience with PHP cURL, what is the recommended library in Python? Is there a reason to use one but not the other? Which is the more popular option?","AnswerCount":4,"Available Count":2,"Score":0.049958375,"is_accepted":false,"ViewCount":4948,"Q_Id":2121945,"Users Score":1,"Answer":"Use urllib2. It's got very good documentation in python, while pycurl is mostly C documentation. If you hit a wall, switch to mechanize or pycurl.","Q_Score":2,"Tags":"python,urllib2,pycurl","A_Id":2122198,"CreationDate":"2010-01-23T03:20:00.000","Title":"Python: urllib2 or Pycurl?","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},{"Question":"I have extensive experience with PHP cURL but for the last few months I've been coding primarily in Java, utilizing the HttpClient library.\nMy new project requires me to use Python, once again putting me at the crossroads of seemingly comparable libraries: pycurl and urllib2.\nPutting aside my previous experience with PHP cURL, what is the recommended library in Python? Is there a reason to use one but not the other? Which is the more popular option?","AnswerCount":4,"Available Count":2,"Score":0.1488850336,"is_accepted":false,"ViewCount":4948,"Q_Id":2121945,"Users Score":3,"Answer":"urllib2 is part of the standard library, pycurl isn't (so it requires a separate step of download\/install\/package etc). That alone, quite apart from any difference in intrinsic quality, is guaranteed to make urllib2 more popular (and can be a pretty good pragmatical reason to pick it -- convenience!-).","Q_Score":2,"Tags":"python,urllib2,pycurl","A_Id":2121967,"CreationDate":"2010-01-23T03:20:00.000","Title":"Python: urllib2 or Pycurl?","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},{"Question":"I have a big list of Twitter users stored in a database, almost 1000.\nI would like to use the Streaming API in order to stream tweets from these users, but I cannot find an appropriate way to do this.\nHelp would be very much appreciated.","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":2823,"Q_Id":2123651,"Users Score":2,"Answer":"You can track 400 filter words and 5000 userids via streaming api. \nFilter words can be something apple, orange, ipad etc...\nAnd in order to track any user's timeline you need to get the user's twitter user id.","Q_Score":6,"Tags":"php,python,twitter","A_Id":8286513,"CreationDate":"2010-01-23T15:34:00.000","Title":"Streaming multiple tweets - from multiple users? - Twitter 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},{"Question":"I have some daemons that use PID files to prevent parallel execution of my program. I have set up a signal handler to trap SIGTERM and do the necessary clean-up including the PID file. This works great when I test using \"kill -s SIGTERM #PID\". However, when I reboot the server the PID files are still hanging around preventing start-up of the daemons. It is my understanding that SIGTERM is sent to all processes when a server is shutting down. Should I be trapping another signal (SIGINT, SIGQUIT?) in my daemon?","AnswerCount":3,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":727,"Q_Id":2134732,"Users Score":3,"Answer":"Not a direct solution but it might be a good idea to check for an actual process running with the pid in the pid file at startup and if none exists, to cleanup the stale file. \nIt's possible that your process is getting a SIGKILL before it has a chance to cleanup the pid file.","Q_Score":3,"Tags":"python,linux,sigterm","A_Id":2134763,"CreationDate":"2010-01-25T18:53:00.000","Title":"PID files hanging around for daemons after server restart","Data Science and Machine Learning":0,"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},{"Question":"I am trying to set a cron task to read updates for a Facebook application. I have prompted the user to grant Offline Access permissions and i have store the session_key in the db.\nI am crearing a new Facebook object and besides api and secret key I also use the session_key (previously stored in db) and the fb uid. When i am trying to create the auth token or do a API call i get a Error 104: Incorrect signature\nAny ideas, experience, hints ?","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":819,"Q_Id":2140142,"Users Score":0,"Answer":"I've never used PyFacebook. Or tried to resume sessions in this manner. But I'd imagine just storing session_key and uid is not enough. There are other params too, and a signature param that's calculated based on all the fb_* params. So you might need to store all of them.\nBut even so, they might only work for 20-30 minutes if you're unlucky.","Q_Score":2,"Tags":"python,facebook,pyfacebook","A_Id":2140233,"CreationDate":"2010-01-26T14:53:00.000","Title":"PyFacebook Infinite 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":1},{"Question":"I am trying to set a cron task to read updates for a Facebook application. I have prompted the user to grant Offline Access permissions and i have store the session_key in the db.\nI am crearing a new Facebook object and besides api and secret key I also use the session_key (previously stored in db) and the fb uid. When i am trying to create the auth token or do a API call i get a Error 104: Incorrect signature\nAny ideas, experience, hints ?","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":819,"Q_Id":2140142,"Users Score":1,"Answer":"I faced the same problem where the error displayed was:\n\n\"facebook.FacebookError: Error 104: Incorrect signature\"\n\nJust reset your APP Secret_key and make corresponding change in the code and that sgould fix the problem.\nCheers!","Q_Score":2,"Tags":"python,facebook,pyfacebook","A_Id":11015676,"CreationDate":"2010-01-26T14:53:00.000","Title":"PyFacebook Infinite 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":1},{"Question":"I would like to have my PHP website destroy a users session if they have been idle for 5 minutes. If this does happen, I'd like to present the user with a message stating why they were logged out and redirect them to the login page.\nWhat is the best way to handle this?\nI am running on php and myadmin.\nThanks\nAvinash","AnswerCount":4,"Available Count":4,"Score":0.049958375,"is_accepted":false,"ViewCount":2505,"Q_Id":2145365,"Users Score":1,"Answer":"I assume you mean 'idle' time. There is no need to calculate that, but you have to store the last (authenticated) access made by that user and reset the counter.\nTypically, one would should issue an authentication cookie with a certain timestamp. Upon authentication of the cookie, you compare the current time with the timestamp. If this difference is larger than some threshold, say 5 minutes, you present an error page.\nTo improve the user experience, you might also want to display a timer to the user so there is no bad surprise.","Q_Score":1,"Tags":"php,session,python-idle","A_Id":2145413,"CreationDate":"2010-01-27T08:23:00.000","Title":"How do I detect when a user has been idle for a certain time and destroy their session 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":1},{"Question":"I would like to have my PHP website destroy a users session if they have been idle for 5 minutes. If this does happen, I'd like to present the user with a message stating why they were logged out and redirect them to the login page.\nWhat is the best way to handle this?\nI am running on php and myadmin.\nThanks\nAvinash","AnswerCount":4,"Available Count":4,"Score":0.049958375,"is_accepted":false,"ViewCount":2505,"Q_Id":2145365,"Users Score":1,"Answer":"Can you not just use PHP's built-in session functions to set session expiry time to 5 mins. and re-direct if a session no longer exists?","Q_Score":1,"Tags":"php,session,python-idle","A_Id":2145866,"CreationDate":"2010-01-27T08:23:00.000","Title":"How do I detect when a user has been idle for a certain time and destroy their session 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":1},{"Question":"I would like to have my PHP website destroy a users session if they have been idle for 5 minutes. If this does happen, I'd like to present the user with a message stating why they were logged out and redirect them to the login page.\nWhat is the best way to handle this?\nI am running on php and myadmin.\nThanks\nAvinash","AnswerCount":4,"Available Count":4,"Score":1.2,"is_accepted":true,"ViewCount":2505,"Q_Id":2145365,"Users Score":7,"Answer":"Every time you load a page, store a timestamp in a session variable. When the user goes to a page, check to see if $SESSION['lastActivity'] < time() - . If true, then redirect to a 'your session has expired' page or similar. If not, continue loading the page.","Q_Score":1,"Tags":"php,session,python-idle","A_Id":2145390,"CreationDate":"2010-01-27T08:23:00.000","Title":"How do I detect when a user has been idle for a certain time and destroy their session 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":1},{"Question":"I would like to have my PHP website destroy a users session if they have been idle for 5 minutes. If this does happen, I'd like to present the user with a message stating why they were logged out and redirect them to the login page.\nWhat is the best way to handle this?\nI am running on php and myadmin.\nThanks\nAvinash","AnswerCount":4,"Available Count":4,"Score":0.0,"is_accepted":false,"ViewCount":2505,"Q_Id":2145365,"Users Score":0,"Answer":"Create a javascript function that has a x minute timeout that pops up and redirects.\nAlso on the server make sure their session expires so that in the case of Javascript not being available, they cannot continue actions after their idle time has passed.","Q_Score":1,"Tags":"php,session,python-idle","A_Id":2145652,"CreationDate":"2010-01-27T08:23:00.000","Title":"How do I detect when a user has been idle for a certain time and destroy their session 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":1},{"Question":"My own answer to this question is YES, but I'd like to hear from others. Put another way the question could be: Would the success of 1-click-install WordPress (not WordPress.com, which is SaaS) be possible if it weren't written in PHP, all other things being equal?\nThe critical associated requirements I believe support PHP are:\n\nhosting\/deployment flexibility\ndeveloper reach\nflexibility and depth of knowledge around server performance tuning\n\nItems #1 and #2 are equally critical, and both are far more important than #3.\nFWIW, I'm not a particular fan of PHP - can anyone truly be? - but the goals of re-deployment and extensibility point wherever they point. Please, please do not pollute this space if you do not grok the question. This is not about PHP and it's relative merits, or lack of merit, compared to other programming languages out of context. I am looking for insight specifically around language choice as it relates to deployment\/uptake\/extensibility strategy as outlined.\nThanks.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":181,"Q_Id":2150947,"Users Score":3,"Answer":"As far as points #1 and #2 go, you are probably right. No other platform is so widely, easily and cheaply available in terms of hosting companies and packages like the LAMP stack. Plus, most incompatibilities that can occur when deploying an application to a completely unknown web space are well documented, their number is limited, and can mostly be checked beforehand (register_globals, safe mode, allocated script memory, etc.) \nIf I were thinking about developing a web application that I want to see spreading as quickly and as far as possible also among non-professionals and end users, PHP would be my platform of choice for these reasons. I must add that I am deeply familiar only with the hosting market in Germany, but I'm quite sure the basic characteristics are the same.\nAs for developer availability: People who claim to be able to speak PHP are easy to find. Those who will actually do a good job for you, less so. Still, I think it is safe to say that PHP developers are easier to find than, say, Pythonists or Ruby developers.\nI don't expect this to stay this way forever, though. Other languages are gaining popularity, and in the end, developers and which languages they like influences the hosting market massively in the long term.","Q_Score":3,"Tags":"php,python,wordpress,deployment,hosting","A_Id":2150982,"CreationDate":"2010-01-27T22:55:00.000","Title":"Is PHP the only choice re: massive and rapid uptake of a re-deployable, extensible 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},{"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},{"Question":"Can anyone help me to send and receive SMS using AT commands in Python?\nIn case it matters, I'm using Fedora 8.\nWhich phone will be better with Linux (Nokia, Sony Ericson, Samsung,.....)?\nWill all phones support sending and receiving SMS using AT commands?","AnswerCount":4,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":53296,"Q_Id":2161197,"Users Score":2,"Answer":"Talking to the phone is easy. You just need to open the appropriate \/dev\/ttyACM* device and talk to it. Which phone is trickier. Any phone that supports \"tethering\" and the full AT command set for SMS messages should be fine.","Q_Score":13,"Tags":"python,sms,at-command","A_Id":2161275,"CreationDate":"2010-01-29T10:13:00.000","Title":"How to Send\/Receive SMS using AT commands?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"Can anyone help me to send and receive SMS using AT commands in Python?\nIn case it matters, I'm using Fedora 8.\nWhich phone will be better with Linux (Nokia, Sony Ericson, Samsung,.....)?\nWill all phones support sending and receiving SMS using AT commands?","AnswerCount":4,"Available Count":2,"Score":0.049958375,"is_accepted":false,"ViewCount":53296,"Q_Id":2161197,"Users Score":1,"Answer":"I would suggest replace the time.sleep with condition loop waiting for the response from the modem \"OK\" before continue next state.","Q_Score":13,"Tags":"python,sms,at-command","A_Id":48543135,"CreationDate":"2010-01-29T10:13:00.000","Title":"How to Send\/Receive SMS using AT commands?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"How can I retrieve contacts from hotmail with python?\nIs there any example?","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1864,"Q_Id":2165517,"Users Score":0,"Answer":"use octazen, but you have to pay for it","Q_Score":2,"Tags":"python,hotmail","A_Id":2458380,"CreationDate":"2010-01-29T22:08:00.000","Title":"How do I retrieve Hotmail contacts 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},{"Question":"Here is the situation:\nI have a Mediawiki installation, and a few additional server-side scripts that require more resources and were already written in a different language (python). The python code will be very loosely coupled with the Mediawiki code (only called by clicking on a link here or there)\nWhat I would like is that when a GET or POST command is sent to the server to execute a python script, I would like to check to see if a user is already logged in to Mediawiki. If not, I would like to just redirect them to the Mediawiki login page.\nAny ideas?\nThere are several articles on integrating Mediawiki with other PHP frameworks like Drupal and forum software, but that is more than I need.\nWhat is the best way to do this?\n-check for cookies somehow (is this secure?)\n-does the Mediawiki database keep track of who is logged in?\n\nThanks","AnswerCount":5,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":4553,"Q_Id":2170990,"Users Score":0,"Answer":"All you need to do is essentially forward the session, cookies and all, to the API as if it's the user querying.\n\nHow would one go about doing that? I can access the API directly and see my login info, but if I access it via PHP, it shows me as not being logged in (anonymous user id \"0\"). How do I forward the session, cookies, etc. to the API via PHP to show the user's info?","Q_Score":4,"Tags":"python,authentication,mediawiki","A_Id":2456365,"CreationDate":"2010-01-31T08:01:00.000","Title":"How to check if a user is logged on in mediawiki in a different 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":0,"Web Development":1},{"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},{"Question":"I know some Python and I'm really impressed by the language's ease of use. From what I've seen of Objective-C it looks a lot less pretty, but it seems to be the lingua franca for Mac OS X development (which means it has better documentation). \nI'm thinking about starting Mac development - will using PyObjC+Python make me a second class citizen?","AnswerCount":8,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":3245,"Q_Id":2175573,"Users Score":0,"Answer":"You're going to need Objective-C: that's what all the tutorials, documentation, sample code, and everything is written in. In addition to a wilder variety of people being able to help you.\nSo learn ObjC first. If, on your second or third project, or a year down the road, you start a project that needs a Python module (like, say, Twisted, or SQLAlchemy. But a SERIOUS need like foundation of your app need, where the extra boost your app gets makes everything worth it), then you can write a PyObjC app and get a lot of the speed benefits of that language, with your background in Cocoa.","Q_Score":13,"Tags":"python,cocoa,macos,pyobjc","A_Id":2176578,"CreationDate":"2010-02-01T09:01:00.000","Title":"What are the downsides of using Python instead of Objective-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},{"Question":"I know some Python and I'm really impressed by the language's ease of use. From what I've seen of Objective-C it looks a lot less pretty, but it seems to be the lingua franca for Mac OS X development (which means it has better documentation). \nI'm thinking about starting Mac development - will using PyObjC+Python make me a second class citizen?","AnswerCount":8,"Available Count":3,"Score":0.049958375,"is_accepted":false,"ViewCount":3245,"Q_Id":2175573,"Users Score":2,"Answer":"Second class citizen seems a bit strong. The Objective-C API's are available from Python as well, should you need them, and that's mostly if you want to make Cocoa apps. But then they are restricted to OS X anyway. Personally, I have no interest in building apps that isn't cross-platform, but that's me. That also means I haven't actually done this, so I don't know how tricky it is, but there was an article in the Python Magazine not long ago, and it didn't look that horrible.\nThe major drawback of Python is execution time, and that mainly comes from it being a dynamic language. This can be solved with Cython and C-extensions, etc, but then you get a mix of Python + ObjectiveC API's + Cython which can be daunting.\nSo it depends a lot of what kinds of applications you are going to make. Something uniquely OSX-ish that makes no sense anywhere else? ObjectiveC is probably the ticket. Cross-platform servers, well then Python rocks! Something else? Then it depends.","Q_Score":13,"Tags":"python,cocoa,macos,pyobjc","A_Id":2175875,"CreationDate":"2010-02-01T09:01:00.000","Title":"What are the downsides of using Python instead of Objective-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},{"Question":"I know some Python and I'm really impressed by the language's ease of use. From what I've seen of Objective-C it looks a lot less pretty, but it seems to be the lingua franca for Mac OS X development (which means it has better documentation). \nI'm thinking about starting Mac development - will using PyObjC+Python make me a second class citizen?","AnswerCount":8,"Available Count":3,"Score":0.0748596907,"is_accepted":false,"ViewCount":3245,"Q_Id":2175573,"Users Score":3,"Answer":"DO NOT ATTEMPT to avoid learning objective-C if you're going to write apps for the Mac. The purpose of PyObjC and the other language bindings is to let you re-use existing libraries in your apps, not to let you avoid learning the native tools.","Q_Score":13,"Tags":"python,cocoa,macos,pyobjc","A_Id":2176187,"CreationDate":"2010-02-01T09:01:00.000","Title":"What are the downsides of using Python instead of Objective-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},{"Question":"Calling resource.getrusage() from Python returns a 0 value for resident set size on Solaris and Linux systems. On Linux you can pull the RSS From \/proc\/\/status instead. Does anybody have a good way to pull RSS on Solaris, either similar or not to the Linux workaround?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":479,"Q_Id":2180156,"Users Score":0,"Answer":"Well...you can pull it from the pmap application by calling pmap -x. But I was looking more for a way to access the info directly in \/proc from my app. The only way to do it is to access the \/proc\/\/xmap file. Unfortunately, the data is stored as an array of prxmap structs...so either a Python C-module is in order or using the ctypes module. I'll post an update when I get one of those written.","Q_Score":1,"Tags":"python,solaris,getrusage","A_Id":2193909,"CreationDate":"2010-02-01T21:17:00.000","Title":"How can I grap resident set size from Python on Solaris?","Data Science and Machine Learning":0,"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},{"Question":"I'm building a genetic algorithm to tackle the traveling salesman problem. Unfortunately, I hit peaks that can sustain for over a thousand generations before mutating out of them and getting better results. What crossover and mutation operators generally do well in this case?","AnswerCount":3,"Available Count":1,"Score":0.1325487884,"is_accepted":false,"ViewCount":2732,"Q_Id":2185177,"Users Score":2,"Answer":"If your problem is that peaks remain for over one thousand generations, then the problem might not be with the crossover and mutation operators. You might not be introducing or keeping enough variation to your population: I would examine the proportions of crossovers, of mutations, and of survivors from one generation to the next, and possibly raise the proportion of mutations.","Q_Score":5,"Tags":"python,algorithm,genetic-algorithm,evolutionary-algorithm,traveling-salesman","A_Id":2185816,"CreationDate":"2010-02-02T15:27:00.000","Title":"Suggested GA operators for a TSP problem?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"Or is there a better way to quickly output the contents of an array (multidimensional or what not). Thanks.","AnswerCount":9,"Available Count":1,"Score":0.1106561105,"is_accepted":false,"ViewCount":77118,"Q_Id":2187821,"Users Score":5,"Answer":"print and pprint are great for built-in data types or classes which define a sane object representation. If you want a full dump of arbitrary objects, you'll have to roll your own. That is not that hard: simply create a recursive function with the base case being any non-container built-in data type, and the recursive case applying the function to each item of a container or each attribute of the object, which can be gotten using dir() or the inspect module.","Q_Score":87,"Tags":"php,python","A_Id":2187885,"CreationDate":"2010-02-02T21:24:00.000","Title":"What is the equivalent of php's print_r() 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},{"Question":"I'm going to help my friend in a improve of his phpBB board, but I want to make somethings there in Python or Perl. But it's possible to integrate these languages with PHP?","AnswerCount":3,"Available Count":2,"Score":1.0,"is_accepted":false,"ViewCount":848,"Q_Id":2187998,"Users Score":8,"Answer":"You can always call the python or perl interpreter from within PHP! Minimalistic interchange is possible by means of passing command line arguments and capturing stdout (exec or passthru are related php functions).\nHowever, I don't think its's a good idea - using two interpreters instead of one doubles the overall runtime overhead and startup time.","Q_Score":2,"Tags":"php,python,perl,integration,phpbb","A_Id":2188027,"CreationDate":"2010-02-02T21:53:00.000","Title":"Integrating Python or Perl with 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":0},{"Question":"I'm going to help my friend in a improve of his phpBB board, but I want to make somethings there in Python or Perl. But it's possible to integrate these languages with PHP?","AnswerCount":3,"Available Count":2,"Score":1.0,"is_accepted":false,"ViewCount":848,"Q_Id":2187998,"Users Score":8,"Answer":"I'd say that the only reasonable way of doing that is if you are making a separate service, that you talk to via Ajax or XML or something like that. Everything else is more trouble than it's worth.","Q_Score":2,"Tags":"php,python,perl,integration,phpbb","A_Id":2188168,"CreationDate":"2010-02-02T21:53:00.000","Title":"Integrating Python or Perl with 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":0},{"Question":"I use python based as well as rails applications on ubuntu linux. We have functionalities like register, forgot password, reset password, email alerts etc features based on emails. Since now a days, we go on offline development, we want to run a local smtp & pop3 server to send and receive emails.\nEmails shall be send via the our web application and we will use the email clients like thunderbird to receive emails(just to verify).\nI have used jmailsrv (I have used 6 years ago, but could not locate exact package now), a java based simple email server. Are there any other light alternative for development work?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":839,"Q_Id":2195203,"Users Score":2,"Answer":"Why does it need to be a simple mail server?\nCan't you just use something like postfix which is very easy for simple configurations","Q_Score":1,"Tags":"python,ruby-on-rails,linux,email","A_Id":2195237,"CreationDate":"2010-02-03T20:31:00.000","Title":"Linux development\/minimal smtp and pop3 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},{"Question":"What is the Python code to create a password encrypted zip file? I'm fine with using some apt-get'able utilities using system on the command line.","AnswerCount":5,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":51029,"Q_Id":2195747,"Users Score":0,"Answer":"You can use Pygpgme to create a password-protected gpg file, which is compressed.\nYou'll need to use the equivalent of\n gpg -c myFile\nor\n gpg --symmetric myFile\nand\n gpg myFile.gpg\nI don't know what the equivalents are in that Python module, but I know they've existed since version 0.2. There was a bug report before then mentioning the lack of it, but someone released a patch and they fixed it in version 0.2.\nThis uses symmetric encryption so you don't have to worry about keys.\nYou might find my post asking how to use it on UbuntuForums. Feel free to answer it if you know.","Q_Score":17,"Tags":"python","A_Id":22124386,"CreationDate":"2010-02-03T21:51:00.000","Title":"Code to create a password encrypted zip 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},{"Question":"What is the Python code to create a password encrypted zip file? I'm fine with using some apt-get'able utilities using system on the command line.","AnswerCount":5,"Available Count":2,"Score":0.1973753202,"is_accepted":false,"ViewCount":51029,"Q_Id":2195747,"Users Score":5,"Answer":"Extraction is pretty easy, you just use zipfile.ZipFile.setpassword() which was introduced in python 2.6, however the standard python library lacks support for creating encrypted zip files.\nThere are commercially available libraries for Python which supports creation of encrypted and password protected zip files. If you want to use something freely available, you need to use the standard zip command line utility.\n\nzip -e -Ppassword filename.zip fileA fileB ...","Q_Score":17,"Tags":"python","A_Id":2196159,"CreationDate":"2010-02-03T21:51:00.000","Title":"Code to create a password encrypted zip 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},{"Question":"I am building a routine that processes disk buffers for forensic purposes. Am I better off using python strings or the array() type? My first thought was to use strings, but I'm trying to void unicode problems, so perhaps array('c') is better?","AnswerCount":2,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":681,"Q_Id":2200027,"Users Score":6,"Answer":"If you need to alter the buffer in-place (it's not clear if you do, since you use the ambiguous term \"to process\"), arrays will likely be better, since strings are immutable. In Python 2.6 or better, however, bytearrays can be the best of both worlds -- mutable and rich of methods and usable with regular expressions too.\nFor read-only operations, strings have the edge over array (thanks to many more methods, plus extras such as regular expressions, available on them), if you're stuck with old Python versions and so cannot use bytearray. Unicode is not an issue in either case (in Python 2; in Python 3, definitely go for bytearray!-).","Q_Score":3,"Tags":"python,arrays,performance","A_Id":2200806,"CreationDate":"2010-02-04T13:41:00.000","Title":"which is more efficient for buffer manipulations: python strings or array()","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'd like to make a website, it's not a huge project, but I'm a bit out of the web design loop. The last time I made a website was probably around 2002. I figure the web frameworks and tools have come a ways since then. It's mostly the design aspect that I'd like it to make easier. I can do the backend language in any language.\nMy question is:\nWhat are some tools or web frameworks that make the design aspect of making a website easier. It could be a framework in php\/python\/ruby.\nAs far as tools go, free\/open source is preferred, but I wouldn't mind looking at good commercial alternatives.","AnswerCount":5,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":335,"Q_Id":2204223,"Users Score":0,"Answer":"django on Google App Engine gets you free(up to a point) and scalable hosting","Q_Score":4,"Tags":"php,python,ruby","A_Id":2204294,"CreationDate":"2010-02-05T00:19:00.000","Title":"What's a good web framework and\/or tool for a software developer?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I'd like to make a website, it's not a huge project, but I'm a bit out of the web design loop. The last time I made a website was probably around 2002. I figure the web frameworks and tools have come a ways since then. It's mostly the design aspect that I'd like it to make easier. I can do the backend language in any language.\nMy question is:\nWhat are some tools or web frameworks that make the design aspect of making a website easier. It could be a framework in php\/python\/ruby.\nAs far as tools go, free\/open source is preferred, but I wouldn't mind looking at good commercial alternatives.","AnswerCount":5,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":335,"Q_Id":2204223,"Users Score":0,"Answer":"It really depends on a couple things:\n\nWhat are you familiar with? You indicated that you've done some web development in the past. What did you use? If you were using classic ASP, then learning ASP.NET should be less of a jump for you.\nWhat are you trying to create? If all you need are static HTML files with a tiny bit of functionality, you could try learning PHP as it's pretty quick and easy to get going. If you need light database access, then maybe Ruby on Rails will be your cup of tea.\n\nWith that being said, I'd recommend the following in no particular order (just because I've tried them and they're all pretty decent):\n\nRuby on Rails\nASP.NET \/ ASP.NET MVC\nPHP","Q_Score":4,"Tags":"php,python,ruby","A_Id":2204292,"CreationDate":"2010-02-05T00:19:00.000","Title":"What's a good web framework and\/or tool for a software developer?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"i'm doing simulation which generates thousands of result objects.\nEach object size is around 1mb, and all the result objects should be on memory to be queried for various ad hoc reports. And it takes 1~2 secs to make one result object.\nSo it takes more than 5 minutes to get one simulation done even though i fully use my quad-core cpu with parallel execution. And the task process takes more than 4~5 gb memory for one simulation set. The problem is, I want to run more simulation sets simultaneously and get it done more quickly.\nCurrently, I'm doing this job using c# and ironpython on windows vista64, quad-core cpu with 8g memory. I gonna order a new computer, 24 gb memory with better cpu and ultimately, i may buy workstation with multi cpus and more memories. \nSo my question is, what is the best way to utilize new hardware?\nI consider one of the combinations below.\n\nironpython + c# on windows 64\nironpython + c# (mono) on linux 64\njython + java on windows 64\njython + java on linux 64\n\nSimulation engine is written in c# \/ java, and i use python to make reports.\nWhich combination do you guys think is the best?\nIs there no big difference between .net and java platform to handle memory consuming task?\nIs there no difference between windows and linux?\nI sometimes run my current c# + ironpython code on my ubuntu laptop (32bit, 2g ram) and feel that it seems pretty stable compared to windows .net env on the same spec hardware. But i dont know when the underlying hardware is pretty better.\nAnd i welcome any kind of suggestion regardless of the choices above.","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":839,"Q_Id":2205832,"Users Score":2,"Answer":"Since you can install all of those for free and it sounds like you already have the code implemented in both .Net and Java then I suggest you benchmark the program on all four platforms (windows\/linux * java\/.net). \nIt sounds like all the heavy lifting is done in Java\/C#, so I suspect the relative performance of Jython vs. IronPython is largely irrelevant.","Q_Score":3,"Tags":"c#,java,.net,python,memory","A_Id":2205899,"CreationDate":"2010-02-05T08:19:00.000","Title":"best (python) setup for cpu \/ memory intensive task","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"i'm doing simulation which generates thousands of result objects.\nEach object size is around 1mb, and all the result objects should be on memory to be queried for various ad hoc reports. And it takes 1~2 secs to make one result object.\nSo it takes more than 5 minutes to get one simulation done even though i fully use my quad-core cpu with parallel execution. And the task process takes more than 4~5 gb memory for one simulation set. The problem is, I want to run more simulation sets simultaneously and get it done more quickly.\nCurrently, I'm doing this job using c# and ironpython on windows vista64, quad-core cpu with 8g memory. I gonna order a new computer, 24 gb memory with better cpu and ultimately, i may buy workstation with multi cpus and more memories. \nSo my question is, what is the best way to utilize new hardware?\nI consider one of the combinations below.\n\nironpython + c# on windows 64\nironpython + c# (mono) on linux 64\njython + java on windows 64\njython + java on linux 64\n\nSimulation engine is written in c# \/ java, and i use python to make reports.\nWhich combination do you guys think is the best?\nIs there no big difference between .net and java platform to handle memory consuming task?\nIs there no difference between windows and linux?\nI sometimes run my current c# + ironpython code on my ubuntu laptop (32bit, 2g ram) and feel that it seems pretty stable compared to windows .net env on the same spec hardware. But i dont know when the underlying hardware is pretty better.\nAnd i welcome any kind of suggestion regardless of the choices above.","AnswerCount":2,"Available Count":2,"Score":0.1973753202,"is_accepted":false,"ViewCount":839,"Q_Id":2205832,"Users Score":2,"Answer":"@Dave is spot on, if you really care benchmark each combination and see.\nPersonally I'd suggest you stick with the tool set that you are most comfortable with, be that Windows, Java, Linux, .Net or any random combination there of. Your level of productivity in maintaining and developing your software usually trumps any minor performance gain you might get from switching OS or VM.","Q_Score":3,"Tags":"c#,java,.net,python,memory","A_Id":2205986,"CreationDate":"2010-02-05T08:19:00.000","Title":"best (python) setup for cpu \/ memory intensive task","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"So, I know I can use dir() to get information about class members etc. What I'm looking for is a way to get a nicely formatted report on everything related to a class (the members, docstrings, inheritance hierarchy, etc.).\nI want to be able to run this on the command-line so I can explore code and debug better.","AnswerCount":6,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":122,"Q_Id":2225456,"Users Score":5,"Answer":"Try calling help on your class.","Q_Score":1,"Tags":"python","A_Id":2225477,"CreationDate":"2010-02-08T22:43:00.000","Title":"Is there a way for me to get detailed formatted information on a Python 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},{"Question":"I do basic python programming and now I want to get deep into language features. I have collected\/considered the following to be advanced python capabilities and learning them now. \n\nDecorator\nIterator\nGenerator\nMeta Class\n\nAnything else to be added\/considered to the above list?","AnswerCount":4,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":3365,"Q_Id":2227537,"Users Score":2,"Answer":"First, this thread should be community wiki.\nSecond, iterators and generators are pretty basic Python IMHO. I agree with you on decorators and metaclasses. But I'm not a very good programmer, so I probably find this more difficult to wrap my brain around than others.\nThird, I would add threading\/multiprocessing to the list. That's really tricky :)","Q_Score":6,"Tags":"python","A_Id":2227567,"CreationDate":"2010-02-09T07:53:00.000","Title":"What are features considerd as advanced 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},{"Question":"I do basic python programming and now I want to get deep into language features. I have collected\/considered the following to be advanced python capabilities and learning them now. \n\nDecorator\nIterator\nGenerator\nMeta Class\n\nAnything else to be added\/considered to the above list?","AnswerCount":4,"Available Count":2,"Score":0.049958375,"is_accepted":false,"ViewCount":3365,"Q_Id":2227537,"Users Score":1,"Answer":"I think you'll find that there isn't a good answer to your question. What's great about Python is that all of its features are fairly easy to understand. But there's enough stuff in the language and the library that you never get around to learning it all. So it really boils down to which you've had occasion to use, and which you've only heard about.\nIf you haven't used decorators or generators, they sound advanced. But once you actually have to use them in a real-world situation, you'll realize that they're really quite simple, and wonder how you managed to live without them before.","Q_Score":6,"Tags":"python","A_Id":2229792,"CreationDate":"2010-02-09T07:53:00.000","Title":"What are features considerd as advanced 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},{"Question":"I have been using Macromedia \/ Adobe Director & Lingo since 1998. I am extremely familiar with using this software to create CDROMs and DVDs and also have a good knowledge of design elements and their integration such as flash videos, images & audio etc.\nI am always keen to explore other technologies and understand that Python can be used to create CDROMs.\nI have tried Googling some information on this subject but to no avail. Does anyone know the pros and cons of Python CDROM production? Is it capable of delivering such media rich experiences as Adobe Director? What are the limitations?\nAny help \/ resources would be greatly appreciated.","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":214,"Q_Id":2228988,"Users Score":0,"Answer":"It sounds like you're not asking so much for mass-copying of CDs\/DVDs (which is what I assumed from reading the title), but for a Python-based replacement for Adobe Director? I don't think anything like that presently exists.\nHowever, Python could certainly help you out with the scripting and control of various elements in the production process -- for example, taking the tedium out of assembling lots of files together into one final package. You'd have to be more specific about what you're looking for, though.","Q_Score":0,"Tags":"python,adobe,media,dvd,cd-rom","A_Id":2228998,"CreationDate":"2010-02-09T12:36:00.000","Title":"Python CDROM 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},{"Question":"I have been using Macromedia \/ Adobe Director & Lingo since 1998. I am extremely familiar with using this software to create CDROMs and DVDs and also have a good knowledge of design elements and their integration such as flash videos, images & audio etc.\nI am always keen to explore other technologies and understand that Python can be used to create CDROMs.\nI have tried Googling some information on this subject but to no avail. Does anyone know the pros and cons of Python CDROM production? Is it capable of delivering such media rich experiences as Adobe Director? What are the limitations?\nAny help \/ resources would be greatly appreciated.","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":214,"Q_Id":2228988,"Users Score":1,"Answer":"Python isn't the tool you are looking for... [waves hand across in front of Mindblip's face]\nStick with Director or try Flash with either MPlayer or Zinc.","Q_Score":0,"Tags":"python,adobe,media,dvd,cd-rom","A_Id":2229023,"CreationDate":"2010-02-09T12:36:00.000","Title":"Python CDROM 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},{"Question":"I'm considering to use XML-RPC.NET to communicate with a Linux XML-RPC server written in Python. I have tried a sample application (MathApp) from Cook Computing's XML-RPC.NET but it took 30 seconds for the app to add two numbers within the same LAN with server. \nI have also tried to run a simple client written in Python on Windows 7 to call the same server and it responded in 5 seconds. The machine has 4 GB of RAM with comparable processing power so this is not an issue. \nThen I tried to call the server from a Windows XP system with Java and PHP. Both responses were pretty fast, almost instantly. The server was responding quickly on localhost too, so I don't think the latency arise from server. \nMy googling returned me some problems regarding Windows' use of IPv6 but our call to server does include IPv4 address (not hostname) in the same subnet. Anyways I turned off IPv6 but nothing changed.\nAre there any more ways to check for possible causes of latency?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1326,"Q_Id":2235643,"Users Score":0,"Answer":"Run a packet capture on the client machine, check the network traffic timings versus the time the function is called.\nThis may help you determine where the latency is in your slow process, e.g. application start-up time, name resolution, etc.\nHow are you addressing the server from the client? By IP? By FQDN? Is the addressing method the same in each of the applications your using?\nIf you call the same remote procedure multiple times from the same slow application, does the time taken increase linearly?","Q_Score":1,"Tags":"c#,.net,python,windows-7,xml-rpc","A_Id":2235703,"CreationDate":"2010-02-10T09:23:00.000","Title":"Slow XML-RPC in Windows 7 with XML-RPC.NET","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},{"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},{"Question":"I have device connected through serial port to PC. Using c-kermit I can send commands to device and read output. I can also send files using kermit protocol.\nIn python we have pretty nice library - pySerial. I can use it to send\/receive data from device. But is there some nice solution to send files using kermit protocol?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":3905,"Q_Id":2237483,"Users Score":0,"Answer":"You should be able to do it via the subprocess module. The following assumes that you can send commands to your remote machine and parse out the results already. :-)\nI don't have anything to test this on at the moment, so I'm going to be pretty general.\nRoughly:\n 1.) use pyserial to connect to the remote system through the serial port.\n 2.) run the kermit client on the remote system using switches that will send the file or files you wish to transfer over the remote systems serial port (the serial line you are using.)\n 3.) disconnect your pyserial instance\n 4.) start your kermit client with subprocess and accept the files.\n 5.) reconnect your pyserial instance and clean everything up.\nI'm willing to bet this isn't much help, but when I actually did this a few years ago (using os.system, rather than subprocess on a hideous, hideous SuperDOS system) it took me a while to get my fat head around the fact that I had to start a kermit client remotely to send the file to my client! \nIf I have some time this week I'll break out one of my old geode boards and see if I can post some actual working code.","Q_Score":2,"Tags":"python,serial-port,pyserial,kermit","A_Id":3143184,"CreationDate":"2010-02-10T14:31:00.000","Title":"How to send file to serial port using kermit protocol 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},{"Question":"I've noticed two methods to \"message passing\". One I've seen Erlang use and the other is from Stackless Python. From what I understand here's the difference\nErlang Style - Messages are sent and queued into the mailbox of the receiving process. From there they are removed in a FIFO basis. Once the first process sends the message it is free to continue.\nPython Style - Process A queues up to send to process B. B is currently performing some other action, so A is frozen until B is ready to receive. Once B opens a read channel, A sends the data, then they both continue.\nNow I see the pros of the Erlang method being that you don't have any blocked processes. If B never is able to receive, A can still continue. However I have noticed in some programs I have written, that it is possible for Erlang message boxes to get full of hundreds (or thousands) of messages since the inflow of messages is greater than the outflow.\nNow I haven't written a large program in either framework\/language so I'm wondering your experiences are with this, and if it's something I should even worry about. \nYes, I know this is abstract, but I'm also looking for rather abstract answers.","AnswerCount":2,"Available Count":2,"Score":0.3799489623,"is_accepted":false,"ViewCount":1147,"Q_Id":2239731,"Users Score":4,"Answer":"Broadly speaking, this is unbounded queues vs bounded queues. A stackless channel can be considered a special case of a queue with 0 size.\nBounded queues have a tendency to deadlock. Two threads\/processes trying to send a message to each other, both with a full queue.\nUnbounded queues have more subtle failure. A large mailbox won't meet latency requirements, as you mentioned. Go far enough and it will eventually overflow; no such thing as infinite memory, so it's really just a bounded queue with a huge limit that aborts the process when full.\nWhich is best? That's hard to say. There's no easy answers here.","Q_Score":10,"Tags":"python,erlang,actor,stackless,python-stackless","A_Id":2240157,"CreationDate":"2010-02-10T19:32:00.000","Title":"blocking channels vs async message passing","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I've noticed two methods to \"message passing\". One I've seen Erlang use and the other is from Stackless Python. From what I understand here's the difference\nErlang Style - Messages are sent and queued into the mailbox of the receiving process. From there they are removed in a FIFO basis. Once the first process sends the message it is free to continue.\nPython Style - Process A queues up to send to process B. B is currently performing some other action, so A is frozen until B is ready to receive. Once B opens a read channel, A sends the data, then they both continue.\nNow I see the pros of the Erlang method being that you don't have any blocked processes. If B never is able to receive, A can still continue. However I have noticed in some programs I have written, that it is possible for Erlang message boxes to get full of hundreds (or thousands) of messages since the inflow of messages is greater than the outflow.\nNow I haven't written a large program in either framework\/language so I'm wondering your experiences are with this, and if it's something I should even worry about. \nYes, I know this is abstract, but I'm also looking for rather abstract answers.","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":1147,"Q_Id":2239731,"Users Score":8,"Answer":"My experience in Erlang programming is that when you expect a high messaging rate (that is, a faster producer than consumer) then you add your own flow control. A simple scenario\n\nThe consumer will: send message, wait for ack, then repeat. \nThe producer will: wait for message, send ack when message received and processed, then repeat.\n\nOne can also invert it, the producer waits for the consumer to come and grab the N next available messages.\nThese approaches and other flow control can be hidden behind functions, the first one is mostly already available in gen_server:call\/2,3 against a gen_server OTP behavior process.\nI see asynchronous messaging as in Erlang as the better approach, since when latencies are high you might very much want to avoid a synchronization when messaging between computers. One can then compose clever ways to implement flow control. Say, requiring an ack from the consumer for every N messages the producer have sent it, or send a special \"ping me when you have received this one\" message now and then, to count ping time.","Q_Score":10,"Tags":"python,erlang,actor,stackless,python-stackless","A_Id":2240486,"CreationDate":"2010-02-10T19:32:00.000","Title":"blocking channels vs async message passing","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I have a GSM modem that disconnect after a while, maybe because of low signal. I am just wondering is there an AT command that can detect the disconnection and re-establish a reconnection.\nIs there a way in code (preferably python) I can detect the disconnection and re-establish a reconnection?\n\nGath","AnswerCount":3,"Available Count":1,"Score":0.2605204458,"is_accepted":false,"ViewCount":4663,"Q_Id":2251796,"Users Score":4,"Answer":"Depending on what type of connection, circuit switched (CS) or packet switched (PS), the monitoring will be a little bit different. To detect a disconnect you can enable UR (unsolicited result) code AT+CPSB=1 to monitor PDP context activity (aka packet switched connections). For circuit switched calls you can monitor with the +CIEV: UR code enabled with AT+CMER=3,0,0,2.\nTo re-establish the connection you have to set up the connection again. For CS you will either have to know the phone number dialed, or you can use the special form of ATD, ATDL [1] which will dial the last dialed number. You can use ATDL for PS as well if the call was started with ATD (i.e. \"ATD*99*....\") which is quite common, but I do not think there is any way if started with AT+CGDATA for instance.\nHowever, none of the above related to ATD matters, because it is not what you want. For CS you might set up a call from your python script, but then so what? After receiving CONNECT all the data traffic would be coming on the serial connection that your python script are using. And for PS the connection will not even finish successfully unless the phone receives PPP traffic from the PC as part of connection establishment. Do you intend your python script to supply that?\nWhat you really want is to trigger your PC to try to connect again, whether this is standard operating system dial up networking or some special application launching it. So monitor the modem with a python script and then take appropriate action on the PC side to re-establish the connection.\n[1]\nSide note to ATDL: notice that if you want to repeat the last voice call you should still terminate with a semicolon, i.e. ATDL;, otherwise you would start a data call.","Q_Score":2,"Tags":"python,gsm,at-command","A_Id":2251902,"CreationDate":"2010-02-12T12:39:00.000","Title":"What are the functions \/ AT commands to reconnect a disconnected GSM modem?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"Via django iam launching a thread (via middle ware the moment the first request comes) which continously fetches the twitter public steam and puts it down into the database.Assume the thread name is twitterthread.\nI also have have several cron jobs which periodically interacts with other third party api services.\nObserved the following Problem: \nif i don't launch twitterthread cron jobs are running fine.\nWhere as if i launch twitterthread cron jobs are not running\nAny idea on what can go wrong? and any guidelines on the way to fix it.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":253,"Q_Id":2253714,"Users Score":0,"Answer":"I'd advice to avoid launching threads inside the django application. Most of the times you can run the thread as a separate application.\nIf you deploy the app in a Apache server and you don't control it properly each Apache process will assume that a request is the first one and you could end up with more than one instance of twitterthread.","Q_Score":0,"Tags":"python,django,cron","A_Id":3487091,"CreationDate":"2010-02-12T17:23:00.000","Title":"cron job and Long process problem","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I am on working on a Python script which is supposed to process a tarball and output new one, trying to keep the format of the original. Thus, I am looking for a way to lookup the compression method used in an open tarball to open the new one with same compression.\nAFAICS TarFile class doesn't provide any public interface to get the needed information directly. And I would like to avoid reading the file independently of the tarfile module.\nI am currently considering looking up the class of the underlying file object (t.fileobj.__class__) or trying to open the input file in all possible modes and choosing the correct format basing on which one succeeds.","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":267,"Q_Id":2254017,"Users Score":1,"Answer":"Tar doesn't compress, it concatenates (which is why TarFile won't tell you what compression method is used, because there isn't one). \nAre you trying to find out if it's a tar.gz, tar.bz2, or tar.Z ?","Q_Score":1,"Tags":"python,tarfile","A_Id":2254074,"CreationDate":"2010-02-12T18:09:00.000","Title":"tarfile: determine compression of an open tarball","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":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},{"Question":"newb here. I am trying to make a c++ program that will read from a named pipe created by python. My problem is, the named pipe created by python uses os.getpid() as part of the pipe name. when i try calling the pipe from c++, i use getpid(). i am not getting the same value from c++. is there a method equivalent in c++ for os.getpid?\nthanks!\nedit:\nsorry, i am actually using os.getpid() to get the session id via ProcessIDtoSessionID(). i then use the session id as part of the pipe name","AnswerCount":4,"Available Count":4,"Score":0.0,"is_accepted":false,"ViewCount":862,"Q_Id":2257415,"Users Score":0,"Answer":"You cannot easily retrieve the Python interpreter's PID from your C++ program.\nEither assign the named pipe a constant name, or if you really need multiple pipes of the same Python program, create a temporary file to which the Python programs write their PIDs (use file locking!) - then you can read the PIDs from the C++ program.","Q_Score":0,"Tags":"c++,python","A_Id":2257431,"CreationDate":"2010-02-13T12:09:00.000","Title":"How do I do os.getpid() 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},{"Question":"newb here. I am trying to make a c++ program that will read from a named pipe created by python. My problem is, the named pipe created by python uses os.getpid() as part of the pipe name. when i try calling the pipe from c++, i use getpid(). i am not getting the same value from c++. is there a method equivalent in c++ for os.getpid?\nthanks!\nedit:\nsorry, i am actually using os.getpid() to get the session id via ProcessIDtoSessionID(). i then use the session id as part of the pipe name","AnswerCount":4,"Available Count":4,"Score":0.0996679946,"is_accepted":false,"ViewCount":862,"Q_Id":2257415,"Users Score":2,"Answer":"You won't get the same value if you're running as a separate process as each process has their own process ID. Find some other way to identify the pipe.","Q_Score":0,"Tags":"c++,python","A_Id":2257426,"CreationDate":"2010-02-13T12:09:00.000","Title":"How do I do os.getpid() 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},{"Question":"newb here. I am trying to make a c++ program that will read from a named pipe created by python. My problem is, the named pipe created by python uses os.getpid() as part of the pipe name. when i try calling the pipe from c++, i use getpid(). i am not getting the same value from c++. is there a method equivalent in c++ for os.getpid?\nthanks!\nedit:\nsorry, i am actually using os.getpid() to get the session id via ProcessIDtoSessionID(). i then use the session id as part of the pipe name","AnswerCount":4,"Available Count":4,"Score":0.1973753202,"is_accepted":false,"ViewCount":862,"Q_Id":2257415,"Users Score":4,"Answer":"You don't get same proccess IDs because your python program and c++ programs are run in different proccesses thus having different process IDs. So generally use a different logic to name your fifo files.","Q_Score":0,"Tags":"c++,python","A_Id":2257422,"CreationDate":"2010-02-13T12:09:00.000","Title":"How do I do os.getpid() 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},{"Question":"newb here. I am trying to make a c++ program that will read from a named pipe created by python. My problem is, the named pipe created by python uses os.getpid() as part of the pipe name. when i try calling the pipe from c++, i use getpid(). i am not getting the same value from c++. is there a method equivalent in c++ for os.getpid?\nthanks!\nedit:\nsorry, i am actually using os.getpid() to get the session id via ProcessIDtoSessionID(). i then use the session id as part of the pipe name","AnswerCount":4,"Available Count":4,"Score":0.0,"is_accepted":false,"ViewCount":862,"Q_Id":2257415,"Users Score":0,"Answer":"The standard library does not give you anything other than files. You will need to use some other OS specific API.","Q_Score":0,"Tags":"c++,python","A_Id":2257420,"CreationDate":"2010-02-13T12:09:00.000","Title":"How do I do os.getpid() 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},{"Question":"I know Eclipse + PyDev has an option Run As => 3 Python Coverage. But all it reports is:\n\nRan 6 tests in 0.001s\nOK\n\nAnd it says nothing about code coverage. How to get a code coverage report in Pydev?","AnswerCount":3,"Available Count":2,"Score":1.0,"is_accepted":false,"ViewCount":12234,"Q_Id":2262777,"Users Score":8,"Answer":"Note that in pydev 2.0, the coverage support changed, now, you should first open the coverage view and select the 'enable code coverage for new launches'... after that, any launch you do (regular or unit-test) will have coverage information being gathered (and the results inspection also became a bit more intuitive).","Q_Score":13,"Tags":"python,eclipse,code-coverage,pydev","A_Id":5648086,"CreationDate":"2010-02-14T21:07:00.000","Title":"How to get unit test coverage results in Eclipse + 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":0,"Web Development":0},{"Question":"I know Eclipse + PyDev has an option Run As => 3 Python Coverage. But all it reports is:\n\nRan 6 tests in 0.001s\nOK\n\nAnd it says nothing about code coverage. How to get a code coverage report in Pydev?","AnswerCount":3,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":12234,"Q_Id":2262777,"Users Score":14,"Answer":"Run a file with \"Python Coverage\"\nWindow > Show View > Code Coverage Results View\nSelect the directory in which the executed file is\nDouble-click on the executed file in the file list\nStatistics are now at the right, not executed lines are marked red in the code view\n\nActually this is a really nice feature, didn't know about it before :)","Q_Score":13,"Tags":"python,eclipse,code-coverage,pydev","A_Id":2262839,"CreationDate":"2010-02-14T21:07:00.000","Title":"How to get unit test coverage results in Eclipse + 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":0,"Web Development":0},{"Question":"I have edited about 100 html files locally, and now I want to push them to my live server, which I can only access via ftp.\nThe HTML files are in many different directories, but hte directory structure on the remote machine is the same as on the local machine.\nHow can I recursively descend from my top-level directory ftp-ing all of the .html files to the corresponding directory\/filename on the remote machine?\nThanks!","AnswerCount":4,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":409,"Q_Id":2263782,"Users Score":0,"Answer":"umm, maybe by pressing F5 in mc for linux or total commander for windows?","Q_Score":0,"Tags":"python,networking,scripting,ftp","A_Id":2263804,"CreationDate":"2010-02-15T02:37:00.000","Title":"How to upload all .html files to a remote server using FTP and preserving file structure?","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},{"Question":"I have edited about 100 html files locally, and now I want to push them to my live server, which I can only access via ftp.\nThe HTML files are in many different directories, but hte directory structure on the remote machine is the same as on the local machine.\nHow can I recursively descend from my top-level directory ftp-ing all of the .html files to the corresponding directory\/filename on the remote machine?\nThanks!","AnswerCount":4,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":409,"Q_Id":2263782,"Users Score":0,"Answer":"if you have a mac, you can try cyberduck. It's good for syncing remote directory structures via ftp.","Q_Score":0,"Tags":"python,networking,scripting,ftp","A_Id":2299546,"CreationDate":"2010-02-15T02:37:00.000","Title":"How to upload all .html files to a remote server using FTP and preserving file structure?","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},{"Question":"Python is the nicest language I currently know of, but static typing is a big advantage due to auto-completion (although there is limited support for dynamic languages, it is nothing compared to that supported in static). I'm curious if there are any languages which try to add the benefits of Python to a statically typed language. In particular I'm interesting in languages with features like:\n\nSyntax support: such as that for dictionaries, array comprehensions\nFunctions: Keyword arguments, closures, tuple\/multiple return values\nRuntime modification\/creation of classes\nAvoidance of specifying classes everywhere (in Python this is due to duck typing, although type inference would work better in a statically typed language)\nMetaprogramming support: This is achieved in Python through reflection, annotations and metaclasses\n\nAre there any statically typed languages with a significant number of these features?","AnswerCount":12,"Available Count":3,"Score":0.0831409664,"is_accepted":false,"ViewCount":12408,"Q_Id":2264889,"Users Score":5,"Answer":"The Go programming language. I've seen some similar paradigm.","Q_Score":49,"Tags":"python,programming-languages","A_Id":2269524,"CreationDate":"2010-02-15T09:17:00.000","Title":"What statically typed languages are similar 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},{"Question":"Python is the nicest language I currently know of, but static typing is a big advantage due to auto-completion (although there is limited support for dynamic languages, it is nothing compared to that supported in static). I'm curious if there are any languages which try to add the benefits of Python to a statically typed language. In particular I'm interesting in languages with features like:\n\nSyntax support: such as that for dictionaries, array comprehensions\nFunctions: Keyword arguments, closures, tuple\/multiple return values\nRuntime modification\/creation of classes\nAvoidance of specifying classes everywhere (in Python this is due to duck typing, although type inference would work better in a statically typed language)\nMetaprogramming support: This is achieved in Python through reflection, annotations and metaclasses\n\nAre there any statically typed languages with a significant number of these features?","AnswerCount":12,"Available Count":3,"Score":0.0166651236,"is_accepted":false,"ViewCount":12408,"Q_Id":2264889,"Users Score":1,"Answer":"Autocompletion is still possible in a dynamically typed language; nothing prevents the IDE from doing type inference or inspection, even if the language implementation doesn't.","Q_Score":49,"Tags":"python,programming-languages","A_Id":2265030,"CreationDate":"2010-02-15T09:17:00.000","Title":"What statically typed languages are similar 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},{"Question":"Python is the nicest language I currently know of, but static typing is a big advantage due to auto-completion (although there is limited support for dynamic languages, it is nothing compared to that supported in static). I'm curious if there are any languages which try to add the benefits of Python to a statically typed language. In particular I'm interesting in languages with features like:\n\nSyntax support: such as that for dictionaries, array comprehensions\nFunctions: Keyword arguments, closures, tuple\/multiple return values\nRuntime modification\/creation of classes\nAvoidance of specifying classes everywhere (in Python this is due to duck typing, although type inference would work better in a statically typed language)\nMetaprogramming support: This is achieved in Python through reflection, annotations and metaclasses\n\nAre there any statically typed languages with a significant number of these features?","AnswerCount":12,"Available Count":3,"Score":0.0665680765,"is_accepted":false,"ViewCount":12408,"Q_Id":2264889,"Users Score":4,"Answer":"Rpython is a subset of Python that is statically typed.","Q_Score":49,"Tags":"python,programming-languages","A_Id":13959384,"CreationDate":"2010-02-15T09:17:00.000","Title":"What statically typed languages are similar 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},{"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},{"Question":"I need to access the Scripts and tcl sub-directories of the currently executing Python instance's installation directory on Windows.\nWhat is the best way to locate these directories?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":590,"Q_Id":2276512,"Users Score":0,"Answer":"Hmm, find the Lib dir from sys.path and extrapolate from there?","Q_Score":1,"Tags":"python,windows,installation,path,python-3.x","A_Id":2276543,"CreationDate":"2010-02-16T21:31:00.000","Title":"Path of current Python 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":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have a big library written in C++ and someone created an interface to use it in python (2.6) in an automatic way. Now I have a lot of classes with getter and setter methods. Really: I hate them.\nI want to re-implement the classes with a more pythonic interface using properties. The problem is that every class has hundreds of getters and setters and I have a lot of classes. How can I automatically create properties? \nFor example, if I have a class called MyClass with a GetX() and SetX(x), GetY, SetY, etc... methods, how can I automatically create a derived class MyPythonicClass with the property X (readable if there is the getter and writable if there is the setter), and so on? I would like a mechanism that lets me to choose to skip some getter\/setter couples where it is better to do the work by hand.","AnswerCount":4,"Available Count":1,"Score":0.049958375,"is_accepted":false,"ViewCount":2591,"Q_Id":2276800,"Users Score":1,"Answer":"Be careful using magic, especially magically altering other people's bindings. This has the disadvantages that \n\nYour code is incompatible with other people accessing the same library. Someone can't import one of your modules or copy and paste your code and have it work perfectly with their program accessing the same library, and\nYour interface is different from the interface to the C++ code. This would make sense if your wrapper gave you a nicer, higher-level interface, but your changes are only trivial. \n\nConsider whether it wouldn't make more sense just to deal with the library you are using as it came to you.","Q_Score":4,"Tags":"python,properties,metaprogramming,automatic-properties","A_Id":2277257,"CreationDate":"2010-02-16T22:18:00.000","Title":"Automatic transformation from getter\/setter to properties","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am an experienced Perl developer with some degree of experience and\/or familiarity with other languages (working experience with C\/C++, school experience with Java and Scheme, and passing familiarity with many others).\nI might need to get some web work done in Python (most immediately, related to Google App Engine). As such, I'd like to ask SO overmind for good references on how to best learn Python for someone who's coming from Perl background (e.g. the emphasis would be on differences between the two and how to translate perl idiomatics into Python idiomatics, as opposed to generic Python references). Something also centered on Web development is even better.\nI'll take anything - articles, tutorials, books, sample apps?\nThanks!","AnswerCount":7,"Available Count":2,"Score":1.0,"is_accepted":false,"ViewCount":24062,"Q_Id":2283034,"Users Score":9,"Answer":"Being a hardcore Perl programmer, all I can say is DO NOT BUY O'Reilly's \"Learning Python\". It is nowhere NEAR as good as \"Learning Perl\", and there's no equivalent I know of to Larry Wall's \"Programming Perl\", which is simply unbeatable.\nI've had the most success taking past Perl programs and translating them into Python, trying to make use of as many new techniques as possible.","Q_Score":55,"Tags":"python,perl","A_Id":2286686,"CreationDate":"2010-02-17T17:43:00.000","Title":"Python for a Perl programmer","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am an experienced Perl developer with some degree of experience and\/or familiarity with other languages (working experience with C\/C++, school experience with Java and Scheme, and passing familiarity with many others).\nI might need to get some web work done in Python (most immediately, related to Google App Engine). As such, I'd like to ask SO overmind for good references on how to best learn Python for someone who's coming from Perl background (e.g. the emphasis would be on differences between the two and how to translate perl idiomatics into Python idiomatics, as opposed to generic Python references). Something also centered on Web development is even better.\nI'll take anything - articles, tutorials, books, sample apps?\nThanks!","AnswerCount":7,"Available Count":2,"Score":-1.0,"is_accepted":false,"ViewCount":24062,"Q_Id":2283034,"Users Score":-4,"Answer":"I wouldn't try to compare Perl and Python too much in order to learn Python, especially since you have working knowledge of other languages. If you are unfamiliar with OOP\/Functional programming aspects and just looking to work procedurally like in Perl, start learning the Python language constructs \/ syntax and then do a couple examples. if you are making a switch to OO or functional style paradigms, I would read up on OO fundamentals first, then start on Python syntax and examples...so you have a sort of mental blueprint of how things can be constructed before you start working with the actual materials. this is just my humble opinion however..","Q_Score":55,"Tags":"python,perl","A_Id":2283093,"CreationDate":"2010-02-17T17:43:00.000","Title":"Python for a Perl programmer","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":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},{"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},{"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},{"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},{"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},{"Question":"What is the best way in python find the process name and owner?\nNow i use WMI, but this version is too slow.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":325,"Q_Id":2299627,"Users Score":0,"Answer":"Process name: is sys.argv[0] not sufficient for your purposes?","Q_Score":0,"Tags":"python,windows,wmi","A_Id":2505040,"CreationDate":"2010-02-19T21:15:00.000","Title":"python and process","Data Science and Machine Learning":0,"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},{"Question":"If Python was so fast as C, the latter would be present in python apps\/libraries?\nExample: if Python was fast as C would PIL be written completely in Python?","AnswerCount":4,"Available Count":3,"Score":0.0996679946,"is_accepted":false,"ViewCount":196,"Q_Id":2303683,"Users Score":2,"Answer":"It makes sense to use C modules in Python for:\n\nPerformance\nLibraries that won't be ported to Python (because of performance reasons, for example) or that use OS-specific functions\nScripting. For example, many games use Python, Lua and other languages as scripting languages. Therefore they expose C\/C++ functions to Python.\n\nAs to your example: Yes, but Python is inherently slower than C. If both were equally fast, it would make sense to use Python because C code is often more prone to attacks (buffer overflows and stuff).","Q_Score":1,"Tags":"python,c,performance,bytecode","A_Id":2303703,"CreationDate":"2010-02-20T20:55:00.000","Title":"Is there any purpose for a python application use C other than performance?","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},{"Question":"If Python was so fast as C, the latter would be present in python apps\/libraries?\nExample: if Python was fast as C would PIL be written completely in Python?","AnswerCount":4,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":196,"Q_Id":2303683,"Users Score":0,"Answer":"To access hardware.","Q_Score":1,"Tags":"python,c,performance,bytecode","A_Id":2303876,"CreationDate":"2010-02-20T20:55:00.000","Title":"Is there any purpose for a python application use C other than performance?","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},{"Question":"If Python was so fast as C, the latter would be present in python apps\/libraries?\nExample: if Python was fast as C would PIL be written completely in Python?","AnswerCount":4,"Available Count":3,"Score":1.2,"is_accepted":true,"ViewCount":196,"Q_Id":2303683,"Users Score":7,"Answer":"To access \"legacy\" C libraries and OS facilities.","Q_Score":1,"Tags":"python,c,performance,bytecode","A_Id":2303685,"CreationDate":"2010-02-20T20:55:00.000","Title":"Is there any purpose for a python application use C other than performance?","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},{"Question":"Could you provide a regex that match Twitter usernames?\nExtra bonus if a Python example is provided.","AnswerCount":11,"Available Count":2,"Score":0.0363476168,"is_accepted":false,"ViewCount":35359,"Q_Id":2304632,"Users Score":2,"Answer":"The only characters accepted in the form are A-Z, 0-9, and underscore. Usernames are not case-sensitive, though, so you could use r'@(?i)[a-z0-9_]+' to match everything correctly and also discern between users.","Q_Score":46,"Tags":"python,regex,twitter","A_Id":2304704,"CreationDate":"2010-02-21T03:19:00.000","Title":"regex for Twitter username","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Could you provide a regex that match Twitter usernames?\nExtra bonus if a Python example is provided.","AnswerCount":11,"Available Count":2,"Score":0.0181798149,"is_accepted":false,"ViewCount":35359,"Q_Id":2304632,"Users Score":1,"Answer":"Shorter, \/@([\\w]+)\/ works fine.","Q_Score":46,"Tags":"python,regex,twitter","A_Id":2330440,"CreationDate":"2010-02-21T03:19:00.000","Title":"regex for Twitter username","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"How can I get the IMEI number of a mobile phone using Python?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2251,"Q_Id":2309108,"Users Score":0,"Answer":"Sending AT+CGSN through the appropriate serial device will have it return the IMEI.","Q_Score":0,"Tags":"python,mobile-phones,imei","A_Id":2309202,"CreationDate":"2010-02-22T06:02:00.000","Title":"IMEI number of a mobile phone 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},{"Question":"I have quite a lot of C++ legacy code modules from my colleagues, unfortunately poorly written. Each is doing a different job, but they are all GNU C++ code running under Linux. \nI want to write a controller program, to make a singular C++ module for a workflow, for a very urgent demo. Also I need to write a front-end web-app allowing clients submitting jobs to the controller. \nMy main criteria are:\n\ndevelopment speed (very urgent demo)\ngood binding with C++ (I have legacy code I do not want to rewrite in another language)\nsmooth introduction of new programming language to team (has some python, java and perl knowledge)\n\nWhat programming language fits my needs best, and why?\nDetails:\nI lean towards python for its perfect binding with C++, as writing JNI is too much work, and kind of obsolete nowadays. However, no one in my team is Python programmer; I do know some Python (no experience in server side programming at all). I have been developing Java EE apps last year, but I do not think JNI is a good solution. Only one team member knows some Perl, others are pure C++ programmers.","AnswerCount":3,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":317,"Q_Id":2313017,"Users Score":0,"Answer":"I would use Python. You could write very basic wrappers using the Python C API and then call said functions from Python with relative ease.","Q_Score":1,"Tags":"java,python,programming-languages,binding,java-native-interface","A_Id":2313266,"CreationDate":"2010-02-22T18:11:00.000","Title":"Programming language decision for C++ legacy project workflow","Data Science and Machine Learning":0,"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},{"Question":"I have quite a lot of C++ legacy code modules from my colleagues, unfortunately poorly written. Each is doing a different job, but they are all GNU C++ code running under Linux. \nI want to write a controller program, to make a singular C++ module for a workflow, for a very urgent demo. Also I need to write a front-end web-app allowing clients submitting jobs to the controller. \nMy main criteria are:\n\ndevelopment speed (very urgent demo)\ngood binding with C++ (I have legacy code I do not want to rewrite in another language)\nsmooth introduction of new programming language to team (has some python, java and perl knowledge)\n\nWhat programming language fits my needs best, and why?\nDetails:\nI lean towards python for its perfect binding with C++, as writing JNI is too much work, and kind of obsolete nowadays. However, no one in my team is Python programmer; I do know some Python (no experience in server side programming at all). I have been developing Java EE apps last year, but I do not think JNI is a good solution. Only one team member knows some Perl, others are pure C++ programmers.","AnswerCount":3,"Available Count":3,"Score":0.1325487884,"is_accepted":false,"ViewCount":317,"Q_Id":2313017,"Users Score":2,"Answer":"Given the urgency, I'd have to stick with C++.\nWithout that, I'd say keep what you got, but feel free to switch to a preferred language when refactoring. That would be the time to do it. \nWhat you should not do, ever, is \"port\" anything to another language without rewriting or changing functionality in any way. It is a total waste of time, when the \"best\" outcome you can hope for is that it has no new bugs when you are done.","Q_Score":1,"Tags":"java,python,programming-languages,binding,java-native-interface","A_Id":2313312,"CreationDate":"2010-02-22T18:11:00.000","Title":"Programming language decision for C++ legacy project workflow","Data Science and Machine Learning":0,"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},{"Question":"I have quite a lot of C++ legacy code modules from my colleagues, unfortunately poorly written. Each is doing a different job, but they are all GNU C++ code running under Linux. \nI want to write a controller program, to make a singular C++ module for a workflow, for a very urgent demo. Also I need to write a front-end web-app allowing clients submitting jobs to the controller. \nMy main criteria are:\n\ndevelopment speed (very urgent demo)\ngood binding with C++ (I have legacy code I do not want to rewrite in another language)\nsmooth introduction of new programming language to team (has some python, java and perl knowledge)\n\nWhat programming language fits my needs best, and why?\nDetails:\nI lean towards python for its perfect binding with C++, as writing JNI is too much work, and kind of obsolete nowadays. However, no one in my team is Python programmer; I do know some Python (no experience in server side programming at all). I have been developing Java EE apps last year, but I do not think JNI is a good solution. Only one team member knows some Perl, others are pure C++ programmers.","AnswerCount":3,"Available Count":3,"Score":1.2,"is_accepted":true,"ViewCount":317,"Q_Id":2313017,"Users Score":3,"Answer":"Noting the \"very urgent demo\" part, assuming that that would take about a month, depending on the complexity, I'd stick to the familiar.\nTrue, maintaining python would be easier in the end, and learning python should be a breeze, if you deem it viable.\nI'd say, have the team learn python and do the basic stuff, as you learn the deeper parts, you could build classes for them to extend\/implement. That way, you get things done as they learn.","Q_Score":1,"Tags":"java,python,programming-languages,binding,java-native-interface","A_Id":2313159,"CreationDate":"2010-02-22T18:11:00.000","Title":"Programming language decision for C++ legacy project workflow","Data Science and Machine Learning":0,"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},{"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},{"Question":"I've a name of a class stored in var, which I need to create an object from.\nHowever I do not know in which module it is defined (if I did, I would just call getattr(module,var), but I do know it's imported.\nShould I go over every module and test if the class is defined there ? How do I do it in python ?\nWhat if I have the module + class in the same var, how can I create an object from it ? (ie var = 'module.class')\nCheers,\nZe","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":389,"Q_Id":2318044,"Users Score":0,"Answer":"Classes are not added to a global registry in Python by default. You'll need to iterate over all imported modules and look for it.","Q_Score":1,"Tags":"python,ruby,module,metaprogramming","A_Id":2318065,"CreationDate":"2010-02-23T12:29:00.000","Title":"Python equivalent for Ruby's ObjectSpace?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"In general I want to disable as little code as possible, and I want it to be explicit: I don't want the code being tested to decide whether it's a test or not, I want the test to tell that code \"hey, BTW, I'm running a unit test, can you please not make your call to solr, instead can you please stick what you would send to solr in this spot so I can check it\". I have my ideas but I don't like any of them, I am hoping that there's a good pythonic way to do this.","AnswerCount":6,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2347,"Q_Id":2320210,"Users Score":0,"Answer":"I know it's the typical use case for mock objects, but that's also an old argument... are Mock objects necessary at all or are they evil ?\nI'm on the side of those who believe mocks are evil and would try to avoid changing tested code at all. I even believe such need to modify tested code is a code smell...\nIf you wish to change or intercept an internal function call for testing purpose you could also make this function an explicit external dependency set at instanciation time that would be provided both by your production code and test code. If you do that the problem disappear and you end up with a cleaner interface.\nNote that doing that there is not need to change the tested code at all neither internally nor by the test being performed.","Q_Score":10,"Tags":"python,unit-testing,testing,dependency-injection","A_Id":2320900,"CreationDate":"2010-02-23T17:20:00.000","Title":"In Python, what's a good pattern for disabling certain code during 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":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I know that with the SimpleHTTPServer I can make my directories accessible by web-browsers via Internet. So, I run just one line of the code and, as a result, another person working on another computer can use his\/her browser to see content of my directories.\nBut I wander if I can make more complicated things. For example, somebody uses his\/her browser to load my Python program with a set of parameter (example.py?x=2&y=2) and, as a result, he\/she sees the HTML page generated by the Python program (not the Python program).\nI also wander if I can process html form submitted to the SimpleHTTPServer.","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":7811,"Q_Id":2321813,"Users Score":0,"Answer":"have you considered using CGIHTTPServer instead of SimpleHTTPServer? Then you can toss your scripts in cgi-bin and they'll execute. You have to include content-type header and whatnot but if you're looking for quick and dirty it's real convenient","Q_Score":1,"Tags":"python,post,get,webserver,simplehttpserver","A_Id":8673542,"CreationDate":"2010-02-23T21:19:00.000","Title":"Is it possible to write dynamic web pages in Python with the Really Simple HTTP 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},{"Question":"Is there an active Python-Chat?","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":465,"Q_Id":2325938,"Users Score":0,"Answer":"My guess is that you are looking for a IRC channel? well this is not related to programming so you should not be posting that question here?\nany way quakenet has a python channel","Q_Score":1,"Tags":"python,chat,irc","A_Id":2325967,"CreationDate":"2010-02-24T12:32:00.000","Title":"Is there an active Python-Chat?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"do you know\/have you tried any code protection system which works with IronPython assemblies? Can you list it\/them here?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":159,"Q_Id":2325971,"Users Score":1,"Answer":"since iron python compiles to IL I would imagine you can use the same obfuscations tools such as DotFuscator. \nAre you using the pyc tool included in iron pythons tool folder?","Q_Score":0,"Tags":"asp.net,ironpython","A_Id":2326011,"CreationDate":"2010-02-24T12:37:00.000","Title":"Code protection system which works with IronPython assemblies?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I am working with a very large (~11GB) text file on a Linux system. I am running it through a program which is checking the file for errors. Once an error is found, I need to either fix the line or remove the line entirely. And then repeat...\nEventually once I'm comfortable with the process, I'll automate it entirely. For now however, let's assume I'm running this by hand.\nWhat would be the fastest (in terms of execution time) way to remove a specific line from this large file? I thought of doing it in Python...but would be open to other examples. The line might be anywhere in the file.\nIf Python, assume the following interface:\ndef removeLine(filename, lineno):\nThanks,\n-aj","AnswerCount":9,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":16660,"Q_Id":2329417,"Users Score":0,"Answer":"I think there was a somewhat similar if not exactly the same type of question asked here. Reading (and writing) line by line is slow, but you can read a bigger chunk into memory at once, go through that line by line skipping lines you don't want, then writing this as a single chunk to a new file. Repeat until done. Finally replace the original file with the new file.\nThe thing to watch out for is when you read in a chunk, you need to deal with the last, potentially partial line you read, and prepend that into the next chunk you read.","Q_Score":25,"Tags":"python,optimization","A_Id":2330250,"CreationDate":"2010-02-24T20:51:00.000","Title":"Fastest Way to Delete a Line from Large 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":0,"Web Development":0},{"Question":"I am working with a very large (~11GB) text file on a Linux system. I am running it through a program which is checking the file for errors. Once an error is found, I need to either fix the line or remove the line entirely. And then repeat...\nEventually once I'm comfortable with the process, I'll automate it entirely. For now however, let's assume I'm running this by hand.\nWhat would be the fastest (in terms of execution time) way to remove a specific line from this large file? I thought of doing it in Python...but would be open to other examples. The line might be anywhere in the file.\nIf Python, assume the following interface:\ndef removeLine(filename, lineno):\nThanks,\n-aj","AnswerCount":9,"Available Count":2,"Score":0.022218565,"is_accepted":false,"ViewCount":16660,"Q_Id":2329417,"Users Score":1,"Answer":"If the lines are variable length then I don't believe that there is a better algorithm than reading the file line by line and writing out all lines, except for the one(s) that you do not want.\nYou can identify these lines by checking some criteria, or by keeping a running tally of lines read and suppressing the writing of the line(s) that you do not want.\nIf the lines are fixed length and you want to delete specific line numbers, then you may be able to use seek to move the file pointer... I doubt you're that lucky though.","Q_Score":25,"Tags":"python,optimization","A_Id":2329515,"CreationDate":"2010-02-24T20:51:00.000","Title":"Fastest Way to Delete a Line from Large 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":0,"Web Development":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},{"Question":"As far as I read, Django only supports sending mails using SMTP.\nI would like to send Emails from my script in Django, but do not want to setup SMTP server (it's too complex for me, I'm a linux newbie).\nIs it possible, to send mails in Django in the same way like I do it in PHP, without providing SMTP login, password and etc?","AnswerCount":5,"Available Count":1,"Score":0.0798297691,"is_accepted":false,"ViewCount":7844,"Q_Id":2335384,"Users Score":2,"Answer":"So how does PHP do it? By magic?\nIf you don't have an SMTP server, sign up for a GMail account and use that.","Q_Score":8,"Tags":"python,django,email","A_Id":2335399,"CreationDate":"2010-02-25T15:56:00.000","Title":"Send Email in Django without SMTP server. Like php mail() function does","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"We are working on Arabic Natural Language Processing project, we have limited our choices to either write the code in Python or C++ (and Boost library). We are thinking of these points:\n\nPython\n\nSlower than C++ (There is ongoing work to make Python faster)\nBetter UTF8 support\nFaster in writing tests and trying different algorithms\n\nC++\n\nFaster than Python\nFamiliar code, every programmer knows C or C-like code\n\n\nAfter the project is done, it should be not very hard to port the project to another programming languages.\nWhat do you think is better and suitable for the project?","AnswerCount":5,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":4180,"Q_Id":2344081,"Users Score":0,"Answer":"IMO go for C\/C++ simply because of the 'familiar' factor. Though LOC's will be more in C\/C++ you will save time in understanding and testing.","Q_Score":3,"Tags":"c++,python,boost,nlp","A_Id":7779679,"CreationDate":"2010-02-26T18:56:00.000","Title":"NLP project, python or 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":0,"Web Development":0},{"Question":"We are working on Arabic Natural Language Processing project, we have limited our choices to either write the code in Python or C++ (and Boost library). We are thinking of these points:\n\nPython\n\nSlower than C++ (There is ongoing work to make Python faster)\nBetter UTF8 support\nFaster in writing tests and trying different algorithms\n\nC++\n\nFaster than Python\nFamiliar code, every programmer knows C or C-like code\n\n\nAfter the project is done, it should be not very hard to port the project to another programming languages.\nWhat do you think is better and suitable for the project?","AnswerCount":5,"Available Count":2,"Score":0.0798297691,"is_accepted":false,"ViewCount":4180,"Q_Id":2344081,"Users Score":2,"Answer":"Familiar code, every programmer knows C or C-like code\n\nMany devs are familiar with C or C-like code, it doesn't make them C++ compliant.\nUnexperienced C++ devs can do a lot of harm to such a complex project and you would have to take extra care.\nI can't speak for python but I heard it's more beginner-friendly.\nI'd say, once again, you should go for the language you (as a team) know best.","Q_Score":3,"Tags":"c++,python,boost,nlp","A_Id":2344099,"CreationDate":"2010-02-26T18:56:00.000","Title":"NLP project, python or 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":0,"Web Development":0},{"Question":"What is the latest way to write Python tests? What modules\/frameworks to use?\nAnd another question: are doctest tests still of any value? Or should all the tests be written in a more modern testing framework?\nThanks, Boda Cydo.","AnswerCount":5,"Available Count":2,"Score":1.0,"is_accepted":false,"ViewCount":2407,"Q_Id":2352516,"Users Score":9,"Answer":"Using the built-in unittest module is as relevant and easy as ever. The other unit testing options, py.test,nose, and twisted.trial are mostly compatible with unittest. \nDoctests are of the same value they always were\u2014they are great for testing your documentation, not your code. If you are going to put code examples in your docstrings, doctest can assure you keep them correct and up to date. There's nothing worse than trying to reproduce an example and failing, only to later realize it was actually the documentation's fault.","Q_Score":12,"Tags":"python,testing","A_Id":2352607,"CreationDate":"2010-02-28T20:22:00.000","Title":"How to write modern Python 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},{"Question":"What is the latest way to write Python tests? What modules\/frameworks to use?\nAnd another question: are doctest tests still of any value? Or should all the tests be written in a more modern testing framework?\nThanks, Boda Cydo.","AnswerCount":5,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":2407,"Q_Id":2352516,"Users Score":0,"Answer":"The important thing to remember about doctests is that the tests are based on string comparisons, and the way that numbers are rendered as strings will vary on different platforms and even in different python interpreters.\nMost of my work deals with computations, so I use doctests only to test my examples and my version string. I put a few in the __init__.py since that will show up as the front page of my epydoc-generated API documentation.\nI use nose for testing, although I'm very interested in checking out the latest changes to py.test.","Q_Score":12,"Tags":"python,testing","A_Id":2353883,"CreationDate":"2010-02-28T20:22:00.000","Title":"How to write modern Python 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},{"Question":"I'm currently planning out a web app that I want to host for people and allow them to host themselves on either Linux\/Apache of IIS6 or IIS7 (for the benefits of bandwidth, directory services [login, etc.]). \nI see that PHP is supported on both platforms. I've heard people serving Django and Python in IIS using PyISAPIe. I'm not sure about Ruby\/Rails on IIS until IronRuby ships. I don't have much Perl experience but understand it would run in IIS as well.\nAnyone have input for me? Thanks in advance.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":1120,"Q_Id":2359314,"Users Score":0,"Answer":"I have several production php5\/6 applications that run on either windows\/iis and apache\/linux. switching between platforms has not been an issue for me. i test on a windows server talking to a mysql db on a linux machine. i deploy to a linux web server without issue. i cannot speak for rails or pytong as i'm not a ruby or python guy. however, they should work fine from what i understand of them. if i were you i'd pick the language you have the most experience with.","Q_Score":1,"Tags":"php,python,apache,iis","A_Id":2359411,"CreationDate":"2010-03-01T21:49:00.000","Title":"Compatibility with IIS and Apache -- PHP, Python, etc?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I'm currently planning out a web app that I want to host for people and allow them to host themselves on either Linux\/Apache of IIS6 or IIS7 (for the benefits of bandwidth, directory services [login, etc.]). \nI see that PHP is supported on both platforms. I've heard people serving Django and Python in IIS using PyISAPIe. I'm not sure about Ruby\/Rails on IIS until IronRuby ships. I don't have much Perl experience but understand it would run in IIS as well.\nAnyone have input for me? Thanks in advance.","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":1120,"Q_Id":2359314,"Users Score":0,"Answer":"Your lowest common denominator for building apps to seemlessly run on both the LAMP and Microsoft stacks is PHP.\nPerl is another option, it's well supported on both Windows and Linux\/Apache. But I think I'd be choosing PHP over Perl because of support for FastCGI which improves reliability and performance on the Windows stack. Microsoft and Zend have been doing a lot of work on PHP for Windows so that you can write PHP apps and confidently expect them to run well on both platforms. The proof of the pudding of this is that Joomla, WordPress, phpBBS and many other of the well known open source PHP applications run straight out of the box on Windows. \nAlso as a developer and third line support engineer for a shared web hosting company, with a fair bit of experience in this area, I'd say that PHP on Windows is every bit as flexible, performant and reliable as PHP on the LAMP stack.\nFinally, Ruby on Rails and Python\/DJango aren't well supported options on IIS and will be non-existant on shared hosting platforms. This is mostly due to the amount of console access you'd need to knock things into shape to be able to run Rails\/DJango.","Q_Score":1,"Tags":"php,python,apache,iis","A_Id":2359605,"CreationDate":"2010-03-01T21:49:00.000","Title":"Compatibility with IIS and Apache -- PHP, Python, etc?","Data Science and Machine Learning":0,"Database and SQL":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},{"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},{"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},{"Question":"I am looking for example where things in python would be easier to program just because it is dynamically typed? \nI want to compare it with Haskell type system because its static typing doesn't get in the way like c# or java. Can I program in Haskell as I can in python without static typing being a hindrance? \nPS: I am a python user and have played around little bit with ML and Haskell.. ... I hope it is clear now..","AnswerCount":3,"Available Count":2,"Score":1.0,"is_accepted":false,"ViewCount":1567,"Q_Id":2365783,"Users Score":7,"Answer":"Can I program in Haskell as I can in python without static typing being a hindrance\n\nYes. \nTo elaborate, I would say the main gotcha will be the use of existential types in Haskell for heterogeneous data structures (regular data structures holding lists of variously typed elements). This often catches OO people used to a top \"Object\" type. It often catches Lisp\/Scheme programmers. But I'm not sure it will matter to a Pythonista.\nTry to write some Haskell, and come back when you get a confusing type error.\nYou should think of static typing as a benefit -- it checks a lot of things for you, and the more you lean on it, the less things you have to test for. In addition, it enables the compiler to make your code much faster.","Q_Score":2,"Tags":"python,dynamic,haskell,static,types","A_Id":2365869,"CreationDate":"2010-03-02T18:48:00.000","Title":"haskell vs python typing","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am looking for example where things in python would be easier to program just because it is dynamically typed? \nI want to compare it with Haskell type system because its static typing doesn't get in the way like c# or java. Can I program in Haskell as I can in python without static typing being a hindrance? \nPS: I am a python user and have played around little bit with ML and Haskell.. ... I hope it is clear now..","AnswerCount":3,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":1567,"Q_Id":2365783,"Users Score":5,"Answer":"Well for one you can't create a list containing multiple types of values without wrappers (like to get a list that may contain a string or an int, you'd have to create a list of Either Int String and wrap each item in a Left or a Right).\nYou also can't define a function that may return multiple types of values (like if someCondition then 1 else \"this won't compile\"), again, without using wrappers.","Q_Score":2,"Tags":"python,dynamic,haskell,static,types","A_Id":2365873,"CreationDate":"2010-03-02T18:48:00.000","Title":"haskell vs python typing","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am searching for a python package that I can use to simulate molecular dynamics in non-equilibrium situations. I need a setup that can handle a fairly large number of molecules in a primarily kinetic theory manner, and that can handle having solid surfaces present. With regards to the surfaces, I would need to be able to create arbitrary shapes and monitor pressure and other variables resulting from the molecular action. Alternatively, I could add the surface parts myself if I had molecules that could handle it.\nDoes anyone know of any packages that might be suitable?","AnswerCount":7,"Available Count":1,"Score":0.057080742,"is_accepted":false,"ViewCount":7273,"Q_Id":2368671,"Users Score":2,"Answer":"Lampps and gromacs are two well known molecular dynamics codes. These codes both have some python based wrapper stuff, but I am not sure how much functionality the wrappers expose. They may not give you enough control over the simulation.\nGoogle for \"GromacsWrapper\" or google for \"lammps\" and \"pizza.py\"\nDigital material and ASE are two molecular dynamics codes that expose a lot of functionality, but last time I looked, they were both fairly specialized. They may not allow you to use the force potentials that you want\nGoogle for \"digital material\" and \"cornell\" or google for \"ase\" and dtu\nNote to MJV: Normal MD-codes take one time step at a time, and they move all particles in each time step. Most of the time is spend calculating the total force on each atom. This involves iterating over a list of pairs of neighboring atoms. I think the best idea is to do the force calculation and a few more basics in c++ or fortran and then wrap that functionality in python. (But it could be fun to see how far one can get by using numpy matrices)","Q_Score":9,"Tags":"python,packages,simulation,physics,kinematics","A_Id":2369508,"CreationDate":"2010-03-03T04:06:00.000","Title":"Simulation of molecular dynamics 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},{"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},{"Question":"Is there some way (using the standard Django.test.TestCase framework) to perform a global initialization of certain variables, so that it only happens once.\nPutting things setUp() makes it so that the variables are initialized before each test, which kills performance when the setup involves expensive operations. I'd like to run a setup type feature once, and then have the variables initialized here be visible to all my tests.\nI'd prefer not to rewrite the test runner framework.\nI am thinking of something similar to a before(:all) in the Ruby\/RSpec world.\n-S","AnswerCount":3,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":2735,"Q_Id":2374197,"Users Score":3,"Answer":"This is partially addressed in newer versions of python\/django by setUpClass() which will at least allow me to run class level setup.","Q_Score":12,"Tags":"python,django,testing","A_Id":17461581,"CreationDate":"2010-03-03T19:11:00.000","Title":"global set up in django test 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},{"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},{"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},{"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},{"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},{"Question":"thanks for helping me setting my cron jobs, crontab has really been a gold mine for me.\nUnfortunately I have a problem, and have no idea what so ever what it might be... basically a job does not start while the neighbour jobs do. I'll explain\n\nThis is my crontabs job list:\n\n*\/10 * * * * python \/webapps\/foo\/manage.py fetch_articles\n*\/10 * * * * python \/webapps\/bar\/manage.py fetch_books\n\nI wrote them as they are in a file and stored them using crontab \/path\/to\/file .\nChecked with crontab -l and the jobs are there.\n\nThe strange thing is that 1 of these executes every 10 minutes normally... but the other one does not. I tried typing in the command manually, and it works fine without a problem.\n\nDoes anyone have suggestions?\nHelp would be much appreciated, thanks guys.\n\nUpdate:\nI've been in the system log files and I found this:\n\nMar 5 02:50:01 localhost CRON[21652]: (root) CMD (python \/webapps\/foo\/manage.py fetch_books)\n\nDoes this mean crontab is calling the job fine?\n\nThanks for your replies guys!\n\nFIXED IT! thank you very much everyone!!\nThe problem was that the script silently failed, I believe it's due to the PYTHON_PATH changing due to where the script is called from... I'm entirely sure.","AnswerCount":3,"Available Count":2,"Score":0.2605204458,"is_accepted":false,"ViewCount":2936,"Q_Id":2384225,"Users Score":4,"Answer":"From the crontab manpage:\n\nBUGS\n Although cron requires that each entry in a crontab end in a\n newline character,\n neither the crontab command nor the cron daemon will detect this\n error. Instead,\n the crontab will appear to load normally. However, the command\n will never run.\n The best choice is to ensure that your crontab has a blank line at\n the end.\n\n(my emphasis).","Q_Score":1,"Tags":"python,linux,ubuntu,cron,crontab","A_Id":2384246,"CreationDate":"2010-03-05T02:40:00.000","Title":"Crontab job does not start... ideas?","Data Science and Machine Learning":0,"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},{"Question":"thanks for helping me setting my cron jobs, crontab has really been a gold mine for me.\nUnfortunately I have a problem, and have no idea what so ever what it might be... basically a job does not start while the neighbour jobs do. I'll explain\n\nThis is my crontabs job list:\n\n*\/10 * * * * python \/webapps\/foo\/manage.py fetch_articles\n*\/10 * * * * python \/webapps\/bar\/manage.py fetch_books\n\nI wrote them as they are in a file and stored them using crontab \/path\/to\/file .\nChecked with crontab -l and the jobs are there.\n\nThe strange thing is that 1 of these executes every 10 minutes normally... but the other one does not. I tried typing in the command manually, and it works fine without a problem.\n\nDoes anyone have suggestions?\nHelp would be much appreciated, thanks guys.\n\nUpdate:\nI've been in the system log files and I found this:\n\nMar 5 02:50:01 localhost CRON[21652]: (root) CMD (python \/webapps\/foo\/manage.py fetch_books)\n\nDoes this mean crontab is calling the job fine?\n\nThanks for your replies guys!\n\nFIXED IT! thank you very much everyone!!\nThe problem was that the script silently failed, I believe it's due to the PYTHON_PATH changing due to where the script is called from... I'm entirely sure.","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":2936,"Q_Id":2384225,"Users Score":1,"Answer":"I think ~unutbu's answer is probably correct if it's the second job that isn't running.\nHowever another thing to check is whether \/webapps\/bar\/manage.py requires exclusive access to any resources, eg network sockets\/tempfiles etc. Since you are starting 2 processes at the same time, you may be triggering a race condition.","Q_Score":1,"Tags":"python,linux,ubuntu,cron,crontab","A_Id":2384281,"CreationDate":"2010-03-05T02:40:00.000","Title":"Crontab job does not start... ideas?","Data Science and Machine Learning":0,"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},{"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},{"Question":"What's the simplest way to determine if a date is a U.S. bank holiday in Python? There seem to be various calendars and webservices listing holidays for various countries, but I haven't found anything specific to banks in the U.S.","AnswerCount":6,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":35484,"Q_Id":2394235,"Users Score":0,"Answer":"I should caution contributors from thinking this is all solvable by an algorithm. Three examples:\n\nmost Islamic holidays are lunar. The moon is predictable, some countries do this, but others explicitly require that the new moon be actually sighted in the country. Some even post people to the tops of tall mountains, tasked to try to spot the new moon. If the night is cloudy, the new moon may not be sighted, so the following day is not a holiday.\na committee in China meets around November each year to decide on the number of holidays that will be given for Chinese New Year in mainland China the following February. As an added complication, because there are so many public holidays given for Chinese New Year, the Chinese Government sometimes nominates weekends after the holiday as working days, to boost economic activity.\nstock exchanges in India sometimes have a very short trading period at a weekend for auspicious religious reasons.\n\nFor this reason, there are companies that do this research, get the updates, and publish holidays via an API, for a fee. Users typically query that API every day in case new holidays are announced.","Q_Score":30,"Tags":"python,date,bank","A_Id":70469423,"CreationDate":"2010-03-06T21:55:00.000","Title":"Detecting a US Holiday","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have no knowledge of Python. I started with .NET and than learned PHP. Someone later asked me to learn Ruby as well. I started learning it. Since last few months I am seeing many libraries and drivers written in Python. I want to know what are the advantages of Python over PHP\/Ruby? What type of language it is and is there a need to learn Python as well?\nWhich is the purest version of Python? I could see many variants there like IronPython etc.","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":98,"Q_Id":2395157,"Users Score":1,"Answer":"If you're just getting started in python, chances are the standard python distribution will work just fine. Once you get into the guts of your project, changing to IronPython (etc) is not a big deal.\nI think the most important part is the \"getting started\" piece. Start writing python and you'll never look back.","Q_Score":1,"Tags":"php,python,ruby","A_Id":2433699,"CreationDate":"2010-03-07T04:16:00.000","Title":"Python Libraries and drivers","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have no knowledge of Python. I started with .NET and than learned PHP. Someone later asked me to learn Ruby as well. I started learning it. Since last few months I am seeing many libraries and drivers written in Python. I want to know what are the advantages of Python over PHP\/Ruby? What type of language it is and is there a need to learn Python as well?\nWhich is the purest version of Python? I could see many variants there like IronPython etc.","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":98,"Q_Id":2395157,"Users Score":1,"Answer":"Nobody can tell you the exact answer because everybody has their own \"holy grail\". You will just have to find out for yourself which one suits you best for the task you want to perform. Case closed.","Q_Score":1,"Tags":"php,python,ruby","A_Id":2395204,"CreationDate":"2010-03-07T04:16:00.000","Title":"Python Libraries and drivers","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I would like to do the following:\n1) Serialize my class\n2) Also manually edit the serialization dump file to remove certain objects of my class which I find unnecessary.\nI am currently using python with simplejson. As you know, simplejson converts all characters to unicde. As a result, when I dump a particular object with simplejson, the unicode characters becomes something like that \"\\u00bd\" for \u597d. \nI am interested to manually edit the simplejson file for convenience. Anyone here know a work around for me to do this?\nMy requirements for this serialization format:\n1) Easy to use (just dump and load - done)\n2) Allows me to edit them manually without much hassle. \n3) Able to display chinese character \nI use vim. Does anyone know a way to conver \"\\u00bd\" to \u597d in vim?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":600,"Q_Id":2400088,"Users Score":0,"Answer":"If you want json\/simplejson to produce unicode output instead of str output with Unicode escapes then you need to pass ensure_ascii=False to dump()\/dumps(), then either encode before saving or use a file-like from codecs.","Q_Score":1,"Tags":"python,vim","A_Id":2401864,"CreationDate":"2010-03-08T08:37:00.000","Title":"Python: getting \\\\u00bd correctly in 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},{"Question":"I'm Delphi developer, and I would like to build few web applications, I know about Intraweb, but I think it's not a real tool for web development, maybe for just intranet applications\nso I'm considering PHP, Python or ruby, I prefer python because it's better syntax than other( I feel it closer to Delphi), also I want to deploy the application to shared hosting, specially Linux.\nso as Delphi developer, what do you choose to develop web application?","AnswerCount":10,"Available Count":3,"Score":1.0,"is_accepted":false,"ViewCount":2367,"Q_Id":2400605,"Users Score":6,"Answer":"Why should an answer be different if the question was asked by a Delphi programmer, than a programmer from any other platform? Any decent language should be fun to learn, regardless of the tool you are using right now.\nThat said, I myself walked a way from Borland Pascal and Delphi (quite some time ago), over PHP and ASP.NET (using C#). Right now I am working almost exclusively on Ruby (and occasionally Rails) and I am perfectly happy with it. But, then again, it's matter of personal preference: I really enjoy Ruby's pure object-orientation and functional capabilities, as well as dynamical nature of a scripting language. So, it's all up to you and your personal preferences.\nAlthough, one thing I can surely recommend is to stick with one of the major web-players, for pragmatic reasons: PHP, Python, Ruby, ASP.NET or possibly Java. I'm sorry to say that, but I don't think Pascaloid languages have any future anymore.","Q_Score":5,"Tags":"php,python,ruby,delphi","A_Id":2401097,"CreationDate":"2010-03-08T10:26:00.000","Title":"Best web application language for Delphi Developers","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I'm Delphi developer, and I would like to build few web applications, I know about Intraweb, but I think it's not a real tool for web development, maybe for just intranet applications\nso I'm considering PHP, Python or ruby, I prefer python because it's better syntax than other( I feel it closer to Delphi), also I want to deploy the application to shared hosting, specially Linux.\nso as Delphi developer, what do you choose to develop web application?","AnswerCount":10,"Available Count":3,"Score":0.0199973338,"is_accepted":false,"ViewCount":2367,"Q_Id":2400605,"Users Score":1,"Answer":"PHP is a pretty simple answer. \nOne reason is there is both Delphi4PHP (the rather cryptic IDE licensed by Embarcadero which in my estimation is really only for Web Apps (not for doing whole site)s) and PHP4Delphi (the pretty awesome Delphi Component that lets you compile your Delphi code to PHP Extensions).","Q_Score":5,"Tags":"php,python,ruby,delphi","A_Id":2401646,"CreationDate":"2010-03-08T10:26:00.000","Title":"Best web application language for Delphi Developers","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I'm Delphi developer, and I would like to build few web applications, I know about Intraweb, but I think it's not a real tool for web development, maybe for just intranet applications\nso I'm considering PHP, Python or ruby, I prefer python because it's better syntax than other( I feel it closer to Delphi), also I want to deploy the application to shared hosting, specially Linux.\nso as Delphi developer, what do you choose to develop web application?","AnswerCount":10,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":2367,"Q_Id":2400605,"Users Score":0,"Answer":"I have done a fairly large (4-5 FTE) project based on webhub (www.href.com). I can certainly advise this if it is a webapp for internal use.","Q_Score":5,"Tags":"php,python,ruby,delphi","A_Id":2401428,"CreationDate":"2010-03-08T10:26:00.000","Title":"Best web application language for Delphi Developers","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I have some json files with 500MB.\nIf I use the \"trivial\" json.load() to load its content all at once, it will consume a lot of memory.\nIs there a way to read partially the file? If it was a text, line delimited file, I would be able to iterate over the lines. I am looking for analogy to it.","AnswerCount":11,"Available Count":4,"Score":1.2,"is_accepted":true,"ViewCount":70067,"Q_Id":2400643,"Users Score":2,"Answer":"Update\nSee the other answers for advice.\nOriginal answer from 2010, now outdated\nShort answer: no.\nProperly dividing a json file would take intimate knowledge of the json object graph to get right.\nHowever, if you have this knowledge, then you could implement a file-like object that wraps the json file and spits out proper chunks.\nFor instance, if you know that your json file is a single array of objects, you could create a generator that wraps the json file and returns chunks of the array.\nYou would have to do some string content parsing to get the chunking of the json file right.\nI don't know what generates your json content. If possible, I would consider generating a number of managable files, instead of one huge file.","Q_Score":86,"Tags":"python,json,large-files","A_Id":2400780,"CreationDate":"2010-03-08T10:34:00.000","Title":"Is there a memory efficient and fast way to load big JSON 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},{"Question":"I have some json files with 500MB.\nIf I use the \"trivial\" json.load() to load its content all at once, it will consume a lot of memory.\nIs there a way to read partially the file? If it was a text, line delimited file, I would be able to iterate over the lines. I am looking for analogy to it.","AnswerCount":11,"Available Count":4,"Score":0.0544914242,"is_accepted":false,"ViewCount":70067,"Q_Id":2400643,"Users Score":3,"Answer":"On your mention of running out of memory I must question if you're actually managing memory. Are you using the \"del\" keyword to remove your old object before trying to read a new one? Python should never silently retain something in memory if you remove it.","Q_Score":86,"Tags":"python,json,large-files","A_Id":2402371,"CreationDate":"2010-03-08T10:34:00.000","Title":"Is there a memory efficient and fast way to load big JSON 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},{"Question":"I have some json files with 500MB.\nIf I use the \"trivial\" json.load() to load its content all at once, it will consume a lot of memory.\nIs there a way to read partially the file? If it was a text, line delimited file, I would be able to iterate over the lines. I am looking for analogy to it.","AnswerCount":11,"Available Count":4,"Score":0.0181798149,"is_accepted":false,"ViewCount":70067,"Q_Id":2400643,"Users Score":1,"Answer":"in addition to @codeape\nI would try writing a custom json parser to help you figure out the structure of the JSON blob you are dealing with. Print out the key names only, etc. Make a hierarchical tree and decide (yourself) how you can chunk it. This way you can do what @codeape suggests - break the file up into smaller chunks, etc","Q_Score":86,"Tags":"python,json,large-files","A_Id":2402407,"CreationDate":"2010-03-08T10:34:00.000","Title":"Is there a memory efficient and fast way to load big JSON 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},{"Question":"I have some json files with 500MB.\nIf I use the \"trivial\" json.load() to load its content all at once, it will consume a lot of memory.\nIs there a way to read partially the file? If it was a text, line delimited file, I would be able to iterate over the lines. I am looking for analogy to it.","AnswerCount":11,"Available Count":4,"Score":0.0544914242,"is_accepted":false,"ViewCount":70067,"Q_Id":2400643,"Users Score":3,"Answer":"\"the garbage collector should free the memory\" \nCorrect.\nSince it doesn't, something else is wrong. Generally, the problem with infinite memory growth is global variables.\nRemove all global variables.\nMake all module-level code into smaller functions.","Q_Score":86,"Tags":"python,json,large-files","A_Id":2406386,"CreationDate":"2010-03-08T10:34:00.000","Title":"Is there a memory efficient and fast way to load big JSON 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},{"Question":"I have mod_python installed on my server, but if I want to acceses a python script - let's say htt\u00fc:\/\/site.com\/something.py the script doesn't run, the download box \"pops up\"\nAny solutions?","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":280,"Q_Id":2401602,"Users Score":0,"Answer":"This should be on ServerFault. By the way, mod_python is deprecated, use WSGI instead.","Q_Score":2,"Tags":"python,apache,unix","A_Id":2401607,"CreationDate":"2010-03-08T13:34:00.000","Title":"How to run python scripts on your 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":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},{"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},{"Question":"My friend and I are planning on building a sort of a forum type of webapp.\nWe've used the major PHP frameworks but we're really thinking about using Python specifically the Pylons framework for our app. Although we're competent PHP programmers, we're somewhat noobs at Python (We could create practical scripts and such). But the thing is we really want to learn Python but by testing Pylons out it seems to be really difficult with all the numerous imports and all.\nWhat would you suggest? What advice could you give to us? How would you suggest that we learn Pylons?","AnswerCount":4,"Available Count":4,"Score":0.0,"is_accepted":false,"ViewCount":675,"Q_Id":2409812,"Users Score":0,"Answer":"Many many times have we had this discussion at my job. We use PHP and everyone here would love to switch to python. Even for our new web projects PHP delivers, and since we use it every day that is what we use. Many things in PHP irk me, and I love python, that said Im a big fan of \"use the best tool for the job\".\nGood code is possible in PHP (and horrible horrible code too), so use what is the best tool for you, and for this job. If however this webapp is a hobby and\/or not mission-critical software I would fully recommend python if only to learn a new language.","Q_Score":4,"Tags":"php,python,pylons","A_Id":6481796,"CreationDate":"2010-03-09T14:42:00.000","Title":"Should we use Pylons or PHP for our webapp?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"My friend and I are planning on building a sort of a forum type of webapp.\nWe've used the major PHP frameworks but we're really thinking about using Python specifically the Pylons framework for our app. Although we're competent PHP programmers, we're somewhat noobs at Python (We could create practical scripts and such). But the thing is we really want to learn Python but by testing Pylons out it seems to be really difficult with all the numerous imports and all.\nWhat would you suggest? What advice could you give to us? How would you suggest that we learn Pylons?","AnswerCount":4,"Available Count":4,"Score":0.2449186624,"is_accepted":false,"ViewCount":675,"Q_Id":2409812,"Users Score":5,"Answer":"Don't be scared off by imports in python. They're much more common when coding in python than PHP in general, and this is good because your namespace never gets polluted with stuff you aren't expecting, unless you do from foo import * (so don't do that). I think you'll find that the structure pylons gives you will be invaluable. There are frameworks in PHP as well, but if you want to learn python anyway, I see no reason you shouldn't dive in with Pylons.","Q_Score":4,"Tags":"php,python,pylons","A_Id":2409917,"CreationDate":"2010-03-09T14:42:00.000","Title":"Should we use Pylons or PHP for our webapp?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"My friend and I are planning on building a sort of a forum type of webapp.\nWe've used the major PHP frameworks but we're really thinking about using Python specifically the Pylons framework for our app. Although we're competent PHP programmers, we're somewhat noobs at Python (We could create practical scripts and such). But the thing is we really want to learn Python but by testing Pylons out it seems to be really difficult with all the numerous imports and all.\nWhat would you suggest? What advice could you give to us? How would you suggest that we learn Pylons?","AnswerCount":4,"Available Count":4,"Score":1.0,"is_accepted":false,"ViewCount":675,"Q_Id":2409812,"Users Score":9,"Answer":"Decide what you want to put your focus on, being productive or learning a new language:\n\nIf you want to learn Pylons and Python, use Pylon and Python. \nIf you want to deliver a stable forum software, use PHP, because that's what you're competent at. \n\nNote: I should add that this is not meant to imply that you cannot be productive with Python or Pylon in general. All I'm saying is, in your case, you will be more productive with PHP, because you know it.","Q_Score":4,"Tags":"php,python,pylons","A_Id":2409852,"CreationDate":"2010-03-09T14:42:00.000","Title":"Should we use Pylons or PHP for our webapp?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"My friend and I are planning on building a sort of a forum type of webapp.\nWe've used the major PHP frameworks but we're really thinking about using Python specifically the Pylons framework for our app. Although we're competent PHP programmers, we're somewhat noobs at Python (We could create practical scripts and such). But the thing is we really want to learn Python but by testing Pylons out it seems to be really difficult with all the numerous imports and all.\nWhat would you suggest? What advice could you give to us? How would you suggest that we learn Pylons?","AnswerCount":4,"Available Count":4,"Score":0.1973753202,"is_accepted":false,"ViewCount":675,"Q_Id":2409812,"Users Score":4,"Answer":"I don't know about Pylons but I've been in a similar situation and built a site using Django. I learned enough about Python in an environment that I was familiar with (web apps) that I now go to Python as my first choice.","Q_Score":4,"Tags":"php,python,pylons","A_Id":2409860,"CreationDate":"2010-03-09T14:42:00.000","Title":"Should we use Pylons or PHP for our webapp?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"What will be the fastest way to check whether a folder size is beyond a specific size say 10 MB, 1 Gb , 10 GB etc, without actually calculating the folder size. Something like quota. A Pythonic solution will be great, but standard UNIX utilities also welcome","AnswerCount":4,"Available Count":2,"Score":0.049958375,"is_accepted":false,"ViewCount":1806,"Q_Id":2414917,"Users Score":1,"Answer":"Folder size is still the total size of the folder contents.\nYou may try to call du -s foldername from python","Q_Score":2,"Tags":"python,linux,shell","A_Id":2414931,"CreationDate":"2010-03-10T06:21:00.000","Title":"What is the fastest way to check whether a folder size is greater than a specific size?","Data Science and Machine Learning":0,"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},{"Question":"What will be the fastest way to check whether a folder size is beyond a specific size say 10 MB, 1 Gb , 10 GB etc, without actually calculating the folder size. Something like quota. A Pythonic solution will be great, but standard UNIX utilities also welcome","AnswerCount":4,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":1806,"Q_Id":2414917,"Users Score":2,"Answer":"I'd have to say it's impossible. I don't believe any filesystems cache folder sizes. Whatever you do is going to have to walk the tree in some fashion or another. Using du is probably the fastest method since it's all going to be happening in C.\nIf you know the maximum filesize expected or supported you could perhaps optimise a little by counting the enties in each folder rather than the sizes and short-cutting in the case where there aren't enough files to meet the limit.","Q_Score":2,"Tags":"python,linux,shell","A_Id":2414949,"CreationDate":"2010-03-10T06:21:00.000","Title":"What is the fastest way to check whether a folder size is greater than a specific size?","Data Science and Machine Learning":0,"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},{"Question":"I am planning to write web service in python. But, I found wsgi also does the similar thing. Which one can be preferred?\nThank you\nBala\n\nUpdate\n\nI am still confused. Please help.\nBetter in my sense means:\n1. Bug will be fixed periodically.\n2. Chosen by most developers.\n3. Additional features like authentication tokens like AWS, can be supported out of the box.\n4. No strong dependency on version.( I see that wsgi requires python 2.6)\n5. All python libraries will work out of the box.\n6. Scalable in the future.\n7. Future upgrade don't cause any issues. \nWith my limited experience, I want these features. There might be some I might be missing.\nThanks\nBala\n\nUpdate \n\nI am sorry for all the confusion caused. I just want to expose a restful web services in python language. Is there a good framework?","AnswerCount":6,"Available Count":5,"Score":0.1325487884,"is_accepted":false,"ViewCount":5895,"Q_Id":2421007,"Users Score":4,"Answer":"If you just want to run web apps then use mod_wsgi. If you need to write a handler for the rest of httpd's request\/response phases then use mod_python.","Q_Score":5,"Tags":"python,rest,web-services,apache2","A_Id":2421023,"CreationDate":"2010-03-10T22:10:00.000","Title":"Apache2: mod_wsgi or mod_python, which one is better?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I am planning to write web service in python. But, I found wsgi also does the similar thing. Which one can be preferred?\nThank you\nBala\n\nUpdate\n\nI am still confused. Please help.\nBetter in my sense means:\n1. Bug will be fixed periodically.\n2. Chosen by most developers.\n3. Additional features like authentication tokens like AWS, can be supported out of the box.\n4. No strong dependency on version.( I see that wsgi requires python 2.6)\n5. All python libraries will work out of the box.\n6. Scalable in the future.\n7. Future upgrade don't cause any issues. \nWith my limited experience, I want these features. There might be some I might be missing.\nThanks\nBala\n\nUpdate \n\nI am sorry for all the confusion caused. I just want to expose a restful web services in python language. Is there a good framework?","AnswerCount":6,"Available Count":5,"Score":0.0,"is_accepted":false,"ViewCount":5895,"Q_Id":2421007,"Users Score":0,"Answer":"Bug will be fixed periodically.\nUnless you're paying money, you cannot have any idea about this.\n\nChosen by most developers.\nmod_wsgi\n\nAdditional features like authentication tokens like AWS, can be supported out of the box.\nTrue for every framework.\n\nNo strong dependency on version.( I see that wsgi requires python 2.6)\nWhat? Everything depends on compatible versions. Everything. Every single piece of software.\n\nAll python libraries will work out of the box.\n\"All?\" What about the poorly-written ones?\n\nScalable in the future.\nSure. We always hope for this. There's no guarantee.\n\nFuture upgrade don't cause any issues.\nThat's funny.\n\n\n\"I want these features.\"\nWe all do. Realistically, you can get #2. The rest don't make sense or cannot every be assured.","Q_Score":5,"Tags":"python,rest,web-services,apache2","A_Id":2422260,"CreationDate":"2010-03-10T22:10:00.000","Title":"Apache2: mod_wsgi or mod_python, which one is better?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I am planning to write web service in python. But, I found wsgi also does the similar thing. Which one can be preferred?\nThank you\nBala\n\nUpdate\n\nI am still confused. Please help.\nBetter in my sense means:\n1. Bug will be fixed periodically.\n2. Chosen by most developers.\n3. Additional features like authentication tokens like AWS, can be supported out of the box.\n4. No strong dependency on version.( I see that wsgi requires python 2.6)\n5. All python libraries will work out of the box.\n6. Scalable in the future.\n7. Future upgrade don't cause any issues. \nWith my limited experience, I want these features. There might be some I might be missing.\nThanks\nBala\n\nUpdate \n\nI am sorry for all the confusion caused. I just want to expose a restful web services in python language. Is there a good framework?","AnswerCount":6,"Available Count":5,"Score":0.0333209931,"is_accepted":false,"ViewCount":5895,"Q_Id":2421007,"Users Score":1,"Answer":"mod_wsgi is much more actively maintained than mod_python at this point. It also has a good bit of momentum, as it was somewhat recently adopted as the preferred deployment method on apache2 by Django. The author is also actively engaged with the Python community in regards to the future evolution of WSGI.","Q_Score":5,"Tags":"python,rest,web-services,apache2","A_Id":2422564,"CreationDate":"2010-03-10T22:10:00.000","Title":"Apache2: mod_wsgi or mod_python, which one is better?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I am planning to write web service in python. But, I found wsgi also does the similar thing. Which one can be preferred?\nThank you\nBala\n\nUpdate\n\nI am still confused. Please help.\nBetter in my sense means:\n1. Bug will be fixed periodically.\n2. Chosen by most developers.\n3. Additional features like authentication tokens like AWS, can be supported out of the box.\n4. No strong dependency on version.( I see that wsgi requires python 2.6)\n5. All python libraries will work out of the box.\n6. Scalable in the future.\n7. Future upgrade don't cause any issues. \nWith my limited experience, I want these features. There might be some I might be missing.\nThanks\nBala\n\nUpdate \n\nI am sorry for all the confusion caused. I just want to expose a restful web services in python language. Is there a good framework?","AnswerCount":6,"Available Count":5,"Score":0.1651404129,"is_accepted":false,"ViewCount":5895,"Q_Id":2421007,"Users Score":5,"Answer":"Don't confuse what WSGI and mod_wsgi are. WSGI is an interface specification for hosting Python web applications on a server. The mod_wsgi module is an implementation of the WSGI specification using Apache as the underlying web server. Thus, Python and WSGI are not choices exactly, WSGI is just one way of being able to communicate between a Python web service\/application and the web server. The mod_wsgi package is one implementation of that interface. So, WSGI is a means to an end, not a solution in itself.\nPersonally, I'd very much suggest you just use a minimal Python framework\/non framework and as Alex suggests, Werkzeug is a good choice.","Q_Score":5,"Tags":"python,rest,web-services,apache2","A_Id":2421104,"CreationDate":"2010-03-10T22:10:00.000","Title":"Apache2: mod_wsgi or mod_python, which one is better?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I am planning to write web service in python. But, I found wsgi also does the similar thing. Which one can be preferred?\nThank you\nBala\n\nUpdate\n\nI am still confused. Please help.\nBetter in my sense means:\n1. Bug will be fixed periodically.\n2. Chosen by most developers.\n3. Additional features like authentication tokens like AWS, can be supported out of the box.\n4. No strong dependency on version.( I see that wsgi requires python 2.6)\n5. All python libraries will work out of the box.\n6. Scalable in the future.\n7. Future upgrade don't cause any issues. \nWith my limited experience, I want these features. There might be some I might be missing.\nThanks\nBala\n\nUpdate \n\nI am sorry for all the confusion caused. I just want to expose a restful web services in python language. Is there a good framework?","AnswerCount":6,"Available Count":5,"Score":0.0996679946,"is_accepted":false,"ViewCount":5895,"Q_Id":2421007,"Users Score":3,"Answer":"mod_wsgi is specifically tuned to run Python web apps that use WSGI in Apache. mod_python is for any kind of Python web app, including WSGI apps. mod_wsgi also has a lower memory footprint than mod_python.","Q_Score":5,"Tags":"python,rest,web-services,apache2","A_Id":2421190,"CreationDate":"2010-03-10T22:10:00.000","Title":"Apache2: mod_wsgi or mod_python, which one is better?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"Is there a Bash equivalent to the Python's pass statement?","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":36506,"Q_Id":2421586,"Users Score":179,"Answer":"You can use : for this.","Q_Score":125,"Tags":"python,bash,language-comparisons","A_Id":2421592,"CreationDate":"2010-03-10T23:54:00.000","Title":"What is the Bash equivalent of Python's pass statement","Data Science and Machine Learning":0,"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},{"Question":"Is there a Bash equivalent to the Python's pass statement?","AnswerCount":2,"Available Count":2,"Score":1.0,"is_accepted":false,"ViewCount":36506,"Q_Id":2421586,"Users Score":45,"Answer":"true is a command that successfully does nothing.\n(false would, in a way, be the opposite: it doesn't do anything, but claims that a failure occurred.)","Q_Score":125,"Tags":"python,bash,language-comparisons","A_Id":2421637,"CreationDate":"2010-03-10T23:54:00.000","Title":"What is the Bash equivalent of Python's pass statement","Data Science and Machine Learning":0,"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},{"Question":"Are there any downsides to UPX-ing my 32-bit Python 2.6.4 development environment EXE\/PYD\/DLL files?\nThe reason I'm asking is that I frequently use a custom PY2EXE script that UPX's copies of these files on every build.\nYes, I could get fancy and try to cache UPXed files, but I think a simpler, safer, and higher performance solution would be for me to just UPX my Python 2.6.4 directory once and be done with it.\nThoughts?\nMalcolm","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":637,"Q_Id":2431236,"Users Score":2,"Answer":"I have experienced significant increases in start up time when UPX compressed executables are run on systems with certain virus scanners. I was only compressing single executables, but I expect that each compressed dll would add to the start time.\nIs it really necessary to use UPX? I can't imagine the space savings to be significant enough to be worth the trouble.","Q_Score":2,"Tags":"python,py2exe,upx","A_Id":2433251,"CreationDate":"2010-03-12T07:56:00.000","Title":"Any downsides to UPX-ing my 32-bit Python 2.6.4 development environment EXE\/PYD\/DLL 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},{"Question":"I'm doing some prototyping with OpenCV for a hobby project involving processing of real time camera data. I wonder if it is worth the effort to reimplement this in C or C++ when I have it all figured out or if no significant performance boost can be expected. The program basically chains OpenCV functions, so the main part of the work should be done in native code anyway.","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":1352,"Q_Id":2432792,"Users Score":5,"Answer":"You've answered your own question pretty well. Most of the expensive computations should be within the OpenCV library, and thus independent of the language you use. \nIf you're really concerned about efficiency, you could profile your code and confirm that this is indeed the case. If need be, your custom processing functions, if any, could be coded in C\/C++ and exposed in python through the method of your choice (eg: boost-python), to follow the same approach.\nBut in my experience, python works just fine as a \"composition\" tool for such a use.","Q_Score":1,"Tags":"c++,python,c,performance,opencv","A_Id":2433626,"CreationDate":"2010-03-12T12:54:00.000","Title":"OpenCV performance in different languages","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},{"Question":"I'm doing some prototyping with OpenCV for a hobby project involving processing of real time camera data. I wonder if it is worth the effort to reimplement this in C or C++ when I have it all figured out or if no significant performance boost can be expected. The program basically chains OpenCV functions, so the main part of the work should be done in native code anyway.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":1352,"Q_Id":2432792,"Users Score":0,"Answer":"OpenCV used to utilize IPP, which is very fast. However, OpenCV 2.0 does not. You might customize your OpenCV using IPP, for example color conversion routines.","Q_Score":1,"Tags":"c++,python,c,performance,opencv","A_Id":2470491,"CreationDate":"2010-03-12T12:54:00.000","Title":"OpenCV performance in different languages","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},{"Question":"ruby -n is the closest thing I found, but it repeats the whole script. Also it's not available for irb.","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":267,"Q_Id":2437582,"Users Score":1,"Answer":"$ cat > hello.rb\n$hello = 'Hello, world!'\nputs $hello\n^D\n$ irb\nirb(main):001:0> load 'hello.rb'\nHello, world!\n=> true\nirb(main):002:0> $hello\n=> \"Hello, world!\"\n\nA bit tedious, and local variables won't carry through. May be close enough for your usage? (This is basically like Python's execfile.)","Q_Score":2,"Tags":"python,ruby","A_Id":2437648,"CreationDate":"2010-03-13T07:06:00.000","Title":"Is there a ruby equivalent of \"python -i\"?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"ruby -n is the closest thing I found, but it repeats the whole script. Also it's not available for irb.","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":267,"Q_Id":2437582,"Users Score":1,"Answer":"irb -r hello.rb","Q_Score":2,"Tags":"python,ruby","A_Id":2880523,"CreationDate":"2010-03-13T07:06:00.000","Title":"Is there a ruby equivalent of \"python -i\"?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"How do I retrieve the temperature of my CPU using Python? (Assuming I'm on Linux)","AnswerCount":12,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":57891,"Q_Id":2440511,"Users Score":8,"Answer":"If your Linux supports ACPI, reading pseudo-file \/proc\/acpi\/thermal_zone\/THM0\/temperature (the path may differ, I know it's \/proc\/acpi\/thermal_zone\/THRM\/temperature in some systems) should do it. But I don't think there's a way that works in every Linux system in the world, so you'll have to be more specific about exactly what Linux you have!-)","Q_Score":28,"Tags":"python,cpu,temperature","A_Id":2440544,"CreationDate":"2010-03-13T23:35:00.000","Title":"Getting CPU temperature 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},{"Question":"I'm looking for a way to ship the Python interpreter with my application (also written in Python), so that it doesn't need to have Python installed on the machine.\nI searched Google and found a bunch of results about how to embed the Python interpreter in applications written in various languages, but nothing for applications written in Python itself... I don't need to \"hide\" my code or make a binary like cx_freeze does, I just don't want my users to have to install Python to use my app, that's all.","AnswerCount":5,"Available Count":2,"Score":0.0798297691,"is_accepted":false,"ViewCount":3296,"Q_Id":2441172,"Users Score":2,"Answer":"Making a frozen binary using a utility like cx_freeze or py2exe is probably the easiest way to do this. That way you only need to distribute the executable. I know that you might prefer not to distribute a binary, but if that is a concern you could always give users the option to download the source and run from an interpreter.","Q_Score":8,"Tags":"python,interpreter,embedding","A_Id":2441185,"CreationDate":"2010-03-14T04:24:00.000","Title":"Embed Python interpreter in a Python 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":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm looking for a way to ship the Python interpreter with my application (also written in Python), so that it doesn't need to have Python installed on the machine.\nI searched Google and found a bunch of results about how to embed the Python interpreter in applications written in various languages, but nothing for applications written in Python itself... I don't need to \"hide\" my code or make a binary like cx_freeze does, I just don't want my users to have to install Python to use my app, that's all.","AnswerCount":5,"Available Count":2,"Score":0.0798297691,"is_accepted":false,"ViewCount":3296,"Q_Id":2441172,"Users Score":2,"Answer":"You need some sort of executable in order to start Python. May as well be the one your app has been frozen into.\nThe alternative is to copy the executable, library, and pieces of the stdlib that you need into a private directory and invoke that against your app.","Q_Score":8,"Tags":"python,interpreter,embedding","A_Id":2441182,"CreationDate":"2010-03-14T04:24:00.000","Title":"Embed Python interpreter in a Python 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":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Our server cluster consists of 20 machines, each with 10 pids of 5 threads. We'd like some way to prevent any two threads, in any pid, on any machine, from modifying the same object at the same time.\nOur code's written in Python and runs on Linux, if that helps narrow things down.\nAlso, it's a pretty rare case that two such threads want to do this, so we'd prefer something that optimizes the \"only one thread needs this object\" case to be really fast, even if it means that the \"one thread has locked this object and another one needs it\" case isn't great.\nWhat are some of the best practices?","AnswerCount":5,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":2492,"Q_Id":2448984,"Users Score":0,"Answer":"Write code using immutable objects. Write objects that implement the Singleton Pattern.\nUse a stable Distributed messaging technology such as IPC, webservices, or XML-RPC.\nI would take a look at Twisted. They got plenty of solutions for such task. \nI wouldn't use threads in Python esp with regards to the GIL, I would look at using Processes as working applications and use a comms technology as described above for intercommunications.\nYour singleton class could then appear in one of these applications and interfaced via comms technology of choice.\nNot a fast solution with all the interfacing, but if done correctly should be stable.","Q_Score":7,"Tags":"python,linux,multithreading,mutex","A_Id":2449391,"CreationDate":"2010-03-15T17:08:00.000","Title":"What are some good ways to do intermachine locking?","Data Science and Machine Learning":0,"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},{"Question":"Our server cluster consists of 20 machines, each with 10 pids of 5 threads. We'd like some way to prevent any two threads, in any pid, on any machine, from modifying the same object at the same time.\nOur code's written in Python and runs on Linux, if that helps narrow things down.\nAlso, it's a pretty rare case that two such threads want to do this, so we'd prefer something that optimizes the \"only one thread needs this object\" case to be really fast, even if it means that the \"one thread has locked this object and another one needs it\" case isn't great.\nWhat are some of the best practices?","AnswerCount":5,"Available Count":2,"Score":0.0399786803,"is_accepted":false,"ViewCount":2492,"Q_Id":2448984,"Users Score":1,"Answer":"if you can get the complete infrastructure for a distributed lock manager then go ahead and use that. But that infrastructure is not easy to setup! But here is a practical solution:\n-designate the node with the lowest ip address as the the master node \n(that means if the node with lowest ip address hangs, a new node with lowest ip address will become new master)\n-let all nodes contact the master node to get the lock on the object. \n-let the master node use native lock semantics to get the lock.\nthis will simplify things unless you need complete clustering infrastructure and DLM to do the job.","Q_Score":7,"Tags":"python,linux,multithreading,mutex","A_Id":2466954,"CreationDate":"2010-03-15T17:08:00.000","Title":"What are some good ways to do intermachine locking?","Data Science and Machine Learning":0,"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},{"Question":"I have a module \"B\", I want to run it from a script \"C\", and I want to call global variables in \"B\", as they were in the \"C\" root. Another problem is if I imported sys in \"B\" when I run \"C\" it doesn't see sys\n# NameError: global name 'sys' is not defined #\nWhat shall I do?","AnswerCount":2,"Available Count":1,"Score":0.4621171573,"is_accepted":false,"ViewCount":4158,"Q_Id":2454576,"Users Score":5,"Answer":"When you import a module B (like import B), every line in B will be interpreted. I assume this is what you mean when you say you want to run it. To reference members in B's namespace, you can get them like:\nB.something_defined_in_B.\nIf you wish to use sys explicitly in C, you will need to import it within C as well.","Q_Score":0,"Tags":"python,import,global-variables,module","A_Id":2454624,"CreationDate":"2010-03-16T13:19:00.000","Title":"How do you run python scripts from other script and have their root in my root?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'd like to run a spell checker on the docstrings of my Python code, if possible from within emacs. \nI've found the ispell-check-comments setting which can be used to spell check only comments in code, but I was not able to target only the docstrings which are a fairly python-specific thing.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1226,"Q_Id":2455062,"Users Score":19,"Answer":"I recommend you to try flyspell-mode. You could use something like:\n(add-hook 'python-mode-hook 'flyspell-prog-mode)\nin your Emacs configuration.","Q_Score":11,"Tags":"python,emacs,spell-checking,docstring","A_Id":2455436,"CreationDate":"2010-03-16T14:20:00.000","Title":"How to spell check python docstring with 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":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm looking for a way to create a tree of test files to unit test a packaging tool. Basically, I want to create some common file system structures -- directories, nested directories, symlinks within the selected tree, symlinks outside the tree, &c.\nIdeally I want to do this with as little boilerplate as possible. Of course, I could hand-write the set of files I want to see, but I'm thinking that somebody has to have automated this for a test suite somewhere. Any suggestions?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":149,"Q_Id":2456226,"Users Score":1,"Answer":"I do this type of thing for testing Unix user creation and home directory copies. The Zip suggestion is a good one. \nI personally keep two directory structures -- one is a source and one becomes the test structure. I just sync the source to the destination via shutil.copytree as part of the test setup. \nThat makes it easy to change the test structure on the fly (and not have to unzip).","Q_Score":2,"Tags":"python,unit-testing,automation","A_Id":2456703,"CreationDate":"2010-03-16T16:35:00.000","Title":"Using Python, what's the best way to create a set of files on disk 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},{"Question":"I am currently working with converting Pycrypto over to Python 3.X\nWhilst I seem to have the cryptography side working the same cannot be said for the tests\nprovided with the module :(\nI have used the tests under Python 2.64 and all works fine.\nI then ran '2to3' over the tests to generate new files in 3.X format.\nThere are several references to the following:\nfrom .common import make_block_tests\nWhenever I run the tests I get:\nValueError: Attempted relative import in non-package\nIf someone would point me towards a way to fix this it would be much appreciated :)\nCheers\nGrail","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":215,"Q_Id":2459636,"Users Score":0,"Answer":"You are trying to run the test files directly, then you can't have relative imports. Change them to be absolute imports, and it will solve the problem.","Q_Score":0,"Tags":"python-3.x,relative-path","A_Id":5054020,"CreationDate":"2010-03-17T02:54:00.000","Title":"Python 3 relative path conversion 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":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a python CGI which runs some script in the background and shows the stdout in the html page. I run the script when the user clicks some button in the page.\nMy problem is when the script starts running the page becomes busy and the user can't use the other client side features in the page.\nWhat I want is:\nThe script should run in background when the user clicks the button and should notify the CGI when run is complete. Then the CGI show should the stdout of the script run.\nHow can this be done?","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":1221,"Q_Id":2461964,"Users Score":2,"Answer":"well, short answer: you can't.\nmedium answer: CGI sucks.\nlong answer: CGI works by running your script and returning whatever your script prints to the browser. If your script is still running, the browser will be waiting. If your script launches a background job and returns data to the browser, then the background job can't notify the CGI script because it is already done.\nYou must choose an alternate solution. \nSave the results of the background job to a file, database, or some other persistent storage, and make the user request that data, using another link in your page, which runs a different code that retrieves the saved results and display them.\nAnother way is to use AJAX techniques in the browser. Write javascript code to do the request to the data in the background. So the browser can still be responsive with other page elements while the script is running.","Q_Score":1,"Tags":"python,cgi,backgroundworker","A_Id":2462349,"CreationDate":"2010-03-17T11:59:00.000","Title":"Running a python script in background from a 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},{"Question":"One of our page templates is made up of a bunch of macros. These items are a bunch of html tables.\nNow, I want a couple of these tables in a Python script to create a PDF. Is there a way call a macro from a Python script and get back the HTML that is produced?\nIf so, can you explain?\nThanks\nEric","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":334,"Q_Id":2464442,"Users Score":0,"Answer":"Maybe you could create a new template including (use-macro) just the macros you want to access from python and then use z3c.pt.pagetemplate.PageTemplateFile() to render it?\nActually, it might be possible (and certainly easier) to use chameleon.zpt.template.PageTemplate('

\" \/>'), but I've never did this myself.","Q_Score":1,"Tags":"python,zope","A_Id":2466236,"CreationDate":"2010-03-17T17:32:00.000","Title":"Call macro 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":0,"Web Development":1},{"Question":"One of our page templates is made up of a bunch of macros. These items are a bunch of html tables.\nNow, I want a couple of these tables in a Python script to create a PDF. Is there a way call a macro from a Python script and get back the HTML that is produced?\nIf so, can you explain?\nThanks\nEric","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":334,"Q_Id":2464442,"Users Score":0,"Answer":"I'd probably use urllib.urlopen(url), pull the data from the page back to python and use BeautifulSoup to pull the table(s) out of the HTML... And then render that to PDF with XHTML2PDF (pisa.ho).\nThere might be a simpler way but for me, this would be the least stressful approach.","Q_Score":1,"Tags":"python,zope","A_Id":2464507,"CreationDate":"2010-03-17T17:32:00.000","Title":"Call macro 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":0,"Web Development":1},{"Question":"Can C\/C++ be choice of keeping all your logic (business\/domain) for web application?\nWhy?\nI've two resources (cousins) having knowledge on C\/C++ and me also good in C\/C++, Python, HTML, CSS and JavaScript. \nWe like to utilize our free time to work on our some good ideas we developed together. The ideas require knowledge of web application development. And I'm the only one who has it.\nIs there a way they developed the core in C\/C++ and I do the rest of scripting for front-end development?\nThanks.","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":390,"Q_Id":2467807,"Users Score":0,"Answer":"I don't think you should use a compiled language (at least not c++) for web programming. I thought about doing this once too but remember that for any change you'll have to compile etc.\nFacebook uses php and it's hip hop application changes php into c++. Maybe you should take a look at that.\nOf course c++ (or any compiled language) will be faster than an interpreted language, but you also have to take in account the development time of the web site\/app.\nHope this helps :)","Q_Score":2,"Tags":"c++,python,c","A_Id":2468907,"CreationDate":"2010-03-18T06:03:00.000","Title":"C\/C++ for Core Logic Development of a 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},{"Question":"I began learning and loving python about a month ago. Dive into python, django and now Tornado is the path i followed during this time.\nI chose pydev as an IDE since it seems to be the most up to date and i wanted to come back to eclipse since i'm using Netbeans for php and Java.\nMy question is the following:\nWhen i write classes in php or java i declare my methods and properties. I instantiate them somewhere else and use them. The autocompletion works great for java and php but with python, it seems to be always suggesting me a bunch of garbage and never the real object's methods from the class i instantiated.\nIs it the same for you ? Is it a limitation from pydev ? Am i doing something wrong ?\nThank you in advance for pointing me in a direction.\nMatthieu.","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1825,"Q_Id":2470121,"Users Score":0,"Answer":"Well, as you didn't say what 'garbage' is showing, it's a bit hard to guess, but I believe you mean the __hash__, __str__, etc from the object class (is that it?)\nIf that's the case, this has been dealt in the current nightly build (the '_' methods will still appear, but with lower priority, so, the methods you're probably more interested in are at the top)","Q_Score":5,"Tags":"python,pydev","A_Id":5761144,"CreationDate":"2010-03-18T13:31:00.000","Title":"Bad auto completion with python on 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":0,"Web Development":1},{"Question":"I am reading cpython code for python 3k and I have noticed, that __missing__ is called only when dict_subscript is called, but not when PyDict_GetItem is used. What is the difference between those two methods and when each is called? If I pass an PyObject that is a subclass of dict and has __missing__ method, how can I force using it, since PyDict_GetItem doesn't do that.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":698,"Q_Id":2470928,"Users Score":1,"Answer":"Observations, guesses, etc:\nSame happens in Python 2.x.\ndict_subscript implements the equivalent of the high_level dict.__getitem__ method and thus will be called whenever adict[somekey] appears other than on the LHS of an assignment in Python code.\nPyDict_GetItem is part of the C API. Perhaps it's an oversight that it hasn't been updated.\nHaving read the dire comments at the start of PyDict_GetItem, I'd be using PyDict_GetItemWithError instead ;-)\nPerhaps you can do the C-level equivalent of my_getitem = getattr(my_dict, '__getitem__') once then call that.\nPerhaps you could raise a bug ticket or ask on comp.lang.python","Q_Score":1,"Tags":"python,dictionary,cpython","A_Id":2473724,"CreationDate":"2010-03-18T15:17:00.000","Title":"cpython: when PyDict_GetItem is called and when dict_subscript?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a python server that listens on a couple sockets. At startup, I try to connect to these sockets before listening, so I can be sure that nothing else is already using that port. This adds about three seconds to my server's startup (which is about .54 seconds without the test) and I'd like to trim it down. Since I'm only testing localhost, I think a timeout of about 50 milliseconds is more than ample for that. Unfortunately, the socket.setdefaulttimeout(50) method doesn't seem to work for some reason.\nHow I can trim this down?","AnswerCount":7,"Available Count":3,"Score":0.057080742,"is_accepted":false,"ViewCount":46722,"Q_Id":2470971,"Users Score":2,"Answer":"Are you on Linux? If so, perhaps your application could run netstat -lant (or netstat -lanu if you're using UDP) and see what ports are in use. This should be faster...","Q_Score":29,"Tags":"python,sockets","A_Id":2471078,"CreationDate":"2010-03-18T15:21:00.000","Title":"Fast way to test if a port is in use 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},{"Question":"I have a python server that listens on a couple sockets. At startup, I try to connect to these sockets before listening, so I can be sure that nothing else is already using that port. This adds about three seconds to my server's startup (which is about .54 seconds without the test) and I'd like to trim it down. Since I'm only testing localhost, I think a timeout of about 50 milliseconds is more than ample for that. Unfortunately, the socket.setdefaulttimeout(50) method doesn't seem to work for some reason.\nHow I can trim this down?","AnswerCount":7,"Available Count":3,"Score":0.057080742,"is_accepted":false,"ViewCount":46722,"Q_Id":2470971,"Users Score":2,"Answer":"Simon B's answer is the way to go - don't check anything, just try to bind and handle the error case if it's already in use.\nOtherwise you're in a race condition where some other app can grab the port in between your check that it's free and your subsequent attempt to bind to it. That means you still have to handle the possibility that your call to bind will fail, so checking in advance achieved nothing.","Q_Score":29,"Tags":"python,sockets","A_Id":2471762,"CreationDate":"2010-03-18T15:21:00.000","Title":"Fast way to test if a port is in use 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},{"Question":"I have a python server that listens on a couple sockets. At startup, I try to connect to these sockets before listening, so I can be sure that nothing else is already using that port. This adds about three seconds to my server's startup (which is about .54 seconds without the test) and I'd like to trim it down. Since I'm only testing localhost, I think a timeout of about 50 milliseconds is more than ample for that. Unfortunately, the socket.setdefaulttimeout(50) method doesn't seem to work for some reason.\nHow I can trim this down?","AnswerCount":7,"Available Count":3,"Score":1.2,"is_accepted":true,"ViewCount":46722,"Q_Id":2470971,"Users Score":14,"Answer":"How about just trying to bind to the port you want, and handle the error case if the port is occupied?\n(If the issue is that you might start the same service twice then don't look at open ports.)\nThis is the reasonable way also to avoid causing a race-condition, as @eemz said in another answer.","Q_Score":29,"Tags":"python,sockets","A_Id":2471039,"CreationDate":"2010-03-18T15:21:00.000","Title":"Fast way to test if a port is in use 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},{"Question":"I have a folder full of files and I want to search some string inside them. The issue is that some files may be zip, exe, ogg, etc.\nCan I check somehow what kind of file is it so I only open and search through txt, PHP, etc. files.\nI can't rely on the file extension.","AnswerCount":4,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":7602,"Q_Id":2472221,"Users Score":0,"Answer":"If you're on linux you can parse the output of the file command-line tool.","Q_Score":5,"Tags":"python","A_Id":2472233,"CreationDate":"2010-03-18T17:56:00.000","Title":"How to check if a file contains plain text?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm a hobbyist programmer (only in TI-Basic before now), and after much, much, much debating with myself, I've decided to learn Python. I don't have a ton of free time to teach myself a hundred languages and all programming I do will be for personal use or for distributing to people who need them, so I decided that I needed one good, strong language to be good at. My questions:\n\nIs python powerful enough to handle most things that a typical programmer might do in his off-time? I have in mind things like complex stat generators based on user input for tabletop games, making small games, automate install processes, and build interactive websites, but probably a hundred things along those lines\nDoes python handle networking tasks fairly well?\nCan python source be obfuscated, or is it going to be open-source by nature? The reason I ask this is because if I make something cool and distribute it, I don't want some idiot script kiddie to edit his own name in and say he wrote it\nAnd how popular is python, compared to other languages. Ideally, my language would be good and useful with help found online without extreme difficulty, but not so common that every idiot with computer knows python. I like the idea of knowing a slightly obscure language.\n\nThanks a ton for any help you can provide.","AnswerCount":7,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":861,"Q_Id":2474224,"Users Score":0,"Answer":"Python is up to the task (and better) for 1, 2 and 4.\nThe best solution for 3 from what you describe would probably be to make your programs really open-source with GPL or BSD like licence. This way people will edit your super-cool sources (but often experienced programmers, not just script kiddies) and build on then but leave your name in for posterity.","Q_Score":9,"Tags":"python,networking,programming-languages,robust","A_Id":2475530,"CreationDate":"2010-03-19T00:14:00.000","Title":"Python for a hobbyist programmer ( a few questions)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm a hobbyist programmer (only in TI-Basic before now), and after much, much, much debating with myself, I've decided to learn Python. I don't have a ton of free time to teach myself a hundred languages and all programming I do will be for personal use or for distributing to people who need them, so I decided that I needed one good, strong language to be good at. My questions:\n\nIs python powerful enough to handle most things that a typical programmer might do in his off-time? I have in mind things like complex stat generators based on user input for tabletop games, making small games, automate install processes, and build interactive websites, but probably a hundred things along those lines\nDoes python handle networking tasks fairly well?\nCan python source be obfuscated, or is it going to be open-source by nature? The reason I ask this is because if I make something cool and distribute it, I don't want some idiot script kiddie to edit his own name in and say he wrote it\nAnd how popular is python, compared to other languages. Ideally, my language would be good and useful with help found online without extreme difficulty, but not so common that every idiot with computer knows python. I like the idea of knowing a slightly obscure language.\n\nThanks a ton for any help you can provide.","AnswerCount":7,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":861,"Q_Id":2474224,"Users Score":0,"Answer":"Points 1 and 2: HELL YEAH.\nPoint 4: kind of. Python is good at some network stuff. It's not Java or C++. Just use zlib (zip library) and pickle (serialization) for everything, and look at xmlrpclib if you need IPC.\nPoint 3: No. However, you can write C modules (for the performance critical, and hard-to-copy) parts of your code, and that would make it non-trivial to reverse-engineer.","Q_Score":9,"Tags":"python,networking,programming-languages,robust","A_Id":2475188,"CreationDate":"2010-03-19T00:14:00.000","Title":"Python for a hobbyist programmer ( a few questions)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm a hobbyist programmer (only in TI-Basic before now), and after much, much, much debating with myself, I've decided to learn Python. I don't have a ton of free time to teach myself a hundred languages and all programming I do will be for personal use or for distributing to people who need them, so I decided that I needed one good, strong language to be good at. My questions:\n\nIs python powerful enough to handle most things that a typical programmer might do in his off-time? I have in mind things like complex stat generators based on user input for tabletop games, making small games, automate install processes, and build interactive websites, but probably a hundred things along those lines\nDoes python handle networking tasks fairly well?\nCan python source be obfuscated, or is it going to be open-source by nature? The reason I ask this is because if I make something cool and distribute it, I don't want some idiot script kiddie to edit his own name in and say he wrote it\nAnd how popular is python, compared to other languages. Ideally, my language would be good and useful with help found online without extreme difficulty, but not so common that every idiot with computer knows python. I like the idea of knowing a slightly obscure language.\n\nThanks a ton for any help you can provide.","AnswerCount":7,"Available Count":3,"Score":1.0,"is_accepted":false,"ViewCount":861,"Q_Id":2474224,"Users Score":6,"Answer":"I think that Python is very powerful to do a lot of things, but just like Java and C++, it often depends on good third-party libraries. I come from a Java background but use Python for a lot of things, and it's been a fun ride. I've done things like statistics, and automation, not sure about the UI though that often depends on the toolkit more than the language. \nPython networking works well. I don't know if I'd use it to build a fast algorithmic trading system or a VOIP application, but for most intents and purposes, especially at higher levels of abstraction, it's fine and easy to use. You would need external libraries for things like SSH or FTP.\nPython is quite popular and has very good online support, active community, and major corporations (likeGoogle) that use it. I found the official online tutorial and reference to be excellent. \nI have to say that I disagree with the \"every idiot with a computer\" line. There's a difference between knowing a language and using it right, and that's true about every language, even natural ones :) Python does have a lot of functional elements that are not as trivial to use for people coming from a procedural background, so there's always room for growth. \nThe one problem with Python compared to languages like C and Java is that it is not statically typed. This makes it much faster to write code, but also makes it *much easier) to make mistakes that can be quite nasty to debug. For instance, the same variable can contain a String reference at some point, and a reference to a list of strings at some other point.","Q_Score":9,"Tags":"python,networking,programming-languages,robust","A_Id":2474246,"CreationDate":"2010-03-19T00:14:00.000","Title":"Python for a hobbyist programmer ( a few questions)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm a fan of clean code. I like my languages to be able to express what I'm trying to do, but I like the syntax to mirror that too.\nFor example, I work on a lot of programs in Objective-C for jailbroken iPhones, which patch other code using the method_setImplementation() function of the runtime. Or, in PyObjC, I have to use the syntax UIView.initWithFrame_(), which is also pretty awful and unreadable with the way the method names are structured. In both cases, the language does not support this in syntax. I've found three basic ways that this is done:\n\nInsane macros. Take a look at this\n\"CaptainHook\", it does what I'm\nlooking for in a usable way, but it\nisn't quite clean and is a major\nhack.\nThere's also \"Logos\", which\nimplements a very nice syntax, but is\nwritten in Perl parsing my code with\na ton of regular expressions. This\nscares me. I like the idea of adding\na %hook ClassName, but not by using\nregular expressions to parse C or\nObjective-C.\nFinally, there is Cycript. This is an\nextension to JavaScript which\ninterfaces with the Objective-C\nruntime and allows you to use\nObjective-C style code in your\nJavaScript, and inject that into\nother processes. This is likely the\ncleanest as it actually uses a parser\nfor the JavaScript, but I'm not a\nhuge fan of that language in general.\n\nShould, and how should, I create an extension to Python and Objective-C to allow me to do this? Is it worth writing a parser for my language to transform the syntax into something nicer, if it is only in a very specialized niche like this? Should I just live with the horrible syntax of the default Objective-C hooking or PyObjC?","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":775,"Q_Id":2474554,"Users Score":1,"Answer":"There are only two kinds of programming languages:, the truism goes, the ones every one complains about and the ones no one uses. People who want to make programs don't choose a language because it's beautiful or clean; they choose it because it is supported, available, and not so awful that you just can't use it. \nWhen you see something you think you can improve, it can be very tempting to say I can fix that! and run right in, but in this case the cost is probably higher than is worth it. Programming languages that don't fill any bigger goal than being somewhat cleaner or a little more consistent tend not to catch on, as incremental advances in those areas aren't the things that you really, really need to improve the process of making software. Projects in obscure pet languages tend to die and not catch on, as the cost of contributing (learning someone's pet language that is new to you and that doesn't have broad support and documentation) is too high.\nIf you are interested in language design and tinkering, this could be interesting for you. It's harder than it may seem\u2014the designers of all the major languages have had to deal with a lot of tradeoffs in designing them, often sacrificing beauty and purity for practicality and compatibility. If, on the other hand, you want to write software, deal with the imperfect tools you were dealt.","Q_Score":1,"Tags":"python,objective-c,pyobjc","A_Id":2475334,"CreationDate":"2010-03-19T02:01:00.000","Title":"Extending Python and Objective-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},{"Question":"I'm a fan of clean code. I like my languages to be able to express what I'm trying to do, but I like the syntax to mirror that too.\nFor example, I work on a lot of programs in Objective-C for jailbroken iPhones, which patch other code using the method_setImplementation() function of the runtime. Or, in PyObjC, I have to use the syntax UIView.initWithFrame_(), which is also pretty awful and unreadable with the way the method names are structured. In both cases, the language does not support this in syntax. I've found three basic ways that this is done:\n\nInsane macros. Take a look at this\n\"CaptainHook\", it does what I'm\nlooking for in a usable way, but it\nisn't quite clean and is a major\nhack.\nThere's also \"Logos\", which\nimplements a very nice syntax, but is\nwritten in Perl parsing my code with\na ton of regular expressions. This\nscares me. I like the idea of adding\na %hook ClassName, but not by using\nregular expressions to parse C or\nObjective-C.\nFinally, there is Cycript. This is an\nextension to JavaScript which\ninterfaces with the Objective-C\nruntime and allows you to use\nObjective-C style code in your\nJavaScript, and inject that into\nother processes. This is likely the\ncleanest as it actually uses a parser\nfor the JavaScript, but I'm not a\nhuge fan of that language in general.\n\nShould, and how should, I create an extension to Python and Objective-C to allow me to do this? Is it worth writing a parser for my language to transform the syntax into something nicer, if it is only in a very specialized niche like this? Should I just live with the horrible syntax of the default Objective-C hooking or PyObjC?","AnswerCount":2,"Available Count":2,"Score":0.1973753202,"is_accepted":false,"ViewCount":775,"Q_Id":2474554,"Users Score":2,"Answer":"If you don't have any experience in compiler or interpreter design my answer is an emphatic NO, it is one of the biggest challenges in computer science.\nIf you do have experience my answer shifts to \"that is a really dumb idea.\"\nDo you envision this becoming a large mature product that other people will want to use? If you do than go ahead, otherwise it will just distract you from writing great applications.","Q_Score":1,"Tags":"python,objective-c,pyobjc","A_Id":2474626,"CreationDate":"2010-03-19T02:01:00.000","Title":"Extending Python and Objective-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},{"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},{"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},{"Question":"How can I write 'one bit' into a file stream or file structure each time?\nIs it possible to write to a queue and then flush it?\nIs it possible with C# or Java?\nThis was needed when trying to implement an instance of Huffman coding. I can't write bits into files, so write them to a bitset and then (when compression was completed) write 8-bit piece of it each time (exclude last one).","AnswerCount":7,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":5699,"Q_Id":2476748,"Users Score":0,"Answer":"I would recommend allocating a rather large buffer (4096 bytes at least) and flush that off to disk whenever it fills up. Using a one-byte buffer usually causes bad performance.","Q_Score":11,"Tags":"java,c#,python,c++,bit-manipulation","A_Id":2477111,"CreationDate":"2010-03-19T11:18:00.000","Title":"Writing 'bits' to C++ file streams","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"How can I write 'one bit' into a file stream or file structure each time?\nIs it possible to write to a queue and then flush it?\nIs it possible with C# or Java?\nThis was needed when trying to implement an instance of Huffman coding. I can't write bits into files, so write them to a bitset and then (when compression was completed) write 8-bit piece of it each time (exclude last one).","AnswerCount":7,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":5699,"Q_Id":2476748,"Users Score":0,"Answer":"I did this once for huffman decoding and ended up writing the bits as chars and thus handling everything internally as a plain old C string. \nThat way you don't have to worry about the trailing byte and it's human readable as well. Also checking bits is is easier since its just a matter of addressing the char array (binbuf[123] == '1') instead of having to fiddle with bits. Not the most optimized solution, but it solved my problem neatly.\nThe obvious drawback is that this representation uses more memory.","Q_Score":11,"Tags":"java,c#,python,c++,bit-manipulation","A_Id":2477157,"CreationDate":"2010-03-19T11:18:00.000","Title":"Writing 'bits' to C++ file streams","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"How can I write 'one bit' into a file stream or file structure each time?\nIs it possible to write to a queue and then flush it?\nIs it possible with C# or Java?\nThis was needed when trying to implement an instance of Huffman coding. I can't write bits into files, so write them to a bitset and then (when compression was completed) write 8-bit piece of it each time (exclude last one).","AnswerCount":7,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":5699,"Q_Id":2476748,"Users Score":0,"Answer":"The issue here is that many platforms do not have direct bit access. They group bits into a minimal package, often times the byte or word. Also, the protocol for stream devices does not facilitate transmission of individual bits. \nThe common method to deal with individual bits is to pack them into the smallest portable and (addressable) accessible unit. The unused bits are usually set to zero. This can be accomplished with binary arithmetic operations (OR, AND, EXCLUSIVE-OR, NOT, etc.).\nWith modern processors, bit twiddling slows down the machine and the performance. Memory is cheap and with large addressing spaces, justification for bit packing has become more difficult. Generally, bit packing is reserved for hardware oriented operations (and also transmission protocols). For example, if a processor's word capacity is 16 bits, the processor can probably handle 16 words faster than 16 bit manipulations in one word. \nAlso, keep in mind that writing to and from memory is often faster than I\/O from streams. Efficient systems buffer data in memory before transmitting the data. You may want to consider this technique in your designs. Reducing I\/O operations will improve the performance of your program.","Q_Score":11,"Tags":"java,c#,python,c++,bit-manipulation","A_Id":2478818,"CreationDate":"2010-03-19T11:18:00.000","Title":"Writing 'bits' to C++ file streams","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I've got a pile of C code that I'd like to unit test using Python's unittest library (in Windows), but I'm trying to work out the best way of interfacing the C code so that Python can execute it (and get the results back). Does anybody have any experience in the easiest way to do it?\nSome ideas include:\n\nWrapping the code as a Python C extension using the Python API\nWrap the C code using SWIG\nAdd a DLL wrapper to the C code and load it into Python using ctypes\nAdd a small XML-RPC server to the c-code and call it using xmlrpclib (yes, I know this seems a bit far-out!)\n\nIs there a canonical way of doing this? I'm going to be doing this quite a lot, with different C modules, so I'd like to find a way which is least effort.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":12704,"Q_Id":2482270,"Users Score":8,"Answer":"I think that the exact solution depends on your code. Not all libraries are easily suitable for wrapping as a DLL. If your is, then ctypes is certainly the easiest way - just make a DLL out of your library and then test it with ctypes. An added bonus is that you now have your library conveniently wrapped as a standalone DLL which helps to decouple your application.\nSometimes, however, a more thorough interaction will be required between your C code and the testing Python code. Then, it's probably best to hook it as an extension, for which SWIG is a pretty good tool that will automate away most things you'll find boring about the process.","Q_Score":25,"Tags":"python,c,unit-testing,swig","A_Id":2489948,"CreationDate":"2010-03-20T07:12:00.000","Title":"Easiest way of unit testing C code with 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":0,"Web Development":0},{"Question":"How can I set default language for trac. There's nothing about i18n in trac.ini","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2028,"Q_Id":2482399,"Users Score":0,"Answer":"The stable release of trac, 0.11.X does not have support for localization. It is added in the upcoming 0.12 which is currently under development. Do you have 0.12 or did you download \"latest stable\" which is 0.11? In that case you will have to upgrade to get localization support.\nThe trac site itself appears to be running 0.12 as it is localized.","Q_Score":1,"Tags":"python,internationalization,trac","A_Id":2482486,"CreationDate":"2010-03-20T08:19:00.000","Title":"Trac default 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},{"Question":"Tell why you think Python, Perl, Ruby, etc is easiest for plugging in modules from other languages with minimal thought.\nTo clarify, an example: I want to write business logic in Python, but use functionality that conveniently exists as a Perl module.\nIn other words, which language \"just works\" with the most modules?","AnswerCount":7,"Available Count":4,"Score":0.0,"is_accepted":false,"ViewCount":673,"Q_Id":2483924,"Users Score":0,"Answer":"Most scripting languages can handle this kind of thing (by running external programs written in other languages,) but it seems as if your best bet might be shell scripting of some kind (Windows users call this \"batch scripting,\" but the DOS syntax is horrible and not recommended.) UNIX programmers have been freely mixing languages in this way for a long time. On Windows, you can install Cygwin to get a fully functional BASH shell. \nThe shell was originally intended as a user interface, used to launch other programs or combine them in interesting ways. However, many shells (notably the Bourne shell or its modern descendant, BASH) are also fully-fledged programming languages. Each of your \"modules\" can be created as separate, standalone programs which will be run by the shell script.","Q_Score":1,"Tags":"python,ruby,perl,module,dynamic-languages","A_Id":2484750,"CreationDate":"2010-03-20T17:06:00.000","Title":"Which dynamic language can easily use libraries from other 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},{"Question":"Tell why you think Python, Perl, Ruby, etc is easiest for plugging in modules from other languages with minimal thought.\nTo clarify, an example: I want to write business logic in Python, but use functionality that conveniently exists as a Perl module.\nIn other words, which language \"just works\" with the most modules?","AnswerCount":7,"Available Count":4,"Score":0.0855049882,"is_accepted":false,"ViewCount":673,"Q_Id":2483924,"Users Score":3,"Answer":"If you want to plug in a Perl module, the language which is best suited for this is Perl. Perl is able to represent the semantics and capabilities of code written in Perl correctly. This really shouldn't be a shock.\nIf you have a self-contained program you want to call from another program in its own process, not constantly interacting, any of these languages can do that with programs written in whatever language. At that point, you aren't really using other languages inside a program but just calling other problems.\nThere are several projects to combine various pairs and projects (like Parrot) that seek to provide a platform for a large range of languages for compatibility and projects (like .NET) that almost accidentally provide compatibility among previously-incompatible languages. However, I do not think most of these are as robust, mature, and suited for combining normal code as you would hope.","Q_Score":1,"Tags":"python,ruby,perl,module,dynamic-languages","A_Id":2483959,"CreationDate":"2010-03-20T17:06:00.000","Title":"Which dynamic language can easily use libraries from other 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},{"Question":"Tell why you think Python, Perl, Ruby, etc is easiest for plugging in modules from other languages with minimal thought.\nTo clarify, an example: I want to write business logic in Python, but use functionality that conveniently exists as a Perl module.\nIn other words, which language \"just works\" with the most modules?","AnswerCount":7,"Available Count":4,"Score":0.0,"is_accepted":false,"ViewCount":673,"Q_Id":2483924,"Users Score":0,"Answer":"The Dynamic Language Runtime was specifically designed to allow one dynamic language to use objects and functions defined in another dynamic language. Currently Python and Ruby have DLR implementations, but I haven't heard anything about Perl.\nTo use the DLR you need either .NET or Mono.","Q_Score":1,"Tags":"python,ruby,perl,module,dynamic-languages","A_Id":2483997,"CreationDate":"2010-03-20T17:06:00.000","Title":"Which dynamic language can easily use libraries from other 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},{"Question":"Tell why you think Python, Perl, Ruby, etc is easiest for plugging in modules from other languages with minimal thought.\nTo clarify, an example: I want to write business logic in Python, but use functionality that conveniently exists as a Perl module.\nIn other words, which language \"just works\" with the most modules?","AnswerCount":7,"Available Count":4,"Score":0.0,"is_accepted":false,"ViewCount":673,"Q_Id":2483924,"Users Score":0,"Answer":"all 3 languages have very good, clear facilities for just calling any executable in a subprocess (including executables like python somethingelse.py or ruby somethingelse.rb).\nuse what you know best.","Q_Score":1,"Tags":"python,ruby,perl,module,dynamic-languages","A_Id":2483932,"CreationDate":"2010-03-20T17:06:00.000","Title":"Which dynamic language can easily use libraries from other 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},{"Question":"I like Python mostly for the great portability and the ease of coding, but I was wondering, what are some of the advantages that C# has over Python?\nThe reason I ask is that one of my friends runs a private server for an online game (UO), and he offered to make me a dev if I wanted, but the software for the server is all written in C#. I'd love to do this, but I don't really have time to do multiple languages, and I was just after a few more reasons to justify taking C# over Python to myself.\nI'm doing this all self-taught as a hobby, btw","AnswerCount":10,"Available Count":7,"Score":0.0199973338,"is_accepted":false,"ViewCount":7557,"Q_Id":2484578,"Users Score":1,"Answer":"The JITer, and the fact that it can produce tighter code due to it supporting static typing. The JITer can be worked around by using one of the non-CPython implementations, or dropping to i386 and using psyco, but the static typing can't be worked around as trivially (nor do I believe that it should be).","Q_Score":10,"Tags":"c#,python","A_Id":2484600,"CreationDate":"2010-03-20T20:12:00.000","Title":"what are the advantages of C# over 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},{"Question":"I like Python mostly for the great portability and the ease of coding, but I was wondering, what are some of the advantages that C# has over Python?\nThe reason I ask is that one of my friends runs a private server for an online game (UO), and he offered to make me a dev if I wanted, but the software for the server is all written in C#. I'd love to do this, but I don't really have time to do multiple languages, and I was just after a few more reasons to justify taking C# over Python to myself.\nI'm doing this all self-taught as a hobby, btw","AnswerCount":10,"Available Count":7,"Score":1.0,"is_accepted":false,"ViewCount":7557,"Q_Id":2484578,"Users Score":13,"Answer":"Visual Studio - the best IDE out there.\nOf the statically typed languages in circulation, C# is very productive.","Q_Score":10,"Tags":"c#,python","A_Id":2484624,"CreationDate":"2010-03-20T20:12:00.000","Title":"what are the advantages of C# over 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},{"Question":"I like Python mostly for the great portability and the ease of coding, but I was wondering, what are some of the advantages that C# has over Python?\nThe reason I ask is that one of my friends runs a private server for an online game (UO), and he offered to make me a dev if I wanted, but the software for the server is all written in C#. I'd love to do this, but I don't really have time to do multiple languages, and I was just after a few more reasons to justify taking C# over Python to myself.\nI'm doing this all self-taught as a hobby, btw","AnswerCount":10,"Available Count":7,"Score":0.0,"is_accepted":false,"ViewCount":7557,"Q_Id":2484578,"Users Score":0,"Answer":"I've found it helpful to work with different languages, since they each have their strengths. Python is extremely powerful, but relies heavily on good coding conventions and practices to keep code maintainable. In particular, it does not enforce type safety or insulation, which means it is easy to abuse. C# is a modern object oriented language, with strong typing and other features to help enforce insulation and encapsulation. It's not as wildly flexible, but I've also found that larger C# programs are much easier to maintain (especially when you inherit them from other developers.)","Q_Score":10,"Tags":"c#,python","A_Id":2484609,"CreationDate":"2010-03-20T20:12:00.000","Title":"what are the advantages of C# over 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},{"Question":"I like Python mostly for the great portability and the ease of coding, but I was wondering, what are some of the advantages that C# has over Python?\nThe reason I ask is that one of my friends runs a private server for an online game (UO), and he offered to make me a dev if I wanted, but the software for the server is all written in C#. I'd love to do this, but I don't really have time to do multiple languages, and I was just after a few more reasons to justify taking C# over Python to myself.\nI'm doing this all self-taught as a hobby, btw","AnswerCount":10,"Available Count":7,"Score":1.2,"is_accepted":true,"ViewCount":7557,"Q_Id":2484578,"Users Score":9,"Answer":"There are lots of differences, advantages as well as disadvantages. I guess the main advantages would be along the lines of\n\nExcellent Windows integration, including access to all standard GUI functions and other libraries.\nJIT compilation, resulting in better performance than Python, in some or most circumstances. As has been pointed out, this is now also possible in Python.\nOn Windows, the IDE support is arguably better for C#. Visual Studio is a well established and advanced development environment and the \"Express\" editions are free for personal use. In a non-Windows environment, it's probably a draw between different editors.\n\nThe rest is basically up to personal preference (statically typed versus dynamically, C-like syntax or not, etc.).","Q_Score":10,"Tags":"c#,python","A_Id":2484595,"CreationDate":"2010-03-20T20:12:00.000","Title":"what are the advantages of C# over 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},{"Question":"I like Python mostly for the great portability and the ease of coding, but I was wondering, what are some of the advantages that C# has over Python?\nThe reason I ask is that one of my friends runs a private server for an online game (UO), and he offered to make me a dev if I wanted, but the software for the server is all written in C#. I'd love to do this, but I don't really have time to do multiple languages, and I was just after a few more reasons to justify taking C# over Python to myself.\nI'm doing this all self-taught as a hobby, btw","AnswerCount":10,"Available Count":7,"Score":0.0599281035,"is_accepted":false,"ViewCount":7557,"Q_Id":2484578,"Users Score":3,"Answer":"C# is supported by Microsoft ;) (expecting comments)\nC# is typesafe which comes with its advantages.\nNothing is better when you are developing windows applications.\nIts syntax is also very well designed. Code looks pretty good.\nIts worth learning because lots of code is written and is being written in it.\nIt feels so good when you code in C# in Visual Studio. I am still searching for such a nice IDE for Python.\nWith C# you can explore lots of interesting things .NET,WPF,WCF,XNA,ASP.NET,Jon Skeet's Blog... etc.","Q_Score":10,"Tags":"c#,python","A_Id":2485085,"CreationDate":"2010-03-20T20:12:00.000","Title":"what are the advantages of C# over 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},{"Question":"I like Python mostly for the great portability and the ease of coding, but I was wondering, what are some of the advantages that C# has over Python?\nThe reason I ask is that one of my friends runs a private server for an online game (UO), and he offered to make me a dev if I wanted, but the software for the server is all written in C#. I'd love to do this, but I don't really have time to do multiple languages, and I was just after a few more reasons to justify taking C# over Python to myself.\nI'm doing this all self-taught as a hobby, btw","AnswerCount":10,"Available Count":7,"Score":0.0,"is_accepted":false,"ViewCount":7557,"Q_Id":2484578,"Users Score":0,"Answer":"Well, the ease of coding is debatable. I find C# easier to code when you factor in the help you get from teh IDEs (e.g. the free Visual Web Developer). \nSo, portability is less of an issue if you factor in Mono. Performance can be better in some scenarios. I find the online documentation to be generally better in .NET.\nHave you considered IronPython? If you guys are willing to use one of the .Net distros that have the DLR in them (4.0's your best bet there, but some of the DLR betas are alright), then you can write C# code and Python code and have them work together w\/o any difficulties outside naming conventions being a bit different.","Q_Score":10,"Tags":"c#,python","A_Id":2484612,"CreationDate":"2010-03-20T20:12:00.000","Title":"what are the advantages of C# over 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},{"Question":"I like Python mostly for the great portability and the ease of coding, but I was wondering, what are some of the advantages that C# has over Python?\nThe reason I ask is that one of my friends runs a private server for an online game (UO), and he offered to make me a dev if I wanted, but the software for the server is all written in C#. I'd love to do this, but I don't really have time to do multiple languages, and I was just after a few more reasons to justify taking C# over Python to myself.\nI'm doing this all self-taught as a hobby, btw","AnswerCount":10,"Available Count":7,"Score":0.0,"is_accepted":false,"ViewCount":7557,"Q_Id":2484578,"Users Score":0,"Answer":"C# can directly access pointers via \"unmanaged code\", which can give it a performance advantage in some situations.","Q_Score":10,"Tags":"c#,python","A_Id":2484650,"CreationDate":"2010-03-20T20:12:00.000","Title":"what are the advantages of C# over 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},{"Question":"i am creating ( researching possibility of ) a highly customizable python client and would like to allow users to actually edit the code in another language to customize the running of program. ( analogous to browser which itself coded in c\/c++ and run another language html\/js ). so my question is , is there any programming language implemented in pure python which i can see as a reference ( or use directly ? ) -- i need simple language ( simple statements and ifs can do )\nedit: sorry if i did not make myself clear but what i want is \"a language to customize the running of program\" , even though pypi seems a great option, what i am looking for is more simple which i can study and extend myself if need arise. my google searches pointing towards xml based langagues. ( BMEL , XForms etc ).","AnswerCount":8,"Available Count":3,"Score":1.2,"is_accepted":true,"ViewCount":1368,"Q_Id":2486348,"Users Score":1,"Answer":"Numerous template languages such as Cheetah, Django templates, Genshi, Mako, Mighty might serve as an example.","Q_Score":2,"Tags":"python,programming-languages,interpreter","A_Id":2487912,"CreationDate":"2010-03-21T07:46:00.000","Title":"programming language implemented in pure 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},{"Question":"i am creating ( researching possibility of ) a highly customizable python client and would like to allow users to actually edit the code in another language to customize the running of program. ( analogous to browser which itself coded in c\/c++ and run another language html\/js ). so my question is , is there any programming language implemented in pure python which i can see as a reference ( or use directly ? ) -- i need simple language ( simple statements and ifs can do )\nedit: sorry if i did not make myself clear but what i want is \"a language to customize the running of program\" , even though pypi seems a great option, what i am looking for is more simple which i can study and extend myself if need arise. my google searches pointing towards xml based langagues. ( BMEL , XForms etc ).","AnswerCount":8,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":1368,"Q_Id":2486348,"Users Score":0,"Answer":"Possibly Common Lisp (or any other Lisp) will be the best choice for that task. Because Lisp make it possible to easily extend host language with powerful macroses and construct DSL (domain specific language).","Q_Score":2,"Tags":"python,programming-languages,interpreter","A_Id":2486375,"CreationDate":"2010-03-21T07:46:00.000","Title":"programming language implemented in pure 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},{"Question":"i am creating ( researching possibility of ) a highly customizable python client and would like to allow users to actually edit the code in another language to customize the running of program. ( analogous to browser which itself coded in c\/c++ and run another language html\/js ). so my question is , is there any programming language implemented in pure python which i can see as a reference ( or use directly ? ) -- i need simple language ( simple statements and ifs can do )\nedit: sorry if i did not make myself clear but what i want is \"a language to customize the running of program\" , even though pypi seems a great option, what i am looking for is more simple which i can study and extend myself if need arise. my google searches pointing towards xml based langagues. ( BMEL , XForms etc ).","AnswerCount":8,"Available Count":3,"Score":0.024994793,"is_accepted":false,"ViewCount":1368,"Q_Id":2486348,"Users Score":1,"Answer":"Why not Python itself? With some care you can use eval to run user code.\nOne of the good thing about interpreted scripting languages is that you don't need another extra scripting language!","Q_Score":2,"Tags":"python,programming-languages,interpreter","A_Id":2486403,"CreationDate":"2010-03-21T07:46:00.000","Title":"programming language implemented in pure 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},{"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},{"Question":"I have been learning a bit of Python 2 and Python 3 and it seems like Python 2 is overall better than Python 3. So that's where my question comes in. Are there any good reasons to actually switch over to python 3?","AnswerCount":5,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":5413,"Q_Id":2489299,"Users Score":0,"Answer":"More iterators (in things like dict.keys()) will be a big boost for web applications.\nThe core team will put more work into the new version. New books might focus on python 3 (see Dive into Python), but the real work is still done in python 2.\nSooner or later, the big libraries (numpy, wx, django) will be ported. Until those big three switch, I can't see many people using python 3. But those aren't impossible projects to port.\nOnce the big libraries are ported, the community will face a real choice. That's when it will start to catch on.","Q_Score":23,"Tags":"python,python-3.x","A_Id":2490394,"CreationDate":"2010-03-21T23:54:00.000","Title":"Will Python 3 ever catch 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":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have been learning a bit of Python 2 and Python 3 and it seems like Python 2 is overall better than Python 3. So that's where my question comes in. Are there any good reasons to actually switch over to python 3?","AnswerCount":5,"Available Count":3,"Score":1.2,"is_accepted":true,"ViewCount":5413,"Q_Id":2489299,"Users Score":32,"Answer":"On the whole, and even in most details, Python3 is better than Python2.\nThe only area where Python 3 is lagging is with regards to 3rd party libraries. What makes Python great is not only its intrinsic characteristics as a language and its rather extensive standard library, but also the existence of a whole \"eco-system\" of libraries which support so many specific applications of the language.\nSeveral such libraries are, at the moment not fully ported to Python 3.x and this sometimes results in keeping people developing under Python 2.x.\nThis situation may seem a bit like a chicken and egg problem: Application developers won't move to 3.x till the libraries \"get there\", libraries developers would rather only maintain one branch and are waiting in an attempt to time the porting to Py3k in a way that they can put the their Py2.x branches in maintenance shortly thereafter.\nThis situation is somewhat of a testimony the satisfaction people have of Python 2.x (or phrased more negatively, to the lack of truly compelling incentives for a move to 3.x; while Py3k is better and poised for better things yet, as-is, it doesn't have any features that would prompt a move to 3.x \"en masse\".) This said, I believe the momentum is effectively in favor of Python 3. \nTo back this up, I was about to mention the likelihood that Unladen Swallow be only ported to Py3k-only, providing some strong incentive for the move. But Alex Martelli has started answering this question, and is using this example. Obviously Alex speaks first-hand of these roadmap questions, please get it from the Master!\nA word of caution regarding Py3k versions: Be sure to use the most recent version (currently 3.1.2, soon 3.2.x will replace it as the most recent stable version). Beware that some folks (like me) occasionally use the expression \"3.0\" to reference the generic name for all Py3k (or even for the current version thereof). The short lived 3.0 version per-se is now \"defunct\" and of no interest but maybe forensic specialists ;-)","Q_Score":23,"Tags":"python,python-3.x","A_Id":2489398,"CreationDate":"2010-03-21T23:54:00.000","Title":"Will Python 3 ever catch 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":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have been learning a bit of Python 2 and Python 3 and it seems like Python 2 is overall better than Python 3. So that's where my question comes in. Are there any good reasons to actually switch over to python 3?","AnswerCount":5,"Available Count":3,"Score":1.0,"is_accepted":false,"ViewCount":5413,"Q_Id":2489299,"Users Score":6,"Answer":"The main thing holding Python 3.x back right now is the lack of third-party libraries. I'll be converting my code as soon as SciPy gets ported.","Q_Score":23,"Tags":"python,python-3.x","A_Id":2489395,"CreationDate":"2010-03-21T23:54:00.000","Title":"Will Python 3 ever catch 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":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"How could I check if a number is a perfect square?\nSpeed is of no concern, for now, just working.","AnswerCount":24,"Available Count":2,"Score":0.0083331404,"is_accepted":false,"ViewCount":193572,"Q_Id":2489435,"Users Score":1,"Answer":"You could binary-search for the rounded square root. Square the result to see if it matches the original value.\nYou're probably better off with FogleBirds answer - though beware, as floating point arithmetic is approximate, which can throw this approach off. You could in principle get a false positive from a large integer which is one more than a perfect square, for instance, due to lost precision.","Q_Score":103,"Tags":"python,math,perfect-square","A_Id":2489474,"CreationDate":"2010-03-22T00:48:00.000","Title":"Check if a number is a perfect square","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"How could I check if a number is a perfect square?\nSpeed is of no concern, for now, just working.","AnswerCount":24,"Available Count":2,"Score":-0.0083331404,"is_accepted":false,"ViewCount":193572,"Q_Id":2489435,"Users Score":-1,"Answer":"Decide how long the number will be.\ntake a delta 0.000000000000.......000001\nsee if the (sqrt(x))^2 - x is greater \/ equal \/smaller than delta and decide based on the delta error.","Q_Score":103,"Tags":"python,math,perfect-square","A_Id":2489814,"CreationDate":"2010-03-22T00:48:00.000","Title":"Check if a number is a perfect square","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Just wondering whats the best way to test Python CGI while developing a site?\n(I'm used to PHP for web dev so bear with me :P)","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":893,"Q_Id":2490150,"Users Score":0,"Answer":"There are a number of Python web frameworks which make this easier for you. Django, for example, has a built-in web server designed for testing out your application.\nHowever, if you're already using CGI, the easiest way to test it would be to run Apache. Configuring CGI for Apache is straightforward and there is a lot of good documentation.","Q_Score":0,"Tags":"python,cgi","A_Id":2490241,"CreationDate":"2010-03-22T05:27:00.000","Title":"Best\/Fastest Way to Test Python CGI locally?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I need to create daemon that will monitor certain directory and will process every file that's written to that particular path.\nMy choice is either java or python.\nDid you guys have any experience using both technology? what is the best one?\nEDIT 1: files that will be processed is simple text file (one line with tab separated fields).\nI just need to move it to buffer and send to further to my php file.\nEDIT 2: It's for freebsd server","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1498,"Q_Id":2490291,"Users Score":0,"Answer":"Performance-wise, for an I\/O - syscall bound task such as you're mentioning, it's going to be a wash, most likely, depending a bit on the platform. Java tends to have better CPU usage (partly because a JVM can effectively use multiple cores on a multicore CPU on different threads, with CPython having problems with that; partly because of strong JIT abilities), but typically pays for them with higher RAM footprints (no big deal if you have 64GB of RAM laying around and not much else to do on the machine, say, but often an issue in other circumstances).\nIf you specify the platform (Linux vs Windows vs ...), we might be able to offer more help.\nEdit: with processing required as light as the OP's mentioned in the Q's edit, there's really nothing either way in the CPU-load part of the task. Unfortunately I don't know what freebsd offers for \"directory watching\" (like Linux's inotify, etc).","Q_Score":1,"Tags":"java,python,file-io","A_Id":2490299,"CreationDate":"2010-03-22T06:07:00.000","Title":"Performance Wise, Python VS JAVA For File Based Processing","Data Science and Machine Learning":0,"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},{"Question":"Hey - I'm new to python , and I'm having a hard time grasping the concept of Unit testing in python.\nI'm coming from Java - so unit testing makes sense because - well , there you actually have a unit - A Class. But a Python class is not necessarily the same as a Java class , and the way I use Python - as a scripting language - is more functional then OOP - So what do you \"unit test\" in Python ? A flow? \nThanks!","AnswerCount":4,"Available Count":1,"Score":0.2449186624,"is_accepted":false,"ViewCount":941,"Q_Id":2490715,"Users Score":5,"Answer":"If you make functional programming then the unit is the function and I would recommend to unit test your functions","Q_Score":4,"Tags":"python,unit-testing","A_Id":2490736,"CreationDate":"2010-03-22T08:11:00.000","Title":"Unit testing 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},{"Question":"Hello fellow software developers.\nI want to distribute a C program which is scriptable by embedding the Python interpreter.\nThe C program uses Py_Initialize, PyImport_Import and so on to accomplish Python embedding.\nI'm looking for a solution where I distribute only the following components: \n\nmy program executable and its libraries\nthe Python library (dll\/so) \na ZIP-file containing all necessary Python modules and libraries.\n\nHow can I accomplish this? Is there a step-by-step recipe for that?\nThe solution should be suitable for both Windows and Linux.\nThanks in advance.","AnswerCount":6,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":5060,"Q_Id":2494468,"Users Score":0,"Answer":"There's a program called py2exe. I don't know if it's only available for Windows. Also, the latest version that I used does not wrap everything up into one .exe file. It creates a bunch of stuff that has to be distributed - a zip file, etc..","Q_Score":11,"Tags":"python,c,dll,distribution","A_Id":2540638,"CreationDate":"2010-03-22T17:43:00.000","Title":"How to create an application which embeds and runs Python code without local Python installation?","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},{"Question":"A new web application may require adding Artificial Intelligence (AI) in the future, e.g. using ProLog. I know it can be done from a Java environment, but I am wondering about the opportunities with modern web languages like Ruby or Python. The latter is considered to be \"more scientific\" (at least used in that environment), but using Google there seems to be a preliminary ProLog implementation for both. \nAny suggestions on modern (open source) web languages (like Python or Ruby) in combination with AI?","AnswerCount":5,"Available Count":2,"Score":1.0,"is_accepted":false,"ViewCount":3942,"Q_Id":2495350,"Users Score":7,"Answer":"The selection of language is completely irrelevant, all other things being equal.\nIf you're trying to do X and there's a library for it in language Y and meshes well with your Web-based framework, then use it.\nWithout knowing more about what specific areas of AI you're interested in, the question is far too vague to be answered with any more specificity.","Q_Score":4,"Tags":"python,ruby-on-rails,artificial-intelligence,prolog","A_Id":2497026,"CreationDate":"2010-03-22T20:09:00.000","Title":"Python or Ruby for webbased Artificial Intelligence?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"A new web application may require adding Artificial Intelligence (AI) in the future, e.g. using ProLog. I know it can be done from a Java environment, but I am wondering about the opportunities with modern web languages like Ruby or Python. The latter is considered to be \"more scientific\" (at least used in that environment), but using Google there seems to be a preliminary ProLog implementation for both. \nAny suggestions on modern (open source) web languages (like Python or Ruby) in combination with AI?","AnswerCount":5,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":3942,"Q_Id":2495350,"Users Score":0,"Answer":"You could also use Scala (which is a bit functional and runs on the JVW) and the existing Lift framework for web-stuff.","Q_Score":4,"Tags":"python,ruby-on-rails,artificial-intelligence,prolog","A_Id":2498323,"CreationDate":"2010-03-22T20:09:00.000","Title":"Python or Ruby for webbased Artificial Intelligence?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I need to programatically encrypt a directory of files, like in a .zip or whatever. Preferably password protected obviously.\nHow can I accomplish this, and WHAT IS the BEST encryption way to do it, if applicable?\nProgramming language doesn't matter. I am dictioned in all syntax.","AnswerCount":6,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":4494,"Q_Id":2498009,"Users Score":4,"Answer":"How can I accomplish this, and WHAT IS\n the BEST encryption way to do it, if\n applicable?\n\n\ntar and gzip the directory. \nGenerate a random bit stream of equal size to the file\nRun bitwise XOR on the streams\n\nOnly truly secure method is a truly random one time pad.","Q_Score":4,"Tags":"java,.net,c++,python,encryption","A_Id":2498054,"CreationDate":"2010-03-23T06:36:00.000","Title":"Best way to encrypt a directory of 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},{"Question":"I need to programatically encrypt a directory of files, like in a .zip or whatever. Preferably password protected obviously.\nHow can I accomplish this, and WHAT IS the BEST encryption way to do it, if applicable?\nProgramming language doesn't matter. I am dictioned in all syntax.","AnswerCount":6,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":4494,"Q_Id":2498009,"Users Score":3,"Answer":"I still say 7-zip is the answer. It hasn't been \"cracked\".","Q_Score":4,"Tags":"java,.net,c++,python,encryption","A_Id":2498034,"CreationDate":"2010-03-23T06:36:00.000","Title":"Best way to encrypt a directory of 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},{"Question":"I'm using Hudson CI with a Python project. I've installed the Violations plugin and configured it to run the code against pylint. This works, but I only see a list of violations without linking to the source code. Is it possible to setup Violations and pylint to load and highlight the violating source files (something similar to the Cobertura Coverage Reports)?\nBetter yet, can Violations integrate with pep8.py?","AnswerCount":3,"Available Count":1,"Score":0.1325487884,"is_accepted":false,"ViewCount":600,"Q_Id":2502345,"Users Score":2,"Answer":"Well, after some more debugging, I realized that the pylint output file referenced the source code files relative to where pylint was being run, which wasn't the same path that Hudson needed. Basically, Violations needed the paths relative to the Hudson workspace.","Q_Score":3,"Tags":"python,hudson","A_Id":2502582,"CreationDate":"2010-03-23T17:56:00.000","Title":"Is it possible to see the source code of the violating files in Hudson with Violations and Pylint?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I'm not sure if I like Python's dynamic-ness. It often results in me forgetting to check a type, trying to call an attribute and getting the NoneType (or any other) has no attribute x error. A lot of them are pretty harmless but if not handled correctly they can bring down your entire app\/process\/etc. \nOver time I got better predicting where these could pop up and adding explicit type checking, but because I'm only human I miss one occasionally and then some end-user finds it.\nSo I'm interested in your strategy to avoid these. Do you use type-checking decorators? Maybe special object wrappers? \nPlease share...","AnswerCount":10,"Available Count":3,"Score":0.0798297691,"is_accepted":false,"ViewCount":2459,"Q_Id":2503444,"Users Score":4,"Answer":"If you write good unit tests for all of your code, you should find the errors very quickly when testing code.","Q_Score":11,"Tags":"python","A_Id":2503474,"CreationDate":"2010-03-23T20:40:00.000","Title":"What is your strategy to avoid dynamic typing errors in Python (NoneType has no attribute 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":0,"Web Development":0},{"Question":"I'm not sure if I like Python's dynamic-ness. It often results in me forgetting to check a type, trying to call an attribute and getting the NoneType (or any other) has no attribute x error. A lot of them are pretty harmless but if not handled correctly they can bring down your entire app\/process\/etc. \nOver time I got better predicting where these could pop up and adding explicit type checking, but because I'm only human I miss one occasionally and then some end-user finds it.\nSo I'm interested in your strategy to avoid these. Do you use type-checking decorators? Maybe special object wrappers? \nPlease share...","AnswerCount":10,"Available Count":3,"Score":1.2,"is_accepted":true,"ViewCount":2459,"Q_Id":2503444,"Users Score":8,"Answer":"forgetting to check a type\n\nThis doesn't make much sense. You so rarely need to \"check\" a type. You simply run unit tests and if you've provided the wrong type object, things fail. You never need to \"check\" much, in my experience.\n\ntrying to call an attribute and\n getting the NoneType (or any other)\n has no attribute x error.\n\nUnexpected None is a plain-old bug. 80% of the time, I omitted the return. Unit tests always reveal these.\nOf those that remain, 80% of the time, they're plain old bugs due to an \"early exit\" which returns None because someone wrote an incomplete return statement. These if foo: return structures are easy to detect with unit tests. In some cases, they should have been if foo: return somethingMeaningful, and in still other cases, they should have been if foo: raise Exception(\"Foo\"). \nThe rest are dumb mistakes misreading the API's. Generally, mutator functions don't return anything. Sometimes I forget. Unit tests find these quickly, since basically, nothing works right.\nThat covers the \"unexpected None\" cases pretty solidly. Easy to unit test for. Most of the mistakes involve fairly trivial-to-write tests for some pretty obvious species of mistakes: wrong return; failure to raise an exception.\nOther \"has no attribute X\" errors are really wild mistakes where a totally wrong type was used. That's either really wrong assignment statements or really wrong function (or method) calls. They always fail elaborately during unit testing, requiring very little effort to fix.\n\nA lot of them are pretty harmless but if not handled correctly they can bring down your entire app\/process\/etc.\n\nUm... Harmless? If it's a bug, I pray that it brings down my entire app as quickly as possible so I can find it. A bug that doesn't crash my app is the most horrible situation imaginable. \"Harmless\" isn't a word I'd use for a bug that fails to crash my app.","Q_Score":11,"Tags":"python","A_Id":2503704,"CreationDate":"2010-03-23T20:40:00.000","Title":"What is your strategy to avoid dynamic typing errors in Python (NoneType has no attribute 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":0,"Web Development":0},{"Question":"I'm not sure if I like Python's dynamic-ness. It often results in me forgetting to check a type, trying to call an attribute and getting the NoneType (or any other) has no attribute x error. A lot of them are pretty harmless but if not handled correctly they can bring down your entire app\/process\/etc. \nOver time I got better predicting where these could pop up and adding explicit type checking, but because I'm only human I miss one occasionally and then some end-user finds it.\nSo I'm interested in your strategy to avoid these. Do you use type-checking decorators? Maybe special object wrappers? \nPlease share...","AnswerCount":10,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":2459,"Q_Id":2503444,"Users Score":0,"Answer":"I haven\u2019t done a lot of Python programming, but I\u2019ve done no programming at all in staticly typed languages, so I don\u2019t tend to think about things in terms of variable types. That might explain why I haven\u2019t come across this problem much. (Although the small amount of Python programming I\u2019ve done might explain that too.)\nI do enjoy Python 3\u2019s revised handling of strings (i.e. all strings are unicode, everything else is just a stream of bytes), because in Python 2 you might not notice TypeErrors until dealing with unusual real world string values.","Q_Score":11,"Tags":"python","A_Id":2503535,"CreationDate":"2010-03-23T20:40:00.000","Title":"What is your strategy to avoid dynamic typing errors in Python (NoneType has no attribute 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":0,"Web Development":0},{"Question":"Suppose you take the strings 'a' and 'z' and list all the strings that come between them in alphabetical order: ['a','b','c' ... 'x','y','z']. Take the midpoint of this list and you find 'm'. So this is kind of like taking an average of those two strings.\nYou could extend it to strings with more than one character, for example the midpoint between 'aa' and 'zz' would be found in the middle of the list ['aa', 'ab', 'ac' ... 'zx', 'zy', 'zz'].\nMight there be a Python method somewhere that does this? If not, even knowing the name of the algorithm would help.\nI began making my own routine that simply goes through both strings and finds midpoint of the first differing letter, which seemed to work great in that 'aa' and 'az' midpoint was 'am', but then it fails on 'cat', 'doggie' midpoint which it thinks is 'c'. I tried Googling for \"binary search string midpoint\" etc. but without knowing the name of what I am trying to do here I had little luck. \nI added my own solution as an answer","AnswerCount":8,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":2674,"Q_Id":2510755,"Users Score":6,"Answer":"It sounds like what you want, is to treat alphabetical characters as a base-26 value between 0 and 1. When you have strings of different length (an example in base 10), say 305 and 4202, your coming out with a midpoint of 3, since you're looking at the characters one at a time. Instead, treat them as a floating point mantissa: 0.305 and 0.4202. From that, it's easy to come up with a midpoint of .3626 (you can round if you'd like).\nDo the same with base 26 (a=0...z=25, ba=26, bb=27, etc.) to do the calculations for letters:\ncat becomes 'a.cat' and doggie becomes 'a.doggie', doing the math gives cat a decimal value of 0.078004096, doggie a value of 0.136390697, with an average of 0.107197397 which in base 26 is roughly \"cumcqo\"","Q_Score":8,"Tags":"python,algorithm","A_Id":2510928,"CreationDate":"2010-03-24T19:19:00.000","Title":"Average of two strings in alphabetical\/lexicographical order","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I was asked to write a code translator that would take a Python program and produce a C program. Do you have any ideas how could I approach this problem or is it even possible?","AnswerCount":4,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":11985,"Q_Id":2525518,"Users Score":7,"Answer":"There's a fundamental question here: is the intent to basically create a Python compiler that uses C as a back-end, or to convert the program to C and maintain the C afterward?\nWriting a compiler that produces (really ugly) C as its output probably isn't trivial -- a compiler rarely is, and generating code for Python will be more difficult than for a lot of other languages (dynamic typing, in particular, is hard to compile, at least to very efficient output). OTOH, at least the parser will be a lot easier than for some languages.\nIf by \"translating\", you mean converting Python to C that's readable and maintainable, that's a whole different question -- it's substantially more difficult, to put it mildly. Realistically, I doubt any machine translation will be worth much -- there are just too large of differences in how you normally approach problems in Python and C for there to be much hope of a decent machine translation.","Q_Score":11,"Tags":"python,c,code-translation","A_Id":2525638,"CreationDate":"2010-03-26T17:50:00.000","Title":"Writing code translator from Python to 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":0,"Web Development":0},{"Question":"First off I will say I am completely new to security in coding. I am currently helping a friend develop a small game (in Python) which will have a login server. I don't have much knowledge regarding security, but I know many games do have issues with this. Everything from 3rd party applications (bots) to WPE packet manipulation. Considering how small this game will be and the limited user base, I doubt we will have serious issues, but would like to try our best to limit problems. I am not sure where to start or what methods I should use, or what's worth it. For example, sending data to the server such as login name and password. \nI was told his information should be encrypted when sending, so in-case someone was viewing it (with whatever means), that they couldn't get into the account. However, if someone is able to capture the encrypted string, wouldn't this string always work since it's decrypted server side? In other words, someone could just capture the packet, reuse it, and still gain access to the account?\nThe main goal I am really looking for is to make sure the players are logging into the game with the client we provide, and to make sure it's 'secure' (broad, I know). I have looked around at different methods such as Public and Private Key encryption, which I am sure any hex editor could eventually find. There are many other methods that seem way over my head at the moment and leave the impression of overkill.\nI realize nothing is 100% secure. I am just looking for any input or reading material (links) to accomplish the main goal stated above. Would appreciate any help, thanks.","AnswerCount":4,"Available Count":3,"Score":0.049958375,"is_accepted":false,"ViewCount":1320,"Q_Id":2526110,"Users Score":1,"Answer":"As for how to protect the client... The most realistic thing is to say that you don't. When you're writing the server code, never trust any data that the client sends you. Never give the client any information you don't want the player to have.\nIn some games, like chess (or really anything turn-based), that actually works pretty well, because it's very easy for the server to verify that the move passed in by the client is a legal move.\nIn other games, those restrictions aren't so practical, and then I don't know what you'd do, from a code perspective. I'd try to shift the problem to a social one at that point: Are the other players people you'd trust to bring their own dice to your gaming table? If not, can you play with someone else?","Q_Score":4,"Tags":"python,security,authentication,login","A_Id":2526606,"CreationDate":"2010-03-26T19:25:00.000","Title":"Game login authentication and security","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"First off I will say I am completely new to security in coding. I am currently helping a friend develop a small game (in Python) which will have a login server. I don't have much knowledge regarding security, but I know many games do have issues with this. Everything from 3rd party applications (bots) to WPE packet manipulation. Considering how small this game will be and the limited user base, I doubt we will have serious issues, but would like to try our best to limit problems. I am not sure where to start or what methods I should use, or what's worth it. For example, sending data to the server such as login name and password. \nI was told his information should be encrypted when sending, so in-case someone was viewing it (with whatever means), that they couldn't get into the account. However, if someone is able to capture the encrypted string, wouldn't this string always work since it's decrypted server side? In other words, someone could just capture the packet, reuse it, and still gain access to the account?\nThe main goal I am really looking for is to make sure the players are logging into the game with the client we provide, and to make sure it's 'secure' (broad, I know). I have looked around at different methods such as Public and Private Key encryption, which I am sure any hex editor could eventually find. There are many other methods that seem way over my head at the moment and leave the impression of overkill.\nI realize nothing is 100% secure. I am just looking for any input or reading material (links) to accomplish the main goal stated above. Would appreciate any help, thanks.","AnswerCount":4,"Available Count":3,"Score":0.049958375,"is_accepted":false,"ViewCount":1320,"Q_Id":2526110,"Users Score":1,"Answer":"The simple answer to how to protect the password going over the wire, replay attacks, and message tampering is: use SSL. Yes, there are other things you can do with challenge-response authentication schemes for the login part of it, but it sounds like you really want the whole channel protected anyway. Use SSL at the socket layer and then you don't have to do anything else complicated with how you send your credentials.","Q_Score":4,"Tags":"python,security,authentication,login","A_Id":2526532,"CreationDate":"2010-03-26T19:25:00.000","Title":"Game login authentication and security","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"First off I will say I am completely new to security in coding. I am currently helping a friend develop a small game (in Python) which will have a login server. I don't have much knowledge regarding security, but I know many games do have issues with this. Everything from 3rd party applications (bots) to WPE packet manipulation. Considering how small this game will be and the limited user base, I doubt we will have serious issues, but would like to try our best to limit problems. I am not sure where to start or what methods I should use, or what's worth it. For example, sending data to the server such as login name and password. \nI was told his information should be encrypted when sending, so in-case someone was viewing it (with whatever means), that they couldn't get into the account. However, if someone is able to capture the encrypted string, wouldn't this string always work since it's decrypted server side? In other words, someone could just capture the packet, reuse it, and still gain access to the account?\nThe main goal I am really looking for is to make sure the players are logging into the game with the client we provide, and to make sure it's 'secure' (broad, I know). I have looked around at different methods such as Public and Private Key encryption, which I am sure any hex editor could eventually find. There are many other methods that seem way over my head at the moment and leave the impression of overkill.\nI realize nothing is 100% secure. I am just looking for any input or reading material (links) to accomplish the main goal stated above. Would appreciate any help, thanks.","AnswerCount":4,"Available Count":3,"Score":0.049958375,"is_accepted":false,"ViewCount":1320,"Q_Id":2526110,"Users Score":1,"Answer":"This is a tough problem, because the code runs on the client. The replay problem can be solved by using a challenge by letting the server sending a random token which the client adds to the string to be encrypted. This way, the password string will be different each time, and replaying the encrypted string doesn't work (as the server checks if the encrypted password has the last sent token)\nThe problem is that the encryption key has to be stored on the client, and it's possible to retrieve that key.","Q_Score":4,"Tags":"python,security,authentication,login","A_Id":2526148,"CreationDate":"2010-03-26T19:25:00.000","Title":"Game login authentication and security","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I have a very large directory tree I am wanting pyInotify to watch.\nIs it better to have pyInotify watch the entire tree or is it better to have a number of watches reporting changes to specific files ?\nThanks","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":522,"Q_Id":2526273,"Users Score":0,"Answer":"If you're going to watch only a few files in a huge tree, it makes sense to watch individual files. On the other hand, if you're going to watch almost all files in the tree, watching the entire tree instead makes sense. To know the point of turn exactly, you must benchmark both to see which one performs better.","Q_Score":0,"Tags":"python,pyinotify","A_Id":2526820,"CreationDate":"2010-03-26T19:48:00.000","Title":"pyInotify 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":0},{"Question":"I'm part of a six-member build and release team for an embedded software company. We also support a lot of developer tools, such as Atlassian's Fisheye, Jira, etc., Perforce, Bugzilla, AnthillPro, and a couple of homebrew tools (like my Django release notes generator).\nMost of the time, our team just writes little plugins for larger apps (ex: customize workflows in Anthill), long-term utility scripts (package up a release for QA), or things like Perforce triggers (don't let people check into a specific branch unless their change description includes a bug number; authenticate against Active Directory instead of Perforce's internal passwords). That's about the scale of our problems, although we sometimes tackle something slightly more sizable.\nMy boss, who is reasonably technical, has asked us to standardize on one or two languages so we can more easily substitute for each other. He's advocating bash scripts and Perl, due to their universality and simplicity. I can see his point--we mostly do \"glue\", so why not use \"glue\" languages rather than saddle ourselves with something designed for much larger projects? Since some of the tools we work with are Java-based, we do need to use something that speaks JVM sometimes. (The path of least resistance for these projects is BeanShell and Groovy.) I feel a tremendous itch toward language advocacy, but I'm trying to avoid saying \"We should use Python 'cause I like it and Perl is gross.\"\nInstead, I'm trying to come up with a good approach to defining our problem set: what problems do we solve with scripts? Would we benefit from a library of common functions by our team, or are most of our projects more isolated? What is it reasonable to expect my co-workers to learn? What languages give us the most ease of development and ease of modification?\nCan you folks suggest some useful ways to approach this problem, both for my own thinking process and to help me facilitate some brainstorming among my coworkers?","AnswerCount":4,"Available Count":2,"Score":-0.049958375,"is_accepted":false,"ViewCount":196,"Q_Id":2527867,"Users Score":-1,"Answer":"First, it's important to note that it is very hard to convince someone they're wrong.\n\nHe's advocating bash scripts and Perl,\n due to their universality and\n simplicity\n\nBash scripts are not simple. The bash programming model is really complex and unfriendly. if statements and expressions, in particular are horrifying.\nPerl may or may not be simple. \nBash is universal. Perl, however, is exactly as universal as Python. Python is pre-installed in almost all Linux distributions. So that argument is specious.\nThe \"universality\" of bash, Perl and python is exactly the same. The \"simplicity\", however, is not the same. You won't find it easy to to \"prove\" or \"convince\" anyone of this once they've already pronounced Perl as simple.\nThe Situation.\nIf the boss is advocating Perl, and Perl is not the answer, you will find it is very hard to convince someone they're wrong, making this effort nearly impossible.\nIf the boss was just throwing out ideas, then this is just difficult.\nQuick Hack.\nAn easy thing you can do is to attempt head-to-head comparisons of Python and Perl for some randomly-chosen jobs. You can then have a code walkthrough to demonstrate the relative opacity of Perl compared with the relative clarity of Python.\nEven this is fraught with terrible dangers.\n\nSome folks really think code golf is important. Python loses at code golf. Perl wins. There's nothing worse than \"Angry Co-worker with Perl Bias\" who will kill you with code-golf solutions that -- because they're smaller -- can baffle management into thinking that they're clearer or \"better\" on some arbitrary scale.\nSome folks really think explicit is \"wordy\" and bad. Python often loses because the assumptions are stated as actual parameter values. Some folks can (and do) complain at having to actually write things down. Read Stack Overflow for all of the Python questions where someone wants to make the try: block go away in a puff of assumptions.\n\nIf you choose random problems, you may -- accidentally -- chose something for which there's an existing piece of Perl or Python that can be downloaded and installed. A language can win just through an accident of the draw. Rather than a more in-depth comparison of language features.\nBest Bet\nThe best you can do is the following.\n\nIdentify what folks value. You can call these \"non-functional\" requirements. These are quality factors. What are the foundational, core principles? Open, Accessible, Transferrable Skills, Simplicity, Cleanliness, Honesty, Integrity, Thriftiness, Reverence, Patience, Hard Work, A Sense of Perspective, Reef the Main in Winds over 20 kn, etc. This is hard. No sympathy here.\nIdentify the technical use cases. These are \"functional\" requirements. Which bits of glue and integration there are? This is hard, also. Requirements erupt of out of the woodwork when you do this. Also, when you have a Perl bigot on the team, numerous non-functional requirements will pile into this area. Your manager -- who proposed Perl -- may be the Perl bigot, and the use cases may be difficult to collect in the presence of a Perl bigot.\nIdentify how (a) Perl + Bash vs. (b) Python vs. (c) Java fit this core values and the functional requirements. Note that using Python means you do not need to use Bash as much. My preference, BTW, is to pare Bash down to the rock-bottom minimum.\n\nThis is a big, difficult job. It's hard to short-cut. If you find that Perl is not the answer and the Perl bigot you need to convince is the manager who proposed Perl in the first place, you may find that convincing someone that they're wrong is very hard. \nEdit. I am aware that I am forbidden from using the string \"Perl Bigot\" to describe the manager's potential level of bias toward Perl. I, however, insist on using \"Perl Bigot\" to describe the manager who proposed Perl. The question provides no information on which to change this. The worst case is that (a) the manager is the Perl Bigot and (b) Perl is not the answer.","Q_Score":4,"Tags":"python,perl,groovy","A_Id":2529182,"CreationDate":"2010-03-27T02:10:00.000","Title":"Standardizing a Release\/Tools group on a specific 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":1},{"Question":"I'm part of a six-member build and release team for an embedded software company. We also support a lot of developer tools, such as Atlassian's Fisheye, Jira, etc., Perforce, Bugzilla, AnthillPro, and a couple of homebrew tools (like my Django release notes generator).\nMost of the time, our team just writes little plugins for larger apps (ex: customize workflows in Anthill), long-term utility scripts (package up a release for QA), or things like Perforce triggers (don't let people check into a specific branch unless their change description includes a bug number; authenticate against Active Directory instead of Perforce's internal passwords). That's about the scale of our problems, although we sometimes tackle something slightly more sizable.\nMy boss, who is reasonably technical, has asked us to standardize on one or two languages so we can more easily substitute for each other. He's advocating bash scripts and Perl, due to their universality and simplicity. I can see his point--we mostly do \"glue\", so why not use \"glue\" languages rather than saddle ourselves with something designed for much larger projects? Since some of the tools we work with are Java-based, we do need to use something that speaks JVM sometimes. (The path of least resistance for these projects is BeanShell and Groovy.) I feel a tremendous itch toward language advocacy, but I'm trying to avoid saying \"We should use Python 'cause I like it and Perl is gross.\"\nInstead, I'm trying to come up with a good approach to defining our problem set: what problems do we solve with scripts? Would we benefit from a library of common functions by our team, or are most of our projects more isolated? What is it reasonable to expect my co-workers to learn? What languages give us the most ease of development and ease of modification?\nCan you folks suggest some useful ways to approach this problem, both for my own thinking process and to help me facilitate some brainstorming among my coworkers?","AnswerCount":4,"Available Count":2,"Score":0.1973753202,"is_accepted":false,"ViewCount":196,"Q_Id":2527867,"Users Score":4,"Answer":"Google standardized on Python for such tasks (and many more) a bit before I joined the company; as far as I know, huge advantages such as Python's great implementations on the JVM and .NET didn't even play a role in the decision -- it was all about readability. At the time (and to some extent, even now) the theory at Google was that every engineer must be able, at need, to tweak every part of the codebase -- including of course build scripts, spiders (which were in Python at the time), and so forth. Demanding of engineers already proficient in C++ and Java to learn many more \"scripting\" languages (Python, Perl, Bash, Awk, Sed, and so forth) was simply unconsciounable: one had to be selected. Given that constraint, Python was the clear choice (under other constraints, Perl might also have been -- but I can't see the inevitable mix of Bash, Awk and Sed ever competing on such grounds!_) -- and that's how I ended up working there, a bit later;-).\nGiven that the overall potential of Python vs Ruby vs Perl vs PHP vs Bash + Awk + Sed vs ... is roughly equal, picking one is clearly a winner -- and Python has clean readability, strong implementations on JVM and .NET as big vigorishes. Seriously, I can only think of Javascript (inevitable for client-side work, now rich with strong implementations such as V8) as a possible \"competitor\" (unfortunately, JS inevitably carries on a lot of baggage for backwards compatibility -- unless you can use a use strict;-like constraint to help on that, it must be an important downside).","Q_Score":4,"Tags":"python,perl,groovy","A_Id":2527917,"CreationDate":"2010-03-27T02:10:00.000","Title":"Standardizing a Release\/Tools group on a specific 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":1},{"Question":"I've got a python\/WSGI app which needs to check to see if a user has logged on to a PHP web app. The problem is that the PHP app checks if a user has logged on by comparing a value in the $_SESSION variable to a value in the cookie from the user's browser. I would prefer to avoid changing the behavior of the php app if at all possible.\nMy questions:\n\nIs there anyway I can access the session variables from within python? Where should I start to look?\nAre there any obvious security\/performance issues I should be aware of when taking this approach?","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":5062,"Q_Id":2534525,"Users Score":1,"Answer":"Depends on the PHP app, if it's keeping session data in a database (MySQL maybe) you can just connect to the database and get the data, if it's using native PHP sessions you should look to the session.save_path config setting in php.ini, that's the place where the runtime saves files with the session data.\nOnce you have the data you can parse it to get it unserialized, take a look at how serialize() and unserialize() work in PHP.","Q_Score":8,"Tags":"php,python,session,wsgi","A_Id":2534567,"CreationDate":"2010-03-28T20:55:00.000","Title":"Accessing php $_SESSION from python (wsgi) - is it possible?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I've got a python\/WSGI app which needs to check to see if a user has logged on to a PHP web app. The problem is that the PHP app checks if a user has logged on by comparing a value in the $_SESSION variable to a value in the cookie from the user's browser. I would prefer to avoid changing the behavior of the php app if at all possible.\nMy questions:\n\nIs there anyway I can access the session variables from within python? Where should I start to look?\nAre there any obvious security\/performance issues I should be aware of when taking this approach?","AnswerCount":3,"Available Count":2,"Score":0.2605204458,"is_accepted":false,"ViewCount":5062,"Q_Id":2534525,"Users Score":4,"Answer":"yep. session (in default) is a regular file. so all what you need is look over session directory and find file with name of session cookie value. then - you have to implement php-like serialize\/unserialize and do whatever you want.\nnope","Q_Score":8,"Tags":"php,python,session,wsgi","A_Id":2534558,"CreationDate":"2010-03-28T20:55:00.000","Title":"Accessing php $_SESSION from python (wsgi) - is it possible?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"How would I check if the remote host is up without having a port number? Is there any other way I could check other then using regular ping.\nThere is a possibility that the remote host might drop ping packets","AnswerCount":7,"Available Count":3,"Score":0.0285636566,"is_accepted":false,"ViewCount":46690,"Q_Id":2535055,"Users Score":1,"Answer":"Many firewalls are configured to drop ping packets without responding. In addition, some network adapters will respond to ICMP ping requests without input from the operating system network stack, which means the operating system might be down, but the host still responds to pings (usually you'll notice if you reboot the server, say, it'll start responding to pings some time before the OS actually comes up and other services start up).\nThe only way to be certain that a host is up is to actually try to connect to it via some well-known port (e.g. web server port 80).\nWhy do you need to know if the host is \"up\", maybe there's a better way to do it.","Q_Score":10,"Tags":"python,network-programming,network-protocols","A_Id":2535076,"CreationDate":"2010-03-28T23:40:00.000","Title":"Check if remote host is up 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},{"Question":"How would I check if the remote host is up without having a port number? Is there any other way I could check other then using regular ping.\nThere is a possibility that the remote host might drop ping packets","AnswerCount":7,"Available Count":3,"Score":0.057080742,"is_accepted":false,"ViewCount":46690,"Q_Id":2535055,"Users Score":2,"Answer":"A protocol-level PING is best, i.e., connecting to the server and interacting with it in a way that doesn't do real work. That's because it is the only real way to be sure that the service is up. An ICMP ECHO (a.k.a. ping) would only tell you that the other end's network interface is up, and even then might be blocked; FWIW, I have seen machines where all user processes were bricked but which could still be pinged. In these days of application servers, even getting a network connection might not be enough; what if the hosted app is down or otherwise non-functional? As I said, talking sweet-nothings to the actual service that you are interested in is the best, surest approach.","Q_Score":10,"Tags":"python,network-programming,network-protocols","A_Id":2535139,"CreationDate":"2010-03-28T23:40:00.000","Title":"Check if remote host is up 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},{"Question":"How would I check if the remote host is up without having a port number? Is there any other way I could check other then using regular ping.\nThere is a possibility that the remote host might drop ping packets","AnswerCount":7,"Available Count":3,"Score":0.0285636566,"is_accepted":false,"ViewCount":46690,"Q_Id":2535055,"Users Score":1,"Answer":"What about trying something that requires a RPC like a 'tasklist' command in conjunction with a ping?","Q_Score":10,"Tags":"python,network-programming,network-protocols","A_Id":17115260,"CreationDate":"2010-03-28T23:40:00.000","Title":"Check if remote host is up 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},{"Question":"Recently i have developed a billing application for my company with Python\/Django. For few months everything was fine but now i am observing that the performance is dropping because of more and more users using that applications. Now the problem is that the application is now very critical for the finance team. Now the finance team are after my life for sorting out the performance issue. I have no other option but to find a way to increase the performance of the billing application. \nSo do you guys know any performance optimization techniques in python that will really help me with the scalability issue\nGuys we are using mysql database and its hosted on apache web server on Linux box. Secondly what i have noticed more is the over all application is slow and not the database transactional part. For example once the application is loaded then it works fine but if they navigate to other link on that application then it takes a whole lot of time.\nAnd yes we are using HTML, CSS and Javascript","AnswerCount":9,"Available Count":3,"Score":1.0,"is_accepted":false,"ViewCount":1942,"Q_Id":2545820,"Users Score":6,"Answer":"ok, not entirely to the point, but before you go and start fixing it, make sure everyone understands the situation. it seems to me that they're putting some pressure on you to fix the \"problem\".\nwell first of all, when you wrote the application, have they specified the performance requirements? did they tell you that they need operation X to take less than Y secs to complete? Did they specify how many concurrent users must be supported without penalty to the performance? If not, then tell them to back off and that it is iteration (phase, stage, whatever) one of the deployment, and the main goal was the functionality and testing. phase two is performance improvements. let them (with your help obviously) come up with some non functional requirements for the performance of your system.\nby doing all this, a) you'll remove the pressure applied by the finance team (and i know they can be a real pain in the bum) b) both you and your clients will have a clear idea of what you mean by \"performance\" c) you'll have a base that you can measure your progress and most importantly d) you'll have some agreed time to implement\/fix the performance issues.\nPS. that aside, look at the indexing... :)","Q_Score":11,"Tags":"python","A_Id":2545940,"CreationDate":"2010-03-30T14:07:00.000","Title":"Optimization Techniques in Python","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},{"Question":"Recently i have developed a billing application for my company with Python\/Django. For few months everything was fine but now i am observing that the performance is dropping because of more and more users using that applications. Now the problem is that the application is now very critical for the finance team. Now the finance team are after my life for sorting out the performance issue. I have no other option but to find a way to increase the performance of the billing application. \nSo do you guys know any performance optimization techniques in python that will really help me with the scalability issue\nGuys we are using mysql database and its hosted on apache web server on Linux box. Secondly what i have noticed more is the over all application is slow and not the database transactional part. For example once the application is loaded then it works fine but if they navigate to other link on that application then it takes a whole lot of time.\nAnd yes we are using HTML, CSS and Javascript","AnswerCount":9,"Available Count":3,"Score":1.2,"is_accepted":true,"ViewCount":1942,"Q_Id":2545820,"Users Score":4,"Answer":"A surprising feature of Python is that the pythonic code is quite efficient... So a few general hints:\n\nUse built-ins and standard functions whenever possible, they're already quite well optimized.\nTry to use lazy generators instead one-off temporary lists.\nUse numpy for vector arithmetic.\nUse psyco if running on x86 32bit.\nWrite performance critical loops in a lower level language (C, Pyrex, Cython, etc.).\nWhen calling the same method of a collection of objects, get a reference to the class function and use it, it will save lookups in the objects dictionaries (this one is a micro-optimization, not sure it's worth)\n\nAnd of course, if scalability is what matters:\n\nUse O(n) (or better) algorithms! Otherwise your system cannot be linearly scalable.\nWrite multiprocessor aware code. At some point you'll need to throw more computing power at it, and your software must be ready to use it!","Q_Score":11,"Tags":"python","A_Id":2546955,"CreationDate":"2010-03-30T14:07:00.000","Title":"Optimization Techniques in Python","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},{"Question":"Recently i have developed a billing application for my company with Python\/Django. For few months everything was fine but now i am observing that the performance is dropping because of more and more users using that applications. Now the problem is that the application is now very critical for the finance team. Now the finance team are after my life for sorting out the performance issue. I have no other option but to find a way to increase the performance of the billing application. \nSo do you guys know any performance optimization techniques in python that will really help me with the scalability issue\nGuys we are using mysql database and its hosted on apache web server on Linux box. Secondly what i have noticed more is the over all application is slow and not the database transactional part. For example once the application is loaded then it works fine but if they navigate to other link on that application then it takes a whole lot of time.\nAnd yes we are using HTML, CSS and Javascript","AnswerCount":9,"Available Count":3,"Score":0.0444152037,"is_accepted":false,"ViewCount":1942,"Q_Id":2545820,"Users Score":2,"Answer":"before you can \"fix\" something you need to know what is \"broken\". In software development that means profiling, profiling, profiling. Did I mention profiling. Without profiling you don't know where CPU cycles and wall clock time is going. Like others have said to get any more useful information you need to post the details of your entire stack. Python version, what you are using to store the data in (mysql, postgres, flat files, etc), what web server interface cgi, fcgi, wsgi, passenger, etc. how you are generating the HTML, CSS and assuming Javascript. Then you can get more specific answers to those tiers.","Q_Score":11,"Tags":"python","A_Id":2546996,"CreationDate":"2010-03-30T14:07:00.000","Title":"Optimization Techniques in Python","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},{"Question":"Have you tried Psyco in a wsgi application (custom, Pylons, Django...)?\nWhat does your set up look like?\nDid you get measurable results?","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":186,"Q_Id":2548705,"Users Score":1,"Answer":"Psyco is dead -- its successor is called PyPy. You are unlikely to get any speed increase with an I\/O bound application however.","Q_Score":2,"Tags":"python,wsgi","A_Id":9439466,"CreationDate":"2010-03-30T21:02:00.000","Title":"Does anyone have any feedback on using Psyco in a wsgi 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},{"Question":"Have you tried Psyco in a wsgi application (custom, Pylons, Django...)?\nWhat does your set up look like?\nDid you get measurable results?","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":186,"Q_Id":2548705,"Users Score":2,"Answer":"The question you should ask is not did you get measurable results, but does it make your site noticeably faster? Most web applications are not CPU bound, so even if JIT makes them faster, you probably weren't fully utilizing your processor to begin with.\nIt has been a very long time since I played with psyco, but order to get measurable results I would have to simulate thousands of concurrent requests, an unrealistic situation for the average web site.\nKeep in mind that psyco is not compatible with 64-bit python. The average website doesn't need more than 4gb of ram, but think that ram is generally of more value than CPU cycles.","Q_Score":2,"Tags":"python,wsgi","A_Id":2553516,"CreationDate":"2010-03-30T21:02:00.000","Title":"Does anyone have any feedback on using Psyco in a wsgi 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},{"Question":"In pylint I use this command --reports=n to disable the reports, but now I don't see the Global evaluation more.\nIs possible enable only the Global evaluation?","AnswerCount":6,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":2700,"Q_Id":2552605,"Users Score":4,"Answer":"No you can't, Global Evaluation is part of the reports and with --reports=n you disable all the reports .","Q_Score":8,"Tags":"python,pylint","A_Id":2552989,"CreationDate":"2010-03-31T11:53:00.000","Title":"Pylint only Global evaluation","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"In pylint I use this command --reports=n to disable the reports, but now I don't see the Global evaluation more.\nIs possible enable only the Global evaluation?","AnswerCount":6,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":2700,"Q_Id":2552605,"Users Score":0,"Answer":"As systempunttoout said, this is currently not possible. But you can ask for this on the python-projects@logilab.org mailing list, and submitting a patch is a very good way of getting that feature soon. :-)","Q_Score":8,"Tags":"python,pylint","A_Id":3458752,"CreationDate":"2010-03-31T11:53:00.000","Title":"Pylint only Global evaluation","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"Assuming that I cannot run something like this with Fabric:\nrun(\"svn update --password 'password' .\") \nhow's the proper way to pass to Fabric the password for the remote interactive command line?\nThe problem is that the repo is checked out as svn+ssh and I don't have a http\/https\/svn option","AnswerCount":6,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":3015,"Q_Id":2561472,"Users Score":0,"Answer":"You might need to supply the user as well? If not, you may have better luck exporting your repo and making a tar of it (locally) to upload+deploy on the server. If you run the svn commands locally, you'll be able to get prompted for your username and\/or password.","Q_Score":7,"Tags":"python,svn,fabric","A_Id":2561630,"CreationDate":"2010-04-01T15:20:00.000","Title":"fabric and svn password","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I want to check whether or not a cookie is set with every page load in Pylons. Where's the best place to put this logic? Thanks!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":109,"Q_Id":2563528,"Users Score":1,"Answer":"You can modify __call__ function in BaseController.","Q_Score":1,"Tags":"python,pylons","A_Id":2563615,"CreationDate":"2010-04-01T20:40:00.000","Title":"Pylons check for cookie on every page load","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I'm porting an C++ scientific application to python, and as I'm new to python, some problems come to my mind:\n1) I'm defining a class that will contain the coordinates (x,y). These values will be accessed several times, but they only will be read after the class instantiation. Is it better to use an tuple or an numpy array, both in memory and access time wise?\n2) In some cases, these coordinates will be used to build a complex number, evaluated on a complex function, and the real part of this function will be used. Assuming that there is no way to separate real and complex parts of this function, and the real part will have to be used on the end, maybe is better to use directly complex numbers to store (x,y)? How bad is the overhead with the transformation from complex to real in python? The code in c++ does a lot of these transformations, and this is a big slowdown in that code.\n3) Also some coordinates transformations will have to be performed, and for the coordinates the x and y values will be accessed in separate, the transformation be done, and the result returned. The coordinate transformations are defined in the complex plane, so is still faster to use the components x and y directly than relying on the complex variables?\nThank you","AnswerCount":2,"Available Count":2,"Score":0.2913126125,"is_accepted":false,"ViewCount":6196,"Q_Id":2563773,"Users Score":3,"Answer":"A numpy array with an extra dimension is tighter in memory use, and at least as fast!, as a numpy array of tuples; complex numbers are at least as good or even better, including for your third question. BTW, you may have noticed that -- while questions asked later than yours were getting answers aplenty -- your was laying fallow: part of the reason is no doubt that asking three questions within a question turns responders off. Why not just ask one question per question? It's not as if you get charged for questions or anything, you know...!-)","Q_Score":10,"Tags":"python,arrays,numpy,tuples,complex-numbers","A_Id":2564787,"CreationDate":"2010-04-01T21:17:00.000","Title":"Better use a tuple or numpy array for storing coordinates","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},{"Question":"I'm porting an C++ scientific application to python, and as I'm new to python, some problems come to my mind:\n1) I'm defining a class that will contain the coordinates (x,y). These values will be accessed several times, but they only will be read after the class instantiation. Is it better to use an tuple or an numpy array, both in memory and access time wise?\n2) In some cases, these coordinates will be used to build a complex number, evaluated on a complex function, and the real part of this function will be used. Assuming that there is no way to separate real and complex parts of this function, and the real part will have to be used on the end, maybe is better to use directly complex numbers to store (x,y)? How bad is the overhead with the transformation from complex to real in python? The code in c++ does a lot of these transformations, and this is a big slowdown in that code.\n3) Also some coordinates transformations will have to be performed, and for the coordinates the x and y values will be accessed in separate, the transformation be done, and the result returned. The coordinate transformations are defined in the complex plane, so is still faster to use the components x and y directly than relying on the complex variables?\nThank you","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":6196,"Q_Id":2563773,"Users Score":7,"Answer":"In terms of memory consumption, numpy arrays are more compact than Python tuples.\nA numpy array uses a single contiguous block of memory. All elements of the numpy array must be of a declared type (e.g. 32-bit or 64-bit float.) A Python tuple does not necessarily use a contiguous block of memory, and the elements of the tuple can be arbitrary Python objects, which generally consume more memory than numpy numeric types.\nSo this issue is a hands-down win for numpy, (assuming the elements of the array can be stored as a numpy numeric type).\nOn the issue of speed, I think the choice boils down to the question, \"Can you vectorize your code?\"\nThat is, can you express your calculations as operations done on entire arrays element-wise. \nIf the code can be vectorized, then numpy will most likely be faster than Python tuples. (The only case I could imagine where it might not be, is if you had many very small tuples. In this case the overhead of forming the numpy arrays and one-time cost of importing numpy might drown-out the benefit of vectorization.)\nAn example of code that could not be vectorized would be if your calculation involved looking at, say, the first complex number in an array z, doing a calculation which produces an integer index idx, then retrieving z[idx], doing a calculation on that number, which produces the next index idx2, then retrieving z[idx2], etc. This type of calculation might not be vectorizable. In this case, you might as well use Python tuples, since you won't be able to leverage numpy's strength.\nI wouldn't worry about the speed of accessing the real\/imaginary parts of a complex number. My guess is the issue of vectorization will most likely determine which method is faster. (Though, by the way, numpy can transform an array of complex numbers to their real parts simply by striding over the complex array, skipping every other float, and viewing the result as floats. Moreover, the syntax is dead simple: If z is a complex numpy array, then z.real is the real parts as a float numpy array. This should be far faster than the pure Python approach of using a list comprehension of attribute lookups: [z.real for z in zlist].)\nJust out of curiosity, what is your reason for porting the C++ code to Python?","Q_Score":10,"Tags":"python,arrays,numpy,tuples,complex-numbers","A_Id":2564868,"CreationDate":"2010-04-01T21:17:00.000","Title":"Better use a tuple or numpy array for storing coordinates","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},{"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},{"Question":"I'm having difficulty getting PyDev to work.\nI had an installation of Eclipse for PHP developers (1.2.1.20090918-0703). A month ago, I installed PyDev, and everything worked great. I go to fire it up this morning, and PyDev is gone. There is no option to create a Python project, the Python language editor is missing, etc. \nEclipse for PHP does not say that PyDev is installed, so I grab it from the update URL. The version that comes down is 1.5.6. I restart after the installation, and everything works fine again. Sweet.\nThen, I grab Subclipse 1.0.7. Upon restarting after that installation, PyDev is now gone. It isn't recognizing Python projects or Python files, etc. So I uninstall Subclipse. PyDev is still gone. Uninstalling and reinstalling PyDev again doesn't bring it back.\nWhat am I doing wrong? Do I need a different version of Eclipse?\nUPDATE: I downloaded a fresh copy of Eclipse for Java, did all this over again, and had PyDev working fine. Then, when I downloaded JSEclipse, PyDev again disappeared. This is super frustrating.\nUPDATE 2: Another fresh copy of Eclipse. This time I downloaded Subclipse first. It worked fine. Then I downloaded JSEclipse, and Subclipse is gone.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1097,"Q_Id":2567895,"Users Score":0,"Answer":"there's an easy way to install plugin for eclipse, download the pydev package zip file (not install it via eclipse update), extract it, and put it into your eclipse\/dropins\/pydev folder.\nthis is a hidden way to install plugin.","Q_Score":0,"Tags":"python,eclipse,pydev","A_Id":15892577,"CreationDate":"2010-04-02T16:48:00.000","Title":"Eclipse: PyDev installation difficulties","Data Science and Machine Learning":0,"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},{"Question":"I need to upload multiple files from directory to the server via FTP and SFTP.\nI've solved this task for SFTP with python, paramiko and threading. But I have problem with doing it for FTP. I tried to use ftplib for python, but it seems that it doesn't support threading and I upload all files one by one, which is very slow. \nI'm wondering is it even possible to do multithreading uploads with FTP protocol without creating separate connections\/authorizations (it takes too long)?\nSolution can be on Python or PHP. Maybe CURL? Would be grateful for any ideas.","AnswerCount":4,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":4789,"Q_Id":2570621,"Users Score":0,"Answer":"You can run the script in multiple command prompts \/ shells (just make sure each file is only handled once by all the different scripts). I am not sure if this quick and dirty trick will improve transfer speed though..","Q_Score":3,"Tags":"php,python,ftp,curl,multithreading","A_Id":6735686,"CreationDate":"2010-04-03T08:07:00.000","Title":"Multithreaded FTP upload. Is it possible?","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},{"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},{"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},{"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},{"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},{"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},{"Question":"I really like how I can easily share files on a network using the SimpleHTTPServer, but I wish there was an option like \"download entire directory\". Is there an easy (one liner) way to implement this?\nThanks","AnswerCount":5,"Available Count":1,"Score":0.1586485043,"is_accepted":false,"ViewCount":11099,"Q_Id":2573670,"Users Score":4,"Answer":"There is no one liner which would do it, also what do you mean by \"download whole dir\" as tar or zip?\nAnyway you can follow these steps\n\nDerive a class from SimpleHTTPRequestHandler or may be just copy its code \nChange list_directory method to return a link to \"download whole folder\"\nChange copyfile method so that for your links you zip whole dir and return it\nYou may cache zip so that you do not zip folder every time, instead see if any file is modified or not\n\nWould be a fun exercise to do :)","Q_Score":6,"Tags":"python,simplehttpserver","A_Id":2573685,"CreationDate":"2010-04-04T05:30:00.000","Title":"Download whole directories in Python SimpleHTTPServer","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},{"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},{"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},{"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},{"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},{"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},{"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},{"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},{"Question":"I've got a Codebase of around 5,3k LOC with around 30 different classe. The code is already very well formatted and I want to improve it further by prefixing methods that are only called in the module that were defined in with a \"_\", in order to indicate that. Yes it would have been a good idea to do that from the beginning on but now it's too late :D\nBasically I'm searching for a tool that will tell me if a method is not called outside of the module it was defined in, I'm not looking for stuff that will automatically convert the whole thing to use underscores, just a \"simple\" thing that tells me where I have to look for prefixing stuff.\nI'd took a look at the AST module, but there's no easy way to get a list of method definitions and calls, also parsing the plain text yields just too many false positives. I don't insist in spending day(s) on reinventing the wheel when there might be an already existing solution to my problem.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":194,"Q_Id":2586959,"Users Score":0,"Answer":"For me, this sounds like special case of coverage.\nThus I'd take a look at coverage.py or figleaf and modify it to ignore inter-module calls.","Q_Score":1,"Tags":"python,methods,code-analysis","A_Id":2586977,"CreationDate":"2010-04-06T17:34:00.000","Title":"Python analyze method calls from other classes\/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},{"Question":"I recently installed twython, a really sleek and awesome twitter API wrapper for Python. I installed it and it works fine from the interpreter, but when I try to import it via Eclipse, it says that twython is an invalid import.\nHow do I \"tell\" eclipse where twython is so that it will let me import and use it?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":941,"Q_Id":2590435,"Users Score":0,"Answer":"Daniel is right. As long as twython went into site-packages then Pydev will find it.","Q_Score":2,"Tags":"python,eclipse,pydev,twython","A_Id":2594323,"CreationDate":"2010-04-07T06:29:00.000","Title":"Eclipse + PyDev: Eclipse telling me that this is an invalid import?","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},{"Question":"I recently installed twython, a really sleek and awesome twitter API wrapper for Python. I installed it and it works fine from the interpreter, but when I try to import it via Eclipse, it says that twython is an invalid import.\nHow do I \"tell\" eclipse where twython is so that it will let me import and use it?","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":941,"Q_Id":2590435,"Users Score":3,"Answer":"I believe I have had this problem before - try going into the menu: Window_Preferences and then select Pydev and Interpreter-Python. Then try to click Auto-config - it should update its search paths to include everything installed in Python. If that doesn't work, you should at least be able to manually add the folder by clicking \"New Folder\" in the bottom part of that screen and navigating to the location where you have twython installed.","Q_Score":2,"Tags":"python,eclipse,pydev,twython","A_Id":2590469,"CreationDate":"2010-04-07T06:29:00.000","Title":"Eclipse + PyDev: Eclipse telling me that this is an invalid import?","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},{"Question":"I'm running Django on Linux using fcgi and Lighttpd. Every now and again (about once a day) the server just dies. I'm using the latest stable release of Django, Python and Lighttpd.\nThe only thing I can think of is that my program is opening a lot of files and executing a lot of external processes, but I'm fairly sure that side of things is watertight. \nLooking at the error and access logs, there's nothing exceptional happening (i.e. load isn't above normal). On those occasions where I have had exceptions from Python, these have shown up in the error.log, but when this crash happens I get nothing.\nIs there any way of finding out why the process died? Short of putting logging statements on every single line? Obviously I can't reproduce this so I don't know exactly where to look.\nEdit\nIt's the django process that's dying. I'm running the server with manage.py runfcgi daemonize=true method=threaded host=127.0.0.1 port=12345","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":916,"Q_Id":2600212,"Users Score":0,"Answer":"Have had the same problems. Not only do they die without warning or reason they leak like crazy too with threads being stuck without a master process. We solved this problem by having a cronjob run every 5 minutes that checks if the port number is up and running and if not restart.\nBy the way, we've now (slowly migrating) given up on fcgi and moved over to uwsgi.","Q_Score":6,"Tags":"python,django,logging,crash,lighttpd","A_Id":2664142,"CreationDate":"2010-04-08T13:32:00.000","Title":"Why would Django fcgi just die? How can I find 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},{"Question":"I'm running Django on Linux using fcgi and Lighttpd. Every now and again (about once a day) the server just dies. I'm using the latest stable release of Django, Python and Lighttpd.\nThe only thing I can think of is that my program is opening a lot of files and executing a lot of external processes, but I'm fairly sure that side of things is watertight. \nLooking at the error and access logs, there's nothing exceptional happening (i.e. load isn't above normal). On those occasions where I have had exceptions from Python, these have shown up in the error.log, but when this crash happens I get nothing.\nIs there any way of finding out why the process died? Short of putting logging statements on every single line? Obviously I can't reproduce this so I don't know exactly where to look.\nEdit\nIt's the django process that's dying. I'm running the server with manage.py runfcgi daemonize=true method=threaded host=127.0.0.1 port=12345","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":916,"Q_Id":2600212,"Users Score":0,"Answer":"Is this on your server? (do you own the box?). I've had that problem on shared hosting, and the host was just killing long processes. Do you know if your fcgi is receiving a SIGTERM?","Q_Score":6,"Tags":"python,django,logging,crash,lighttpd","A_Id":2653742,"CreationDate":"2010-04-08T13:32:00.000","Title":"Why would Django fcgi just die? How can I find 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},{"Question":"Looking in my \/usr\/local\/lib\/python...\/dist-package directory, I have .egg directories and .egg files. \nWhy does the installer choose to extra packages to the .egg directory, yet leave other files with .egg extensions?","AnswerCount":2,"Available Count":1,"Score":0.4621171573,"is_accepted":false,"ViewCount":8363,"Q_Id":2604600,"Users Score":5,"Answer":"I can't explain why some eggs are zipped (the files) and some are directories, but I can offer this: if you hate zipped eggs (like I do) put this in the [easy_install] section of your ~\/.pydistutils.cfg:\n\nzip_ok = false","Q_Score":19,"Tags":"python,egg","A_Id":2604612,"CreationDate":"2010-04-09T01:45:00.000","Title":"Why does easy_install extract some python eggs and not 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":1,"Web Development":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},{"Question":"How can I get the parent class(es) of a Python class?","AnswerCount":9,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":137219,"Q_Id":2611892,"Users Score":19,"Answer":"New-style classes have an mro method you can call which returns a list of parent classes in method resolution order.","Q_Score":273,"Tags":"python,oop","A_Id":2612192,"CreationDate":"2010-04-10T01:32:00.000","Title":"How to get the parents of a Python 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},{"Question":"There is a problem when I used the pylibmc. When I \"import pylibmc\", then I'll get some error following:\nImportError: \/usr\/local\/python2.6\/lib\/python2.6\/site-packages\/_pylibmc.so: undefined symbol: memcached_server_list.\nMy enviroment are Python 2.6.5, libmemcached 0.39, memcached 1.4.5\nSo, how can I solve it?\nThanks very much.\nUPDATE 1: \nI read the pylibmc doc again, and found this: libmemcached 0.32 or later (last test with 0.38). Then I guest maybe my libmemcached is too newer to avaliable.\nUPDATE 2:\nI test the libmemcached 0.38, there is another error in _pylibmc.so: Undefined symbol: memcached_server_count.","AnswerCount":3,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":1860,"Q_Id":2612515,"Users Score":0,"Answer":"Sounds like linker issues. What system is this on? How is _pylibmc.so linked to libmemcached.so? Can you provide the commands run by your build phase, and perhaps the ldd output?","Q_Score":1,"Tags":"python,memcached","A_Id":2614485,"CreationDate":"2010-04-10T06:35:00.000","Title":"pylibmc: undefined symbol: memcached_server_list","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"There is a problem when I used the pylibmc. When I \"import pylibmc\", then I'll get some error following:\nImportError: \/usr\/local\/python2.6\/lib\/python2.6\/site-packages\/_pylibmc.so: undefined symbol: memcached_server_list.\nMy enviroment are Python 2.6.5, libmemcached 0.39, memcached 1.4.5\nSo, how can I solve it?\nThanks very much.\nUPDATE 1: \nI read the pylibmc doc again, and found this: libmemcached 0.32 or later (last test with 0.38). Then I guest maybe my libmemcached is too newer to avaliable.\nUPDATE 2:\nI test the libmemcached 0.38, there is another error in _pylibmc.so: Undefined symbol: memcached_server_count.","AnswerCount":3,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":1860,"Q_Id":2612515,"Users Score":0,"Answer":"I was having the same problem and I got it working by using libmemcached 0.34 and then setting the environment variable LD_LIBRARY_PATH to \/usr\/local\/lib (where the libmemcache library was stored).","Q_Score":1,"Tags":"python,memcached","A_Id":2620050,"CreationDate":"2010-04-10T06:35:00.000","Title":"pylibmc: undefined symbol: memcached_server_list","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"There is a problem when I used the pylibmc. When I \"import pylibmc\", then I'll get some error following:\nImportError: \/usr\/local\/python2.6\/lib\/python2.6\/site-packages\/_pylibmc.so: undefined symbol: memcached_server_list.\nMy enviroment are Python 2.6.5, libmemcached 0.39, memcached 1.4.5\nSo, how can I solve it?\nThanks very much.\nUPDATE 1: \nI read the pylibmc doc again, and found this: libmemcached 0.32 or later (last test with 0.38). Then I guest maybe my libmemcached is too newer to avaliable.\nUPDATE 2:\nI test the libmemcached 0.38, there is another error in _pylibmc.so: Undefined symbol: memcached_server_count.","AnswerCount":3,"Available Count":3,"Score":0.0665680765,"is_accepted":false,"ViewCount":1860,"Q_Id":2612515,"Users Score":1,"Answer":"There appears to be some confusion about the symbol memcached_server_list: libmemcached 0.38 exposes it, but 0.39 does not. The symbol has even been removed from the documentation. pylibmc relies on memcached_server_list for its get_stats() method. I suspect pylibmc should be using memcached_server_cursor instead.\nSo I think we can say that pylibmc 1.0 requires libmemcached <= 0.38.","Q_Score":1,"Tags":"python,memcached","A_Id":2660258,"CreationDate":"2010-04-10T06:35:00.000","Title":"pylibmc: undefined symbol: memcached_server_list","Data Science and Machine Learning":0,"Database and SQL":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},{"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},{"Question":"How can I protect my web server, if I run custom users code on server. If any user can submit his python source on my server and run it.\nMaybe some modules or linux tools for close any network and hardware activity for this script.\nThank's all for help!","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":620,"Q_Id":2618862,"Users Score":0,"Answer":"In general, python is not the best language choice if you want to allow the execution of untrusted code. The JVM and .NET have much better support for sandboxing, so Jython and IronPython would be better choices.","Q_Score":5,"Tags":"python,system","A_Id":2619276,"CreationDate":"2010-04-11T21:59:00.000","Title":"Safest python code running","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},{"Question":"We have a project that uses HP Quality Center and one of the regular issues we face is people not updating comments on the defect.\nSo I was thinkingif we could come up with a small script or tool that could be used to periodically throw up a reminder and force the user to update the comments.\nI came across the Open Test Architecture API and was wondering if there are any good Python or java examples for the same that I could see.\nThanks\nHari","AnswerCount":6,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":32717,"Q_Id":2627419,"Users Score":0,"Answer":"You can use a new Test and select type (VPXP_API) which allow script to run. The good thing there is that you'd have the function definition ready to be dragged from within QC instead of having to heavily rely on doc.\nI've done an implementation in Python running some script from within QC still using its API but via a QC test which is handy to retrieve directly the result (Output) etc.. going through some shell command which can then call any script on any server etc...","Q_Score":7,"Tags":"java,python,hp-quality-center","A_Id":4309246,"CreationDate":"2010-04-13T06:29:00.000","Title":"Automating HP Quality Center with Python or 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":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"is there a difference between using FAPWS3 and MOD_WSGI when dealing with Django?\nFAPWS3 seems alot faster when serving requests toward Python scripts. I would like to know if I'm missing out anything. :)\nAny ideas?","AnswerCount":2,"Available Count":1,"Score":0.2913126125,"is_accepted":false,"ViewCount":853,"Q_Id":2629070,"Users Score":3,"Answer":"The underlying web server is not the bottleneck, it is your application and database access. The differences between any underlying web server are going to very minimal or non existent in the context of an actual full application stack. You cannot base decisions on hello world type tests as they are pretty meaningless. Decisions should therefore be based on the quality and stability of the hosting solutions under load, as well as ease of configuration and support, including your own competence to manage a particular setup. If you have no idea how to configure and support a particular web server properly, eg., Apache, then why would you use it.","Q_Score":0,"Tags":"python,django,mod-wsgi,wsgi,fapws3","A_Id":2633716,"CreationDate":"2010-04-13T11:26:00.000","Title":"Mod_wsgi versus fapws3 - 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},{"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},{"Question":"I'm trying to use boost.python library in a C++ project (Windows + VS9) but it always tries to link against pyton25.lib.\nIs it possible to link with version 2.6.x of python?\nthanks","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":712,"Q_Id":2635933,"Users Score":0,"Answer":"You could try putting -lpython26 when linking","Q_Score":2,"Tags":"python,boost","A_Id":2636724,"CreationDate":"2010-04-14T08:35:00.000","Title":"boost python version","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},{"Question":"I'm trying to use boost.python library in a C++ project (Windows + VS9) but it always tries to link against pyton25.lib.\nIs it possible to link with version 2.6.x of python?\nthanks","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":712,"Q_Id":2635933,"Users Score":1,"Answer":"You need to recompile boost-python library pointing Boost.Build to needed python version.\nP.S. This heals a problem of undefined references while linking with library needed. I beleive you've already turned of autolinking.","Q_Score":2,"Tags":"python,boost","A_Id":2636711,"CreationDate":"2010-04-14T08:35:00.000","Title":"boost python version","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},{"Question":"I'm playing around with sockets in C\/Python and I wonder what is the most efficient way to send headers from a Python dictionary to the client socket.\nMy ideas:\n\nuse a send call for every header. Pros: No memory allocation needed. Cons: many send calls -- probably error prone; error management should be rather complicated\nuse a buffer. Pros: one send call, error checking a lot easier. Cons: Need a buffer :-) malloc\/realloc should be rather slow and using a (too) big buffer to avoid realloc calls wastes memory.\n\nAny tips for me? Thanks :-)","AnswerCount":3,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":867,"Q_Id":2638490,"Users Score":0,"Answer":"Unless you're sending a truly huge amount of data, you're probably better off using one buffer. If you use a geometric progression for growing your buffer size, the number of allocations becomes an amortized constant, and the time to allocate the buffer will generally follow.","Q_Score":5,"Tags":"python,c,sockets,buffer,send","A_Id":2638568,"CreationDate":"2010-04-14T15:04:00.000","Title":"What is faster: multiple `send`s or using buffering?","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},{"Question":"I'm playing around with sockets in C\/Python and I wonder what is the most efficient way to send headers from a Python dictionary to the client socket.\nMy ideas:\n\nuse a send call for every header. Pros: No memory allocation needed. Cons: many send calls -- probably error prone; error management should be rather complicated\nuse a buffer. Pros: one send call, error checking a lot easier. Cons: Need a buffer :-) malloc\/realloc should be rather slow and using a (too) big buffer to avoid realloc calls wastes memory.\n\nAny tips for me? Thanks :-)","AnswerCount":3,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":867,"Q_Id":2638490,"Users Score":0,"Answer":"A send() call implies a round-trip to the kernel (the part of the OS which deals with the hardware directly). It has a unit cost of about a few hundred clock cycles. This is harmless unless you are trying to call send() millions of times.\nUsually, buffering is about calling send() only once in a while, when \"enough data\" has been gathered. \"Enough\" does not mean \"the whole message\" but something like \"enough bytes so that the unit cost of the kernel round-trip is dwarfed\". As a rule of thumb, an 8-kB buffer (8192 bytes) is traditionally considered as good.\nAnyway, for all performance-related questions, nothing beats an actual measure. Try it. Most of the time, there not any actual performance problem worth worrying about.","Q_Score":5,"Tags":"python,c,sockets,buffer,send","A_Id":2638599,"CreationDate":"2010-04-14T15:04:00.000","Title":"What is faster: multiple `send`s or using buffering?","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},{"Question":"I'm playing around with sockets in C\/Python and I wonder what is the most efficient way to send headers from a Python dictionary to the client socket.\nMy ideas:\n\nuse a send call for every header. Pros: No memory allocation needed. Cons: many send calls -- probably error prone; error management should be rather complicated\nuse a buffer. Pros: one send call, error checking a lot easier. Cons: Need a buffer :-) malloc\/realloc should be rather slow and using a (too) big buffer to avoid realloc calls wastes memory.\n\nAny tips for me? Thanks :-)","AnswerCount":3,"Available Count":3,"Score":1.2,"is_accepted":true,"ViewCount":867,"Q_Id":2638490,"Users Score":3,"Answer":"Because of the way TCP congestion control works, it's more efficient to send data all at once. TCP maintains a window of how much data it will allow to be \"in the air\" (sent but not yet acknowledged). TCP measures the acknowledgments coming back to figure out how much data it can have \"in the air\" without causing congestion (i.e., packet loss). If there isn't enough data coming from the application to fill the window, TCP can't make accurate measurements so it will conservatively shrink the window.\nIf you only have a few, small headers and your calls to send are in rapid succession, the operating system will typically buffer the data for you and send it all in one packet. In that case, TCP congestion control isn't really an issue. However, each call to send involves a context switch from user mode to kernel mode, which incurs CPU overhead. In other words, you're still better off buffering in your application.\nThere is (at least) one case where you're better off without buffering: when your buffer is slower than the context switching overhead. If you write a complicated buffer in Python, that might very well be the case. A buffer written in CPython is going to be quite a bit slower than the finely optimized buffer in the kernel. It's quite possible that buffering would cost you more than it buys you.\nWhen in doubt, measure.\nOne word of caution though: premature optimization is the root of all evil. The difference in efficiency here is pretty small. If you haven't already established that this is a bottleneck for your application, go with whatever makes your life easier. You can always change it later.","Q_Score":5,"Tags":"python,c,sockets,buffer,send","A_Id":2639059,"CreationDate":"2010-04-14T15:04:00.000","Title":"What is faster: multiple `send`s or using buffering?","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},{"Question":"A fellow developer on a project I am on believes that doctests are as good as unit-tests, and that if a piece of code is doctested, it does not need to be unit-tested. I do not believe this to be the case. Can anyone provide some solid, ideally cited, examples either for or against the argument that doctests replace the need for unit-tests?\nThank you\n-Daniel\nEDIT: Can anyone provide a reference showing that doctesting should not replace unit-testing?","AnswerCount":6,"Available Count":3,"Score":0.1651404129,"is_accepted":false,"ViewCount":3655,"Q_Id":2642282,"Users Score":5,"Answer":"There's a concrete example in the Python standard library that persuades me that doctests alone aren't always enough, namely the decimal module. It has over 60000 individual testcases (in Lib\/test\/decimaltestdata); if all those were rewritten as doctests, the decimal module would become very unwieldy indeed. It's possible the number of tests could be slimmed down whilst still giving good coverage, but many of the numerical algorithms are sufficiently complicated that you need huge numbers of individual tests to cover all possible combinations of branches.","Q_Score":12,"Tags":"python,unit-testing,doctest","A_Id":2643423,"CreationDate":"2010-04-15T01:57:00.000","Title":"Does Python doctest remove the need for 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":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"A fellow developer on a project I am on believes that doctests are as good as unit-tests, and that if a piece of code is doctested, it does not need to be unit-tested. I do not believe this to be the case. Can anyone provide some solid, ideally cited, examples either for or against the argument that doctests replace the need for unit-tests?\nThank you\n-Daniel\nEDIT: Can anyone provide a reference showing that doctesting should not replace unit-testing?","AnswerCount":6,"Available Count":3,"Score":0.1325487884,"is_accepted":false,"ViewCount":3655,"Q_Id":2642282,"Users Score":4,"Answer":"doctests are great for some uses\n\nworking and up to date documentation\nsample tests embeded in docstrings\nspikes or design phases when classes API is not really clear\n\nunit tests are better in differents cases:\n\nwhen you need clear and somewhat complex setup\/teardown\nwhen trying to get better coverage of all cases, inclusinf corner cases\nfor keeping tests independant from each other\n\nIn other words, at least for my own use, doctests are great when you focus on explaining what you are doing (docs, but also design phases) but more of a burden when you intent to use tests as a seat belt for refactoring or code coverage.","Q_Score":12,"Tags":"python,unit-testing,doctest","A_Id":2643550,"CreationDate":"2010-04-15T01:57:00.000","Title":"Does Python doctest remove the need for 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":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"A fellow developer on a project I am on believes that doctests are as good as unit-tests, and that if a piece of code is doctested, it does not need to be unit-tested. I do not believe this to be the case. Can anyone provide some solid, ideally cited, examples either for or against the argument that doctests replace the need for unit-tests?\nThank you\n-Daniel\nEDIT: Can anyone provide a reference showing that doctesting should not replace unit-testing?","AnswerCount":6,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":3655,"Q_Id":2642282,"Users Score":0,"Answer":"I think this is the wrong way to think about doctests. Doctests are documentation. They complement regular unit tests. Think of doctests as documentation examples that happen to be tested. The doctests should be there to illustrate the function to human users. The unit tests should test all the code, even the corner cases. If you add doctests for corner cases, or dozens of doctests, that will just make your docstring hard to read.","Q_Score":12,"Tags":"python,unit-testing,doctest","A_Id":16453043,"CreationDate":"2010-04-15T01:57:00.000","Title":"Does Python doctest remove the need for 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":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've done what I shouldn't have done and written 4 modules (6 hours or so) without running any tests along the way.\nI have a method inside of \/mydir\/__init__.py called get_hash(), and a class inside of \/mydir\/utils.py called SpamClass.\n\/mydir\/utils.py imports get_hash() from \/mydir\/__init__. \n\/mydir\/__init__.py imports SpamClass from \/mydir\/utils.py.\nBoth the class and the method work fine on their own but for some reason if I try to import \/mydir\/, I get an import error saying \"Cannot import name get_hash\" from \/mydir\/__init__.py.\nThe only stack trace is the line saying that __init__.py imported SpamClass. The next line is where the error occurs in in SpamClass when trying to import get_hash. Why is this?","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":493,"Q_Id":2647088,"Users Score":1,"Answer":"In absence of more information, I would say you have a circular import that you aren't working around. The simplest, most obvious fix is to not put anything in mydir\/__init__.py that you want to use from any module inside mydir. So, move your get_hash function to another module inside the mydir package, and import that module where you need it.","Q_Score":2,"Tags":"python,python-import","A_Id":2647367,"CreationDate":"2010-04-15T16:20:00.000","Title":"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":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've done what I shouldn't have done and written 4 modules (6 hours or so) without running any tests along the way.\nI have a method inside of \/mydir\/__init__.py called get_hash(), and a class inside of \/mydir\/utils.py called SpamClass.\n\/mydir\/utils.py imports get_hash() from \/mydir\/__init__. \n\/mydir\/__init__.py imports SpamClass from \/mydir\/utils.py.\nBoth the class and the method work fine on their own but for some reason if I try to import \/mydir\/, I get an import error saying \"Cannot import name get_hash\" from \/mydir\/__init__.py.\nThe only stack trace is the line saying that __init__.py imported SpamClass. The next line is where the error occurs in in SpamClass when trying to import get_hash. Why is this?","AnswerCount":3,"Available Count":2,"Score":0.1325487884,"is_accepted":false,"ViewCount":493,"Q_Id":2647088,"Users Score":2,"Answer":"To add to what the others have said, another good approach to avoiding circular import problems is to avoid from module import stuff.\nIf you just do standard import module at the top of each script, and write module.stuff in your functions, then by the time those functions run, the import will have finished and the module members will all be available.\nYou then also don't have to worry about situations where some modules can update\/change one of their members (or have it monkey-patched by a naughty third party). If you'd imported from the module, you'd still have your old, out-of-date copy of the member.\nPersonally, I only use from-import for simple, dependency-free members that I'm likely to refer to a lot: in particular, symbolic constants.","Q_Score":2,"Tags":"python,python-import","A_Id":2647459,"CreationDate":"2010-04-15T16:20:00.000","Title":"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":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I recently came across a simple but nasty bug.\nI had a list and I wanted to find the smallest member in it. I used Python's built-in min().\nEverything worked great until in some strange scenario the list was empty (due to strange user input I could not have anticipated). My application crashed with a ValueError (BTW - not documented in the official docs).\nI have very extensive unit tests and I regularly check coverage to avoid surprises like this. I also use Pylint (everything is integrated in PyDev) and I never ignore warnings, yet I failed to catch this bug before my users did.\nIs there anything I can change in my methodology to avoid these kind of runtime errors?\n (which would have been caught at compile time in Java \/ C#?).\nI'm looking for something more than wrapping my code with a big try-except. What else can I do? How many other build in Python functions are hiding nasty surprises like this???","AnswerCount":4,"Available Count":2,"Score":1.0,"is_accepted":false,"ViewCount":784,"Q_Id":2647790,"Users Score":7,"Answer":"The problem here is that malformed external input crashed your program. The solution is to exhaustively unit test possible input scenarios at the boundaries of your code. You say your unit tests are 'extensive', but you clearly hadn't tested for this possibility. Code coverage is a useful tool, but it's important to remember that covering code is not the same as thoroughly testing it. Thorough testing is a combination of covering usage scenarios as well as lines of code.\nThe methodology I use is to trust internal callers, but never to trust external callers or input. So I explicitly don't unit test for the empty list case in any code beyond the first function that receives the external input. But that input function should be exhaustively covered.\nIn this case I think the library's exception is reasonable behaviour - it makes no sense to ask for the min of an empty list. The library can't legitimately set a value such as 0 for you, since you may be dealing with negative numbers, for example.\nI think the empty list should never have reached the code that asks for the min - it should have been identified at input, and either raised an exception there, or set it to 0 if that works for you, or whatever else it is that does work for you.","Q_Score":4,"Tags":"python,unit-testing,exception-handling,runtime-error,code-coverage","A_Id":2648113,"CreationDate":"2010-04-15T18:00:00.000","Title":"Python Pre-testing for exceptions when coverage fails","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I recently came across a simple but nasty bug.\nI had a list and I wanted to find the smallest member in it. I used Python's built-in min().\nEverything worked great until in some strange scenario the list was empty (due to strange user input I could not have anticipated). My application crashed with a ValueError (BTW - not documented in the official docs).\nI have very extensive unit tests and I regularly check coverage to avoid surprises like this. I also use Pylint (everything is integrated in PyDev) and I never ignore warnings, yet I failed to catch this bug before my users did.\nIs there anything I can change in my methodology to avoid these kind of runtime errors?\n (which would have been caught at compile time in Java \/ C#?).\nI'm looking for something more than wrapping my code with a big try-except. What else can I do? How many other build in Python functions are hiding nasty surprises like this???","AnswerCount":4,"Available Count":2,"Score":0.1973753202,"is_accepted":false,"ViewCount":784,"Q_Id":2647790,"Users Score":4,"Answer":"Even in Java\/C#, a class of exceptions the RuntimeError are unchecked and will not be detected by the compiler (that's why they're called RuntimeError not CompileError).\nIn python, certain exceptions such as KeyboardInterrupt are particularly hairy since it can be raised practically at any arbitrary point in the program.\n\nI'm looking for something more than wrapping my code with a big try-except. \n\nAnything but that please. It is much better to let exceptions get to user and halt the program rather than letting error pass around silently (Zen of Python). \nUnlike Java, Python does not require all Exceptions to be caught because requiring all Exceptions to be caught makes it too easy for programmers to ignore the Exception (by writing blank exception handler).\nJust relax, let the error halt; let the user report it to you, so you can fix it. The other alternative is you stepping into a debugger for forty-two hours because customer's data is getting corrupted everywhere due to a blank mandatory exception handler.\nSo, what you should change in your methodology is thinking that exception is bad; they're not pretty, but they're better than the alternatives.","Q_Score":4,"Tags":"python,unit-testing,exception-handling,runtime-error,code-coverage","A_Id":2647972,"CreationDate":"2010-04-15T18:00:00.000","Title":"Python Pre-testing for exceptions when coverage fails","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm looking to do some basic encryption of server messages which would be encrypted with C++ and decrypted using Python server side. I was wondering if anyone knew if there were good solutions that were simpler or more lightweight than Keyczar. I see that supports both C++ and python, but would using Crypto++ and PyCrypto be simpler for a newbie that just wants to get something up and running for the time being?\nOr should I use Keyczar for python and Crypto++ for the C++ end? The C++ libraries seem to have dependencies to hundreds of files.","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":942,"Q_Id":2650073,"Users Score":2,"Answer":"The C++ libraries seem to have dependencies to hundreds of files.\nI don't know much about Python, but that is absolutely normal for C++. I'd recommend Crypto++ -- it's a great easy to use library, and it's public domain, meaning you won't have any license problems with it.\nEDIT: Keep in mind a large library with lots of code does not mean that you're going to pay in terms of object code. If there are functions you don't use (Crypto++ supports hundreds of algorithms) they won't be compiled into the resulting binary.","Q_Score":1,"Tags":"python,c++,encryption,cryptography","A_Id":2650311,"CreationDate":"2010-04-16T01:41:00.000","Title":"Lightweight cryptography toolkit(s) for C++ and 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":0,"Web Development":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},{"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},{"Question":"what is the advantage of using a python virtualbox API instead of using XPCOM?","AnswerCount":3,"Available Count":1,"Score":0.3215127375,"is_accepted":false,"ViewCount":14030,"Q_Id":2652146,"Users Score":5,"Answer":"I would generally recommend against either one. If you need to use virtualization programmatically, take a look at libvirt, which gives you cross platform and cross hypervisor support; which lets you do kvm\/xen\/vz\/vmware later on.\nThat said, the SOAP api is using two extra abstraction layers (the client and server side of the HTTP transaction), which is pretty clearly then just calling the XPCOM interface.\nIf you need local host only support, use XPCOM. The extra indirection of libvirt\/SOAP doesn't help you.\nIf you need to access virtualbox on a various hosts across multiple client machines, use SOAP or libvirt\nIf you want cross platform support, or to run your code on Linux, use libvirt.","Q_Score":9,"Tags":"python,virtualbox,xpcom","A_Id":2655522,"CreationDate":"2010-04-16T10:26:00.000","Title":"What is the advantage of using Python Virtualbox 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},{"Question":"I was going over some pages from WikiVS, that I quote from:\n\nbecause lambdas in Python are restricted to expressions and cannot\n contain statements\n\nI would like to know what would be a good example (or more) where this restriction would be, preferably compared to the Ruby language. \nThank you for your answers, comments and feedback!","AnswerCount":5,"Available Count":2,"Score":0.0798297691,"is_accepted":false,"ViewCount":2261,"Q_Id":2654425,"Users Score":2,"Answer":"Instead of f=lambda s:pass you can do f=lambda s:None.","Q_Score":6,"Tags":"python,ruby,lambda,restriction","A_Id":3209231,"CreationDate":"2010-04-16T16:02:00.000","Title":"Restrictons of Python compared to Ruby: lambda's","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I was going over some pages from WikiVS, that I quote from:\n\nbecause lambdas in Python are restricted to expressions and cannot\n contain statements\n\nI would like to know what would be a good example (or more) where this restriction would be, preferably compared to the Ruby language. \nThank you for your answers, comments and feedback!","AnswerCount":5,"Available Count":2,"Score":0.0399786803,"is_accepted":false,"ViewCount":2261,"Q_Id":2654425,"Users Score":1,"Answer":"lambda is simply a shortcut way in Python to define a function that returns a simple expression.\nThis isn't a restriction in any meaningful way. If you need more than a single expression then just use a function: there is nothing you can do with a lambda that you cannot do with a function.\nThe only disadvantages to using a function instead of a lambda are that the function has to be defined on 1 or more separate lines (so you may lose some locality compared to the lambda), and you have to invent a name for the function (but if you can't think of one then f generally works).\nAll the other reasons people think they have to use a lambda (such as accessing nested variables or generating lots of lambdas with separate default arguments) will work just as well with a function.\nThe big advantage of using a named function is of course that when it goes wrong you get a meaningful stack trace. I had that bite me yesterday when I got a stack trace involving a lambda and no context about which lambda it was.","Q_Score":6,"Tags":"python,ruby,lambda,restriction","A_Id":2654789,"CreationDate":"2010-04-16T16:02:00.000","Title":"Restrictons of Python compared to Ruby: lambda's","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":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},{"Question":"When I write with business logic, my code often depends on the current time. For example the algorithm which looks at each unfinished order and checks if an invoice should be sent (which depends on the no of days since the job was ended). In these cases creating an invoice is not triggered by an explicit user action but by a background job.\nNow this creates a problem for me when it comes to testing:\n\nI can test invoice creation itself easily\nHowever it is hard to create an order in a test and check that the background job identifies the correct orders at the correct time.\n\nSo far I found two solutions:\n\nIn the test setup, calculate the job dates relative to the current date. Downside: The code becomes quite complicated as there are no explicit dates written anymore. Sometimes the business logic is pretty complex for edge cases so it becomes hard to debug due to all these relative dates.\nI have my own date\/time accessor functions which I use throughout my code. In the test I just set a current date and all modules get this date. So I can simulate an order creation in February and check that the invoice is created in April easily. Downside: 3rd party modules do not use this mechanism so it's really hard to integrate+test these.\n\nThe second approach was way more successful to me after all. Therefore I'm looking for a way to set the time Python's datetime+time modules return. Setting the date is usually enough, I don't need to set the current hour or second (even though this would be nice).\nIs there such a utility? Is there an (internal) Python API that I can use?","AnswerCount":6,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":12107,"Q_Id":2658026,"Users Score":0,"Answer":"there might be few ways of doing this, like creating the orders (with the current timestamp) and then changing that value in the DB directly by some external process (assuming data is in the DB).\nI'll suggest something else. Have you though about running your application in a virtual machine, setting the time to say Feb, creating orders, and then just changing the VMs time? This approach is the closest as you can get to the real-life situation.","Q_Score":24,"Tags":"python,unit-testing,datetime,testing,time","A_Id":2658048,"CreationDate":"2010-04-17T10:22:00.000","Title":"How to change the date\/time in Python for all 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},{"Question":"I have an executable that run time should take configuration parameters from a script file. This way I dont need to re-compile the code for every configuration change. Right now I have all the configuration values in a .h file. Everytime I change it i need to re-compile. \nThe platform is C, gcc under Linux.\nWhat is the best solution for this problem? I looked up on google and so XML, phthon and Lua bindings for C. Is using a separate scripting language the best approach? If so, which one would you recommend for my need?\nAddendum:\nWhat if I would like to mirror data structures in script files? If I have an array of structures for example, if there an easy way to store and load it?\nThanks","AnswerCount":7,"Available Count":2,"Score":0.0285636566,"is_accepted":false,"ViewCount":828,"Q_Id":2667866,"Users Score":1,"Answer":"How much configuration do you need that it needs to be a \"script file\"? \nI just keep a little chunk of code handy that's a ini format parser.","Q_Score":2,"Tags":"python,c,linux,gcc,lua","A_Id":2667907,"CreationDate":"2010-04-19T13:49:00.000","Title":"Configuration files for 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":1,"Web Development":0},{"Question":"I have an executable that run time should take configuration parameters from a script file. This way I dont need to re-compile the code for every configuration change. Right now I have all the configuration values in a .h file. Everytime I change it i need to re-compile. \nThe platform is C, gcc under Linux.\nWhat is the best solution for this problem? I looked up on google and so XML, phthon and Lua bindings for C. Is using a separate scripting language the best approach? If so, which one would you recommend for my need?\nAddendum:\nWhat if I would like to mirror data structures in script files? If I have an array of structures for example, if there an easy way to store and load it?\nThanks","AnswerCount":7,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":828,"Q_Id":2667866,"Users Score":0,"Answer":"You could reread the configuration file when a signal such as SIGUSR1 is received.","Q_Score":2,"Tags":"python,c,linux,gcc,lua","A_Id":2667901,"CreationDate":"2010-04-19T13:49:00.000","Title":"Configuration files for 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":1,"Web Development":0},{"Question":"Python has the idea of metaclasses that, if I understand correctly, allow you to modify an object of a class at the moment of construction. You are not modifying the class, but instead the object that is to be created then initialized.\nPython (at least as of 3.0 I believe) also has the idea of class decorators. Again if I understand correctly, class decorators allow the modifying of the class definition at the moment it is being declared. \nNow I believe there is an equivalent feature or features to the class decorator in Ruby, but I'm currently unaware of something equivalent to metaclasses. I'm sure you can easily pump any Ruby object through some functions and do what you will to it, but is there a feature in the language that sets that up like metaclasses do?\nSo again, Does Ruby have something similar to Python's metaclasses?\nEdit I was off on the metaclasses for Python. A metaclass and a class decorator do very similar things it appears. They both modify the class when it is defined but in different manners. Hopefully a Python guru will come in and explain better on these features in Python.\nBut a class or the parent of a class can implement a __new__(cls[,..]) function that does customize the construction of the object before it is initialized with __init__(self[,..]).\nEdit This question is mostly for discussion and learning about how the two languages compare in these features. I'm familiar with Python but not Ruby and was curious. Hopefully anyone else who has the same question about the two languages will find this post helpful and enlightening.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1693,"Q_Id":2676007,"Users Score":24,"Answer":"Ruby doesn't have metaclasses. There are some constructs in Ruby which some people sometimes wrongly call metaclasses but they aren't (which is a source of endless confusion).\nHowever, there's a lot of ways to achieve the same results in Ruby that you would do with metaclasses. But without telling us what exactly you want to do, there's no telling what those mechanisms might be.\nIn short:\n\nRuby doesn't have metaclasses\nRuby doesn't have any one construct that corresponds to Python's metaclasses\nEverything that Python can do with metaclasses can also be done in Ruby\nBut there is no single construct, you will use different constructs depending on what exactly you want to do\nAny one of those constructs probably has other features as well that do not correspond to metaclasses (although they probably correspond to something else in Python)\nWhile you can do anything in Ruby that you can do with metaclasses in Python, it might not necessarily be straightforward\nAlthough often there will be a more Rubyish solution that is elegant\nLast but not least: while you can do anything in Ruby that you can do with metaclasses in Python, doing it might not necessarily be The Ruby Way\n\nSo, what are metaclasses exactly? Well, they are classes of classes. So, let's take a step back: what are classes exactly?\nClasses \u2026\n\nare factories for objects\ndefine the behavior of objects\ndefine on a metaphysical level what it means to be an instance of the class\n\nFor example, the Array class produces array objects, defines the behavior of arrays and defines what \"array-ness\" means.\nBack to metaclasses.\nMetaclasses \u2026\n\nare factories for classes\ndefine the behavior of classes\ndefine on a metaphysical level what it means to be a class\n\nIn Ruby, those three responsibilities are split across three different places:\n\nthe Class class creates classes and defines a little bit of the behavior\nthe individual class's eigenclass defines a little bit of the behavior of the class\nthe concept of \"classness\" is hardwired into the interpreter, which also implements the bulk of the behavior (for example, you cannot inherit from Class to create a new kind of class that looks up methods differently, or something like that\u00a0\u2013 the method lookup algorithm is hardwired into the interpreter)\n\nSo, those three things together play the role of metaclasses, but neither one of those is a metaclass (each one only implements a small part of what a metaclass does), nor is the sum of those the metaclass (because they do much more than that).\nUnfortunately, some people call eigenclasses of classes metaclasses. (Until recently, I was one of those misguided souls, until I finally saw the light.) Other people call all eigenclasses metaclasses. (Unfortunately, one of those people is the author of one the most popular tutorials on Ruby metaprogramming and the Ruby object model.) Some popular libraries add a metaclass method to Object that returns the object's eigenclass (e.g. ActiveSupport, Facets, metaid). Some people call all virtual classes (i.e. eigenclasses and include classes) metaclasses. Some people call Class the metaclass. Even within the Ruby source code itself, the word \"metaclass\" is used to refer to things that are not metaclasses.","Q_Score":10,"Tags":"python,ruby,metaprogramming,metaclass","A_Id":2678233,"CreationDate":"2010-04-20T14:39:00.000","Title":"What is Ruby's analog to Python Metaclasses?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using py.test for unit testing my python program. I wish to debug my test code with the python debugger the normal way (by which I mean pdb.set_trace() in the code) but I can't make it work. \nPutting pdb.set_trace() in the code doesn't work (raises IOError: reading from stdin while output is captured). I have also tried running py.test with the option --pdb but that doesn't seem to do the trick if I want to explore what happens before my assertion. It breaks when an assertion fails, and moving on from that line means terminating the program.\nDoes anyone know a way to get debugging, or is debugging and py.test just not meant to be together?","AnswerCount":7,"Available Count":1,"Score":0.057080742,"is_accepted":false,"ViewCount":70637,"Q_Id":2678792,"Users Score":2,"Answer":"Simply use: pytest --trace test_your_test.py.\nThis will invoke the Python debugger at the start of the test","Q_Score":89,"Tags":"python,unit-testing,pdb","A_Id":66974346,"CreationDate":"2010-04-20T21:28:00.000","Title":"Can I debug with python debugger when using py.test somehow?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have some binary data produced as base-256 bytestrings in Python (2.x). I need to read these into JavaScript, preserving the ordinal value of each byte (char) in the string. If you'll allow me to mix languages, I want to encode a string s in Python such that ord(s[i]) == s.charCodeAt(i) after I've read it back into JavaScript.\nThe cleanest way to do this seems to be to serialize my Python strings to JSON. However, json.dump doesn't like my bytestrings, despite fiddling with the ensure_ascii and encoding parameters. Is there a way to encode bytestrings to Unicode strings that preserves ordinal character values? Otherwise I think I need to encode the characters above the ASCII range into JSON-style \\u1234 escapes; but a codec like this does not seem to be among Python's codecs. \nIs there an easy way to serialize Python bytestrings to JSON, preserving char values, or do I need to write my own encoder?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1629,"Q_Id":2679936,"Users Score":5,"Answer":"Is there a way to encode bytestrings\n to Unicode strings that preserves\n ordinal character values?\n\nThe byte -> unicode transformation is called decode, not encode. But yes, decoding with a codec such as iso-8859-1 should indeed \"preserve ordinal character values\" as you wish.","Q_Score":6,"Tags":"python,json","A_Id":2679957,"CreationDate":"2010-04-21T02:31:00.000","Title":"Serializing Python bytestrings to JSON, preserving ordinal character values","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a script in python that needs to read iso-8859-1 files and also write in that encoding.\nNow I am running the script in an environment with all locales set at utf-8. Is there a way to define in my python scripts that all file acces have to use the iso-8859-1 encoding?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":294,"Q_Id":2681713,"Users Score":4,"Answer":"Python doesn't really listen to the environment when it comes to reading and writing files in a particular encoding. It only listens to the environment when it comes to encoding unicode written to stdout, if stdout is connected to a terminal.\nWhen reading and writing files in Python 2.x, you deal with bytestrings (the str type) by default. They're encoded data. You have to decode the data you read by hand, and encode what you want to write. Or you can use codecs.open() to open the files, which will do the encoding for you.\nIn Python 3.x, you open files either in binary mode, in which case you get bytes, or you open it in text mode, in which case you should specify an encoding just like with codecs.open() in Python 2.x.\nNone of these are affected by environment variables; you either read bytes, or you specify the encoding.","Q_Score":2,"Tags":"python,encoding,file-io","A_Id":2682226,"CreationDate":"2010-04-21T09:33:00.000","Title":"Is there a way to set the encoding for all files read and written by 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},{"Question":"Assuming that I have the following directory structure for a Python project:\nconfig\/ scripts\/ src\/\nwhere should a fabric deployment script should go? I assume that it should be in scripts, obviously, but for me it seems more appropriate to store in scripts, the actual code that fires up the project.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":454,"Q_Id":2691528,"Users Score":2,"Answer":"This is really a preference thing -- however there are a couple places I like, depending on situation.\nMost frequently, and particularly in cases like yours where the fabfile is tied to a piece of software, I like to put it the project directory. I view fabfiles as akin to Makefiles in this case, so this feels like a natural place. (e.g. for your example, put the fabfile in the same directory holding config\/ scripts\/ and src\/)\nIn other cases, I use fab for information gathering. Specifically I run a few commands and pull files from a series of servers. Similarly I initiate various tests on remote hosts. In these cases I like to set up a special directory for the fabfile (called tests, or whatever) and pull data to the relevant subdirectory.\nFinally I have a few fabfiles I keep in $HOME\/lib. These do some remote tasks that I frequently deal with. One of these is for setting up new pylons projects on my dev server. I have rpaste set up as an alias to fab -f $HOME\/lib\/rpaste.py. This allows me to select the target action at will.","Q_Score":0,"Tags":"python,deployment,fabric","A_Id":2692615,"CreationDate":"2010-04-22T14:09:00.000","Title":"Where to store deployment 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":0,"Web Development":0},{"Question":"I had never noticed the __path__ attribute that gets defined on some of my packages before today. According to the documentation:\n\nPackages support one more special\n attribute, __path__. This is\n initialized to be a list containing\n the name of the directory holding the\n package\u2019s __init__.py before the code\n in that file is executed. This\n variable can be modified; doing so\n affects future searches for modules\n and subpackages contained in the\n package.\nWhile this feature is not often\n needed, it can be used to extend the\n set of modules found in a package.\n\nCould somebody explain to me what exactly this means and why I would ever want to use it?","AnswerCount":4,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":39895,"Q_Id":2699287,"Users Score":34,"Answer":"If you change __path__, you can force the interpreter to look in a different directory for modules belonging to that package. \nThis would allow you to, e.g., load different versions of the same module based on runtime conditions. You might do this if you wanted to use different implementations of the same functionality on different platforms.","Q_Score":75,"Tags":"python,path,module","A_Id":2699333,"CreationDate":"2010-04-23T14:22:00.000","Title":"What is __path__ useful for?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I used python 2.5 and imported a file named \"irit.py\" from C:\\util\\Python25\\Lib\\site-packages directory. This files imports the file \"_irit.pyc which is in the same directory. It worked well and did what I wanted.\nThan, I tried the same thing with python version 2.6.4. \"irit.py\" which is in C:\\util\\Python26\\Lib\\site-packages was imported, but \"_irit.pyc\" (which is in the same directory of 26, like before) hasn't been found. I got the error message:\nFile \"C:\\util\\Python26\\lib\\site-packages\\irit.py\", line 5, in \nimport _irit\nImportError: DLL load failed: The specified module could not be found.\nCan someone help me understand the problem and how to fix it??\nThanks, Almog.","AnswerCount":2,"Available Count":2,"Score":0.4621171573,"is_accepted":false,"ViewCount":1712,"Q_Id":2705304,"Users Score":5,"Answer":"\"DLL load failed\" can't directly refer to the .pyc, since that's a bytecode file, not a DLL; a DLL would be .pyd on Windows. So presumably that _irit.pyc bytecode file tries to import some .pyd and that .pyd is not available in a 2.6-compatible version in the appropriate directory. Unfortunately it also appears that the source file _irit.py isn't around either, so the error messages end up less informative that they could be. I'd try to run python -v, which gives verbose messages on all module loading and unloading actions -- maybe that will let you infer the name of the missing .pyd when you compare its behavior in 2.5 and 2.6.","Q_Score":2,"Tags":"python,import,version,pyc","A_Id":2705337,"CreationDate":"2010-04-24T16:50:00.000","Title":"How to import *.pyc file from different version 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":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I used python 2.5 and imported a file named \"irit.py\" from C:\\util\\Python25\\Lib\\site-packages directory. This files imports the file \"_irit.pyc which is in the same directory. It worked well and did what I wanted.\nThan, I tried the same thing with python version 2.6.4. \"irit.py\" which is in C:\\util\\Python26\\Lib\\site-packages was imported, but \"_irit.pyc\" (which is in the same directory of 26, like before) hasn't been found. I got the error message:\nFile \"C:\\util\\Python26\\lib\\site-packages\\irit.py\", line 5, in \nimport _irit\nImportError: DLL load failed: The specified module could not be found.\nCan someone help me understand the problem and how to fix it??\nThanks, Almog.","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":1712,"Q_Id":2705304,"Users Score":1,"Answer":"Pyc files are not guaranteed to be compatible across python versions, so even if you fix the missing dll, you could still run in to problems.","Q_Score":2,"Tags":"python,import,version,pyc","A_Id":2706673,"CreationDate":"2010-04-24T16:50:00.000","Title":"How to import *.pyc file from different version 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":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am writing a python script that downloads a file given by a URL. Unfortuneatly the URL is in the form of a PHP script i.e. www.website.com\/generatefilename.php?file=5233\nIf you visit the link in a browser, you are prompted to download the actual file and extension. I need to send this link to the downloader, but I can't send the downloader the PHP link.\nHow would I get the full file name in a usable variable?","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":171,"Q_Id":2705856,"Users Score":2,"Answer":"What you need to do is examine the Content-Disposition header sent by the PHP script. it will look something like:\nContent-Disposition: attachment; filename=theFilenameYouWant\nAs to how you actually examine that header it depends on the python code you're currently using to fetch the URL. If you post some code I'll be able to give a more detailed answer.","Q_Score":0,"Tags":"php,python,url,scripting","A_Id":2705877,"CreationDate":"2010-04-24T19:36:00.000","Title":"I want the actual file name that is returned by a PHP 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},{"Question":"What are the best practices for extending an existing Python module \u2013 in this case, I want to extend the python-twitter package by adding new methods to the base API class.\nI've looked at tweepy, and I like that as well; I just find python-twitter easier to understand and extend with the functionality I want.\nI have the methods written already \u2013 I'm trying to figure out the most Pythonic and least disruptive way to add them into the python-twitter package module, without changing this modules\u2019 core.","AnswerCount":6,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":33640,"Q_Id":2705964,"Users Score":6,"Answer":"Don't add them to the module. Subclass the classes you want to extend and use your subclasses in your own module, not changing the original stuff at all.","Q_Score":29,"Tags":"python,module,tweepy,python-module,python-twitter","A_Id":2705976,"CreationDate":"2010-04-24T20:12:00.000","Title":"How do I extend a python module? Adding new functionality to the `python-twitter` package","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},{"Question":"I am designing a python web app, where people can have an email sent to them on a particular day. So a user puts in his emai and date in a form and it gets stored in my database.\nMy script would then search through the database looking for all records of todays date, retrive the email, sends them out and deletes the entry from the table.\nIs it possible to have a setup, where the script starts up automatically at a give time, say 1 pm everyday, sends out the email and then quits? If I have a continuously running script, i might go over the CPU limit of my shared web hosting. Or is the effect negligible?\nAli","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":168,"Q_Id":2708705,"Users Score":3,"Answer":"Is it possible to have a setup, where\n the script starts up automatically at\n a give time, say 1 pm everyday, sends\n out the email and then quits?\n\nIt's surely possible in general, but it entirely depends on what your shared web hosting provider is offering you. For these purposes, you'd use some kind of cron in any version or variant of Unix, Google App Engine, and so on. But since you tell us nothing about your provider and what services it offers you, we can't guess whether it makes such functionality available at all, or in what form.\n(Incidentally: this isn't really a programming question, so, if you want to post more details and get help, you might have better luck at serverfault.com, the companion site to stackoverflow.com that deals with system administration questions).","Q_Score":1,"Tags":"python,email","A_Id":2708720,"CreationDate":"2010-04-25T15:15:00.000","Title":"Python script repeated auto start up","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"We think about whether we should convert a quite large python web application to Python 3 in the near future.\nAll experiences, possible challenges or guidelines are highly appreciated.","AnswerCount":2,"Available Count":2,"Score":0.3799489623,"is_accepted":false,"ViewCount":918,"Q_Id":2712283,"Users Score":4,"Answer":"For each third-party library that you use, make sure it has Python 3 support. A lot of the major Python libraries are migrated to 3 now. Check the docs and mailing lists for the libraries.\nWhen all the libraries you depend on are supported, I suggest you go for it.","Q_Score":25,"Tags":"python,python-3.x","A_Id":2712972,"CreationDate":"2010-04-26T09:20:00.000","Title":"Make the Move to Python 3 - 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":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"We think about whether we should convert a quite large python web application to Python 3 in the near future.\nAll experiences, possible challenges or guidelines are highly appreciated.","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":918,"Q_Id":2712283,"Users Score":13,"Answer":"My suggestion is that you stick with Python 2.6+, but simply add the -3 flag to warn you about incompatibilities with Python 3.0. Then you can make sure your Python 2.6 can be easily upgraded to Python 3.0 via 2to3, without actually making that jump quite yet. I would suggest you hold back at the moment, because you may at some point want to use a library and find out that it is only available for 2.6 and not 3.0; if you make sure to cleanup things flagged by -3, then you will be easily able to make the jump, but you will also be able to take advantage of the code that is only available for 2.6+ and which is not yet ready for 3.0.","Q_Score":25,"Tags":"python,python-3.x","A_Id":2712306,"CreationDate":"2010-04-26T09:20:00.000","Title":"Make the Move to Python 3 - 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":1,"System Administration and DevOps":0,"Web Development":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},{"Question":"In the question","AnswerCount":8,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":885,"Q_Id":2722758,"Users Score":0,"Answer":"the Python STDLIB","Q_Score":4,"Tags":"python,coding-style","A_Id":2723111,"CreationDate":"2010-04-27T15:53:00.000","Title":"Any good python open source projects exemplifying coding standards and 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":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"In the question","AnswerCount":8,"Available Count":2,"Score":0.024994793,"is_accepted":false,"ViewCount":885,"Q_Id":2722758,"Users Score":1,"Answer":"You can't read too much source. I think a good idea would be to take some Pythonistas (Raymond Hettinger and Ian Bicking come to mind) and fish out their code from their projects or from other sources like ActiveState and go through them.","Q_Score":4,"Tags":"python,coding-style","A_Id":2723221,"CreationDate":"2010-04-27T15:53:00.000","Title":"Any good python open source projects exemplifying coding standards and 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":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"The question is, basically: what would be more preferable, both performance-wise and design-wise - to have a list of objects of a Python class or to have several lists of numerical properties?\nI am writing some sort of a scientific simulation which involves a rather large system of interacting particles. For simplicity, let's say we have a set of balls bouncing inside a box so each ball has a number of numerical properties, like x-y-z-coordinates, diameter, mass, velocity vector and so on. How to store the system better? Two major options I can think of are:\nto make a class \"Ball\" with those properties and some methods, then store a list of objects of the class, e. g. [b1, b2, b3, ...bn, ...], where for each bn we can access bn.x, bn.y, bn.mass and so on;\nto make an array of numbers for each property, then for each i-th \"ball\" we can access it's 'x' coordinate as xs[i], 'y' coordinate as ys[i], 'mass' as masses[i] and so on;\nTo me it seems that the first option represents a better design. The second option looks somewhat uglier, but might be better in terms of performance, and it could be easier to use it with numpy and scipy, which I try to use as much as I can.\nI am still not sure if Python will be fast enough, so it may be necessary to rewrite it in C++ or something, after initial prototyping in Python. Would the choice of data representation be different for C\/C++? What about a hybrid approach, e.g. Python with C++ extension?\nUpdate: I never expected any performance gain from parallel arrays per se, but in a mixed environment like Python + Numpy (or whatever SlowScriptingLanguage + FastNativeLibrary) using them may (or may not?) let you move more work out of you slow scripting code and into the fast native library.","AnswerCount":4,"Available Count":2,"Score":0.049958375,"is_accepted":false,"ViewCount":1102,"Q_Id":2723790,"Users Score":1,"Answer":"I think it depends on what you're going to be doing with them, and how often you're going to be working with (all attributes of one particle) vs (one attribute of all particles). The former is better suited to the object approach; the latter is better suited to the array approach.\nI was facing a similar problem (although in a different domain) a couple of years ago. The project got deprioritized before I actually implemented this phase, but I was leaning towards a hybrid approach, where in addition to the Ball class I would have an Ensemble class. The Ensemble would not be a list or other simple container of Balls, but would have its own attributes (which would be arrays) and its own methods. Whether the Ensemble is created from the Balls, or the Balls from the Ensemble, depends on how you're going to construct them. \nOne of my coworkers was arguing for a solution where the fundamental object was an Ensemble which might contain only one Ball, so that no calling code would ever have to know whether you were operating on just one Ball (do you ever do that for your application?) or on many.","Q_Score":3,"Tags":"python,performance,data-structures,numpy","A_Id":2726598,"CreationDate":"2010-04-27T18:13:00.000","Title":"List of objects or parallel arrays of properties?","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},{"Question":"The question is, basically: what would be more preferable, both performance-wise and design-wise - to have a list of objects of a Python class or to have several lists of numerical properties?\nI am writing some sort of a scientific simulation which involves a rather large system of interacting particles. For simplicity, let's say we have a set of balls bouncing inside a box so each ball has a number of numerical properties, like x-y-z-coordinates, diameter, mass, velocity vector and so on. How to store the system better? Two major options I can think of are:\nto make a class \"Ball\" with those properties and some methods, then store a list of objects of the class, e. g. [b1, b2, b3, ...bn, ...], where for each bn we can access bn.x, bn.y, bn.mass and so on;\nto make an array of numbers for each property, then for each i-th \"ball\" we can access it's 'x' coordinate as xs[i], 'y' coordinate as ys[i], 'mass' as masses[i] and so on;\nTo me it seems that the first option represents a better design. The second option looks somewhat uglier, but might be better in terms of performance, and it could be easier to use it with numpy and scipy, which I try to use as much as I can.\nI am still not sure if Python will be fast enough, so it may be necessary to rewrite it in C++ or something, after initial prototyping in Python. Would the choice of data representation be different for C\/C++? What about a hybrid approach, e.g. Python with C++ extension?\nUpdate: I never expected any performance gain from parallel arrays per se, but in a mixed environment like Python + Numpy (or whatever SlowScriptingLanguage + FastNativeLibrary) using them may (or may not?) let you move more work out of you slow scripting code and into the fast native library.","AnswerCount":4,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":1102,"Q_Id":2723790,"Users Score":2,"Answer":"Having an object for each ball in this example is certainly better design. Parallel arrays are really a workaround for languages that do not support proper objects. I wouldn't use them in a language with OO capabilities unless it's a tiny case that fits within a function (and maybe not even then) or if I've run out of every other optimization option and the profiler shows that property access is the culprit. This applies twice as much to Python as to C++, as the former places a large emphasis on readability and elegance.","Q_Score":3,"Tags":"python,performance,data-structures,numpy","A_Id":2723845,"CreationDate":"2010-04-27T18:13:00.000","Title":"List of objects or parallel arrays of properties?","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},{"Question":"If I obfuscated python code, would it provide the same level of 'security' as c#\/java obfuscating?\ni.e it makes things a little hard, but really you can still reverse engineer if you really wanted to, its just a bit cryptic.","AnswerCount":4,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":293,"Q_Id":2724885,"Users Score":0,"Answer":"Python code gets compiled to bytecode (.pyc) files as it is imported. You can distribute those .pyc files instead of the .py source code files, and the Python interpreter should be able to load them. While Python bytecode is more \"obfuscated\" than Python source code, it's still relatively easy to disassemble Python bytecode -- but, then again, it's not that hard to disassemble Java bytecode, either.","Q_Score":0,"Tags":"c#,java,python,obfuscation","A_Id":2724925,"CreationDate":"2010-04-27T20:34:00.000","Title":"Can python code (say if I used djangno) be obfuscated to the same 'level' as c#\/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":1},{"Question":"If I obfuscated python code, would it provide the same level of 'security' as c#\/java obfuscating?\ni.e it makes things a little hard, but really you can still reverse engineer if you really wanted to, its just a bit cryptic.","AnswerCount":4,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":293,"Q_Id":2724885,"Users Score":0,"Answer":"Obfuscation doesn't provide security. What you describe isn't security.\nIf you distribute your Python program or your Java program or your C program, it is vunerable. What protects you from people using what you distributed unfairly is the law and people not being jerks.\nObfuscation not only provides no security, it has the potential of breaking working code, hurting performance, and ruining documentation.","Q_Score":0,"Tags":"c#,java,python,obfuscation","A_Id":2725016,"CreationDate":"2010-04-27T20:34:00.000","Title":"Can python code (say if I used djangno) be obfuscated to the same 'level' as c#\/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":1},{"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},{"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},{"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},{"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},{"Question":"Are there any disadvantages about using eggs through easy-install compared to the \"traditional\" packages\/modules\/libs?","AnswerCount":2,"Available Count":2,"Score":1.0,"is_accepted":false,"ViewCount":688,"Q_Id":2733629,"Users Score":8,"Answer":"Using eggs does cause a long sys.path, which has to be searched and when it's really long that search can take a while. Only when you get a hundred entries or so is this going to be a problem (but installing a hundred eggs via easy_install is certainly possible).","Q_Score":7,"Tags":"python,comparison,egg","A_Id":2734885,"CreationDate":"2010-04-28T22:46:00.000","Title":"Disadvantage of Python eggs?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Are there any disadvantages about using eggs through easy-install compared to the \"traditional\" packages\/modules\/libs?","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":688,"Q_Id":2733629,"Users Score":8,"Answer":"One (potential) disadvantage is that eggs are zipped by default unless zip_safe=False is set in their setup() function in setup.py. If an egg is zipped, you can't get at the files in it (without unzipping it, obviously). If the module itself uses non-source files (such as templates) it will probably specify zip_safe=False, but another consequence is that you cannot effectively step into zipped modules using pdb, the Python debugger. That is, you can, but you won't be able to see the source or navigate properly.","Q_Score":7,"Tags":"python,comparison,egg","A_Id":2733647,"CreationDate":"2010-04-28T22:46:00.000","Title":"Disadvantage of Python eggs?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":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},{"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},{"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},{"Question":"I am configuring a distutils-based setup.py for a python module that is to be installed on a heterogeneous set of resources. Due to the heterogeneity, the location where the module is installed is not the same on each host however disutils picks the host-specific location.\nI find that the module is installed without o+rx permissions using disutils (in spite of setting umask ahead of running setup.py). One solution is to manually correct this problem, however I would like an automated means that works on heterogeneous install targets.\nFor example, is there a way to extract the ending location of the installation from within setup.py?\nAny other suggestions?","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1654,"Q_Id":2753966,"Users Score":0,"Answer":"I find that the module is installed without o+rx permissions using disutils\n\nI don\u2019t remember right now if distutils copies the files with their rights as is or if it just copies the contents.\n\n(in spite of setting umask ahead of running setup.py)\n\nI\u2019m not sure how umask and file copying from Python should interact; does umask apply to the system calls or does it need to be explicitly heeded by Python code?\n\nFor example, is there a way to extract the ending location of the installation\n from within setup.py?\n\nThere is one, a bit convoluted. What would you do with that information?","Q_Score":1,"Tags":"python,permissions,distutils,setup.py","A_Id":7931034,"CreationDate":"2010-05-02T15:39:00.000","Title":"setting permissions of python module (python setup 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":0,"Web Development":0},{"Question":"I am trying to migrate a legacy mailing list to a new web forum software and was wondering if mailman has an export option or an API to get all lists, owners, members and membership types.","AnswerCount":3,"Available Count":1,"Score":0.2605204458,"is_accepted":false,"ViewCount":2988,"Q_Id":2756311,"Users Score":4,"Answer":"probably too late, but the list_members LISTNAME command (executed from a shell) will give you all the members of a list.\nlist_admins LISTNAME will give you the owners\nWhat do you mean by membership type? list_members does have an option to filter on digest vs non-digest members. I don't think there's a way to get the moderation flag without writing a script for use with withlist","Q_Score":2,"Tags":"python,api,mailman","A_Id":3154975,"CreationDate":"2010-05-03T05:41:00.000","Title":"Does Mailman have an API or an export lists, users and owners option?","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},{"Question":"Imagine I have a video playing.. Can I have some sort of motion graphics being played 'over' that video.. Like say the moving graphics is on an upper layer than the video, which would be the lower layer..\nI am comfortable in a C++ and Python, so a solution that uses these two will be highly appreciated.. \nThank you in advance,\nRishi..","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":169,"Q_Id":2759738,"Users Score":0,"Answer":"I'm not sure I understand the question correctly but a video file is a sequence of pictures that you can extract (for instance with the opencv library C++ interface) and then you can use it wherever you want. You can play the video on the sides of an opengl 3D cube (available in all opengl tutorials) and other 3D elements around it.\nOf course you can also displays it in a conventional 2D interface and draw stuff on top of it, but for this you need a graphical ui.\nIs it what you thought or am I completely lost?","Q_Score":0,"Tags":"c++,python,graphics,video,video-processing","A_Id":2760860,"CreationDate":"2010-05-03T17:00:00.000","Title":"Navigation graphics overlayed over video","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},{"Question":"Are classes necessary for creating methods (defs) in Python?","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":380,"Q_Id":2761145,"Users Score":0,"Answer":"It depends on your definition of \"method\".\nIn some sense, no, classes aren't necessary for creating methods in Python, because there are no methods anyway in Python. There are only procedures (which, for some strange reason, are called functions in Python). You can create a procedure anywhere you like. A method is just syntactic sugar for a procedure assigned to an attribute.\nIn another sense, yes, classes are necessary for creating methods. It follows pretty much from the definition of what a method is in Python: a procedure stuck into a class's __dict__. (Note, however, that this means that you do not have to be inside a class definition to create method, you can create a procedure anywhere and any way you like and stick it into the class afterwards.)\n[Note: I have simplified a bit when it comes to exactly what a method is, how they are synthesized, how they are represented and how you can create your own.]","Q_Score":3,"Tags":"python","A_Id":2761222,"CreationDate":"2010-05-03T20:57:00.000","Title":"Are classes necessary for creating methods (defs) 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},{"Question":"I think in the past python scripts would run off CGI, which would create a new thread for each process.\nI am a newbie so I'm not really sure, what options do we have?\nIs the web server pipeline that python works under any more\/less effecient than say php?","AnswerCount":3,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":232,"Q_Id":2767013,"Users Score":6,"Answer":"You can still use CGI if you want, but the normal approach these days is using WSGI on the Python side, e.g. through mod_wsgi on Apache or via bridges to FastCGI on other web servers. At least with mod_wsgi, I know of no inefficiencies with this approach.\nBTW, your description of CGI (\"create a new thread for each process\") is inaccurate: what it does is create a new process for each query's service (and that process typically needs to open a database connection, import all needed modules, etc etc, which is what may make it slow even on platforms where forking a process, per se, is pretty fast, such as all Unix variants).","Q_Score":1,"Tags":"python,webserver","A_Id":2767055,"CreationDate":"2010-05-04T16:16:00.000","Title":"When deploying python, what web server options do we have? is the process inefficient at all?","Data Science and Machine Learning":0,"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},{"Question":"I have 4 reasonably complex r scripts that are used to manipulate csv and xml files. These were created by another department where they work exclusively in r. \nMy understanding is that while r is very fast when dealing with data, it's not really optimised for file manipulation. Can I expect to get significant speed increases by converting these scripts to python? Or is this something of a waste of time?","AnswerCount":6,"Available Count":5,"Score":0.0333209931,"is_accepted":false,"ViewCount":2365,"Q_Id":2770030,"Users Score":1,"Answer":"what do you mean by \"file manipulation?\" are you talking about moving files around, deleting, copying, etc., in which case i would use a shell, e.g., bash, etc. if you're talking about reading in the data, performing calculations, perhaps writing out a new file, etc., then you could probably use Python or R. unless maintenance is an issue, i would just leave it as R and find other fish to fry as you're not going to see enough of a speedup to justify your time and effort in porting that code.","Q_Score":3,"Tags":"python,file,r,performance","A_Id":2770393,"CreationDate":"2010-05-05T01:24:00.000","Title":"R or Python for file manipulation","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},{"Question":"I have 4 reasonably complex r scripts that are used to manipulate csv and xml files. These were created by another department where they work exclusively in r. \nMy understanding is that while r is very fast when dealing with data, it's not really optimised for file manipulation. Can I expect to get significant speed increases by converting these scripts to python? Or is this something of a waste of time?","AnswerCount":6,"Available Count":5,"Score":0.0333209931,"is_accepted":false,"ViewCount":2365,"Q_Id":2770030,"Users Score":1,"Answer":"Know where the time is being spent. If your R scripts are bottlenecked on disk IO (and that is very possible in this case), then you could rewrite them in hand-optimized assembly and be no faster. As always with optimization, if you don't measure first, you're just pissing into the wind. If they're not bottlenecked on disk IO, you would likely see more benefit from improving the algorithm than changing the language.","Q_Score":3,"Tags":"python,file,r,performance","A_Id":2770138,"CreationDate":"2010-05-05T01:24:00.000","Title":"R or Python for file manipulation","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},{"Question":"I have 4 reasonably complex r scripts that are used to manipulate csv and xml files. These were created by another department where they work exclusively in r. \nMy understanding is that while r is very fast when dealing with data, it's not really optimised for file manipulation. Can I expect to get significant speed increases by converting these scripts to python? Or is this something of a waste of time?","AnswerCount":6,"Available Count":5,"Score":0.0,"is_accepted":false,"ViewCount":2365,"Q_Id":2770030,"Users Score":0,"Answer":"My guess is that you probably won't see much of a speed-up in time. When comparing high-level languages, overhead in the language is typically not to blame for performance problems. Typically, the problem is your algorithm.\nI'm not very familiar with R, but you may find speed-ups by reading larger chunks of data into memory at once vs smaller chunks (less system calls). If R doesn't have the ability to change something like this, you will probably find that python can be much faster simply because of this ability.","Q_Score":3,"Tags":"python,file,r,performance","A_Id":2770071,"CreationDate":"2010-05-05T01:24:00.000","Title":"R or Python for file manipulation","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},{"Question":"I have 4 reasonably complex r scripts that are used to manipulate csv and xml files. These were created by another department where they work exclusively in r. \nMy understanding is that while r is very fast when dealing with data, it's not really optimised for file manipulation. Can I expect to get significant speed increases by converting these scripts to python? Or is this something of a waste of time?","AnswerCount":6,"Available Count":5,"Score":0.0,"is_accepted":false,"ViewCount":2365,"Q_Id":2770030,"Users Score":0,"Answer":"R data manipulation has rules for it to be fast. The basics are: \n\nvectorize\nuse data.frames as little as possible (for example, in the end)\n\nSearch for R time optimization and profiling and you will find many resources to help you.","Q_Score":3,"Tags":"python,file,r,performance","A_Id":2771903,"CreationDate":"2010-05-05T01:24:00.000","Title":"R or Python for file manipulation","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},{"Question":"I have 4 reasonably complex r scripts that are used to manipulate csv and xml files. These were created by another department where they work exclusively in r. \nMy understanding is that while r is very fast when dealing with data, it's not really optimised for file manipulation. Can I expect to get significant speed increases by converting these scripts to python? Or is this something of a waste of time?","AnswerCount":6,"Available Count":5,"Score":1.2,"is_accepted":true,"ViewCount":2365,"Q_Id":2770030,"Users Score":10,"Answer":"I write in both R and Python regularly. I find Python modules for writing, reading and parsing information easier to use, maintain and update. Little niceties like the way python lets you deal with lists of items over R's indexing make things much easier to read.\nI highly doubt you will gain any significant speed-up by switching the language. If you are becoming the new \"maintainer\" of these scripts and you find Python easier to understand and extend, then I'd say go for it.\nComputer time is cheap ... programmer time is expensive. If you have other things to do then I'd just limp along with what you've got until you have a free day to putz with them.\nHope that helps.","Q_Score":3,"Tags":"python,file,r,performance","A_Id":2770354,"CreationDate":"2010-05-05T01:24:00.000","Title":"R or Python for file manipulation","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},{"Question":"I'm looking for a nice tutorial or framework for developing Python written web applications.\nI've done lots in PHP, but very little in Python or Ruby and figured I'd start with the first one alphabetically.","AnswerCount":4,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":617,"Q_Id":2770426,"Users Score":0,"Answer":"I just started Python for web myself. I also came from a PHP background and felt that PHP is fine when it comes to making regular stuff like forums, blogs and stuff like that. Sadly though I didn't like PHP when it came to create more complex systems.\nI looked at a few of the different frameworks out there and came to the conclusion if I want to use a Framework that applies as much to web as to client and server side programming Turbogears2 would suit med best.\nSeems like one of the \"newer\" frameworks and looks like they got a solid community that will keep they going for years to come.\nOh, lol this post sounds like and ad. Sorry ;)\nAnyway, I like to use webpages that you can work with the hardware on the server, which means CGI\/WSGI or just Turbogears :)","Q_Score":2,"Tags":"php,python","A_Id":4735025,"CreationDate":"2010-05-05T03:33:00.000","Title":"Beginning python for the web","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"Hey, I'm totally behind this topic.\nYesterday I was doing profiling using Python profiler module for some script I'm working on, and the unit for time spent was a 'CPU second'. Can anyone remind me with the definition of it?\nFor example for some profiling I got: 200.750 CPU seconds. What does that supposed to mean? At other case and for time consuming process I got: -347.977 CPU seconds, a negative number!\nIs there anyway I can convert that time, to calendar time?\nCheers,","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":1333,"Q_Id":2771561,"Users Score":1,"Answer":"A CPU second is one second that your process is actually scheduled on the CPU. It can be significantly smaller than than the elapsed real time in case of a busy system, and it can be higher in case of your process running on multiple cores (if the count is per-process, not per-thread).\nIt should never be negative, though...","Q_Score":4,"Tags":"python,profiling","A_Id":2771660,"CreationDate":"2010-05-05T08:25:00.000","Title":"Python profiler and CPU seconds","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Hey, I'm totally behind this topic.\nYesterday I was doing profiling using Python profiler module for some script I'm working on, and the unit for time spent was a 'CPU second'. Can anyone remind me with the definition of it?\nFor example for some profiling I got: 200.750 CPU seconds. What does that supposed to mean? At other case and for time consuming process I got: -347.977 CPU seconds, a negative number!\nIs there anyway I can convert that time, to calendar time?\nCheers,","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":1333,"Q_Id":2771561,"Users Score":8,"Answer":"Roughly speaking, a CPU time of, say, 200.75 seconds means that if only one processor worked on the task and that processor were working on it all the time, it would have taken 200.75 seconds. CPU time can be contrasted with wall clock time, which means the actual time elapsed from the start of the task to the end of the task on a clock hanging on the wall of your room.\nThe two are not interchangeable and there is no way to convert one to the other unless you know exactly how your task was scheduled and distributed among the CPU cores of your system. The CPU time can be less than the wall clock time if the task was distributed among multiple CPU cores, and it can be more if the system was under a heavy load and your task was interrupted temporarily by other tasks.","Q_Score":4,"Tags":"python,profiling","A_Id":2771828,"CreationDate":"2010-05-05T08:25:00.000","Title":"Python profiler and CPU seconds","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've been using Ruby as my main scripting language for years but switched to .NET several years ago. I'd like to continue using Ruby (primarily for testing) BUT the toolset for IronRuby is really nonexistent. Why?\nIn Python, meanwhile, there are project templates and full intellisense support. Why isn't there something like that for IronRuby? The only thing I've been able to find on it is \"there are no plans for VS integration at this time.\" Why???","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":580,"Q_Id":2776721,"Users Score":1,"Answer":"Shortly the same support for IronRuby is arriving to visual studio. It will take maybe another couple of months but then it will get there. They first needed to get the language implementation right.","Q_Score":0,"Tags":"ironpython,ironruby,ironpython-studio","A_Id":2789483,"CreationDate":"2010-05-05T20:57:00.000","Title":"Why doesn't IronRuby have the same tools that IronPython does?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I've been using Ruby as my main scripting language for years but switched to .NET several years ago. I'd like to continue using Ruby (primarily for testing) BUT the toolset for IronRuby is really nonexistent. Why?\nIn Python, meanwhile, there are project templates and full intellisense support. Why isn't there something like that for IronRuby? The only thing I've been able to find on it is \"there are no plans for VS integration at this time.\" Why???","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":580,"Q_Id":2776721,"Users Score":1,"Answer":"IronRuby has been out for 4 weeks, IronPython for 4 years. Developing an IDE takes months, if not years. When exactly where they supposed to squeeze that in?\nAlso, I believe the IronRuby team is smaller than the IronPython team.\nThere actually is a Ruby plugin for Visual Studio produced by SapphireSteel. It's called Ruby in Steel. Unfortunately, they currently only support MRI, YARV and JRuby. They did have IronRuby support at one point, but they removed it, because a) none of their customers actually used it, b) IronRuby was still changing faster than they could adapt and c) some of the IronRuby developers announced that Microsoft is considering developing IronRuby support for Visual Studio in the future and SapphireSteel didn't see much business sense in trying to compete with Microsoft.\nAlso, Visual Studio is not the only IDE on the planet. MonoDevelop has an open bug for IronRuby support, for example. And I'm pretty confident that it wouldn't be too hard to add IronRuby support to NetBeans: it already supports JRuby, MRI and YARV.","Q_Score":0,"Tags":"ironpython,ironruby,ironpython-studio","A_Id":2778756,"CreationDate":"2010-05-05T20:57:00.000","Title":"Why doesn't IronRuby have the same tools that IronPython does?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"What is the most lightweight way to create a random string of 30 characters like the following?\n\nufhy3skj5nca0d2dfh9hwd2tbk9sw1\n\nAnd an hexadecimal number of 30 digits like the followin?\n\n8c6f78ac23b4a7b8c0182d7a89e9b1","AnswerCount":13,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":115807,"Q_Id":2782229,"Users Score":15,"Answer":"Note: random.choice(string.hexdigits) is incorrect, because string.hexdigits returns 0123456789abcdefABCDEF (both lowercase and uppercase), so you will get a biased result, with the hex digit 'c' twice as likely to appear as the digit '7'. Instead, just use random.choice('0123456789abcdef').","Q_Score":112,"Tags":"python","A_Id":15462293,"CreationDate":"2010-05-06T15:23:00.000","Title":"Most lightweight way to create a random string and a random hexadecimal number","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I would like to know if is there any way to convert a plain unicode string to HTML in Genshi, so, for example, it renders newlines as .\nI want this to render some text entered in a textarea.\nThanks in advance!","AnswerCount":4,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":764,"Q_Id":2786803,"Users Score":0,"Answer":"Maybe use a
 tag.","Q_Score":1,"Tags":"python,html,newline,genshi","A_Id":2786862,"CreationDate":"2010-05-07T07:03:00.000","Title":"Print string as HTML","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"If a path such as b\/c\/ does not exist in .\/a\/b\/c , shutil.copy(\".\/blah.txt\", \".\/a\/b\/c\/blah.txt\") will complain that the destination does not exist. What is the best way to create both the destination path and copy the file to this path?","AnswerCount":8,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":114233,"Q_Id":2793789,"Users Score":39,"Answer":"Use os.makedirs to create the directory tree.","Q_Score":89,"Tags":"python","A_Id":2793824,"CreationDate":"2010-05-08T11:00:00.000","Title":"create destination path for shutil.copy 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},{"Question":"I'm having a problem where I have a queue set up in shared mode and multiple consumers bound to it.  The issue is that it appears that rabbitmq is serializing the messages, that is, only one consumer at a time is able to run.  I need this to be parallel, however, I can't seem to figure out how.\nEach consumer is running in its own process.  There are plenty of messages in the queue.  I'm using py-amqplib to interface with RabbitMQ.\nAny thoughts?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":926,"Q_Id":2794994,"Users Score":0,"Answer":"what about prefetching (QOS)? on small queueus I give the appearance of parallelism by declaring the queue, getting the number of messages currently available, attaching a consumer, consuming the messages and then closing it once the number of messages has been consumed. Closing the channel without acknowledging the messages makes the messages available to other consumers, poll the queue quickly enough and you could have a parallel-ish solution.","Q_Score":2,"Tags":"python,parallel-processing,rabbitmq","A_Id":3437797,"CreationDate":"2010-05-08T17:30:00.000","Title":"RabbitMQ serializing messages from queue with multiple consumers","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm having a problem where I have a queue set up in shared mode and multiple consumers bound to it.  The issue is that it appears that rabbitmq is serializing the messages, that is, only one consumer at a time is able to run.  I need this to be parallel, however, I can't seem to figure out how.\nEach consumer is running in its own process.  There are plenty of messages in the queue.  I'm using py-amqplib to interface with RabbitMQ.\nAny thoughts?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":926,"Q_Id":2794994,"Users Score":0,"Answer":"Refefer, the preferred AMQP model seems to be a queue-per-connected-consumer. You should create a \"direct\" exchange and agree upon a routing key that your consumers will all listen for. Then, each consumer that connects should create an exclusive, private, not-durable queue, and use queue_bind() to subscribe their queue to messages matching the public routing key on the exchange. Using this arrangement, my workers are getting to operate in parallel instead of having their operations serialized!","Q_Score":2,"Tags":"python,parallel-processing,rabbitmq","A_Id":6284649,"CreationDate":"2010-05-08T17:30:00.000","Title":"RabbitMQ serializing messages from queue with multiple consumers","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I need to write a module which will be used from both CPython and IronPython. What's the best way to detect IronPython, since I need a slightly different behaviour in that case?\nI noticed that sys.platform is \"win32\" on CPython, but \"cli\" on IronPython.\nIs there another preferred\/standard way of detecting it?","AnswerCount":4,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":3087,"Q_Id":2795240,"Users Score":2,"Answer":"The \"cli\" (= Common Language Infrastructure = .NET = IronPython) is probably reliable.\nAs far as I know, you can access .NET libraries within IronPython, so you could try importing a .NET library, and catch the exception it throws when .NET is not available (as in CPython).","Q_Score":15,"Tags":"python,ironpython,version,detection","A_Id":2795246,"CreationDate":"2010-05-08T18:54:00.000","Title":"Best way to detect 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":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to see if there is a microphone active using Python.\nHow can I do it?\nThanks in advance!","AnswerCount":2,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":1773,"Q_Id":2797572,"Users Score":4,"Answer":"Microphones are analog devices, most api's probably couldn't even tell you if there is a microphone plugged in, your computer just reads data from one of your soundcards input channels.\nWhat you probably want to know is if the input channels are turned on or off.  Determining that is highly platform specific.","Q_Score":1,"Tags":"python,python-2.7,microphone","A_Id":2797821,"CreationDate":"2010-05-09T12:06:00.000","Title":"How to see if there is one microphone active 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},{"Question":"I have a bunch of files.  Some are Unix line endings, many are DOS.  I'd like to test each file to see if if is dos formatted, before I switch the line endings.\nHow would I do this?  Is there a flag I can test for? Something similar?","AnswerCount":7,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":21186,"Q_Id":2798627,"Users Score":0,"Answer":"dos linebreaks are \\r\\n, unix only \\n. So just search for \\r\\n.","Q_Score":14,"Tags":"python,bash,file,line-breaks,line-endings","A_Id":2798651,"CreationDate":"2010-05-09T18:16:00.000","Title":"How can I detect DOS line breaks in 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":1,"Web Development":0},{"Question":"I have used the 2to3 utility to convert code from the command line. What I would like to do is run it basically as a unittest. Even if it tests the file rather than parts(functions, methods...) as would be normal for a unittest.\nIt does not need to be a unittest and I don't what to automatically convert the files I just want to monitor the py3 compliance of files in a unittest like manor. I can't seem to find any documentation or examples for this.\nAn example and\/or documentation would be great.","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":349,"Q_Id":2800231,"Users Score":2,"Answer":"Simply use the -3 option with python2.6+ to be informed of Python3 compliance.","Q_Score":4,"Tags":"python,unit-testing,python-2to3","A_Id":2800242,"CreationDate":"2010-05-10T04:00:00.000","Title":"use\/run python's 2to3 as or like a unittest","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have used the 2to3 utility to convert code from the command line. What I would like to do is run it basically as a unittest. Even if it tests the file rather than parts(functions, methods...) as would be normal for a unittest.\nIt does not need to be a unittest and I don't what to automatically convert the files I just want to monitor the py3 compliance of files in a unittest like manor. I can't seem to find any documentation or examples for this.\nAn example and\/or documentation would be great.","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":349,"Q_Id":2800231,"Users Score":1,"Answer":"If you are trying to verify the code will work in Python 3.x, I would suggest a script that copies the source files to a new directory, runs 2to3 on them, then copies the unit tests to the directory and runs them.\nThis may seem slightly inelegant, but is consistent with the spirit of unit testing. You are making a series of assertions that you believe ought to be true about the external behavior of the code, regardless of implementation. If the converted code passes your unit tests, you can consider your code to support Python 3.","Q_Score":4,"Tags":"python,unit-testing,python-2to3","A_Id":2800372,"CreationDate":"2010-05-10T04:00:00.000","Title":"use\/run python's 2to3 as or like a unittest","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've got a Python module which is distributed on PyPI, and therefore installable using easy_install. It depends on lxml, which in turn depends on libxslt1-dev. I'm unable to install libxslt1-dev with easy_install, so it doesn't work to put it in install_requires. Is there any way I can get setuptools to install it instead of resorting to apt-get?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":1090,"Q_Id":2808956,"Users Score":1,"Answer":"It's better use apt-get to install lxml (or the python packages that has c extensions) and then pull pure python package from pypi. Also I generally try to avoid using easy_install for top level install, I rather create a virtual env using virtualenv and then use easy_install created by virtualenv to keep my setups clean.\nThis strategy is working successfully for me for couple of production environments.","Q_Score":2,"Tags":"python,installation,packaging,setuptools","A_Id":2809025,"CreationDate":"2010-05-11T08:05:00.000","Title":"Installing Python egg dependencies without 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":0,"Web Development":0},{"Question":"Why can Lisp with all its dynamic features be statically compiled but Python cannot (without losing all its dynamic features)?","AnswerCount":4,"Available Count":3,"Score":0.1973753202,"is_accepted":false,"ViewCount":2658,"Q_Id":2812954,"Users Score":4,"Answer":"Actually, there isn't anything that stops you from statically compile a Python program, it's just that no-one wrote such a compiler so far (I personally find Python's runtime to be very easy compared to CL's). \nYou could say that the difference lies in details like \"how much time was spent on actually writing compilers and does the language have a formal specification of how to write one\".\nLet's address those points:\n\nLisp compilers have been evolving for over 40 years now, with work starting back in 70's if not earlier (I'm not sure of my dates, too lazy too google exact ones). That creates a massive chunk of lore about how to write a compiler. OTOH, Python was nominally designed as \"teaching language\", and as such compilers weren't that important.\nLack of specification - Python doesn't have a single source specifying exact semantics of the language. Sure, you can point to PEP documents, but it still doesn't change the fact that the only real spec is the source of the main implementation, CPython. Which, nota bene, is a simple compiler of sorts (into bytecode).\n\nAs for whether it is possible - Python uses quite simple structure to deal with symbols etc., namely its dictionaries. You can treat them as symbol table of a program. You can tag the data types to recognize primitive ones and get the rest based on stored naming and internal structure. rest of the language is also quite simple. The only bit missing is actual work to implement it, and make it run correctly.","Q_Score":13,"Tags":"python,lisp,compilation,dynamic-languages","A_Id":2819922,"CreationDate":"2010-05-11T17:27:00.000","Title":"Lisp vs Python -- Static Compilation","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Why can Lisp with all its dynamic features be statically compiled but Python cannot (without losing all its dynamic features)?","AnswerCount":4,"Available Count":3,"Score":1.2,"is_accepted":true,"ViewCount":2658,"Q_Id":2812954,"Users Score":13,"Answer":"There is nothing that prevents static compilation of Python. It's a bit less efficient because Python reveals more mutable local scope, also, to retain some of the dynamic properties (e.g. eval) you need to include the compiler with the compiled program but nothing prevents that too.\nThat said, research shows that most Python programs, while dynamic under static analysis, are rather static and monomorphic at runtime. This means that runtime JIT compilation approaches work much better on Python programs. See unladen-swallow, PyPy, Psyco for approaches that do compile Python into machine code. But also IronPython and Jython that  use a virtual machines originally intended for a static languages to compile Python into machinecode.","Q_Score":13,"Tags":"python,lisp,compilation,dynamic-languages","A_Id":2813126,"CreationDate":"2010-05-11T17:27:00.000","Title":"Lisp vs Python -- Static Compilation","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Why can Lisp with all its dynamic features be statically compiled but Python cannot (without losing all its dynamic features)?","AnswerCount":4,"Available Count":3,"Score":0.1973753202,"is_accepted":false,"ViewCount":2658,"Q_Id":2812954,"Users Score":4,"Answer":"Python can be 'compiled', where compilation is seen as a translation from one Turing Complete language (source code) to another (object code). However in Lisp, the object is assembly, something which is theoretically possible with Python (proven) but not feasible.\nThe true reason however is less flattening. Lisp is in many ways a revolutionary language that pioneered in its dialects a lot of the features in programming languages we are used to today. In Lisps however they just 'follow' logically from the basics of the language. Language which are inspired by the raw expressive powers of lisps such as JavaScript, Ruby, Perl and Python are necessarily interpreted because getting those features in a language with an 'Algol-like syntax' is just hard. \nLisp gains these features from being 'homo-iconic' there is no essential difference between a lisp program, and a lisp data-structure. Lisp programs are data-structures, they are structural descriptions of a program in such an S-expression if you like, therefore a compiled lisp program effectively 'interprets itself' without the need of a lexer and all that stuff, a lisp program could just be seen as a manual input of parse tree. Which necessitates a syntax which many people find counter-intuitive to work with, therefore there were a lot of attempts to transport the raw expressive power of the paradigm to a more readable syntax, which means that it's infeasible, but not impossible, to compile it towards assembly.\nAlso, compiling Python to assembly would possibly be slower and larger than 'half-interpreting' it on a virtual machine, a lot of features in python depend upon a syntactic analysis.\nThe above though is written by a huge lisp fanboy, keep that conflict of interest in mind.","Q_Score":13,"Tags":"python,lisp,compilation,dynamic-languages","A_Id":2854477,"CreationDate":"2010-05-11T17:27:00.000","Title":"Lisp vs Python -- Static Compilation","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"In c++ instance variables are private by default,in Python variables are public by default \ni have two questions regarding the same:-\n1: why Python have all the members are public by default?\n2: People say you should  your member data should be private\n   what if i make my data to be public?\n   what are the disadvantages of this approch?\n   why it is a bad design?","AnswerCount":4,"Available Count":3,"Score":0.1488850336,"is_accepted":false,"ViewCount":303,"Q_Id":2824579,"Users Score":3,"Answer":"I can't comment on Python, but in C++, structs provide public access by default.  \nThe primary reason you want a private part of your class is that, without one, it is impossible to guarantee your invariants are satisfied.  If you have a string class, for instance, that is supposed to keep track of the length of the string, you need to be able to track insertions. But if the underlying char* member is public, you can't do that.  Anybody can just come along and tack something onto the end, or overwrite your null terminator, or call delete[] on it, or whatever.  When you call your length() member, you just have to hope for the best.","Q_Score":2,"Tags":"c++,python","A_Id":2824708,"CreationDate":"2010-05-13T05:26:00.000","Title":"what if i keep my class members are public?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"In c++ instance variables are private by default,in Python variables are public by default \ni have two questions regarding the same:-\n1: why Python have all the members are public by default?\n2: People say you should  your member data should be private\n   what if i make my data to be public?\n   what are the disadvantages of this approch?\n   why it is a bad design?","AnswerCount":4,"Available Count":3,"Score":0.049958375,"is_accepted":false,"ViewCount":303,"Q_Id":2824579,"Users Score":1,"Answer":"It's really a question of language design philosophies. I favour the Python camp so might come down a little heavy handedly on the C++ style but the bottom line is that in C++ it's possible to forcibly prevent users of your class from accessing certain internal parts. \nIn Python, it's a matter of convention and stating that it's internal. Some applications might want to access the internal member for non-malignant purposes (eg. documentation generators). Some users who know what they're doing might want to do the same. People who want to shoot themselves in the foot twiddling with the internal details are not protected from suicide. \nLike Dennis said \"Anybody can just come along and tack something onto the end, or overwrite your null terminator\". Python treats the user like an adult and expects her to take care of herself.  C++ protects the user as one would a child.","Q_Score":2,"Tags":"c++,python","A_Id":2824800,"CreationDate":"2010-05-13T05:26:00.000","Title":"what if i keep my class members are public?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"In c++ instance variables are private by default,in Python variables are public by default \ni have two questions regarding the same:-\n1: why Python have all the members are public by default?\n2: People say you should  your member data should be private\n   what if i make my data to be public?\n   what are the disadvantages of this approch?\n   why it is a bad design?","AnswerCount":4,"Available Count":3,"Score":1.2,"is_accepted":true,"ViewCount":303,"Q_Id":2824579,"Users Score":13,"Answer":"You can use a leading underscore in the name to tell readers of the code that the name in question is an internal detail and they must not rely on it remaining in future versions.  Such a convention is really all you need -- why weigh the language down with an enforcement mechanism?\nData, just like methods, should be public (named without a leading underscore) if they're part of your class's designed API which you intend to support going forward.  In C++, or Java, that's unlikely to happen because if you want to change the data member into an accessor method, you're out of luck -- you'll have to break your API and every single client of the class will have to change.\nIn Python, and other languages supporting a property-like construct, that's not the case -- you can always replace a data member with a property which calls accessor methods transparently, the API does not change, nor does client code.  So, in Python and other languages with property-like constructs (I believe .NET languages are like that, at source-code level though not necessarily at bytecode level), you may as well leave your data public when it's part of the API and no accessors are currently needed (you can always add accessor methods to later implementation releases if need be, and not break the API).\nSo it's not really a general OO issue, it's language specific: does a given language support a property-like construct.  Python does.","Q_Score":2,"Tags":"c++,python","A_Id":2824654,"CreationDate":"2010-05-13T05:26:00.000","Title":"what if i keep my class members are public?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am looking for good End to End testing framework under python, where the tests can be written in python and managed in a comfortable way. I know there are many unit testing frameworks, but I am looking for bigger scope, something like test director with support for reports etc,where a whole system is under test.","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":22530,"Q_Id":2826734,"Users Score":0,"Answer":"The TTCN3 is a quite good test framework for black-box testing. The comercial tools are having lot of reporting stuff there. It is not in python.","Q_Score":16,"Tags":"python,testing,automated-tests,system-testing","A_Id":6698351,"CreationDate":"2010-05-13T12:32:00.000","Title":"Good automated system testing framework 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},{"Question":"How can I distinguish between a broadcasted message and a direct message for my ip?\nI'm doing this in python.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":83,"Q_Id":2830326,"Users Score":0,"Answer":"Basically what you need to do is create a raw socket, receive a datagram, and examine the destination address in the header. If that address is a broadcast address for the network adapter the socket is bound to, then you're golden.\nI don't know how to do this in Python, so I suggest looking for examples of raw sockets and go from there. Bear in mind, you will need root access to use raw sockets, and you had better be real careful if you plan on sending using a raw socket.\nAs you might imagine, this will not be a fun thing to do. I suggest trying to find a way to avoid doing this.","Q_Score":0,"Tags":"python","A_Id":2830485,"CreationDate":"2010-05-13T21:09:00.000","Title":"Distinguishing between broadcasted messages and direct messages","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},{"Question":"I cannot seem to find a good simple explanation of what python does differently when running with the -O or optimize flag.","AnswerCount":4,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":17421,"Q_Id":2830358,"Users Score":38,"Answer":"assert statements are completely eliminated, as are statement blocks of the form if __debug__: ... (so you can put your debug code in such statements blocks and just run with -O to avoid that debug code).\nWith -OO, in addition, docstrings are also eliminated.","Q_Score":45,"Tags":"python,optimization","A_Id":2830411,"CreationDate":"2010-05-13T21:14:00.000","Title":"What are the implications of running python with the optimize flag?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":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},{"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},{"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},{"Question":"I would like to know what are the certificates available for programming, like \n\nZend for PHP\nSUN Certification for java\n\nWhat are the others? Javascript? C++? Python? etc...\nPlease give me some suggestion for other available certifications.","AnswerCount":5,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":3805,"Q_Id":2839663,"Users Score":0,"Answer":"For linux (implies perl\/bash)\nComptia+ \nRed Hat Certified Engineer","Q_Score":4,"Tags":"php,javascript,python,programming-languages,certificate","A_Id":2840048,"CreationDate":"2010-05-15T09:53:00.000","Title":"What are the most valuable certification available for Programming?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I would like to know what are the certificates available for programming, like \n\nZend for PHP\nSUN Certification for java\n\nWhat are the others? Javascript? C++? Python? etc...\nPlease give me some suggestion for other available certifications.","AnswerCount":5,"Available Count":3,"Score":1.0,"is_accepted":false,"ViewCount":3805,"Q_Id":2839663,"Users Score":16,"Answer":"Most valuable thing for a developer: being able to show you can convert requirements into working and maintainable software.\nCertifications generally are worth very little, except in a few niches that demand them (or at least ask, until they give up and get someone who puts practice before pieces of paper).","Q_Score":4,"Tags":"php,javascript,python,programming-languages,certificate","A_Id":2839684,"CreationDate":"2010-05-15T09:53:00.000","Title":"What are the most valuable certification available for Programming?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I would like to know what are the certificates available for programming, like \n\nZend for PHP\nSUN Certification for java\n\nWhat are the others? Javascript? C++? Python? etc...\nPlease give me some suggestion for other available certifications.","AnswerCount":5,"Available Count":3,"Score":1.0,"is_accepted":false,"ViewCount":3805,"Q_Id":2839663,"Users Score":7,"Answer":"Let me be bold and say that your Experience is your best certificate.","Q_Score":4,"Tags":"php,javascript,python,programming-languages,certificate","A_Id":2839748,"CreationDate":"2010-05-15T09:53:00.000","Title":"What are the most valuable certification available for Programming?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I'm working with web2py and for some reason web2py seems to fail to notice when code has changed in certain cases. I can't really narrow it down, but from time to time changes in the code are not reflected, web2py obviously has the old version cached somewhere. \nThe only thing that helps is quitting web2py and restarting it (i'm using the internal server).\nAny hints ? Thank you !","AnswerCount":2,"Available Count":1,"Score":0.4621171573,"is_accepted":false,"ViewCount":1547,"Q_Id":2840201,"Users Score":5,"Answer":"web2py does cache your code, except for Google App Engine (for speed). That is not the problem. If you you edit code in models, views or controllers, you see the effect immediately.\nThe problem may be modules; if you edit code in modules you will not see the effect immediately, unless you import them with local_import('module', reload=True), or by restarting web2py.\nIs that is also not your problem, then your browser is caching something. Please bring up this question to the web2py mailing list as we can help more.\nP.S. If you are using the latest web2py it no longer comes with cherrypy. The built-in web server is called Rocket.","Q_Score":5,"Tags":"python,caching,web2py","A_Id":2840650,"CreationDate":"2010-05-15T13:07:00.000","Title":"Prevent web2py from caching?","Data Science and Machine Learning":0,"Database and SQL":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},{"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},{"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},{"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},{"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},{"Question":"I'm writing a simple parser of .git\/* files. I covered almost everything, like objects, refs, pack files etc. But I have a problem. Let's say I have a big 300M repository (in a pack file) and I want to find out all the commits which changed \/some\/deep\/inside\/file file. What I'm doing now is:\n\nfetching last commit\nfinding a file in it by:\n\n\nfetching parent tree\nfinding out a tree inside\nrecursively repeat until I get into the file\nadditionally I'm checking hashes of each subfolders on my way to file. If one of them is the same as in commit before, I assume that file was not changed (because it's parent dir didn't change)\n\nthen I store the hash of a file and fetch parent commit\nfinding file again and check if hash change occurs\n\n\nif yes then original commit (i.e. one before parent) was changing a file\n\n\nAnd I repeat it over and over until I reach very first commit.\nThis solution works, but it sucks. In worse case scenario, first search can take even 3 minutes (for 300M pack).\nIs there any way to speed it up ? I tried to avoid putting so large objects in memory, but right now I don't see any other way. And even that, initial memory load will take forever :(\nGreets and thanks for any help!","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":75,"Q_Id":2841863,"Users Score":1,"Answer":"That's the basic algorithm that git uses to track changes to a particular file. That's why \"git log -- some\/path\/to\/file.txt\" is a comparatively slow operation, compared to many other SCM systems where it would be simple (e.g. in CVS, P4 et al each repo file is a server file with the file's history).\nIt shouldn't take so long to evaluate though: the amount you ever have to keep in memory is quite small. You already mentioned the main point: remember the tree IDs going down to the path to quickly eliminate commits that didn't even touch that subtree. It's rare for tree objects to be very big, just like directories on a filesystem (unsurprisingly).\nAre you using the pack index? If you're not, then you essentially have to unpack the entire pack to find this out since trees could be at the end of a long delta chain. If you have an index, you'll still have to apply deltas to get your tree objects, but at least you should be able to find them quickly. Keep a cache of applied deltas, since obviously it's very common for trees to reuse the same or similar bases- most tree object changes are just changing 20 bytes from a previous tree object. So if in order to get tree T1, you have to start with object T8 and apply Td7 to get T7, T6.... etc. it's entirely likely that these other trees T2-8 will be referenced again.","Q_Score":2,"Tags":"python,git","A_Id":2844342,"CreationDate":"2010-05-15T21:40:00.000","Title":"How does git fetches commits associated to 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},{"Question":"I'm using Python in a webapp (CGI for testing, FastCGI for production) that needs to send an occasional email (when a user registers or something else important happens).  Since communicating with an SMTP server takes a long time, I'd like to spawn a thread for the mail function so that the rest of the app can finish up the request without waiting for the email to finish sending.\nI tried using thread.start_new(func, (args)), but the Parent return's and exits before the sending is complete, thereby killing the sending process before it does anything useful.  Is there anyway to keep the process alive long enough for the child process to finish?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":3627,"Q_Id":2850566,"Users Score":0,"Answer":"You might want to use threading.enumerate, if you have multiple workers and want to see which one(s) are still running.  \nOther alternatives include using threading.Event---the main thread sets the event to True and starts the worker thread off.  The worker thread unsets the event when if finishes work, and the main check whether the event is set\/unset to figure out if it can exit.","Q_Score":2,"Tags":"python,multithreading,smtp,cgi","A_Id":2851122,"CreationDate":"2010-05-17T15:50:00.000","Title":"Parent Thread exiting before Child Threads [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},{"Question":"I decided to rewrite all our Bash scripts in Python (there are not so many of them) as my first Python project. The reason for it is that although being quite fluent in Bash I feel it's somewhat archaic language and since our system is in the first stages of its developments I think switching to Python now will be the right thing to do.\nAre there scripts that should always be written in Bash? For example, we have an init.d daemon script - is it OK to use Python for it?\nWe run CentOS.\nThanks.","AnswerCount":4,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":387,"Q_Id":2852397,"Users Score":0,"Answer":"Certain scripts that I write simply involving looping over a glob in some directories, and then executing some a piped series of commands on them.  This kind of thing is much more tedious in python.","Q_Score":1,"Tags":"python,linux,bash,scripting","A_Id":2853719,"CreationDate":"2010-05-17T20:13:00.000","Title":"What scripts should not be ported from bash 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":1,"Web Development":0},{"Question":"I decided to rewrite all our Bash scripts in Python (there are not so many of them) as my first Python project. The reason for it is that although being quite fluent in Bash I feel it's somewhat archaic language and since our system is in the first stages of its developments I think switching to Python now will be the right thing to do.\nAre there scripts that should always be written in Bash? For example, we have an init.d daemon script - is it OK to use Python for it?\nWe run CentOS.\nThanks.","AnswerCount":4,"Available Count":3,"Score":1.2,"is_accepted":true,"ViewCount":387,"Q_Id":2852397,"Users Score":3,"Answer":"It is OK in the sense that you can do it. But the scripts in \/etc\/init.d usually need to load config data and some functions (for example to print the nice green OK on the console) which will be hard to emulate in Python.\nSo try to convert those which make sense (i.e. those which contain complex logic). If you need job control (starting\/stopping processes), then bash is better suited than Python.","Q_Score":1,"Tags":"python,linux,bash,scripting","A_Id":2852418,"CreationDate":"2010-05-17T20:13:00.000","Title":"What scripts should not be ported from bash 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":1,"Web Development":0},{"Question":"I decided to rewrite all our Bash scripts in Python (there are not so many of them) as my first Python project. The reason for it is that although being quite fluent in Bash I feel it's somewhat archaic language and since our system is in the first stages of its developments I think switching to Python now will be the right thing to do.\nAre there scripts that should always be written in Bash? For example, we have an init.d daemon script - is it OK to use Python for it?\nWe run CentOS.\nThanks.","AnswerCount":4,"Available Count":3,"Score":0.049958375,"is_accepted":false,"ViewCount":387,"Q_Id":2852397,"Users Score":1,"Answer":"Every task has languages that are better suited for it and less so. Replacing the backtick ` quote of sh is pretty ponderous in Python as would be myriad quoting details, just to name a couple. There are likely better projects to cut your teeth on.\nAnd all that they said above about Python being relatively heavyweight and not necessarily available when needed.","Q_Score":1,"Tags":"python,linux,bash,scripting","A_Id":2853661,"CreationDate":"2010-05-17T20:13:00.000","Title":"What scripts should not be ported from bash 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":1,"Web Development":0},{"Question":"Do you know any PHP statement that works like Python's pass statement?","AnswerCount":6,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":22582,"Q_Id":2852784,"Users Score":60,"Answer":"Just leave the bracket's empty...\nPython has the pass word because they don't use brackets to define the body part of classes, function, and other statement. PHP doesn't have this dilemma , and therefore doesn't need something to say that a body statement is empty.","Q_Score":28,"Tags":"php,python,language-comparisons","A_Id":2852795,"CreationDate":"2010-05-17T21:01:00.000","Title":"What is the equivalent in PHP for Python's pass statement?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I am struggling to find any method of using RSA in ECB mode with PKCS1 padding in python. I've looked into pyCrypto, but they don't have PKCS1 padding in the master branch (but do in a patch).  Nevertheless I found RSA with PKCS1 in the M2Crypto package, but I'm not sure if I can choose ECB mode...","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":9374,"Q_Id":2855326,"Users Score":13,"Answer":"Chaining mode such as ECB makes no sense for RSA, unless you are doing it wrong.\nECB is for block ciphers: the input data is split into equal-size blocks, and each block is encrypted separately. This induces some weaknesses so ECB mode is best avoided for block ciphers.\nRSA is not a block cipher. In particular, RSA necessarily enlarges the encrypted message: with a 1024-bit RSA key (a fairly typical size), one can encrypt a message up to 117 bytes, but the result is a 128-byte value.\nOne could imagine taking a larger message, split it into individual blocks of length 117 bytes (or less) and RSA-encrypt each of them individually, but nobody ever does that, mostly because of the size increase, and the CPU cost. Also, security issues related to that splitting and recombining are not studied at all, so it is quite possible that the result would be quite weak. Usually, when a cryptographic library requires a padding mode as part of an algorithm name, such as in \"RSA\/ECB\/PKCS1Padding\", this is only due to the syntaxic constraints on the name, and the chaining part (ECB) is actually ignored (this is what Java does, for instance).\nIn practice, when encrypting some data which may be larger than the maximum RSA input size, hybrid encryption is used: what is RSA-encrypted is a random symmetric key (e.g. a bunch of 16 uniformly random bytes), and that key is used to symmetrically encrypt (e.g. with AES) the actual data. This is more space-effective (because symmetric encryption does not enlarge blocks) and CPU-efficient (symmetric encryption is vastly faster than asymmetric encryption, and in particular RSA decryption).","Q_Score":6,"Tags":"python,encryption,rsa","A_Id":2856628,"CreationDate":"2010-05-18T07:44:00.000","Title":"How can I create a key using RSA\/ECB\/PKCS1Padding 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},{"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},{"Question":"How do you guys deploy your code on your servers? I am using Fabric and Python and I would like a more automated way of pulling code from the repository through the use of public keys, but without any ops or manual intervention to set up the public keys.\nAre you storing them in the code as text or in a database and generate the pk file on the fly? Any other opinions on this one ?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":212,"Q_Id":2855650,"Users Score":1,"Answer":"This is what ssh-copy-id is for. It deploys your public key onto a machine for you. Key management isn't something I'd suggest putting into code\/VCS. Each user needs to setup their keys so that the local ssh client knows to use them. We use Fabric as well, but it only uses the key that the ssh config is already telling it to.","Q_Score":0,"Tags":"python,fabric","A_Id":2857218,"CreationDate":"2010-05-18T08:34:00.000","Title":"deployment public keys","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I have a WSGI app that I would like to place behind SSL. My WSGI server is gevent.\nWhat would a good way to serve the app through SSL in this case be?","AnswerCount":3,"Available Count":1,"Score":0.1325487884,"is_accepted":false,"ViewCount":7474,"Q_Id":2857273,"Users Score":2,"Answer":"I would let the http server deal with the ssl transport.","Q_Score":5,"Tags":"python,ssl,wsgi,gevent","A_Id":2857301,"CreationDate":"2010-05-18T12:40:00.000","Title":"SSL and WSGI apps - 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},{"Question":"I've been using for more than 12 years PHP with Apache (a.k.a mod_php) for my web\ndevelopment work. I've recenlty discovered python and its real power (I still don't understand why this is not always the best product that becomes the most famous).\nI've just discovered mod_python for Apache. I've already googled but without success things like mod_python vs mod_php. I wanted to know the differences between the two mod_php and mod_python in terms of:\n\nspeed\nproductivity\nmaintainance\n(I know `python is most productive and maintainable language in the world, but is it the same for Web programming with Apache)\navailability of features e.g, cookies and session handling, databases, protocols, etc.","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":1262,"Q_Id":2863618,"Users Score":1,"Answer":"I wanted to know the differences between the two mod_php and mod_python...\n\nPHP is more widely available on Internet hosts than Python.\nI've noticed on one of my Python web sites that if I'm the first user to use Python, on that Internet host, the start up time of the Python services can be measured in minutes.  Most people won't wait minutes for a web page to pop up.\nPython has the same web features (cookies, session handling, database connections, protocols) as PHP.","Q_Score":3,"Tags":"apache,mod-python,mod-php","A_Id":2863923,"CreationDate":"2010-05-19T07:36:00.000","Title":"Web programming: Apache modules: mod_python vs mod_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},{"Question":"I've been using for more than 12 years PHP with Apache (a.k.a mod_php) for my web\ndevelopment work. I've recenlty discovered python and its real power (I still don't understand why this is not always the best product that becomes the most famous).\nI've just discovered mod_python for Apache. I've already googled but without success things like mod_python vs mod_php. I wanted to know the differences between the two mod_php and mod_python in terms of:\n\nspeed\nproductivity\nmaintainance\n(I know `python is most productive and maintainable language in the world, but is it the same for Web programming with Apache)\navailability of features e.g, cookies and session handling, databases, protocols, etc.","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":1262,"Q_Id":2863618,"Users Score":2,"Answer":"My understanding is that PHP was designed with Internet\/Web in mind, but Python is for a more general purpose.\nNow most people are leaving mod_python for mod_wsgi, which is more robust and flexible.\nTo answer other questions:\n\nspeed: python is faster. (PHP is slower than both ruby and python)\nproductivity: at least the same as php with numerous libraries\nmaintenance: python is clear and neat\nfeatures: more than you need, I would say.\n\nPython was not popular on web because it wasn't focused on web at all. It has too many web frameworks (more frameworks than programming languages), so the community has not been as strong as Ruby on Rails.","Q_Score":3,"Tags":"apache,mod-python,mod-php","A_Id":2869850,"CreationDate":"2010-05-19T07:36:00.000","Title":"Web programming: Apache modules: mod_python vs mod_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},{"Question":"I have a project which is essentially a game server where users connect and send text commands via telnet.\nThe code is in C and really old and unmodular and has several bugs and missing features. The main function alone is half the code.\nI came to the conclusion that rewriting it in Python, with Twisted, could actually result in faster completement, besides other benefits.\nSo, here is the questions:\nWhat packages and modules I should use? I see a \"telnet\" module inside \"protocols\" package.  I also see \"cronch\" package with \"ssh\" and another \"telnet\" module.\nI'm a complete novice regarding Python.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":2482,"Q_Id":2864663,"Users Score":1,"Answer":"It sounds like you've got two separate tasks here:\n\nPort the code from C to Python.\nRewrite the whole program to use Twisted.\n\nSince you're new to Python, I would be inclined to do the first one first, before trying to make the program structure work in Twisted. If the program is old, there isn't likely to be any performance problems running it on modern hardware.\nConverting the C code to Python first will give you the familiarity with Python you need to start on the port to Twisted.","Q_Score":4,"Tags":"python,twisted,telnet","A_Id":2864683,"CreationDate":"2010-05-19T10:33:00.000","Title":"Twisted Matrix and telnet server implementation","Data Science and Machine Learning":0,"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},{"Question":"I just finished my second year as a university CS student, so my \"real-world\" knowledge is lacking.  I learned Java my first year, continued with Java and picked up C and simple Bash \nscripting my second.  This summer I'm trying to learn Perl (God help me).  I've dabbled with Python a bit in the past.\nMy question is, now that we have very readable, very writable scripting languages like Python, Ruby, Perl, etc, why does anyone write Bash scripts?  Is there something I'm missing?  I know my linux box has perl and python.  Are they not ubiquitous enough?  Is there really something\nthat's easier to do in Bash than in some other hll?","AnswerCount":18,"Available Count":10,"Score":0.0111106539,"is_accepted":false,"ViewCount":50948,"Q_Id":2872041,"Users Score":1,"Answer":"What I don't get is why people say bash when they mean any bourne-shell compatible shell.\nWhen writing shell scripts: always try to use constructs that also work in older bourne shell interpreters as well. It will save you lots of trouble some day.\nAnd yes, there is plenty of use for shell scripts today, as the shell always exist on all unixes, out of the box, contrary to perl, python, csh, zsh, ksh (possibly?), and so on.\nMost of the time they only add extra convenience or different syntax for constructs like loops and tests. Some have improved redirection features.\nMost of the time, I would say that ordinary bourne shell works equally well.\nTypical pitfall:\nif ! test $x -eq $y works as expected in bash that has a more clever builtin \"if\" operator, but the \"correct\" if test ! $x -eq $y should work in all environments.","Q_Score":76,"Tags":"python,perl,bash,scripting,comparison","A_Id":3203607,"CreationDate":"2010-05-20T08:20:00.000","Title":"Is there any use for Bash scripting anymore?","Data Science and Machine Learning":0,"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},{"Question":"I just finished my second year as a university CS student, so my \"real-world\" knowledge is lacking.  I learned Java my first year, continued with Java and picked up C and simple Bash \nscripting my second.  This summer I'm trying to learn Perl (God help me).  I've dabbled with Python a bit in the past.\nMy question is, now that we have very readable, very writable scripting languages like Python, Ruby, Perl, etc, why does anyone write Bash scripts?  Is there something I'm missing?  I know my linux box has perl and python.  Are they not ubiquitous enough?  Is there really something\nthat's easier to do in Bash than in some other hll?","AnswerCount":18,"Available Count":10,"Score":0.0111106539,"is_accepted":false,"ViewCount":50948,"Q_Id":2872041,"Users Score":1,"Answer":"As mentioned, the GNU tools are great, and are easiest to use within the shell. It is especially nice if your data is already in a linear or tabular form of plain text. Just as an example, the other day I was able to build a script to create an XHTML word cloud of any text file in 8 lines of Bourne Shell, which is even less powerful (but more widely supported) than Bash.","Q_Score":76,"Tags":"python,perl,bash,scripting,comparison","A_Id":3147413,"CreationDate":"2010-05-20T08:20:00.000","Title":"Is there any use for Bash scripting anymore?","Data Science and Machine Learning":0,"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},{"Question":"I just finished my second year as a university CS student, so my \"real-world\" knowledge is lacking.  I learned Java my first year, continued with Java and picked up C and simple Bash \nscripting my second.  This summer I'm trying to learn Perl (God help me).  I've dabbled with Python a bit in the past.\nMy question is, now that we have very readable, very writable scripting languages like Python, Ruby, Perl, etc, why does anyone write Bash scripts?  Is there something I'm missing?  I know my linux box has perl and python.  Are they not ubiquitous enough?  Is there really something\nthat's easier to do in Bash than in some other hll?","AnswerCount":18,"Available Count":10,"Score":0.022218565,"is_accepted":false,"ViewCount":50948,"Q_Id":2872041,"Users Score":2,"Answer":"I'm a perl guy, but the number of the bash (or ksh) functions I use and create on a daily basis is quite significant. For anything involved, I'll write a perl script, but for navigating the directory structure, and specifically for manipulating environment variables bash\/ksh\/... are indispensable. \nAgain, especially for environment variables nothing beats shell, and quite a few programs use environment variables. In Perl, I have to write a bash alias or function that calls the Perl script, which writes out a temporary bash script, which then gets sourced after Perl exits in order to make the change in the same environment I'm launching from. \nI've done this, especially for heavy-lifting on path variables. But there's no way to do it in just Perl (or python or ruby... or C-code for that matter).","Q_Score":76,"Tags":"python,perl,bash,scripting,comparison","A_Id":2877257,"CreationDate":"2010-05-20T08:20:00.000","Title":"Is there any use for Bash scripting anymore?","Data Science and Machine Learning":0,"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},{"Question":"I just finished my second year as a university CS student, so my \"real-world\" knowledge is lacking.  I learned Java my first year, continued with Java and picked up C and simple Bash \nscripting my second.  This summer I'm trying to learn Perl (God help me).  I've dabbled with Python a bit in the past.\nMy question is, now that we have very readable, very writable scripting languages like Python, Ruby, Perl, etc, why does anyone write Bash scripts?  Is there something I'm missing?  I know my linux box has perl and python.  Are they not ubiquitous enough?  Is there really something\nthat's easier to do in Bash than in some other hll?","AnswerCount":18,"Available Count":10,"Score":0.0111106539,"is_accepted":false,"ViewCount":50948,"Q_Id":2872041,"Users Score":1,"Answer":"In my experience, Perl meets something like 99% of any need that might require a shell script.  As a bonus, it is possible to write code that runs on Windows sans Cygwin.  If I won't have a Perl install on a Windows box I want to target, I can use PAR::Packer or PerlApp to produce an executable.  Python, Ruby and others should work just as well, too.\nHowever, shell scripting isn't all that complicated--at least things that you should be scripting in a shell aren't all that complicated. You can do what you need to do with a fairly shallow level of knowledge.\nLearn how to read and set variables.  How to create and call functions.  How to source other files.  Learn how flow control works.\nAnd most important, learn to read the shell man page.  This may sound facetious, but I am 100% serious--don't worry about cramming every detail of shell scripting into your brain, instead learn to find what you need to know in the man page quickly and efficiently. If you find yourself using shell scripting often, the pertinent info will naturally stick in your brain.\nSo, yes, basic shell is worth learning.","Q_Score":76,"Tags":"python,perl,bash,scripting,comparison","A_Id":2875733,"CreationDate":"2010-05-20T08:20:00.000","Title":"Is there any use for Bash scripting anymore?","Data Science and Machine Learning":0,"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},{"Question":"I just finished my second year as a university CS student, so my \"real-world\" knowledge is lacking.  I learned Java my first year, continued with Java and picked up C and simple Bash \nscripting my second.  This summer I'm trying to learn Perl (God help me).  I've dabbled with Python a bit in the past.\nMy question is, now that we have very readable, very writable scripting languages like Python, Ruby, Perl, etc, why does anyone write Bash scripts?  Is there something I'm missing?  I know my linux box has perl and python.  Are they not ubiquitous enough?  Is there really something\nthat's easier to do in Bash than in some other hll?","AnswerCount":18,"Available Count":10,"Score":0.022218565,"is_accepted":false,"ViewCount":50948,"Q_Id":2872041,"Users Score":2,"Answer":"Easier, probably not.  I actually prefer perl to bash scripting in many cases.  Bash does have one advantage, though, especially on Linux systems: it's all but guaranteed to be installed.  And if it's not, its largely-compatible father (sh) will be, cause almost all system scripts are written for sh.  Even perl isn't that ubiquitous, and it's everyfreakingwhere.","Q_Score":76,"Tags":"python,perl,bash,scripting,comparison","A_Id":2872083,"CreationDate":"2010-05-20T08:20:00.000","Title":"Is there any use for Bash scripting anymore?","Data Science and Machine Learning":0,"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},{"Question":"I just finished my second year as a university CS student, so my \"real-world\" knowledge is lacking.  I learned Java my first year, continued with Java and picked up C and simple Bash \nscripting my second.  This summer I'm trying to learn Perl (God help me).  I've dabbled with Python a bit in the past.\nMy question is, now that we have very readable, very writable scripting languages like Python, Ruby, Perl, etc, why does anyone write Bash scripts?  Is there something I'm missing?  I know my linux box has perl and python.  Are they not ubiquitous enough?  Is there really something\nthat's easier to do in Bash than in some other hll?","AnswerCount":18,"Available Count":10,"Score":1.0,"is_accepted":false,"ViewCount":50948,"Q_Id":2872041,"Users Score":8,"Answer":"Well, when writing with bash, you can directly use every possible tool you have on the command line for your script. With any other language you would first have to execute that command and get some result etc. A simple script that (for example) gets a list of processes, runs through grep and gets some result would be a lot more complicated in other languages. As such, bash is still a good tool for writing quick things.","Q_Score":76,"Tags":"python,perl,bash,scripting,comparison","A_Id":2872064,"CreationDate":"2010-05-20T08:20:00.000","Title":"Is there any use for Bash scripting anymore?","Data Science and Machine Learning":0,"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},{"Question":"I just finished my second year as a university CS student, so my \"real-world\" knowledge is lacking.  I learned Java my first year, continued with Java and picked up C and simple Bash \nscripting my second.  This summer I'm trying to learn Perl (God help me).  I've dabbled with Python a bit in the past.\nMy question is, now that we have very readable, very writable scripting languages like Python, Ruby, Perl, etc, why does anyone write Bash scripts?  Is there something I'm missing?  I know my linux box has perl and python.  Are they not ubiquitous enough?  Is there really something\nthat's easier to do in Bash than in some other hll?","AnswerCount":18,"Available Count":10,"Score":0.022218565,"is_accepted":false,"ViewCount":50948,"Q_Id":2872041,"Users Score":2,"Answer":"If you do lots of GUI stuff, you'll probably only meet bash whenever you're doing some sort of customization on your own machine. Various hacks and stuff. If you use the command line to do stuff, bash is just indispensable. In fact, being good on the command line requires bash or some other shell familiarity.\nI get miles out of having learned Bash when I wanted to navigate around my harddrive quickly. I wrote a navigation\/menu interface that let me beam to different folders and files quickly and easily. Writing it in bash was simple and easy. And there's lots of easily accessed, and free, stuff that'll show you how.\nAlso, learning Bash is great for understanding how Unix and some of the core stuff really works -- and how far we've come with tools like Python.","Q_Score":76,"Tags":"python,perl,bash,scripting,comparison","A_Id":2874267,"CreationDate":"2010-05-20T08:20:00.000","Title":"Is there any use for Bash scripting anymore?","Data Science and Machine Learning":0,"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},{"Question":"I just finished my second year as a university CS student, so my \"real-world\" knowledge is lacking.  I learned Java my first year, continued with Java and picked up C and simple Bash \nscripting my second.  This summer I'm trying to learn Perl (God help me).  I've dabbled with Python a bit in the past.\nMy question is, now that we have very readable, very writable scripting languages like Python, Ruby, Perl, etc, why does anyone write Bash scripts?  Is there something I'm missing?  I know my linux box has perl and python.  Are they not ubiquitous enough?  Is there really something\nthat's easier to do in Bash than in some other hll?","AnswerCount":18,"Available Count":10,"Score":0.0444152037,"is_accepted":false,"ViewCount":50948,"Q_Id":2872041,"Users Score":4,"Answer":"Apart from what others have said, I'd like to point out what's in my opinion the main reason to learn Bash: it's the (almost) standard Linux shell.\nOther scripting languages are surely useful, and maybe a lot more powerful, but what you'll be dealing with when you have a terminal in front of you is... Bash.\nBeing able to manage I\/O, pipes and processes, assing and use variables, and do at least some loop and condition evaluation is a must, if you want to manage a Linux system.","Q_Score":76,"Tags":"python,perl,bash,scripting,comparison","A_Id":2875677,"CreationDate":"2010-05-20T08:20:00.000","Title":"Is there any use for Bash scripting anymore?","Data Science and Machine Learning":0,"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},{"Question":"I just finished my second year as a university CS student, so my \"real-world\" knowledge is lacking.  I learned Java my first year, continued with Java and picked up C and simple Bash \nscripting my second.  This summer I'm trying to learn Perl (God help me).  I've dabbled with Python a bit in the past.\nMy question is, now that we have very readable, very writable scripting languages like Python, Ruby, Perl, etc, why does anyone write Bash scripts?  Is there something I'm missing?  I know my linux box has perl and python.  Are they not ubiquitous enough?  Is there really something\nthat's easier to do in Bash than in some other hll?","AnswerCount":18,"Available Count":10,"Score":0.022218565,"is_accepted":false,"ViewCount":50948,"Q_Id":2872041,"Users Score":2,"Answer":"Bash (and the original Bourne sh and myriad derivatives) is - from one perspective - an incredibly high-level language. Where many languages use simple primitives, shell primitives are entire programs.\nThat it might not be the best language to express your tasks, doesn't mean it is dead, dying, or even moribund.","Q_Score":76,"Tags":"python,perl,bash,scripting,comparison","A_Id":2872085,"CreationDate":"2010-05-20T08:20:00.000","Title":"Is there any use for Bash scripting anymore?","Data Science and Machine Learning":0,"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},{"Question":"I just finished my second year as a university CS student, so my \"real-world\" knowledge is lacking.  I learned Java my first year, continued with Java and picked up C and simple Bash \nscripting my second.  This summer I'm trying to learn Perl (God help me).  I've dabbled with Python a bit in the past.\nMy question is, now that we have very readable, very writable scripting languages like Python, Ruby, Perl, etc, why does anyone write Bash scripts?  Is there something I'm missing?  I know my linux box has perl and python.  Are they not ubiquitous enough?  Is there really something\nthat's easier to do in Bash than in some other hll?","AnswerCount":18,"Available Count":10,"Score":1.0,"is_accepted":false,"ViewCount":50948,"Q_Id":2872041,"Users Score":26,"Answer":"The real difference between bash and python is that python is a general purpose scripting language, while bash is simply a way to run a myriad of small (and often very fast) programs in a series. Python can do this, but it is not optimized for it. The programs (sort, find, uniq, scp) might do very complex tasks very simply, and bash allows these tasks to interoperate very simply with piping, flushing output in and out from files or devices etc. While Python can run the same programs, you will be forced to do bash scripting in the python script to accomplish the same thing, and then you are stuck with both python and bash. Both are fine by them self, but a mix of these don't improve anything IMHO.","Q_Score":76,"Tags":"python,perl,bash,scripting,comparison","A_Id":2872171,"CreationDate":"2010-05-20T08:20:00.000","Title":"Is there any use for Bash scripting anymore?","Data Science and Machine Learning":0,"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},{"Question":"My config file is really just a big python dict, but I have many config files to run different experiments and I want to 'import' a different one based on a command line option. Instinctively I want to do import ConfigFileName where ConfigFileName is a string with the config file's python package name in it...  but that doesn't work.\nAny ideas?","AnswerCount":3,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":564,"Q_Id":2874431,"Users Score":5,"Answer":"Use the __import__ builtin function. But like nosklo, I prefer to store it in simpler data format like JSON of INI config file.","Q_Score":1,"Tags":"python,configuration,import,config","A_Id":2874547,"CreationDate":"2010-05-20T14:02:00.000","Title":"What's the best way to use python-syntax config files (in python of course)?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"My config file is really just a big python dict, but I have many config files to run different experiments and I want to 'import' a different one based on a command line option. Instinctively I want to do import ConfigFileName where ConfigFileName is a string with the config file's python package name in it...  but that doesn't work.\nAny ideas?","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":564,"Q_Id":2874431,"Users Score":1,"Answer":"You might consider ConfigParser, also included with python.  It offers simple sectioned name\/value items, default settings, and some substitution capabilities.  If that's flexible enough for your needs, it would be a nice alternative.","Q_Score":1,"Tags":"python,configuration,import,config","A_Id":2877557,"CreationDate":"2010-05-20T14:02:00.000","Title":"What's the best way to use python-syntax config files (in python of course)?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to find a decent IDE that supports Python 3.x, and offers code completion\/in-built Pydocs viewer, Mercurial integration, and SSH\/SFTP support.\nAnyhow, I'm trying Pydev, and I open up a .py file, it's in the Pydev perspective and the Run As doesn't offer any options. It does when you start a Pydev project, but I don't want to start a project just to edit one single Python script, lol, I want to just open a .py file and have It Just Work...\nPlan 2, I try Komodo 6 Alpha 2. I actually quite like Komodo, and it's nice and snappy, offers in-built Mercurial support, as well as in-built SSH support (although it lacks SSH HTTP Proxy support, which is slightly annoying).\nHowever, for some reason, this refuses to pick up Python 3. In Edit-Preferences-Languages, there's two option, one for Python and Python3, but the Python3 one refuses to work, with either the official Python.org binaries, or ActiveState's own ActivePython 3. Of course, I can set the \"Python\" interpreter to the 3.1 binary, but that's an ugly hack and breaks Python 2.x support.\nSo, does anybody who uses an IDE for Python have any suggestions on either of these accounts, or can you recommend an alternate IDE for Python 3.0 development?\nCheers,\nVictor","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":584,"Q_Id":2879008,"Users Score":0,"Answer":"You did not mention these so I'm not sure if you've tried them but there are:\n- Aptana (aptana.com)\n- The Eric Python IDE (http:\/\/eric-ide.python-projects.org\/)\n- WingWare Python IDE (wingware.com)\nI haven't used any of them so I don't know if they will match your needs, but I'd expected them to be pretty close as they are all mature.\nAs for PyCharm, I've been using it for a while and it's fine, actully I like it very much.\nHowever I'm a Python noob and probably do not use many advanced features so YMMV.","Q_Score":3,"Tags":"python,ide","A_Id":11520785,"CreationDate":"2010-05-21T01:18:00.000","Title":"Python 3.0 IDE - Komodo and Eclipse both flaky?","Data Science and Machine Learning":0,"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},{"Question":"I have a system where a central Java controller launches analysis processes, which may be written in C++, Java, or Python (mostly they are C++). All these processes currently run on the same server. What are you suggestions to\n\nCreate a central log to which all processes can write to\nWhat if in the future I push some processes to another server. How can I support distributed logging?\n\nThanks!","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":2806,"Q_Id":2885822,"Users Score":1,"Answer":"I'd use Apache log4cxx or Apache log4j.\nIt's Efficient. It has Logger hierarchies to modularize your logs. It's proven tecnology for a  while now.\nCurrently, appenders exist for the console , files , GUI components, remote socket servers, NT Event Loggers , and remote UNIX Syslog daemons. It is also possible to log asynchronously.\nHow can I support distributed logging? \nWith remote socket servers appenders for example.","Q_Score":11,"Tags":"java,c++,python,logging","A_Id":2926570,"CreationDate":"2010-05-21T21:49:00.000","Title":"Which logging library to use for cross-language (Java, C++, Python) 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":1},{"Question":"in python tutorial added that python cannot hide its attributes from other classes. some thing such as private data in C++ or java..But also i know that we can use _ or __ to set some variables as privated  one but it is not enogh. I think it is a weak if it is not any thing to do it.","AnswerCount":4,"Available Count":3,"Score":0.1973753202,"is_accepted":false,"ViewCount":5646,"Q_Id":2888035,"Users Score":4,"Answer":"Data encapsulation in Python is enforced by convention and peer review.  Surprisingly, having every attribute effectively be public hasn't caused a problem for the majority of Python programmers.","Q_Score":0,"Tags":"python","A_Id":2888059,"CreationDate":"2010-05-22T12:18:00.000","Title":"information hiding 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},{"Question":"in python tutorial added that python cannot hide its attributes from other classes. some thing such as private data in C++ or java..But also i know that we can use _ or __ to set some variables as privated  one but it is not enogh. I think it is a weak if it is not any thing to do it.","AnswerCount":4,"Available Count":3,"Score":0.1973753202,"is_accepted":false,"ViewCount":5646,"Q_Id":2888035,"Users Score":4,"Answer":"Using an underscore at the start of the name for an element or a method signals to the reader that what they're looking at is \"internal implementation details\". If they want to use that, they can, but it is very likely that a new version of the class will not preserve the API for internal-only method or elements (eh, \"slots\", I guess, the instance variables).\nBy having compiler-enforced guarantees as to what is and isn't visible, you are more sure that external parties are not looking at the internal bits, but even in C++ it is not that hard to access private things.\nIn practice, as long as you trust people not to do stupid things there's no problem having \"this is internal, don't touch\" as a polite reminder rather than enforced.","Q_Score":0,"Tags":"python","A_Id":2888071,"CreationDate":"2010-05-22T12:18:00.000","Title":"information hiding 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},{"Question":"in python tutorial added that python cannot hide its attributes from other classes. some thing such as private data in C++ or java..But also i know that we can use _ or __ to set some variables as privated  one but it is not enogh. I think it is a weak if it is not any thing to do it.","AnswerCount":4,"Available Count":3,"Score":0.0996679946,"is_accepted":false,"ViewCount":5646,"Q_Id":2888035,"Users Score":2,"Answer":"You are right that the _foo convention isn't sufficient to make data private; it's not supposed to be! Information hiding is not part of the design of Python. When writing programs in Python, you depend on the caller's good manners to leave your internals alone based on the naming convention and your documentation. Don't try to exert more control than this; we're all consenting adults.\nThere is a convention of naming internal-use methods like _foo with a single leading underscore; this serves more documentation purposes than anything else. Python name-mangles __foo attributes. Some people think this makes them more private, but it doesn't make them at all private, though it does make your classes harder to use, extend, and test. I never use them.","Q_Score":0,"Tags":"python","A_Id":2888448,"CreationDate":"2010-05-22T12:18:00.000","Title":"information hiding 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},{"Question":"I need huffman code(best in python or in java), which could encode text not by one character (a = 10, b = 11), but by two (ab = 11, ag = 10). Is it possible and if yes, where could i find it, maybe it's somewhere in the internet and i just can'd find it?","AnswerCount":3,"Available Count":2,"Score":1.0,"is_accepted":false,"ViewCount":1395,"Q_Id":2888468,"Users Score":6,"Answer":"Huffman code doesn't care about characters, it cares about symbols.  Generally, it is used to encode the alphabet \/ other single characters, but can very easily be generalized to encode strings of characters.  Basically, you would just take an existing implementation and allow symbols to be strings rather than characters.  A leaf node would then correspond to a list of strings.","Q_Score":3,"Tags":"java,python,huffman-code","A_Id":2888480,"CreationDate":"2010-05-22T14:36:00.000","Title":"Huffman coding two characters as 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},{"Question":"I need huffman code(best in python or in java), which could encode text not by one character (a = 10, b = 11), but by two (ab = 11, ag = 10). Is it possible and if yes, where could i find it, maybe it's somewhere in the internet and i just can'd find it?","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":1395,"Q_Id":2888468,"Users Score":0,"Answer":"There is probably some code somewhere. But this sounds like a parsing and tokenising question. One of the first questions I would be answering is how many unique pairs are you dealing with. Huffman encoding works best with small numbers of tokens. For example, the 101 characters on your keyboard. But if your two characters can be anything, you are now expanding the maximum number of characters massively.","Q_Score":3,"Tags":"java,python,huffman-code","A_Id":2888494,"CreationDate":"2010-05-22T14:36:00.000","Title":"Huffman coding two characters as 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},{"Question":"We have discussion in my job place about question (We use 1 of the php frameworks):\nWhy program with php frameworks big web application if it can be done better with ruby on rails, python or java? \nPlease say our opinion\nthanks","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":240,"Q_Id":2891017,"Users Score":3,"Answer":"If you only know PHP and you don't feel like learning Ruby\/Python\/Java. Seriously, if it can be done better with another tool, it should be done with another tool. Of course, this assumes the other tools are actually better. That part is arguable. Some people are so stuck up on their \"my way is the best way\" that they leave out the \"because it's the only way I know\" part.","Q_Score":1,"Tags":"java,php,python,ruby-on-rails,django","A_Id":2891024,"CreationDate":"2010-05-23T07:56:00.000","Title":"Why program with php frameworks if it can be done better with ruby on rails, python or 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":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Reasoning: I'm trying to convert a large library from Scheme to Python\nAre there any good strategies for doing this kind of conversion? Specifically cross-paradigm in this case since Python is more OO and Scheme is Functional.\nTotally subjective so I'm making it community wiki","AnswerCount":5,"Available Count":3,"Score":1.0,"is_accepted":false,"ViewCount":193,"Q_Id":2893313,"Users Score":7,"Answer":"I would treat the original language implementation almost like a requirements specification, and write up a design based on it (most importantly including detailed interface definitions, both for the external interfaces and for those between modules within the library). Then I would implement from that design. \nWhat I would most definitely NOT do is any kind of function-by-function translation.","Q_Score":5,"Tags":"python,scheme,code-translation","A_Id":2893338,"CreationDate":"2010-05-23T20:29:00.000","Title":"Advice on translating code from very unrelated languages (in this case Scheme 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},{"Question":"Reasoning: I'm trying to convert a large library from Scheme to Python\nAre there any good strategies for doing this kind of conversion? Specifically cross-paradigm in this case since Python is more OO and Scheme is Functional.\nTotally subjective so I'm making it community wiki","AnswerCount":5,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":193,"Q_Id":2893313,"Users Score":0,"Answer":"If you don't have time to do as the others have suggested and actually re-implement the functionality, there is no reason you CAN'T implement it in a strictly functional fashion.\nPython supports the key features necessary to do functional programming, and you might find that your time was better spent doing other things, especially if absolute optimization is not required. On the other hand, you might find bug-hunting to be quite hard.","Q_Score":5,"Tags":"python,scheme,code-translation","A_Id":2893602,"CreationDate":"2010-05-23T20:29:00.000","Title":"Advice on translating code from very unrelated languages (in this case Scheme 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},{"Question":"Reasoning: I'm trying to convert a large library from Scheme to Python\nAre there any good strategies for doing this kind of conversion? Specifically cross-paradigm in this case since Python is more OO and Scheme is Functional.\nTotally subjective so I'm making it community wiki","AnswerCount":5,"Available Count":3,"Score":0.0399786803,"is_accepted":false,"ViewCount":193,"Q_Id":2893313,"Users Score":1,"Answer":"I would setup a bunch of whiteboards and write out the algorithms from the Scheme code. Then I would implement the algorithms in Python. Then, as @PaulHankin suggests, use the Scheme code as a way to write test cases to test the Python code","Q_Score":5,"Tags":"python,scheme,code-translation","A_Id":2893563,"CreationDate":"2010-05-23T20:29:00.000","Title":"Advice on translating code from very unrelated languages (in this case Scheme 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},{"Question":"for large files or slow connections, copying files may take some time.\nusing pyinotify, i have been watching for the IN_CREATE event code. but this seems to occur at the start of a file transfer. i need to know when a file is completely copied - it aint much use if it's only half there.\nwhen a file transfer is finished and completed, what inotify event is fired?","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":4934,"Q_Id":2895187,"Users Score":0,"Answer":"Why don't you add a dummy file at the end of the transfer? You can use the IN_CLOSE or IN_CREATE event code on the dummy. The important thing is that the dummy as to be transfered as the last file in the sequence.\nI hope it'll help.","Q_Score":4,"Tags":"python,inotify,pyinotify","A_Id":22093028,"CreationDate":"2010-05-24T06:36:00.000","Title":"which inotify event signals the completion of a large file operation?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"Is there a way to add tempate string which contains error to mako`s error trace?","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":198,"Q_Id":2905948,"Users Score":0,"Answer":"I don't think you're likely to find such a thing.  Like all the other fast python template engines, Mako achieves its speed by compiling your template into python code and then executing it.  An exception will divert execution out of your template's code, so by the time one is raised, that template will have no way of displaying it (or doing anything else for that matter).\nAs an alternative, I suggest putting your template rendering code inside a try block, and rendering any caught exceptions with a separate template used specifically for that purpose.","Q_Score":2,"Tags":"python,mako","A_Id":2946762,"CreationDate":"2010-05-25T15:12:00.000","Title":"Better error reporting mako","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"Is there a way to add tempate string which contains error to mako`s error trace?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":198,"Q_Id":2905948,"Users Score":0,"Answer":"I was looking for another error I have and found this. I though it would be nice if you still ever need this, you can achieve it by setting mako.strict_undefined = True. I am using mako-0.6.2 so it may not been possible in the version back in 2010.","Q_Score":2,"Tags":"python,mako","A_Id":9271873,"CreationDate":"2010-05-25T15:12:00.000","Title":"Better error reporting mako","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I'm researching how to best extend a C++ application with scripting capability, and I am looking at either Python or JavaScript.  User-defined scripts will need the ability to access the application's data model.  \nHave any of you had experiences with embedding these scripting engines?  What are some potential pitfalls?","AnswerCount":5,"Available Count":2,"Score":0.0399786803,"is_accepted":false,"ViewCount":2816,"Q_Id":2907087,"Users Score":1,"Answer":"Have a look at angelscript\nsimple and easy to embed, c\/c++ like syntax. free and corss-platform. u can get start in a few hrs.","Q_Score":4,"Tags":"javascript,c++,python,scripting,embedding","A_Id":5080151,"CreationDate":"2010-05-25T17:47:00.000","Title":"Embedding a scripting engine 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":0,"Web Development":0},{"Question":"I'm researching how to best extend a C++ application with scripting capability, and I am looking at either Python or JavaScript.  User-defined scripts will need the ability to access the application's data model.  \nHave any of you had experiences with embedding these scripting engines?  What are some potential pitfalls?","AnswerCount":5,"Available Count":2,"Score":1.0,"is_accepted":false,"ViewCount":2816,"Q_Id":2907087,"Users Score":7,"Answer":"Lua is also a great candidate for embedding in programs. Its very self contained, and even the native cross-language call system isn't bad.\nFor JavaScript, your best bet right now is to look at V8 (from Google), which is easy enough to work with.","Q_Score":4,"Tags":"javascript,c++,python,scripting,embedding","A_Id":2907217,"CreationDate":"2010-05-25T17:47:00.000","Title":"Embedding a scripting engine 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":0,"Web Development":0},{"Question":"Is there a way to determine an MP3 file's encoded bit depth (ie 8, 16, 24, 32) in Python using the Mutagen library?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1355,"Q_Id":2909605,"Users Score":3,"Answer":"The transformations done by the MP3 encoding process drop completely the concept of \u201cbit depth\u201d. You can only know the bit depth of the source audio if such information was stored in a tag of the MP3 file. Otherwise, you can take the MP3 data and produce 8-bit, 16-bit or 24-bit audio.","Q_Score":1,"Tags":"python,mp3,lame,mutagen","A_Id":3113148,"CreationDate":"2010-05-26T01:15:00.000","Title":"Determine MP3 bit depth in Python via Mutagen","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I'm a c# programmer by trade and looking to move my wares over to Ubuntu as a business concern. I have some experience of Python and like it a lot. My question is, as a developer which would be the best language to use when targeting ubuntu Mono c# or python as a commercial concern.\nplease note that I am not interested in the technical aspects but strictly the commercials of where Ubuntu is heading, I see that there is a lot of work done within using Python and thinking that maybe with the whole Mono issue of who \"might\" purchase them.","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":309,"Q_Id":2912216,"Users Score":2,"Answer":"I cannot say much about the market for Ubuntu. And since business is your primary concern, the programming language is, as you say yourself, secondary. I would say that in any business, choose the language and tools that solves the business problem most effectively. When release comes do your end users really care?\nThat said, if you can do it with Mono\/C# I would encourage you to do so since you already have C# and .Net experience. But knowing a second language and development environment will only make you stronger.","Q_Score":2,"Tags":"c#,python,ubuntu,mono","A_Id":2912360,"CreationDate":"2010-05-26T10:52:00.000","Title":"Which Language to target 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":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"Is it possible to get the full path of the file on the user's computer being uploaded to my site?\nUsing os.path.abspath(fileitem.filename) simply gets me the address of where my script is executing from on my shared hosting server.\nFYI: fileitem = form['file']  and form = cgi.FieldStorage()","AnswerCount":2,"Available Count":1,"Score":0.4621171573,"is_accepted":false,"ViewCount":1903,"Q_Id":2918010,"Users Score":5,"Answer":"No, that information isn't sent by the user, so it's not available on your end","Q_Score":0,"Tags":"python,upload","A_Id":2918021,"CreationDate":"2010-05-27T01:53:00.000","Title":"Get Path of Uploaded File 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":1},{"Question":"My student group and I are trying to continue working on a project we worked on this semester over the summer to become a professional, deployable app. We originally did it in Adobe AIR but it seems now that the computers this program will be running on will be very slow, maybe 600mhz and 128-256mb ram so flash just isn't going to cut it. It is basically a health diagnosis application that we will be shipping out to impoverished countries.\nNow comes the real question. We are wondering what language to rebuild our application in. It has to have a good gui builder associated with it, like adobe flex\/air gui builder or visual studio's gui builder but the application should run on linux primarily, and if it can run on windows thats just a plus. We are all students too without really any outside help so whatever we decide to do this in there must be ample documentation available when we hit problems.\nSome things we have considered so far are using python and glade or c# and monodevelop, but again we really are not experts on any of this which is why I am asking for help as I would rather spend the time now choosing the right tools instead of wasting time down the line when we hit a roadblock.\nThanks in advance!","AnswerCount":4,"Available Count":1,"Score":0.049958375,"is_accepted":false,"ViewCount":1292,"Q_Id":2918445,"Users Score":1,"Answer":"To access really low end computers, and if you have no real graphics requirements, you could consider a text mode interface - curses\/ncurses for one.","Q_Score":3,"Tags":"python,user-interface,open-source,monodevelop,glade","A_Id":2918582,"CreationDate":"2010-05-27T04:23:00.000","Title":"Making GUI applications on Linux\/Windows. What languages\/tools 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":1,"Web Development":0},{"Question":"Can a python script on my server access the webcam and audio input of a user as easily and as well as a Flash plugin can?","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":2165,"Q_Id":2926220,"Users Score":0,"Answer":"Server-side web scripts have no access to the client other than through requests. You need to use JavaScript, Java, or Flash to access devices that the browser (and consequently user) allows them to.","Q_Score":2,"Tags":"python,streaming,webcam","A_Id":2926268,"CreationDate":"2010-05-28T01:56:00.000","Title":"Python access webcam and audio input","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"Can a python script on my server access the webcam and audio input of a user as easily and as well as a Flash plugin can?","AnswerCount":3,"Available Count":2,"Score":0.1325487884,"is_accepted":false,"ViewCount":2165,"Q_Id":2926220,"Users Score":2,"Answer":"No: the \"plugin\" you mention runs in the user's browser, your server-side script (Python or otherwise) runs on the server, a completely different proposition.  This relates to your other recent question about a server-side script accessing information on your desktop: your client machine tends to be very protected against possibly malicious server-side apps (never enough, but everybody keeps trying to make it more and more protected these days).","Q_Score":2,"Tags":"python,streaming,webcam","A_Id":2926270,"CreationDate":"2010-05-28T01:56:00.000","Title":"Python access webcam and audio input","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I am trying to create a directory with news articles collected from an rss feed, meaning that whenever there is a link to an article within the rss feed, I would like for it to be downloaded in a directory with the title of the specific article as the filename as as a text file.\nIs that something Python can help me do ?\nThank you for your help :-)","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":442,"Q_Id":2927543,"Users Score":1,"Answer":"Of course. BeautifulSoup, lxml, urllib2, urlgrabber.","Q_Score":0,"Tags":"python,rss","A_Id":2927551,"CreationDate":"2010-05-28T08:22:00.000","Title":"Downloading from links in an rss feed","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},{"Question":"I'm currently aware of the following Python JIT compilers: Psyco, PyPy and Unladen Swallow.\nBasically, I'd like to ask for your personal experiences on the strengths and weaknesses of these compilers - and if there are any others worth looking into.\nThanks in advance,\nAz","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":5073,"Q_Id":2933434,"Users Score":1,"Answer":"Some other tools you might investigate to speed up python are \n\nCython, which requires type specification of all variables in the relevant method and then statically compiles the method\nNumba, which requires LLVM but is JIT (methods must be decorated with argument types for compilation to occur).","Q_Score":11,"Tags":"python,compiler-construction,project","A_Id":12135232,"CreationDate":"2010-05-29T01:49:00.000","Title":"Strengths and weaknesses of JIT compilers 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},{"Question":"Is there a way to encrypt files (.zip, .doc, .exe, ... any type of file) with Python? \nI've looked at a bunch of crypto libraries for Python including pycrypto and ezpycrypto but as far as I see they only offer string encryption.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":972,"Q_Id":2938757,"Users Score":1,"Answer":"You can read the complete file into a string, encrypt it, write the encrypted string in a new file. If the file is too large, you can read in chunks.\nEvery time you .read from a file, you get a string (in Python < 3.0).","Q_Score":6,"Tags":"python,encryption","A_Id":2939776,"CreationDate":"2010-05-30T13:14:00.000","Title":"File encryption 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},{"Question":"This is a weird bug. I know it's something funky going on with my PATH variable, but no idea how to fix it.\nIf I have a script C:\\Test\\test.py and I execute it from within IDLE, it works fine. If I open up Command Prompt using Run>>cmd.exe and navigate manually it works fine. But if I use Windows 7's convenient Right Click on folder >> Command Prompt Here then type test.py it fails with import errors.\nI also cannot just type \"python\" to reach a python shell session if I use the latter method above.\nAny ideas?\nEdit: printing the python path for the command prompt that works yields the correct paths. Printing it on the non-working \"Command prompt here\" yields: Environment variable python not defined\".","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":2823,"Q_Id":2943071,"Users Score":0,"Answer":"You can check the currently present enviroment variables with the \"set\" command on the command line. For python to work you need at least PYTHONPATH pointing to your python libs and the path to python.exe should be included in your PATH variable.","Q_Score":0,"Tags":"python,windows-7,path","A_Id":2943171,"CreationDate":"2010-05-31T11:03:00.000","Title":"Python doesn't work properly when I execute a script after using Right Click >> Command Prompt Here","Data Science and Machine Learning":0,"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},{"Question":"This is a weird bug. I know it's something funky going on with my PATH variable, but no idea how to fix it.\nIf I have a script C:\\Test\\test.py and I execute it from within IDLE, it works fine. If I open up Command Prompt using Run>>cmd.exe and navigate manually it works fine. But if I use Windows 7's convenient Right Click on folder >> Command Prompt Here then type test.py it fails with import errors.\nI also cannot just type \"python\" to reach a python shell session if I use the latter method above.\nAny ideas?\nEdit: printing the python path for the command prompt that works yields the correct paths. Printing it on the non-working \"Command prompt here\" yields: Environment variable python not defined\".","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":2823,"Q_Id":2943071,"Users Score":1,"Answer":"I don't use Windows much, but maybe when you open Right Click -> Command Prompt, the PATH is different from navigate manually. First try to print your PATH (oh I have no ideal how to do this) and see if it different in 2 situation.","Q_Score":0,"Tags":"python,windows-7,path","A_Id":2943111,"CreationDate":"2010-05-31T11:03:00.000","Title":"Python doesn't work properly when I execute a script after using Right Click >> Command Prompt Here","Data Science and Machine Learning":0,"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},{"Question":"Starting a Perl script with alarm(3600) will make the script abort if it is still running after one hour (3600 seconds).\nAssume I want to set an upper bound on the running time of a Python script, what is the easiest way to achieve that?","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":362,"Q_Id":2948455,"Users Score":2,"Answer":"Just for your information: this is much self-descriptive to use multiplication when you set up  timers, for example alarm(24 * 60 * 60) for 24 hours, instead of alarm(86400) for the same period. Hope this will help keep your code clean and easy-maintainable :)","Q_Score":1,"Tags":"python","A_Id":2949014,"CreationDate":"2010-06-01T09:09:00.000","Title":"Equivalent of alarm(3600) 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},{"Question":"I am developing a small testing website using Django 1.2 in Aptana Studio build  2.0.4.1268158907. I have a Django project that I test by running the command \"runserver 8001\" on my project. This command runs the project on a small server that comes with Django. \nHowever the problem arises that every time I run this command Aptana opens two instances of the process \"python.exe\". Upon terminating the command only one of these instances is ended. The other process continues to run and use memory. My server is not online, and the process doesn't seem to do anything that I can find. This happens every time i run the runserver command on my project and therefore more and more python.exe instances will open up through my development period.\nAny help discovering either the purpose of this extra python.exe or a way to prevent it from opening would be much appreciated.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":509,"Q_Id":2952957,"Users Score":2,"Answer":"You should try adding --noreload to the runserver argument","Q_Score":2,"Tags":"python,django,aptana","A_Id":2952983,"CreationDate":"2010-06-01T20:08:00.000","Title":"Aptana Studio is opening but not ever closing a python.exe process","Data Science and Machine Learning":0,"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},{"Question":"Looking to use FastLZ in Python, or something similar. Tried Google and didn't find anything. Wondering if there is another algorithm with similar performance available in Python?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":565,"Q_Id":2954696,"Users Score":4,"Answer":"What about using ctypes to call directly into fastlz.so (or .dll as the case may be)?  It seems to have only 3 entry points, so wrapping them in ctypes should not be hard.  Yes, SWIG or a custom C API wrapper should be almost as trivial, but ctypes lets you start experimenting right now even if you don't have a compiler (as long as you can get a working DLL\/so of FastLZ for your platform)... hard to beat!-)","Q_Score":1,"Tags":"python,compression","A_Id":2954788,"CreationDate":"2010-06-02T02:50:00.000","Title":"Is there a python wrapper for a FastLZ implementation","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I have a python script and am wondering is there any way that I can ensure that the script run's continuously on a remote computer? Like for example, if the script crashes for whatever reason, is there a way to start it up automatically instead of having to remote desktop. Are there any other factors I have to be aware of? The script will be running on a window's machine.","AnswerCount":3,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1086,"Q_Id":2957588,"Users Score":1,"Answer":"Many ways - In the case of windows, even a simple looping batch file would probably do - just have it start the script in a loop (whenever it crashes it would return to the shell and be restarted).","Q_Score":1,"Tags":"python","A_Id":2957649,"CreationDate":"2010-06-02T12:21:00.000","Title":"running a python script on a remote 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":1,"System Administration and DevOps":1,"Web Development":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},{"Question":"I'm interested in reproducing a particular python script.\nI have a friend who was accessing an ldap database, without authentication. There was a particular field of interest, we'll call it nin (an integer) for reference, and this field wasn't accessible without proper authentication. However, my friend managed to access this field through some sort of binary search (rather than just looping through integers) on the data; he would check the first digit, check if it was greater or less than the starting value, he would augment that until it returned a true value indicating existence, adding digits and continuing checking until he found the exact value of the integer nin. \nAny ideas on how he went about this? I've access to a similarly set up database.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":231,"Q_Id":2968127,"Users Score":0,"Answer":"Your best bet would be to get authorization to access that field.  You are circumventing the security of the database otherwise.","Q_Score":0,"Tags":"python,ldap","A_Id":2968258,"CreationDate":"2010-06-03T17:00:00.000","Title":"Binary search of unaccesible data field in ldap 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},{"Question":"i wonder if there is a php equivalent to jython so you can use java classes with php?\nthanks","AnswerCount":5,"Available Count":2,"Score":0.0399786803,"is_accepted":false,"ViewCount":494,"Q_Id":2968381,"Users Score":1,"Answer":"Well: Java Server Pages (JSP) are \"equivalent\" to PHP, but using java classes. \nIt's \"equivalent\" in that it's HTML with embedded java code, but not at all compatible to PHP syntax.","Q_Score":4,"Tags":"java,php,python,jython","A_Id":2968495,"CreationDate":"2010-06-03T17:35:00.000","Title":"php equivalent to jython?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"i wonder if there is a php equivalent to jython so you can use java classes with php?\nthanks","AnswerCount":5,"Available Count":2,"Score":0.0399786803,"is_accepted":false,"ViewCount":494,"Q_Id":2968381,"Users Score":1,"Answer":"I just googled php jvm and got a bunch of hits. Never tried any of them.","Q_Score":4,"Tags":"java,php,python,jython","A_Id":2968418,"CreationDate":"2010-06-03T17:35:00.000","Title":"php equivalent to jython?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I've finally figured out how to create a Python egg and gotten it to work. Now... what do I do with it? How do I use it? How do I ensure that everything was correctly included? (Simple steps please... not just redirection to another site. I've googled, but it's confusing me, and I was hoping someone could explain it in a couple of simple bullet points or sentences.)\nEdit:\nI asked this question a couple of weeks ago, and I'm clarifying now in the hope of getting clearer answers... basically, I have an egg, I want to take it to another machine and be able to use it and import modules from it from my (other, unrelated) code. How do I do this?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":612,"Q_Id":2968809,"Users Score":0,"Answer":"What I ended up doing was:\n\nRan PYTHONPATH=fullPathOfMyEgg in command line\nWas then able to do import someModuleInMyEgg from my Python code\n\nI'm not sure if this is the most standard or accepted way to do it, but it worked. If anyone has any comments or other methods, please feel free to add...","Q_Score":6,"Tags":"python,distribution,egg","A_Id":3063352,"CreationDate":"2010-06-03T18:40:00.000","Title":"I created a Python egg; now what?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have Python script bgservice.py and I want it to run all the time, because it is part of the web service I build. How can I make it run continuously even after I logout SSH?","AnswerCount":12,"Available Count":2,"Score":1.0,"is_accepted":false,"ViewCount":252941,"Q_Id":2975624,"Users Score":37,"Answer":"If you've already started the process, and don't want to kill it and restart under nohup, you can send it to the background, then disown it.\nCtrl+Z  (suspend the process)\nbg   (restart the process in the background\ndisown %1 (assuming this is job #1, use jobs to determine)","Q_Score":145,"Tags":"python,service,cron","A_Id":2975852,"CreationDate":"2010-06-04T15:39:00.000","Title":"How to run a script in the background even after I logout 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},{"Question":"I have Python script bgservice.py and I want it to run all the time, because it is part of the web service I build. How can I make it run continuously even after I logout SSH?","AnswerCount":12,"Available Count":2,"Score":1.0,"is_accepted":false,"ViewCount":252941,"Q_Id":2975624,"Users Score":7,"Answer":"Alternate answer: tmux\n\nssh into the remote machine\ntype tmux into cmd\nstart the process you want inside the tmux e.g. python3 main.py\nleaving the tmux session by Ctrl+b then d\n\nIt is now safe to exit the remote machine. When you come back use tmux attach to re-enter tmux session.\nIf you want to start multiple sessions, name each session using Ctrl+b then $. then type your session name.\nto list all session use tmux list-sessions\nto attach a running session use tmux attach-session -t .","Q_Score":145,"Tags":"python,service,cron","A_Id":69754988,"CreationDate":"2010-06-04T15:39:00.000","Title":"How to run a script in the background even after I logout 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},{"Question":"if i want to script a mini-application (in the Terminal) in mac and windows, which one is preferred: ruby or python?\nor is there no major difference just a matter of taste?\ncause i know python definetely is a good scripting language.\nthanks","AnswerCount":6,"Available Count":6,"Score":0.1651404129,"is_accepted":false,"ViewCount":551,"Q_Id":2978801,"Users Score":5,"Answer":"Personally, I find the documentation for Python is much better than that for Ruby. The Docs for Ruby are full of cryptic examples that are terse, short, and just not very helpful.\nOn the other hand, docs for Python exist everywhere, but more importantly, in a useful, helpful form.","Q_Score":1,"Tags":"python,ruby","A_Id":2979717,"CreationDate":"2010-06-05T01:53:00.000","Title":"ruby or python more suitable for scripting in all OSes?","Data Science and Machine Learning":0,"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},{"Question":"if i want to script a mini-application (in the Terminal) in mac and windows, which one is preferred: ruby or python?\nor is there no major difference just a matter of taste?\ncause i know python definetely is a good scripting language.\nthanks","AnswerCount":6,"Available Count":6,"Score":0.0665680765,"is_accepted":false,"ViewCount":551,"Q_Id":2978801,"Users Score":2,"Answer":"I believe python and ruby (since at least OS X 10.4) came pre-installed on Mac, that is a convenience. \nThere are easy installers for Windows. On Linux of course your mileage may vary.\nAs much as i like python myself, don't think one is better than the other for your purpose.","Q_Score":1,"Tags":"python,ruby","A_Id":2978961,"CreationDate":"2010-06-05T01:53:00.000","Title":"ruby or python more suitable for scripting in all OSes?","Data Science and Machine Learning":0,"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},{"Question":"if i want to script a mini-application (in the Terminal) in mac and windows, which one is preferred: ruby or python?\nor is there no major difference just a matter of taste?\ncause i know python definetely is a good scripting language.\nthanks","AnswerCount":6,"Available Count":6,"Score":0.0665680765,"is_accepted":false,"ViewCount":551,"Q_Id":2978801,"Users Score":2,"Answer":"Python is perhaps a little more common, and arguably more mature, so on that basis alone, it may be worth choosing Python.\nThat said, both are available by default on Mac OS X, and neither are available on Windows by default, so in this case it really does not matter.","Q_Score":1,"Tags":"python,ruby","A_Id":2979070,"CreationDate":"2010-06-05T01:53:00.000","Title":"ruby or python more suitable for scripting in all OSes?","Data Science and Machine Learning":0,"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},{"Question":"if i want to script a mini-application (in the Terminal) in mac and windows, which one is preferred: ruby or python?\nor is there no major difference just a matter of taste?\ncause i know python definetely is a good scripting language.\nthanks","AnswerCount":6,"Available Count":6,"Score":0.0665680765,"is_accepted":false,"ViewCount":551,"Q_Id":2978801,"Users Score":2,"Answer":"I would suggest to go for Python over Ruby on Windows unless you are willing to port some gems as a few (no I cannot say what percentage) of the gems use unix\/mac specific stuff (example from ENV[OSTYPE] to wget to unix processes) that I have seen break on windows.","Q_Score":1,"Tags":"python,ruby","A_Id":2979691,"CreationDate":"2010-06-05T01:53:00.000","Title":"ruby or python more suitable for scripting in all OSes?","Data Science and Machine Learning":0,"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},{"Question":"if i want to script a mini-application (in the Terminal) in mac and windows, which one is preferred: ruby or python?\nor is there no major difference just a matter of taste?\ncause i know python definetely is a good scripting language.\nthanks","AnswerCount":6,"Available Count":6,"Score":0.0,"is_accepted":false,"ViewCount":551,"Q_Id":2978801,"Users Score":0,"Answer":"Both are excelent options, you won't go wrong no  matter which one you chose. You should check out the availability of libraries for the task at hand and also how helpful the community is. The Python community is humongous and seems friendlier to me. Rubists seem to have some anger management issues.","Q_Score":1,"Tags":"python,ruby","A_Id":3028950,"CreationDate":"2010-06-05T01:53:00.000","Title":"ruby or python more suitable for scripting in all OSes?","Data Science and Machine Learning":0,"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},{"Question":"if i want to script a mini-application (in the Terminal) in mac and windows, which one is preferred: ruby or python?\nor is there no major difference just a matter of taste?\ncause i know python definetely is a good scripting language.\nthanks","AnswerCount":6,"Available Count":6,"Score":1.2,"is_accepted":true,"ViewCount":551,"Q_Id":2978801,"Users Score":5,"Answer":"Matter of taste, really. They each have a pretty good set of libraries and are cross-platform, so it'll be a matter of which one you prefer to code in.","Q_Score":1,"Tags":"python,ruby","A_Id":2978809,"CreationDate":"2010-06-05T01:53:00.000","Title":"ruby or python more suitable for scripting in all OSes?","Data Science and Machine Learning":0,"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},{"Question":"Are there any real differences between them?\nI want to program in java and python. And of corse be a normal user: internet, etc\nWhich one will give me less headaches\/more satisfaction ? \nAnd which is better for a server machine ?\nThank you","AnswerCount":6,"Available Count":5,"Score":0.1325487884,"is_accepted":false,"ViewCount":20812,"Q_Id":2985426,"Users Score":4,"Answer":"Both use Debian packages and Ubuntu is based on Debian but is more user friendly. Everything yo can do on one you can do on the other. I'd recommend Ubuntu if your new to linux on a Desktop. Though when it comes to servers I'd recommend Debian as it has less stuff \"taken out\" basically.","Q_Score":10,"Tags":"java,python,ubuntu,debian,operating-system","A_Id":2985450,"CreationDate":"2010-06-06T18:44:00.000","Title":"Which os is better for development : Debian or 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},{"Question":"Are there any real differences between them?\nI want to program in java and python. And of corse be a normal user: internet, etc\nWhich one will give me less headaches\/more satisfaction ? \nAnd which is better for a server machine ?\nThank you","AnswerCount":6,"Available Count":5,"Score":0.0333209931,"is_accepted":false,"ViewCount":20812,"Q_Id":2985426,"Users Score":1,"Answer":"In Ubuntu it is a bit easier to install packages for Java development, but it doesn't really matter that much. Remember that Ubuntu is based on Debian, so it works the same. Ubuntu just adds more user-friendly GUI's.","Q_Score":10,"Tags":"java,python,ubuntu,debian,operating-system","A_Id":2985456,"CreationDate":"2010-06-06T18:44:00.000","Title":"Which os is better for development : Debian or 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},{"Question":"Are there any real differences between them?\nI want to program in java and python. And of corse be a normal user: internet, etc\nWhich one will give me less headaches\/more satisfaction ? \nAnd which is better for a server machine ?\nThank you","AnswerCount":6,"Available Count":5,"Score":0.0665680765,"is_accepted":false,"ViewCount":20812,"Q_Id":2985426,"Users Score":2,"Answer":"Ubuntu is the more user-friendly of the two (I think Ubuntu is actually one of the most newbie-friendly Linux distros), so if you are new to Linux, Ubuntu is the way to go.  Otherwise, the packages are mostly the same except for branding, so it's pretty much your choice.","Q_Score":10,"Tags":"java,python,ubuntu,debian,operating-system","A_Id":2985463,"CreationDate":"2010-06-06T18:44:00.000","Title":"Which os is better for development : Debian or 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},{"Question":"Are there any real differences between them?\nI want to program in java and python. And of corse be a normal user: internet, etc\nWhich one will give me less headaches\/more satisfaction ? \nAnd which is better for a server machine ?\nThank you","AnswerCount":6,"Available Count":5,"Score":0.0333209931,"is_accepted":false,"ViewCount":20812,"Q_Id":2985426,"Users Score":1,"Answer":"Neither is better. They both support the same tools and libraries. They are both linux. Anything and everything you can do on one you can do on the other.","Q_Score":10,"Tags":"java,python,ubuntu,debian,operating-system","A_Id":2985472,"CreationDate":"2010-06-06T18:44:00.000","Title":"Which os is better for development : Debian or 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},{"Question":"Are there any real differences between them?\nI want to program in java and python. And of corse be a normal user: internet, etc\nWhich one will give me less headaches\/more satisfaction ? \nAnd which is better for a server machine ?\nThank you","AnswerCount":6,"Available Count":5,"Score":0.0665680765,"is_accepted":false,"ViewCount":20812,"Q_Id":2985426,"Users Score":2,"Answer":"java and python would most likely run the same on both.\nWith Ubuntu you get additional space of support and active community, and perhaps larger user base. \nSo if and when you face a particular problem, chances are with Ubuntu, the solution will appear faster. \n(although, whatever works on this should work on the other as well in theory)","Q_Score":10,"Tags":"java,python,ubuntu,debian,operating-system","A_Id":2985442,"CreationDate":"2010-06-06T18:44:00.000","Title":"Which os is better for development : Debian or 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},{"Question":"I'm newish to the python ecosystem, and have a question about module editing. \nI use a bunch of third-party modules, distributed on PyPi.  Coming from a C and Java background, I love the ease of easy_install .  This is a new, wonderful world, but the model breaks down when I want to edit the newly installed module for two reasons:\n\nThe egg files may be stored in a folder or archive somewhere crazy on the file system.\nUsing an egg seems to preclude using the version control system of the originating project, just as using a debian package precludes development from an originating VCS repository.\n\nWhat is the best practice for installing modules from an arbitrary VCS repository?  I want to be able to continue to import foomodule in other scripts.  And if I modify the module's source code, will I need to perform any additional commands?","AnswerCount":4,"Available Count":1,"Score":0.049958375,"is_accepted":false,"ViewCount":1655,"Q_Id":2986357,"Users Score":1,"Answer":"Packages installed by easy_install tend to come from snapshots of the developer's version control, generally made when the developer releases an official version.  You're therefore going to have to choose between convenient automatic downloads via easy_install and up-to-the-minute code updates via version control.  If you pick the latter, you can build and install most packages seen in the python package index directly from a version control checkout by running python setup.py install.\nIf you don't like the default installation directory, you can install to a custom location instead, and export a PYTHONPATH environment variable whose value is the path of the installed package's parent folder.","Q_Score":5,"Tags":"python,version-control,module,easy-install","A_Id":2986445,"CreationDate":"2010-06-06T23:32:00.000","Title":"Best practice for installing python modules from an arbitrary VCS 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":1,"Web Development":0},{"Question":"How do I get the ports that a process is listening on using python? The pid of the process is known.","AnswerCount":5,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":21117,"Q_Id":2987168,"Users Score":0,"Answer":"One thing that wasn't mentioned. Most port applications in python take a command line argument. You can parse \/proc\/pid\/cmdline and parse out the port number. This avoids the large overhead of using ss or netstat on servers with a ton of connections.","Q_Score":23,"Tags":"python,linux,sockets,port","A_Id":42511544,"CreationDate":"2010-06-07T05:04:00.000","Title":"How to obtain ports that a process in listening 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":1,"Web Development":0},{"Question":"How do I get the ports that a process is listening on using python? The pid of the process is known.","AnswerCount":5,"Available Count":3,"Score":0.0399786803,"is_accepted":false,"ViewCount":21117,"Q_Id":2987168,"Users Score":1,"Answer":"You can use netstat -lnp, last column will contain pid and process name. In Python you can parse output of this command.","Q_Score":23,"Tags":"python,linux,sockets,port","A_Id":2987231,"CreationDate":"2010-06-07T05:04:00.000","Title":"How to obtain ports that a process in listening 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":1,"Web Development":0},{"Question":"How do I get the ports that a process is listening on using python? The pid of the process is known.","AnswerCount":5,"Available Count":3,"Score":0.1586485043,"is_accepted":false,"ViewCount":21117,"Q_Id":2987168,"Users Score":4,"Answer":"If you don't want to parse the output of a program like netstat or lsof, you can grovel through the \/proc filesystem and try to find documentation on the files within.  \/proc\/\/net\/tcp might be especially interesting to you.  Of course, the format of those files might change between kernel releases, so parsing command output is generally considered more reliable.","Q_Score":23,"Tags":"python,linux,sockets,port","A_Id":2987379,"CreationDate":"2010-06-07T05:04:00.000","Title":"How to obtain ports that a process in listening 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":1,"Web Development":0},{"Question":"What are the options for achieving parallelism in Python?  I want to perform a bunch of CPU bound calculations over some very large rasters, and would like to parallelise them.  Coming from a C background, I am familiar with three approaches to parallelism:\n\nMessage passing processes, possibly distributed across a cluster, e.g. MPI.\nExplicit shared memory parallelism, either using pthreads or fork(), pipe(), et. al\nImplicit shared memory parallelism, using OpenMP.\n\nDeciding on an approach to use is an exercise in trade-offs.\nIn Python, what approaches are available and what are their characteristics?  Is there a clusterable MPI clone?  What are the preferred ways of achieving shared memory parallelism?  I have heard reference to problems with the GIL, as well as references to tasklets.  \nIn short, what do I need to know about the different parallelization strategies in Python before choosing between them?","AnswerCount":5,"Available Count":1,"Score":0.0798297691,"is_accepted":false,"ViewCount":14722,"Q_Id":2987980,"Users Score":2,"Answer":"Depending on how much data you need to process and how many CPUs\/machines you intend to use, it is in some cases better to write a part of it in C (or Java\/C# if you want to use jython\/IronPython)\nThe speedup you can get from that might do more for your performance than running things in parallel on 8 CPUs.","Q_Score":26,"Tags":"python,multithreading,parallel-processing,message-passing","A_Id":2988386,"CreationDate":"2010-06-07T08:22:00.000","Title":"Parallelism 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},{"Question":"I'm writing python package\/module and would like the logging messages mention what module\/class\/function they come from. I.e. if I run this code:\n\nimport mymodule.utils.worker as worker\n\nw = worker.Worker()\nw.run()\n\nI'd like to logging messages looks like this:\n\n2010-06-07 15:15:29 INFO mymodule.utils.worker.Worker.run : Hello from worker\n\nHow can I accomplish this?\nThanks.","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":3330,"Q_Id":2989398,"Users Score":2,"Answer":"Here is my solution that came out of this discussion. Thanks to everyone for suggestions.\nUsage:\n\n>>> import logging\n>>> logging.basicConfig(level=logging.DEBUG)\n>>> from hierlogger import hierlogger as logger\n>>> def main():\n...     logger().debug(\"test\")\n...\n>>> main()\nDEBUG:main:test\n\nBy default it will name logger as ... You can also control the depth by providing parameter:\n3 - module.class.method default\n2 - module.class\n1 - module only\nLogger instances are also cached to prevent calculating logger name on each call.\nI hope someone will enjoy it.\nThe code:\n\nimport logging\nimport inspect\n\nclass NullHandler(logging.Handler):\n        def emit(self, record): pass\n\ndef hierlogger(level=3):\n    callerFrame = inspect.stack()[1]\n    caller = callerFrame[0]\n    lname = '__heirlogger'+str(level)+'__'\n    if lname not in caller.f_locals:\n        loggerName = str()\n        if level >= 1:\n            try:\n                loggerName += inspect.getmodule(inspect.stack()[1][0]).__name__\n            except: pass\n        if 'self' in caller.f_locals and (level >= 2):\n            loggerName += ('.' if len(loggerName) > 0 else '') + \n                          caller.f_locals['self'].__class__.__name__\n        if callerFrame[3] != '' and level >= 3:\n            loggerName += ('.' if len(loggerName) > 0 else '') + callerFrame[3]\n        caller.f_locals[lname] = logging.getLogger(loggerName)\n        caller.f_locals[lname].addHandler(NullHandler())\n    return caller.f_locals[lname]","Q_Score":6,"Tags":"python,logging","A_Id":3060995,"CreationDate":"2010-06-07T12:24:00.000","Title":"logger chain 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},{"Question":"I know it is a kind of broad question but any answer are appreciated.","AnswerCount":10,"Available Count":9,"Score":0.0399786803,"is_accepted":false,"ViewCount":29161,"Q_Id":2991554,"Users Score":2,"Answer":"Java and C# are statically typed languages, while Python is a dynamically typed language. That's a huge difference.\nThe syntax of Java and C# is similar (but I would not call it \"almost identical\" as Justin Niessner says).","Q_Score":6,"Tags":"c#,java,python","A_Id":2991586,"CreationDate":"2010-06-07T17:07:00.000","Title":"How Similar are Java, C#, 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},{"Question":"I know it is a kind of broad question but any answer are appreciated.","AnswerCount":10,"Available Count":9,"Score":1.0,"is_accepted":false,"ViewCount":29161,"Q_Id":2991554,"Users Score":7,"Answer":"C# and Java have almost identical syntax and very similar libraries. There are differences that you have to be aware of (Type Erasure in Java, for example).\nPython is a completely different animal. It is a dynamic language (where the other two aren't). Python winds up being closer in style to something like Ruby.","Q_Score":6,"Tags":"c#,java,python","A_Id":2991562,"CreationDate":"2010-06-07T17:07:00.000","Title":"How Similar are Java, C#, 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},{"Question":"I know it is a kind of broad question but any answer are appreciated.","AnswerCount":10,"Available Count":9,"Score":1.0,"is_accepted":false,"ViewCount":29161,"Q_Id":2991554,"Users Score":11,"Answer":"Python is a dynamic language where Java and C# are really not.  It is totally different than the other two.  There are ways to accomplishing things in Python that do not translate well to the others and vice versa.\nJava and C# look the same, but they have differences between the two under the sheets.  Being an expert in one, does not make you an expert in the other by any stretch of the imagination.  The syntax is similar and libraries are too, so it would be easier to get up to speed in one or the other, but there are subtleties that can trip you up.","Q_Score":6,"Tags":"c#,java,python","A_Id":2991567,"CreationDate":"2010-06-07T17:07:00.000","Title":"How Similar are Java, C#, 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},{"Question":"I know it is a kind of broad question but any answer are appreciated.","AnswerCount":10,"Available Count":9,"Score":-0.0399786803,"is_accepted":false,"ViewCount":29161,"Q_Id":2991554,"Users Score":-2,"Answer":"They are not similar at ALL. They all take widely different approaches to OOP, syntax, and static\/dynamic typing.","Q_Score":6,"Tags":"c#,java,python","A_Id":2991564,"CreationDate":"2010-06-07T17:07:00.000","Title":"How Similar are Java, C#, 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},{"Question":"I know it is a kind of broad question but any answer are appreciated.","AnswerCount":10,"Available Count":9,"Score":0.0199973338,"is_accepted":false,"ViewCount":29161,"Q_Id":2991554,"Users Score":1,"Answer":"Java and c# are pretty similar in terms of syntax and are mostly strongly typed (C# is getting more dynamic with every version), Python is a dynamic language","Q_Score":6,"Tags":"c#,java,python","A_Id":2991569,"CreationDate":"2010-06-07T17:07:00.000","Title":"How Similar are Java, C#, 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},{"Question":"I know it is a kind of broad question but any answer are appreciated.","AnswerCount":10,"Available Count":9,"Score":0.0199973338,"is_accepted":false,"ViewCount":29161,"Q_Id":2991554,"Users Score":1,"Answer":"Java and C# are very similar and are syntactically similar to C\/C++. They also use braces to mark code blocks.\nPython is completely different. Although imperative like Java and C#, Python uses indentation to define blocks of code.\nJava and C# are also compiled languages, whereas Python is interpreted and dynamic.\nPython, Ruby, and Groovy are somewhat similar languages.","Q_Score":6,"Tags":"c#,java,python","A_Id":2991581,"CreationDate":"2010-06-07T17:07:00.000","Title":"How Similar are Java, C#, 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},{"Question":"I know it is a kind of broad question but any answer are appreciated.","AnswerCount":10,"Available Count":9,"Score":0.0199973338,"is_accepted":false,"ViewCount":29161,"Q_Id":2991554,"Users Score":1,"Answer":"C# and Java are the two languages you listed that are most similar.  Python has a very different syntax, and uses a slightly different programming model.  Both C# and Java are Object Oriented languages at their core, with increasing nods to Dynamic Typing.  Python began as a Dynamically Typed scripting language and has been picking up more and more Object Oriented features over the years.  \nThe C# class library (.NET Framework) is theoretically multi-platform, though it's heavily weighted towards the Windows platform, and any other OS compatibility is largely an afterthought.  The .NET framework currently has two \"official\" frameworks for building windowed applications (Windows Forms, and WPF) and  two \"official\" frameworks for building web applications (ASP.NET, and ASP.NET MVC).  Windows Forms is similar to Java Swing, but the other four frameworks are very different from much of what is found in the Java or Python worlds.  There are many language features in C# that are different or lacking in Java, such as Delegates.\nThe Java class library is pretty solidly multi-platform.  It's officially supported desktop and web frameworks (Swing and J2EE) are generally regarded as slow, and difficult to use.  However, there is a very lively open source community which has built several competing frameworks that are very powerful and versatile.  Java as a language is very slow to introduce new language features, though it is runtime-compatible with several other languages that run on the Java platform (Groovy, Jython, Scala, etc..).  Java is the language which has has the most run-time optimizations put into it, so an application written in Java is almost certainly going to be faster than an application written in C# or Python. \nPython is an interpreted language (in general), and is pretty solidly multi-platform.  Python has no \"official\" desktop or web frameworks, though desktop applications can be written using GTK or Qt support, both of which are multi-platform.  Django has become a de-facto standard for Python web development, and is regarded as a very powerful and expressive framework.  Python is at this point fully Object Oriented, and is notable for it's powerful tools for working with collections\/arrays\/lists.  As an interpreted language, Python will be significantly slower than either C# or Java.","Q_Score":6,"Tags":"c#,java,python","A_Id":2992318,"CreationDate":"2010-06-07T17:07:00.000","Title":"How Similar are Java, C#, 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},{"Question":"I know it is a kind of broad question but any answer are appreciated.","AnswerCount":10,"Available Count":9,"Score":0.0199973338,"is_accepted":false,"ViewCount":29161,"Q_Id":2991554,"Users Score":1,"Answer":"C# and Java are easy to move between, although I don't know many people who are experts in both.  C#'s syntax is based off of Java, so they read very, very similarly.  They both run cross-platform; Java on the JVM, C# on .NET or Mono.  They're both OOP, and widely used for web development.  I'd use whichever the team was more familiar with.\nPython's off to the side there.  It's also used frequently as a scripting language.  It can use classes and object orientation, but isn't forced to.  It's not as well supported for web work.  I'd use this for a different set of tasks than C#\/Java.","Q_Score":6,"Tags":"c#,java,python","A_Id":2991604,"CreationDate":"2010-06-07T17:07:00.000","Title":"How Similar are Java, C#, 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},{"Question":"I know it is a kind of broad question but any answer are appreciated.","AnswerCount":10,"Available Count":9,"Score":-0.0199973338,"is_accepted":false,"ViewCount":29161,"Q_Id":2991554,"Users Score":-1,"Answer":"Python was made to be simpler, more readable, flexible and object oriented than what existed before - i.e. Java, Perl etc.  It's actually closer to Java than it is to Ruby.  Ruby is more like Smalltalk.  Think of Python as Java without the stuff that mostly gets in your way, makes things awkward to do, slows you down or clutters the essence of your logic.  So no semi-colons, curly braces for scoping.  No static variable declaration or variables at all really they're identifiers that point to objects instead.  \nThere's also a standard style guide for Python unlike other languages.  Indentation is used to indicate scope and inconsistent indentation is a syntax error.\nIt also includes some often used things built into the language: lists, dictionaries, sets, generators etc.\nJava is nice for those familiar with C \/ C++ syntax and are set in their ways, like that syntax and find it readable.  Ruby and Python are for those that preferred Pascal or Smalltalk to C, like Lisp etc.","Q_Score":6,"Tags":"c#,java,python","A_Id":2991639,"CreationDate":"2010-06-07T17:07:00.000","Title":"How Similar are Java, C#, 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},{"Question":"I am passing some weakrefs from Python into C++ class, but C++ destructors are actively trying to access the ref when the real object is already dead, obviously it crashes...\nIs there any Python C\/API approach to find out if Python reference is still alive or any other known workaround for this ?\nThanks","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1004,"Q_Id":2993393,"Users Score":3,"Answer":"If you call PyWeakref_GetObject on the weak reference it should return either Py_None or NULL, I forget which. But you should check if it's returning one of those and that will tell you that the referenced object is no longer alive.","Q_Score":7,"Tags":"c++,python,reference,weak","A_Id":2993422,"CreationDate":"2010-06-07T21:43:00.000","Title":"Python - how to check if weak reference is still available","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I'm just starting out learning python with GEdit plus various plugins as my IDE.\nVisual Studio\/F# has a feature  which permits the highlighting on a piece of text in the code window which then, on a keypress, gets executed in the F# console. \nIs there a similar facility\/plugin which would enable this sort of behaviour for GEdit\/Python? I do have various execution type plugins (Run In Python,Better Python Console) but they don't give me this particular behaviour - or at least I'm not sure how to configure them to give me this. I find it useful because in learning python, I have some test code I want to execute particular individual lines or small segments of code (rather then a complete file) to try and understand what they are doing (and the copy\/paste can get a bit tiresome)\n... or perhaps there is a better way to do code exploration?\nMany thx\nSimon","AnswerCount":8,"Available Count":3,"Score":0.024994793,"is_accepted":false,"ViewCount":23890,"Q_Id":2995041,"Users Score":1,"Answer":"What I do is keep a file called python_temp.py.  I have a shortcut to it in my dock.  I use it as a scratch pad.  Whenever I want to quickly run some code, I copy the code, click the shortcut in the doc, paste in the text and hit f5 to run.  Quick, easy, simple, flexible.","Q_Score":7,"Tags":"python,plugins,gedit","A_Id":2995380,"CreationDate":"2010-06-08T05:51:00.000","Title":"GEdit\/Python execution plugin?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm just starting out learning python with GEdit plus various plugins as my IDE.\nVisual Studio\/F# has a feature  which permits the highlighting on a piece of text in the code window which then, on a keypress, gets executed in the F# console. \nIs there a similar facility\/plugin which would enable this sort of behaviour for GEdit\/Python? I do have various execution type plugins (Run In Python,Better Python Console) but they don't give me this particular behaviour - or at least I'm not sure how to configure them to give me this. I find it useful because in learning python, I have some test code I want to execute particular individual lines or small segments of code (rather then a complete file) to try and understand what they are doing (and the copy\/paste can get a bit tiresome)\n... or perhaps there is a better way to do code exploration?\nMany thx\nSimon","AnswerCount":8,"Available Count":3,"Score":0.024994793,"is_accepted":false,"ViewCount":23890,"Q_Id":2995041,"Users Score":1,"Answer":"The closest to a decent IDE...\nInstall gedit-developer-plugins (through synaptic || apt-get) and don't forget to enable (what you need) from gEdit's plugins (Edit->Preferences [tab] plugins)  and happy coding","Q_Score":7,"Tags":"python,plugins,gedit","A_Id":18914523,"CreationDate":"2010-06-08T05:51:00.000","Title":"GEdit\/Python execution plugin?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm just starting out learning python with GEdit plus various plugins as my IDE.\nVisual Studio\/F# has a feature  which permits the highlighting on a piece of text in the code window which then, on a keypress, gets executed in the F# console. \nIs there a similar facility\/plugin which would enable this sort of behaviour for GEdit\/Python? I do have various execution type plugins (Run In Python,Better Python Console) but they don't give me this particular behaviour - or at least I'm not sure how to configure them to give me this. I find it useful because in learning python, I have some test code I want to execute particular individual lines or small segments of code (rather then a complete file) to try and understand what they are doing (and the copy\/paste can get a bit tiresome)\n... or perhaps there is a better way to do code exploration?\nMany thx\nSimon","AnswerCount":8,"Available Count":3,"Score":0.024994793,"is_accepted":false,"ViewCount":23890,"Q_Id":2995041,"Users Score":1,"Answer":"I installed iPython console in gedit and do most of my simple scripting in it, but gedit is a very simple editor, so it'll not have some advance feature like an IDE\nBut if you want code exploring, or auto completion, I recommend a real IDE like Eclipse.\nIf you just want a editor, KomodoEdit is fine.","Q_Score":7,"Tags":"python,plugins,gedit","A_Id":2995332,"CreationDate":"2010-06-08T05:51:00.000","Title":"GEdit\/Python execution plugin?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Think the title summarizes the question :-)","AnswerCount":2,"Available Count":2,"Score":1.0,"is_accepted":false,"ViewCount":32140,"Q_Id":2996110,"Users Score":31,"Answer":"Any Python module may be executed as a script. The only significant difference is that when imported as a module the filename is used as the basis for the module name whereas if you execute it as a script the module is named __main__.\nThis distinction makes it possible to have different behaviour when imported by enclosing script specific code in a block guarded by if __name__==\"__main__\". This has been known to cause confusion when a user attempts to import the main module under its own name rather than importing __main__.\nA minor difference between scripts and modules is that when you import a module the system will attempt to use an existing .pyc file (provided it exists and is up to date and for that version of Python) and if it has to compile from a .py file it will attempt to save a .pyc file. When you run a .py file as script it does not attempt to load a previously compiled module, nor will it attempt to save the compiled code. For this reason it may be worth keeping scripts small to minimise startup time.","Q_Score":51,"Tags":"python,scripting,module","A_Id":2997044,"CreationDate":"2010-06-08T09:27:00.000","Title":"What is the difference between a module and a script 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},{"Question":"Think the title summarizes the question :-)","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":32140,"Q_Id":2996110,"Users Score":62,"Answer":"A script is generally a directly executable piece of code, run by itself.  A module is generally a library, imported by other pieces of code.\nNote that there's no internal distinction -- both are executable and importable, although library code often won't do anything (or will just run its unit tests) when executed directly and importing code designed to be a script will cause it to execute, hence the common if __name__ == \"__main__\" test.","Q_Score":51,"Tags":"python,scripting,module","A_Id":2996170,"CreationDate":"2010-06-08T09:27:00.000","Title":"What is the difference between a module and a script 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},{"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},{"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},{"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},{"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},{"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},{"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},{"Question":"I cannot understand it. Very simple, and obvious functionality:\nYou have a code in any programming language, You run it. In this code You generate variables, than You save them (the values, names, namely everything) to a file, with one command. When it's saved You may open such a file in Your code also with simple command. \nIt works perfect in matlab (save Workspace , load Workspace ) - in python there's some weird \"pickle\" protocol, which produces errors all the time, while all I want to do is save variable, and load it again in another session (?????) \nf.e. You cannot save class with variables (in Matlab there's no problem)\nYou cannot load arrays in cPickle (but YOu can save them (?????) )\nWhy don't make it easier?\nIs there a way to save the current variables with values, and then load them?","AnswerCount":5,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":8265,"Q_Id":3016116,"Users Score":0,"Answer":"I take issue with the statement that the saving of variables in Matlab is an environment function. the \"save\" statement in matlab is a function and part of the matlab language not just a command.  It is a very useful function as you don't have to worry about the trivial minutia of file i\/o and it handles all sorts of variables from scalar, matrix, objects, structures.","Q_Score":3,"Tags":"python,serialization","A_Id":27096538,"CreationDate":"2010-06-10T15:58:00.000","Title":"Save Workspace - save all variables to a file. Python doesn't have it)","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},{"Question":"I cannot understand it. Very simple, and obvious functionality:\nYou have a code in any programming language, You run it. In this code You generate variables, than You save them (the values, names, namely everything) to a file, with one command. When it's saved You may open such a file in Your code also with simple command. \nIt works perfect in matlab (save Workspace , load Workspace ) - in python there's some weird \"pickle\" protocol, which produces errors all the time, while all I want to do is save variable, and load it again in another session (?????) \nf.e. You cannot save class with variables (in Matlab there's no problem)\nYou cannot load arrays in cPickle (but YOu can save them (?????) )\nWhy don't make it easier?\nIs there a way to save the current variables with values, and then load them?","AnswerCount":5,"Available Count":2,"Score":0.0798297691,"is_accepted":false,"ViewCount":8265,"Q_Id":3016116,"Users Score":2,"Answer":"What you are describing is Matlab environment feature not a programming language. \nWhat you need is a way to store serialized state of some object which could be easily done in almost any programming language. In python world pickle is the easiest way to achieve it and if you could provide more details about the errors it produces for you people would probably be able to give you more details on that.\nIn general for object oriented languages (including python) it is always a good approach to incapsulate a your state into single object that could be serialized and de-serialized and then store\/load an instance of such class. Pickling and unpickling of such objects works perfectly for many developers so this must be something specific to your implementation.","Q_Score":3,"Tags":"python,serialization","A_Id":3016188,"CreationDate":"2010-06-10T15:58:00.000","Title":"Save Workspace - save all variables to a file. Python doesn't have it)","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},{"Question":"I'm trying to solve the following problem:  Say I have a Python script (let's call it Test.py) which uses a C++ extension module (made via SWIG, let's call the module \"Example\").  I have Test.py, Example.py, and _Example.so in the same directory.\nNow, in the middle of running Test.py, I want to make a change to my Example module, recompile (which will overwrite the existing .so), and use a command to gracefully stop Test.py which is still using the old version of the module (Test.py has some cleaning up to do, which uses some stuff which is defined in the Example module), then start it up again, using the new version of the module.  Gracefully stopping Test.py and THEN recompiling the module is not an option in my case.\nThe problem is, as soon as _Example.so is overwritten and Test.py tries to access anything defined in the Example module (while gracefully stopping), I get a segmentation fault.  One solution to this is to explicitly name the Example module by appending a version number at the end, but I was wondering if there was a better solution (I don't want to be importing Example_1_0)?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":133,"Q_Id":3018122,"Users Score":2,"Answer":"You could, on starting Test.py, copy the Example.* files to a temp folder unique for that instance (take a look at tempfile.mkdtemp, it can create safe, unique folders), add that to sys.path and then import Example; and on Test.py shutdown remove that folder (shutils.rmtree) at the cleanup stage.\nThis would mean that each instance of Test.py would run on its own copy of the Example module, not interfering with the others, and would update to the new one only upon relaunch.\nYou would need the Example.* files not to be on the same folder as Test.py for this, otherwise the import would get those first. Just storing them on a subfolder should be fine.","Q_Score":3,"Tags":"python,swig,segmentation-fault","A_Id":3018504,"CreationDate":"2010-06-10T20:14:00.000","Title":"Problems replacing a Python extension module while Python script is executing","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"im trying to build android from source on ubuntu 10.04. when i enter the repo command:\nrepo init -u git:\/\/android.git.kernel.org\/platform\/manifest.git -b eclair\nit get this error back\nexec: 23: python: not found\nany ideas.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":3027,"Q_Id":3019742,"Users Score":0,"Answer":"You should check your python instalation as the repo command is an python script made by Google to interact with git repositories.\nIf you do have python installed it is possible that it is not in your shell path or you are using a diferent version than required by repo, ie. you have version 3 while repo requires version 2.5 (just an example, I'm not sure what version repo uses).","Q_Score":2,"Tags":"python,android","A_Id":3019817,"CreationDate":"2010-06-11T01:59:00.000","Title":"exec: 23: python: not found 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":1,"Web Development":0},{"Question":"I need to optimize the RAM usage of my application.\nPLEASE spare me the lectures telling me I shouldn't care about memory when coding Python. I have a memory problem because I use very large default-dictionaries (yes, I also want to be fast). My current memory consumption is 350MB and growing. I already cannot use shared hosting and if my Apache opens more processes the memory doubles and triples... and it is expensive.\nI have done extensive profiling and I know exactly where my problems are.\nI have several large (>100K entries) dictionaries with Unicode keys. A dictionary starts at 140 bytes and grows fast, but the bigger problem is the keys. Python optimizes strings in memory (or so I've read) so that lookups can be ID comparisons ('interning' them). Not sure this is also true for unicode strings (I was not able to 'intern' them).\nThe objects stored in the dictionary are lists of tuples (an_object, an int, an int).\n\nmy_big_dict[some_unicode_string].append((my_object, an_int, another_int))\n\nI already found that it is worth while to split to several dictionaries because the tuples take a lot of space...\nI found that I could save RAM by hashing the strings before using them as keys!\nBut then, sadly, I ran into birthday collisions on my 32 bit system. (side question: is there a 64-bit key dictionary I can use on a 32-bit system?)\nPython 2.6.5 on both Linux(production) and Windows. \nAny tips on optimizing memory usage of dictionaries \/ lists \/ tuples?\nI even thought of using C - I don't care if this very small piece of code is ugly. It is just a singular location.\nThanks in advance!","AnswerCount":7,"Available Count":2,"Score":0.1137907297,"is_accepted":false,"ViewCount":12150,"Q_Id":3021264,"Users Score":4,"Answer":"For a web application you should use a database, the way you're doing it you are creating one copy of your dict for each apache process, which is extremely wasteful. If you have enough memory on the server the database table will be cached in memory (if you don't have enough for one copy of your table, put more RAM into the server). Just remember to put correct indices on your database table or you will get bad performance.","Q_Score":13,"Tags":"python,optimization,memory-management","A_Id":3021350,"CreationDate":"2010-06-11T08:22:00.000","Title":"Python tips for memory optimization","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I need to optimize the RAM usage of my application.\nPLEASE spare me the lectures telling me I shouldn't care about memory when coding Python. I have a memory problem because I use very large default-dictionaries (yes, I also want to be fast). My current memory consumption is 350MB and growing. I already cannot use shared hosting and if my Apache opens more processes the memory doubles and triples... and it is expensive.\nI have done extensive profiling and I know exactly where my problems are.\nI have several large (>100K entries) dictionaries with Unicode keys. A dictionary starts at 140 bytes and grows fast, but the bigger problem is the keys. Python optimizes strings in memory (or so I've read) so that lookups can be ID comparisons ('interning' them). Not sure this is also true for unicode strings (I was not able to 'intern' them).\nThe objects stored in the dictionary are lists of tuples (an_object, an int, an int).\n\nmy_big_dict[some_unicode_string].append((my_object, an_int, another_int))\n\nI already found that it is worth while to split to several dictionaries because the tuples take a lot of space...\nI found that I could save RAM by hashing the strings before using them as keys!\nBut then, sadly, I ran into birthday collisions on my 32 bit system. (side question: is there a 64-bit key dictionary I can use on a 32-bit system?)\nPython 2.6.5 on both Linux(production) and Windows. \nAny tips on optimizing memory usage of dictionaries \/ lists \/ tuples?\nI even thought of using C - I don't care if this very small piece of code is ugly. It is just a singular location.\nThanks in advance!","AnswerCount":7,"Available Count":2,"Score":0.057080742,"is_accepted":false,"ViewCount":12150,"Q_Id":3021264,"Users Score":2,"Answer":"I've had situations where I've had a collection of large objects that I've needed to sort and filter by different methods based on several metadata properties. I didn't need the larger parts of them so I dumped them to disk.\nAs you data is so simple in type, a quick SQLite database might solve all your problems, even speed things up a little.","Q_Score":13,"Tags":"python,optimization,memory-management","A_Id":3021346,"CreationDate":"2010-06-11T08:22:00.000","Title":"Python tips for memory optimization","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Ideally I'd like to find a library for Python.\nAll I need is the caller number, I do not need to answer the call.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1371,"Q_Id":3024344,"Users Score":0,"Answer":"i don't know for this specific model, but GSM modem are generally handled as a communication port. they are mapped as a communication port (COMXX under windows, don't know for linux). \nthe documentation of the modem will give you a set of AT command which will allow you to configure the modem so that it notifies incoming calls to the port. just open the port, send the configuration commands and listen for incoming events. (you should also be able to receive SMS this way).","Q_Score":0,"Tags":"python,call,modem,gsm","A_Id":3028528,"CreationDate":"2010-06-11T16:06:00.000","Title":"Is it possible to detect an incoming call to a GSM modem (HUAWEI E160) plugged into the USB port?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I have a variable in init of a module which get loaded from the database and takes about 15 seconds. \nFor django development server everything is working fine but looks like with apache2 and mod_wsgi the module is loaded with every request (taking 15 seconds).\nAny idea about this behavior? \nUpdate: I have enabled daemon mode in mod wsgi, looks like its not reloading the modules now! needs more testing and I will update.","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":629,"Q_Id":3025378,"Users Score":1,"Answer":"I guess, you had a value of 1 for MaxClients \/ MaxRequestsPerChild and\/or ThreadsPerChild in your Apache settings. So Apache had to startup Django for every mod_python call. That's why it took so long. If you have a wsgi-daemon, then a restart takes only place if you \"touch\" the wsgi script.","Q_Score":2,"Tags":"python,django,apache,mod-wsgi","A_Id":3027902,"CreationDate":"2010-06-11T18:46:00.000","Title":"Python module being reloaded for each request with django and 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},{"Question":"I have a variable in init of a module which get loaded from the database and takes about 15 seconds. \nFor django development server everything is working fine but looks like with apache2 and mod_wsgi the module is loaded with every request (taking 15 seconds).\nAny idea about this behavior? \nUpdate: I have enabled daemon mode in mod wsgi, looks like its not reloading the modules now! needs more testing and I will update.","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":629,"Q_Id":3025378,"Users Score":3,"Answer":"You were likely ignoring the fact that in embedded mode of mod_wsgi or with mod_python, the application is multiprocess. Thus requests may go to different processes and you will see a delay the first time a process which hasn't been hit before is encountered. In mod_wsgi daemon mode the default has only a single process. That or as someone else mentioned you had MaxRequestsPerChild set to 1, which is a really bad idea.","Q_Score":2,"Tags":"python,django,apache,mod-wsgi","A_Id":3032332,"CreationDate":"2010-06-11T18:46:00.000","Title":"Python module being reloaded for each request with django and 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},{"Question":"Hey as a project to improve my programing skills I've begun programing a nice code editor in python to teach myself project management, version control, and gui programming. I was wanting to utilize syntax files made for other programs so I could have a large collection already. I was wondering if there was any kind of universal syntax file format much in the same sense as .odt files. I heard of one once in a forum, it had a website, but I can't remember it now. If not I may just try to use gedit syntax files or geany.\nthanks","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":252,"Q_Id":3026786,"Users Score":0,"Answer":"Not sure what .odt has to do with any of this.\nI could see some sort of BNF being able to describe (almost) any syntax: Just run the text and the BNF through a parser, and apply a color scheme to the terminals. You could even get a bit more fancy, since you'd have the syntax tree.\nIn reality, I think most syntax files take an easier approach, such as regular expressions. This would put then somewhere above regular expressions but not really quite context-free in terms of power.\nAs for file formats, if you re-use something that exists, then you can just loot and pillage (subject to license agreements) their syntax file data.","Q_Score":0,"Tags":"python,syntax,editor,text-editor","A_Id":3026797,"CreationDate":"2010-06-11T23:02:00.000","Title":"Universal syntax file 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":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Is there a way I can programmatically determine the status of a download in Chrome or Mozilla Firefox? I would like to know if the download was aborted or completed successfully.\nFor writing the code I'd be using either Perl, PHP or Python.\nPlease help.\nThank You.","AnswerCount":2,"Available Count":1,"Score":-0.1973753202,"is_accepted":false,"ViewCount":676,"Q_Id":3029824,"Users Score":-2,"Answer":"There are scripts out there that output the file in chunks, recording how many bytes they've echoed out, but those are completely unreliable and you can't accurately ascertain whether or not the user successfully received the complete file.\nThe short answer is no, really, unless you write your own download manager (in Java) that runs a callback to your server when the download completes.","Q_Score":0,"Tags":"php,python,perl,download","A_Id":3029877,"CreationDate":"2010-06-12T19:18:00.000","Title":"Programmatically determining the status of a file download","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},{"Question":"I utilize the standard python logging module.  When I call python manage.py test I'd like to disable logging before all the tests are ran.  Is there a signal or some other kind of hook I could use to call logging.disable?  Or is there some other way to disable logging when python manage.py test is ran?","AnswerCount":7,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":5944,"Q_Id":3030277,"Users Score":2,"Answer":"The only way I know of is to edit manage.py itself... not very elegant, of course, but at least it should get you to where you need to be.","Q_Score":7,"Tags":"python,django,logging","A_Id":3031000,"CreationDate":"2010-06-12T22:11:00.000","Title":"Disable logging during manage.py test?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"Has anyone tried using uWSGI with Cherokee? Can you share your experiences and what documents you relied upon the most? I am trying to get started from the documentation on both (uWSGI and Cherokee) websites. Nothing works yet. I am using Ubuntu 10.04.\n\nEdit: To clarify, Cherokee has been working fine. I am getting the error message:\n\nuWSGI Error, wsgi application not found\n\nSo something must be wrong with my configurations. Or maybe my application.","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":2309,"Q_Id":3030936,"Users Score":1,"Answer":"There seems to be an issue with the 'make' method of installation on the uwsgi docs.  Use 'python uwsgiconfig.py --build' instead.  That worked for me.  Cherokee, Django running on Ubuntu 10.10.","Q_Score":2,"Tags":"python,wsgi,cherokee,uwsgi","A_Id":5033390,"CreationDate":"2010-06-13T03:16:00.000","Title":"uWSGI with Cherokee: first steps","Data Science and Machine Learning":0,"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},{"Question":"I am building a trading portfolio management system that is responsible for production, optimization, and simulation of non-high frequency trading portfolios (dealing with 1min or 3min bars of data, not tick data). \nI plan on employing Amazon web services to take on the entire load of the application.\nI have four choices that I am considering as language.\n\nJava\nC++\nC#\nPython\n\nHere is the scope of the extremes of the project scope. This isn't how it will be, maybe ever, but it's within the scope of the requirements:\n\nWeekly simulation of 10,000,000 trading systems.\n(Each trading system is expected to have its own data mining methods, including feature selection algorithms which are extremely computationally-expensive. Imagine 500-5000 features using wrappers. These are not run often by any means, but it's still a consideration)\nReal-time production of portfolio w\/ 100,000 trading strategies\nTaking in 1 min or 3 min data from every stock\/futures market around the globe (approx 100,000)\nPortfolio optimization of portfolios with up to 100,000 strategies. (rather intensive algorithm)\n\nSpeed is a concern, but I believe that Java can handle the load.\nI just want to make sure that Java CAN handle the above requirements comfortably. I don't want to do the project in C++, but I will if it's required.\nThe reason C# is on there is because I thought it was a good alternative to Java, even though I don't like Windows at all and would prefer Java if all things are the same.\nPython - I've read somethings on PyPy and pyscho that claim python can be optimized with JIT compiling to run at near C-like speeds... That's pretty much the only reason it is on this list, besides that fact that Python is a great language and would probably be the most enjoyable language to code in, which is not a factor at all for this project, but a perk.\nTo sum up:\n\nreal time production\nweekly simulations of a large number of systems\nweekly\/monthly optimizations of portfolios\nlarge numbers of connections to collect data from\n\nThere is no dealing with millisecond or even second based trades. The only consideration is if Java can possibly deal with this kind of load when spread out of a necessary amount of EC2 servers.\nThank you guys so much for your wisdom.","AnswerCount":7,"Available Count":6,"Score":0.1418931938,"is_accepted":false,"ViewCount":995,"Q_Id":3031225,"Users Score":5,"Answer":"Pick the language you are most familiar with. If you know them all equally and speed is a real concern, pick C.","Q_Score":5,"Tags":"java,python,trading","A_Id":3031234,"CreationDate":"2010-06-13T05:45:00.000","Title":"Which programming language for compute-intensive trading portfolio simulation?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I am building a trading portfolio management system that is responsible for production, optimization, and simulation of non-high frequency trading portfolios (dealing with 1min or 3min bars of data, not tick data). \nI plan on employing Amazon web services to take on the entire load of the application.\nI have four choices that I am considering as language.\n\nJava\nC++\nC#\nPython\n\nHere is the scope of the extremes of the project scope. This isn't how it will be, maybe ever, but it's within the scope of the requirements:\n\nWeekly simulation of 10,000,000 trading systems.\n(Each trading system is expected to have its own data mining methods, including feature selection algorithms which are extremely computationally-expensive. Imagine 500-5000 features using wrappers. These are not run often by any means, but it's still a consideration)\nReal-time production of portfolio w\/ 100,000 trading strategies\nTaking in 1 min or 3 min data from every stock\/futures market around the globe (approx 100,000)\nPortfolio optimization of portfolios with up to 100,000 strategies. (rather intensive algorithm)\n\nSpeed is a concern, but I believe that Java can handle the load.\nI just want to make sure that Java CAN handle the above requirements comfortably. I don't want to do the project in C++, but I will if it's required.\nThe reason C# is on there is because I thought it was a good alternative to Java, even though I don't like Windows at all and would prefer Java if all things are the same.\nPython - I've read somethings on PyPy and pyscho that claim python can be optimized with JIT compiling to run at near C-like speeds... That's pretty much the only reason it is on this list, besides that fact that Python is a great language and would probably be the most enjoyable language to code in, which is not a factor at all for this project, but a perk.\nTo sum up:\n\nreal time production\nweekly simulations of a large number of systems\nweekly\/monthly optimizations of portfolios\nlarge numbers of connections to collect data from\n\nThere is no dealing with millisecond or even second based trades. The only consideration is if Java can possibly deal with this kind of load when spread out of a necessary amount of EC2 servers.\nThank you guys so much for your wisdom.","AnswerCount":7,"Available Count":6,"Score":0.1137907297,"is_accepted":false,"ViewCount":995,"Q_Id":3031225,"Users Score":4,"Answer":"Write it in your preferred language. To me that sounds like python. When you start running the system you can profile it and see where the bottlenecks are. Once you do some basic optimisations if it's still not acceptable you can rewrite portions in C. \nA consideration could be writing this in iron python to take advantage of the clr and dlr in .net. Then you can leverage .net 4 and parallel extensions. If anything will give you performance increases it'll be some flavour of threading which .net does extremely well.\nEdit:\nJust wanted to make this part clear. From the description, it sounds like parallel processing \/ multithreading is where the majority of the performance gains are going to come from.","Q_Score":5,"Tags":"java,python,trading","A_Id":3031266,"CreationDate":"2010-06-13T05:45:00.000","Title":"Which programming language for compute-intensive trading portfolio simulation?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I am building a trading portfolio management system that is responsible for production, optimization, and simulation of non-high frequency trading portfolios (dealing with 1min or 3min bars of data, not tick data). \nI plan on employing Amazon web services to take on the entire load of the application.\nI have four choices that I am considering as language.\n\nJava\nC++\nC#\nPython\n\nHere is the scope of the extremes of the project scope. This isn't how it will be, maybe ever, but it's within the scope of the requirements:\n\nWeekly simulation of 10,000,000 trading systems.\n(Each trading system is expected to have its own data mining methods, including feature selection algorithms which are extremely computationally-expensive. Imagine 500-5000 features using wrappers. These are not run often by any means, but it's still a consideration)\nReal-time production of portfolio w\/ 100,000 trading strategies\nTaking in 1 min or 3 min data from every stock\/futures market around the globe (approx 100,000)\nPortfolio optimization of portfolios with up to 100,000 strategies. (rather intensive algorithm)\n\nSpeed is a concern, but I believe that Java can handle the load.\nI just want to make sure that Java CAN handle the above requirements comfortably. I don't want to do the project in C++, but I will if it's required.\nThe reason C# is on there is because I thought it was a good alternative to Java, even though I don't like Windows at all and would prefer Java if all things are the same.\nPython - I've read somethings on PyPy and pyscho that claim python can be optimized with JIT compiling to run at near C-like speeds... That's pretty much the only reason it is on this list, besides that fact that Python is a great language and would probably be the most enjoyable language to code in, which is not a factor at all for this project, but a perk.\nTo sum up:\n\nreal time production\nweekly simulations of a large number of systems\nweekly\/monthly optimizations of portfolios\nlarge numbers of connections to collect data from\n\nThere is no dealing with millisecond or even second based trades. The only consideration is if Java can possibly deal with this kind of load when spread out of a necessary amount of EC2 servers.\nThank you guys so much for your wisdom.","AnswerCount":7,"Available Count":6,"Score":1.2,"is_accepted":true,"ViewCount":995,"Q_Id":3031225,"Users Score":4,"Answer":"I would pick Java for this task. In terms of RAM, the difference between Java and C++ is that in Java, each Object has an overhead of 8 Bytes (using the Sun 32-bit JVM or the Sun 64-bit JVM with compressed pointers). So if you have millions of objects flying around, this can make a difference. In terms of speed, Java and C++ are almost equal at that scale.\nSo the more important thing for me is the development time. If you make a mistake in C++, you get a segmentation fault (and sometimes you don't even get that), while in Java you get a nice Exception with a stack trace. I have always preferred this.\nIn C++ you can have collections of primitive types, which Java hasn't. You would have to use external libraries to get them.\nIf you have real-time requirements, the Java garbage collector may be a nuisance, since it takes some minutes to collect a 20 GB heap, even on machines with 24 cores. But if you don't create too many temporary objects during runtime, that should be fine, too. It's just that your program can make that garbage collection pause whenever you don't expect it.","Q_Score":5,"Tags":"java,python,trading","A_Id":3031544,"CreationDate":"2010-06-13T05:45:00.000","Title":"Which programming language for compute-intensive trading portfolio simulation?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I am building a trading portfolio management system that is responsible for production, optimization, and simulation of non-high frequency trading portfolios (dealing with 1min or 3min bars of data, not tick data). \nI plan on employing Amazon web services to take on the entire load of the application.\nI have four choices that I am considering as language.\n\nJava\nC++\nC#\nPython\n\nHere is the scope of the extremes of the project scope. This isn't how it will be, maybe ever, but it's within the scope of the requirements:\n\nWeekly simulation of 10,000,000 trading systems.\n(Each trading system is expected to have its own data mining methods, including feature selection algorithms which are extremely computationally-expensive. Imagine 500-5000 features using wrappers. These are not run often by any means, but it's still a consideration)\nReal-time production of portfolio w\/ 100,000 trading strategies\nTaking in 1 min or 3 min data from every stock\/futures market around the globe (approx 100,000)\nPortfolio optimization of portfolios with up to 100,000 strategies. (rather intensive algorithm)\n\nSpeed is a concern, but I believe that Java can handle the load.\nI just want to make sure that Java CAN handle the above requirements comfortably. I don't want to do the project in C++, but I will if it's required.\nThe reason C# is on there is because I thought it was a good alternative to Java, even though I don't like Windows at all and would prefer Java if all things are the same.\nPython - I've read somethings on PyPy and pyscho that claim python can be optimized with JIT compiling to run at near C-like speeds... That's pretty much the only reason it is on this list, besides that fact that Python is a great language and would probably be the most enjoyable language to code in, which is not a factor at all for this project, but a perk.\nTo sum up:\n\nreal time production\nweekly simulations of a large number of systems\nweekly\/monthly optimizations of portfolios\nlarge numbers of connections to collect data from\n\nThere is no dealing with millisecond or even second based trades. The only consideration is if Java can possibly deal with this kind of load when spread out of a necessary amount of EC2 servers.\nThank you guys so much for your wisdom.","AnswerCount":7,"Available Count":6,"Score":0.0855049882,"is_accepted":false,"ViewCount":995,"Q_Id":3031225,"Users Score":3,"Answer":"Why only one language for your system? If I were you, I will build the entire system in Python, but C or C++ will be used for performance-critical components. In this way, you will have a very flexible and extendable system with fast-enough performance. You can find even tools to generate wrappers automatically (e.g. SWIG, Cython). Python and C\/C++\/Java\/Fortran are not competing each other; they are complementing.","Q_Score":5,"Tags":"java,python,trading","A_Id":3031844,"CreationDate":"2010-06-13T05:45:00.000","Title":"Which programming language for compute-intensive trading portfolio simulation?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I am building a trading portfolio management system that is responsible for production, optimization, and simulation of non-high frequency trading portfolios (dealing with 1min or 3min bars of data, not tick data). \nI plan on employing Amazon web services to take on the entire load of the application.\nI have four choices that I am considering as language.\n\nJava\nC++\nC#\nPython\n\nHere is the scope of the extremes of the project scope. This isn't how it will be, maybe ever, but it's within the scope of the requirements:\n\nWeekly simulation of 10,000,000 trading systems.\n(Each trading system is expected to have its own data mining methods, including feature selection algorithms which are extremely computationally-expensive. Imagine 500-5000 features using wrappers. These are not run often by any means, but it's still a consideration)\nReal-time production of portfolio w\/ 100,000 trading strategies\nTaking in 1 min or 3 min data from every stock\/futures market around the globe (approx 100,000)\nPortfolio optimization of portfolios with up to 100,000 strategies. (rather intensive algorithm)\n\nSpeed is a concern, but I believe that Java can handle the load.\nI just want to make sure that Java CAN handle the above requirements comfortably. I don't want to do the project in C++, but I will if it's required.\nThe reason C# is on there is because I thought it was a good alternative to Java, even though I don't like Windows at all and would prefer Java if all things are the same.\nPython - I've read somethings on PyPy and pyscho that claim python can be optimized with JIT compiling to run at near C-like speeds... That's pretty much the only reason it is on this list, besides that fact that Python is a great language and would probably be the most enjoyable language to code in, which is not a factor at all for this project, but a perk.\nTo sum up:\n\nreal time production\nweekly simulations of a large number of systems\nweekly\/monthly optimizations of portfolios\nlarge numbers of connections to collect data from\n\nThere is no dealing with millisecond or even second based trades. The only consideration is if Java can possibly deal with this kind of load when spread out of a necessary amount of EC2 servers.\nThank you guys so much for your wisdom.","AnswerCount":7,"Available Count":6,"Score":0.1418931938,"is_accepted":false,"ViewCount":995,"Q_Id":3031225,"Users Score":5,"Answer":"While I am a huge fan of Python and personaly I'm not a great lover of Java, in this case I have to concede that Java is the right way to go.\nFor many projects Python's performance just isn't a problem, but in your case even minor performance penalties will add up extremely quickly. I know this isn't a real-time simulation, but even for batch processing it's still a factor to take into consideration. If it turns out the load is too big for one virtual server, an implementation that's twice as fast will halve your virtual server costs.\nFor many projects I'd also argue that Python will allow you to develop a solution faster, but here I'm not sure that would be the case. Java has world-class development tools and top-drawer enterprise grade frameworks for parallell processing and cross-server deployment and while Python has solutions in this area, Java clearly has the edge. You also have architectural options with Java that Python can't match, such as Javaspaces.\nI would argue that C and C++ impose too much of a development overhead for a project like this. They're viable inthat if you are very familiar with those languages I'm sure it would be doable, but other than the potential for higher performance, they have nothing else to bring to the table.\nC# is just a rewrite of Java. That's not a bad thing if you're a Windows developer and if you prefer Windows I'd use C# rather than Java, but if you don't care about Windows there's no reason to care about C#.","Q_Score":5,"Tags":"java,python,trading","A_Id":3035998,"CreationDate":"2010-06-13T05:45:00.000","Title":"Which programming language for compute-intensive trading portfolio simulation?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I am building a trading portfolio management system that is responsible for production, optimization, and simulation of non-high frequency trading portfolios (dealing with 1min or 3min bars of data, not tick data). \nI plan on employing Amazon web services to take on the entire load of the application.\nI have four choices that I am considering as language.\n\nJava\nC++\nC#\nPython\n\nHere is the scope of the extremes of the project scope. This isn't how it will be, maybe ever, but it's within the scope of the requirements:\n\nWeekly simulation of 10,000,000 trading systems.\n(Each trading system is expected to have its own data mining methods, including feature selection algorithms which are extremely computationally-expensive. Imagine 500-5000 features using wrappers. These are not run often by any means, but it's still a consideration)\nReal-time production of portfolio w\/ 100,000 trading strategies\nTaking in 1 min or 3 min data from every stock\/futures market around the globe (approx 100,000)\nPortfolio optimization of portfolios with up to 100,000 strategies. (rather intensive algorithm)\n\nSpeed is a concern, but I believe that Java can handle the load.\nI just want to make sure that Java CAN handle the above requirements comfortably. I don't want to do the project in C++, but I will if it's required.\nThe reason C# is on there is because I thought it was a good alternative to Java, even though I don't like Windows at all and would prefer Java if all things are the same.\nPython - I've read somethings on PyPy and pyscho that claim python can be optimized with JIT compiling to run at near C-like speeds... That's pretty much the only reason it is on this list, besides that fact that Python is a great language and would probably be the most enjoyable language to code in, which is not a factor at all for this project, but a perk.\nTo sum up:\n\nreal time production\nweekly simulations of a large number of systems\nweekly\/monthly optimizations of portfolios\nlarge numbers of connections to collect data from\n\nThere is no dealing with millisecond or even second based trades. The only consideration is if Java can possibly deal with this kind of load when spread out of a necessary amount of EC2 servers.\nThank you guys so much for your wisdom.","AnswerCount":7,"Available Count":6,"Score":0.0,"is_accepted":false,"ViewCount":995,"Q_Id":3031225,"Users Score":0,"Answer":"It is useful to look at the inner loop of your numerical code. After all you will spend most of your CPU-time inside this loop. \nIf the inner loop is a matrix operation, then I suggest python and scipy, but of the inner loop if not a matrix operation, then I would worry about python being slow. (Or maybe I would wrap c++ in python using swig or boost::python)\nThe benefit of python is that it is easy to debug, and you save a lot of time by not having to compile all the time. This is especially useful for a project where you spend a lot of time programming deep internals.","Q_Score":5,"Tags":"java,python,trading","A_Id":3036242,"CreationDate":"2010-06-13T05:45:00.000","Title":"Which programming language for compute-intensive trading portfolio simulation?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"Looking for good source code either in C or C++ or Python to understand how a hash function is implemented and also how a hash table is implemented using it.\nVery good material on how hash fn and hash table implementation works.\n\nThanks in advance.","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":571,"Q_Id":3031358,"Users Score":1,"Answer":"When you want to learn, I suggest you look at the Java implementation of java.util.HashMap. It's clear code, well-documented and comparably short. Admitted, it's neither C, nor C++, nor Python, but you probably don't want to read the GNU libc++'s upcoming implementation of a hashtable, which above all consists of the complexity of the C++ standard template library.\nTo begin with, you should read the definition of the java.util.Map interface. Then you can jump directly into the details of the java.util.HashMap. And everything that's missing you will find in java.util.AbstractMap.\nThe implementation of a good hash function is independent of the programming language. The basic task of it is to map an arbitrarily large value set onto a small value set (usually some kind of integer type), so that the resulting values are evenly distributed.","Q_Score":0,"Tags":"c++,python,c,hashtable,hash","A_Id":3031578,"CreationDate":"2010-06-13T07:02:00.000","Title":"Looking for production quality Hash table\/ unordered map implementation to learn?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"Whenever I change my python source files in my Django project, the .pyc files become out of date.  Of course that's because I need to recompile them in order to test them through my local Apache web server.  I would like to get around this manual process by employing some automatic means of compiling them on save, or on build through Eclipse, or something like that.  What's the best and proper way to do this?","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":463,"Q_Id":3031383,"Users Score":2,"Answer":"You shouldn't ever need to 'compile' your .pyc files manually. This is always done automatically at runtime by the Python interpreter.\nIn rare instances, such as when you delete an entire .py module, you may need to manually delete the corresponding .pyc. But there's no need to do any other manual compiling.\nWhat makes you think you need to do this?","Q_Score":2,"Tags":"python,django,build-process,build,bytecode","A_Id":3031660,"CreationDate":"2010-06-13T07:09:00.000","Title":"Eclipse + Django: How to get bytecode output when python source files 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":0,"Web Development":1},{"Question":"Why does Python seem slower, on average, than C\/C++? I learned Python as my first programming language, but I've only just started with C and already I feel I can see a clear difference.","AnswerCount":11,"Available Count":3,"Score":0.0363476168,"is_accepted":false,"ViewCount":44926,"Q_Id":3033329,"Users Score":2,"Answer":"C and C++ compile to native code- that is, they run directly on the CPU. Python is an interpreted language, which means that the Python code you write must go through many, many stages of abstraction before it can become executable machine code.","Q_Score":86,"Tags":"c++,python,c,performance,programming-languages","A_Id":3033341,"CreationDate":"2010-06-13T18:09:00.000","Title":"Why are Python Programs often slower than the Equivalent Program Written in C or 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},{"Question":"Why does Python seem slower, on average, than C\/C++? I learned Python as my first programming language, but I've only just started with C and already I feel I can see a clear difference.","AnswerCount":11,"Available Count":3,"Score":1.0,"is_accepted":false,"ViewCount":44926,"Q_Id":3033329,"Users Score":8,"Answer":"The difference between python and C is the usual difference between an interpreted (bytecode) and compiled (to native) language. Personally, I don't really see python as slow, it manages just fine. If you try to use it outside of its realm, of course, it will be slower. But for that, you can write C extensions for python, which puts time-critical algorithms in native code, making it way faster.","Q_Score":86,"Tags":"c++,python,c,performance,programming-languages","A_Id":3033355,"CreationDate":"2010-06-13T18:09:00.000","Title":"Why are Python Programs often slower than the Equivalent Program Written in C or 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},{"Question":"Why does Python seem slower, on average, than C\/C++? I learned Python as my first programming language, but I've only just started with C and already I feel I can see a clear difference.","AnswerCount":11,"Available Count":3,"Score":1.0,"is_accepted":false,"ViewCount":44926,"Q_Id":3033329,"Users Score":25,"Answer":"Compilation vs interpretation isn't important here: Python is compiled, and it's a tiny part of the runtime cost for any non-trivial program.\nThe primary costs are: the lack of an integer type which corresponds to native integers (making all integer operations vastly more expensive), the lack of static typing (which makes resolution of methods more difficult, and means that the types of values must be checked at runtime), and the lack of unboxed values (which reduce memory usage, and can avoid a level of indirection).\nNot that any of these things aren't possible or can't be made more efficient in Python, but the choice has been made to favor programmer convenience and flexibility, and language cleanness over runtime speed. Some of these costs may be overcome by clever JIT compilation, but the benefits Python provides will always come at some cost.","Q_Score":86,"Tags":"c++,python,c,performance,programming-languages","A_Id":3033545,"CreationDate":"2010-06-13T18:09:00.000","Title":"Why are Python Programs often slower than the Equivalent Program Written in C or 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},{"Question":"I'm using textmate for the first time basically, and I am lost as to what keys map to these funny symbols.\nusing python bundles, what keys do I press for:\nrun\nrun with tests\nrun project unit tests\nAlso, with textmate, do I actually define a project in textmate or do I just work on the files and textmate doesn't create its own .project type file ?","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":527,"Q_Id":3034640,"Users Score":2,"Answer":"Also, with textmate, do I actually define a project in textmate or do I just work on the files and textmate doesn't create its own .project type file ?\n\nYou can do both. You can create a new project in TextMate by going to File -> New Project and add your files manually, or you can drag a folder into TextMate and it will create a project from those files (you can add other files later). Note that the second method will not create a .tmproj file, though, so if you want to \"keep\" that project, you'll have to save it (File -> Save Project).","Q_Score":2,"Tags":"python,textmate","A_Id":3069494,"CreationDate":"2010-06-14T01:51:00.000","Title":"new to mac and textmate, can someone explain these shortcuts?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I have to send F2 key to telnet host. How do I send it using python...using getch() I found that the character < used for the F2 key but when sending >, its not working. I think there is a way to send special function keys but I am not able to find it. If somebody knows please help me. Thanks in advance","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":2908,"Q_Id":3035390,"Users Score":4,"Answer":"Extended keys (non-alphanumeric or symbol) are composed of a sequence of single characters, with the sequence depending on the terminal you have told the telnet server you are using. You will need to send all characters in the sequence in order to make it work. Here, using od -c <<< 'CtrlVF2' I was able to see a sequence of \\x1b0Q with the xterm terminal.","Q_Score":4,"Tags":"python,telnet","A_Id":3035415,"CreationDate":"2010-06-14T06:40:00.000","Title":"how to send F2 key to remote host 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},{"Question":"I once read about minimal python installation without a lot of the libraries that come with the python default installation but could not find it on the web...\nWhat I want to do is to just pack a script with the python stuff required to execute it and make portable.\nDoes any one know about something like that?\nThanks","AnswerCount":4,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":14823,"Q_Id":3035572,"Users Score":2,"Answer":"You can also look for already installed instances.\nOpenOffice \/ LibreOffice\nLook at the environment variable UNO_PATH or into the default install directories, for example for Windows and LO5\n\n%ProgramFiles(x86)%\\LibreOffice 5\\program\\python.exe\n\nGimp\nlook into the default install directories, for example for Windows\n\nC:\\Program Files\\GIMP 2\\Python\n\nand so on...","Q_Score":9,"Tags":"python","A_Id":43765592,"CreationDate":"2010-06-14T07:25:00.000","Title":"Micropython or minimal python installation","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":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},{"Question":"I want to find the square root of a number without using the math module,as i need to call the function some 20k times and dont want to slow down the execution by linking to the math module each time the function is called \nIs there any faster and easier way for finding square root?","AnswerCount":11,"Available Count":1,"Score":0.0906594778,"is_accepted":false,"ViewCount":60866,"Q_Id":3047012,"Users Score":5,"Answer":"In some special cases you can trade program size for blistering speed. Create a large array and store the pre-calculated result for every square root operation (using the input value as the index). It's pretty limited but you won't get anything faster.\n(That's how quake did it)","Q_Score":17,"Tags":"python","A_Id":3047546,"CreationDate":"2010-06-15T16:19:00.000","Title":"How to perform square root without using math 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},{"Question":"Does anyone know of a memory efficient way to generate very large xml files (e.g. 100-500 MiB) in Python? \nI've been utilizing lxml, but memory usage is through the roof.","AnswerCount":4,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":4751,"Q_Id":3049188,"Users Score":2,"Answer":"The only sane way to generate so large an XML file is line by line, which means printing while running a state machine, and lots of testing.","Q_Score":11,"Tags":"python,xml,lxml","A_Id":3049245,"CreationDate":"2010-06-15T21:27:00.000","Title":"Generating very large XML files 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},{"Question":"Does anyone know of a memory efficient way to generate very large xml files (e.g. 100-500 MiB) in Python? \nI've been utilizing lxml, but memory usage is through the roof.","AnswerCount":4,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":4751,"Q_Id":3049188,"Users Score":2,"Answer":"Obviously, you've got to avoid having to build the entire tree ( whether DOM or etree or whatever ) in memory. But the best way depends on the source of your data and how complicated and interlinked the structure of your output is.\nIf it's big because it's got thousands of instances of fairly independent items, then you can generate the outer wrapper, and then build trees for each item and then serialize each fragment to the output. \nIf the fragments aren't so independent, then you'll need to do some extra bookkeeping -- like maybe manage a database of generated ids & idrefs. \nI would break it into 2 or 3 parts: a sax event producer, an output serializer\neating sax events, and optionally, if it seems easier to work with some independent pieces as objects or trees, something to build those objects and then turn them into sax events for the serializer. \nMaybe you could just manage it all as direct text output, instead of dealing with sax events: that depends on how complicated it is. \nThis may also be a good place to use python generators as a way of streaming the output without having to build large structures in memory.","Q_Score":11,"Tags":"python,xml,lxml","A_Id":3050007,"CreationDate":"2010-06-15T21:27:00.000","Title":"Generating very large XML files 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},{"Question":"I have to do one project for my thesis involving Artificial intelligence, collaborative filtering and machine learning methods.\nI only know PHP\/mysq\/JS, and there is not much AI stuff examples in PHP.\nThere are some books on AI on internet but they use Java , Python.\nNow I have to apply AI techniques on web application.\nWhich language should i choose java or python.\nI searhed on internet that I can call java classes inside my php so that can help as as I am very good at php\nI have also seen that python can also be used with php as well\nSo which way should I go and roughly how much it will take me to learn java\nI have done java basics but that was 6 years ago","AnswerCount":9,"Available Count":7,"Score":0.0,"is_accepted":false,"ViewCount":10608,"Q_Id":3050450,"Users Score":0,"Answer":"Never use PHP for AI. Java or C\/C++ is the best, but Python for fast development.","Q_Score":6,"Tags":"java,php,python,artificial-intelligence","A_Id":3050643,"CreationDate":"2010-06-16T02:59:00.000","Title":"Which language should I use for Artificial intelligence on web 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":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have to do one project for my thesis involving Artificial intelligence, collaborative filtering and machine learning methods.\nI only know PHP\/mysq\/JS, and there is not much AI stuff examples in PHP.\nThere are some books on AI on internet but they use Java , Python.\nNow I have to apply AI techniques on web application.\nWhich language should i choose java or python.\nI searhed on internet that I can call java classes inside my php so that can help as as I am very good at php\nI have also seen that python can also be used with php as well\nSo which way should I go and roughly how much it will take me to learn java\nI have done java basics but that was 6 years ago","AnswerCount":9,"Available Count":7,"Score":1.0,"is_accepted":false,"ViewCount":10608,"Q_Id":3050450,"Users Score":6,"Answer":"Does it really matter which language your books use? I mean, you're not gonna copy-paste those examples. And you'll learn to recognize basic constructs (functions, loops, etc) pretty fast. It's not like learning to read Chinese.\nTalking about learning time, there's probably no definite answer to this question. I think the best is to look at examples of code both in java and python and see which seems 'nicer', easier and more familiar to you.\nGood luck!","Q_Score":6,"Tags":"java,php,python,artificial-intelligence","A_Id":3050476,"CreationDate":"2010-06-16T02:59:00.000","Title":"Which language should I use for Artificial intelligence on web 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":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have to do one project for my thesis involving Artificial intelligence, collaborative filtering and machine learning methods.\nI only know PHP\/mysq\/JS, and there is not much AI stuff examples in PHP.\nThere are some books on AI on internet but they use Java , Python.\nNow I have to apply AI techniques on web application.\nWhich language should i choose java or python.\nI searhed on internet that I can call java classes inside my php so that can help as as I am very good at php\nI have also seen that python can also be used with php as well\nSo which way should I go and roughly how much it will take me to learn java\nI have done java basics but that was 6 years ago","AnswerCount":9,"Available Count":7,"Score":0.0665680765,"is_accepted":false,"ViewCount":10608,"Q_Id":3050450,"Users Score":3,"Answer":"Which language should i choose java or python.\n\nHere are a few things to consider:\n\njava is more widely used (presumably more mature code \"out there\" to look at - but I haven't tested that out)\npython is more prolific (you write faster in python than in java), and from learning the language to writing the code that you want takes less in python than in java\npython is multi-paradigm, java is (almost) strictly OOP\njava is compiled (whereas python is scripted); this means that java finds your errors at compilation; python at execution - this can make a big difference, depending on your development style\/practices\njava is more strictly defined and much more verbose than python. Where in java you have to formalize your contracts, in python you use duck-typing.\n\nIn the end, the best you could do is set up a small project, write it in both languages and see what you end up preferring. You may also find some restrictions that you can't get around for one of the languages.\nIn the end it's up to you :)\nEdit: that was not an exhaustive list and I tried to be as impartial as I could (but that ends here: I'd go with python :D)","Q_Score":6,"Tags":"java,php,python,artificial-intelligence","A_Id":3051952,"CreationDate":"2010-06-16T02:59:00.000","Title":"Which language should I use for Artificial intelligence on web 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":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have to do one project for my thesis involving Artificial intelligence, collaborative filtering and machine learning methods.\nI only know PHP\/mysq\/JS, and there is not much AI stuff examples in PHP.\nThere are some books on AI on internet but they use Java , Python.\nNow I have to apply AI techniques on web application.\nWhich language should i choose java or python.\nI searhed on internet that I can call java classes inside my php so that can help as as I am very good at php\nI have also seen that python can also be used with php as well\nSo which way should I go and roughly how much it will take me to learn java\nI have done java basics but that was 6 years ago","AnswerCount":9,"Available Count":7,"Score":0.0444152037,"is_accepted":false,"ViewCount":10608,"Q_Id":3050450,"Users Score":2,"Answer":"You can use any language you like, as long as the server it's hosted on supports it. You can use HTML\/JS as the user interface, and request results from the server with AJAX requests.\nWhat answers those requests would be your AI code, and that can be anything you want. PHP makes it really simple to answer AJAX requests. Since you are already familiar with it I would recommend that, although if your AI is very sophisticated you may want to go with something a little more efficient, like C\/C++.","Q_Score":6,"Tags":"java,php,python,artificial-intelligence","A_Id":3050709,"CreationDate":"2010-06-16T02:59:00.000","Title":"Which language should I use for Artificial intelligence on web 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":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have to do one project for my thesis involving Artificial intelligence, collaborative filtering and machine learning methods.\nI only know PHP\/mysq\/JS, and there is not much AI stuff examples in PHP.\nThere are some books on AI on internet but they use Java , Python.\nNow I have to apply AI techniques on web application.\nWhich language should i choose java or python.\nI searhed on internet that I can call java classes inside my php so that can help as as I am very good at php\nI have also seen that python can also be used with php as well\nSo which way should I go and roughly how much it will take me to learn java\nI have done java basics but that was 6 years ago","AnswerCount":9,"Available Count":7,"Score":0.0,"is_accepted":false,"ViewCount":10608,"Q_Id":3050450,"Users Score":0,"Answer":"I believe Python is nice for this sort of tasks because of it's flexibility. Using the numpy\/scipy libraries together with a nice plotting lib (chaco or matplotlib for instance) makes the workflow of working with the data and algorithms easy and you can lab around with the code in the live interpreter in an almost matlab-like manner. Change a line of code here, cleanse the data there and watch the whole thing live in a graph window without having to bother with recompilation etc.\nOnce you settled on the algorithms it is fairly easy to profile the code and move hotspots into C\/C++ or Fortran for instance if you are worried about performance.\n(you could even write the stuff in Jython and drop down into java for the performance-heavy bits of the code if you really like to be on the JVM platform)","Q_Score":6,"Tags":"java,php,python,artificial-intelligence","A_Id":3264444,"CreationDate":"2010-06-16T02:59:00.000","Title":"Which language should I use for Artificial intelligence on web 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":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have to do one project for my thesis involving Artificial intelligence, collaborative filtering and machine learning methods.\nI only know PHP\/mysq\/JS, and there is not much AI stuff examples in PHP.\nThere are some books on AI on internet but they use Java , Python.\nNow I have to apply AI techniques on web application.\nWhich language should i choose java or python.\nI searhed on internet that I can call java classes inside my php so that can help as as I am very good at php\nI have also seen that python can also be used with php as well\nSo which way should I go and roughly how much it will take me to learn java\nI have done java basics but that was 6 years ago","AnswerCount":9,"Available Count":7,"Score":0.0,"is_accepted":false,"ViewCount":10608,"Q_Id":3050450,"Users Score":0,"Answer":"AI is not a language or a specific problem like summation or finding an average of some numbers. It's the intelligence which is going to be developed artificially. And to make a system intelligent especially a computer you can use any language that computer can understand and you are comfortable with (C, Java, Python, C++). A very simple AI example could be tic-tac-toe. This game could be made by using any language you would like to. The important thing is the algorithm that needs to be developed. AI is a vast area and it comprises of many things like Image processing, NLP, Machine learning, Psychology and more. And most importantly one has to be very strong in Mathematics, which is the most important and integral part of softcomputing. So again AI is not a language rather intelligent algorithm based on pure mathematics.","Q_Score":6,"Tags":"java,php,python,artificial-intelligence","A_Id":47068977,"CreationDate":"2010-06-16T02:59:00.000","Title":"Which language should I use for Artificial intelligence on web 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":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have to do one project for my thesis involving Artificial intelligence, collaborative filtering and machine learning methods.\nI only know PHP\/mysq\/JS, and there is not much AI stuff examples in PHP.\nThere are some books on AI on internet but they use Java , Python.\nNow I have to apply AI techniques on web application.\nWhich language should i choose java or python.\nI searhed on internet that I can call java classes inside my php so that can help as as I am very good at php\nI have also seen that python can also be used with php as well\nSo which way should I go and roughly how much it will take me to learn java\nI have done java basics but that was 6 years ago","AnswerCount":9,"Available Count":7,"Score":0.0,"is_accepted":false,"ViewCount":10608,"Q_Id":3050450,"Users Score":0,"Answer":"Pretty much any language can be used to code pretty much anything - given the effort and will. But Python has more functional programming constructs which may be more useful when you are coding AI.","Q_Score":6,"Tags":"java,php,python,artificial-intelligence","A_Id":3051880,"CreationDate":"2010-06-16T02:59:00.000","Title":"Which language should I use for Artificial intelligence on web 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":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Is there any way to read metadata - watermarks from image files with Python?","AnswerCount":1,"Available Count":1,"Score":0.537049567,"is_accepted":false,"ViewCount":546,"Q_Id":3053480,"Users Score":3,"Answer":"If by watermark you mean some \"signature\" image content added to an image in order to mark it, then no. Such a watermark is merged with the original image and thus an integral part of it. If you mean meta-data info then yes, this can be read: but you don't specify whether you mean programmatically, or what language or stack you're using or would like to use.","Q_Score":1,"Tags":"python,watermark","A_Id":3053551,"CreationDate":"2010-06-16T13:09:00.000","Title":"How to read watermarks 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},{"Question":"Is it just because of dynamic typing we don't require a concept of interfaces(like in Java and C#) in python?","AnswerCount":9,"Available Count":4,"Score":0.022218565,"is_accepted":false,"ViewCount":3173,"Q_Id":3062701,"Users Score":1,"Answer":"Interfaces are used in statically typed languages to describe that two otherwise independent objects \"implement the same behaviour\". In dynamically typed languages one implicitly assumes that when two objects have a method with the same name\/params it does the same thing, so interfaces are of no use.","Q_Score":18,"Tags":"c#,java,python,dynamic-languages","A_Id":3062743,"CreationDate":"2010-06-17T14:44:00.000","Title":"Why don't we require interfaces in dynamic 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},{"Question":"Is it just because of dynamic typing we don't require a concept of interfaces(like in Java and C#) in python?","AnswerCount":9,"Available Count":4,"Score":0.022218565,"is_accepted":false,"ViewCount":3173,"Q_Id":3062701,"Users Score":1,"Answer":"Interface constructs are used in statically typed languages to teach the type system which objects are substitutable for each other in a particular method-calling context. If two objects implement the same method but aren't related through inheritance from a common base class or implementation of a common interface, the type system will raise an error at compile time if you substitute one for the other.\nDynamic languages use \"duck typing\", which means the method is simply looked up at runtime and if it exists with the right signature, it's used; otherwise a runtime error results. If two objects both \"quack like a duck\" by implementing the same method, they are substitutable. Thus, there's no explicit need for the language to relate them via base class or interface.\nThat being said, interfaces as a concept are still very important in the dynamic world, but they're often just defined in documentation and not enforced by the language. Occasionally, I see programmers actually make a base class that sketches out the interface for this purpose as well; this helps formalize the documentation, and is of particular use if part of the interface can be implemented in terms of the rest of the interface.","Q_Score":18,"Tags":"c#,java,python,dynamic-languages","A_Id":3062895,"CreationDate":"2010-06-17T14:44:00.000","Title":"Why don't we require interfaces in dynamic 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},{"Question":"Is it just because of dynamic typing we don't require a concept of interfaces(like in Java and C#) in python?","AnswerCount":9,"Available Count":4,"Score":0.022218565,"is_accepted":false,"ViewCount":3173,"Q_Id":3062701,"Users Score":1,"Answer":"One key thing about at least some dynamic languages that makes explicit interfaces more than a little awkward is that dynamic languages can often respond to messages (err, \u201cmethod calls\u201d) that they don't know about beforehand, even doing things like creating methods on the fly. The only real way to know whether an object will respond to a message correctly is by sending it the message. That's OK, because dynamic languages consider it better to be able to support that sort of thing rather than static type checking; an object is considered to be usable in a particular protocol because it is \u201cknown\u201d to be able to participate in that protocol (e.g., by virtue of being given by another message).","Q_Score":18,"Tags":"c#,java,python,dynamic-languages","A_Id":3063282,"CreationDate":"2010-06-17T14:44:00.000","Title":"Why don't we require interfaces in dynamic 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},{"Question":"Is it just because of dynamic typing we don't require a concept of interfaces(like in Java and C#) in python?","AnswerCount":9,"Available Count":4,"Score":0.0444152037,"is_accepted":false,"ViewCount":3173,"Q_Id":3062701,"Users Score":2,"Answer":"It's worth noting that, contrary to what many people will say as a first response, interfaces can be used to do more than document \"what methods a class supports\". Grzenio touches on this with his wording on \"implement the same behaviour\". As a specific example of this, look at the Java interface Serializable. It doesn't implement any methods; rather it's used as a \"marker\" to indicate that the class can be serialized safely.\nWhen considered this way, it could be reasonable to have a dynamic language that uses interfaces. That being said, something akin to annotations might be a more reasonable approach.","Q_Score":18,"Tags":"c#,java,python,dynamic-languages","A_Id":3063169,"CreationDate":"2010-06-17T14:44:00.000","Title":"Why don't we require interfaces in dynamic 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},{"Question":"Is there an easy way to disable Python egg caching?  We have the situation where a system account needs to run a python program which imports a module.\nSince this is a non-login robot account, it does not have a home directory, and dies trying to create the directory \/.python-eggs.\nWhat's the best way to fix this?  Can I convert my eggs in site-files to something which will not be cached in .python-eggs?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":719,"Q_Id":3064405,"Users Score":3,"Answer":"The best way to fix it is by creating a directory where it can write it's egg cache. You can specify the directory with the PYTHON_EGG_CACHE variable.\n[edit]\nAnd yes, you can convert your apps so they won't need an egg-cache. If you install the python packages with easy_install you can use easy_install -Z so it won't zip the eggs and it won't need to extract them. You should be able to unzip the current eggs to make sure you won't need them.\nBut personally I would just create the egg cache directory.","Q_Score":1,"Tags":"python,egg","A_Id":3064433,"CreationDate":"2010-06-17T18:19:00.000","Title":"Python: disabling $HOME\/.python-eggs?","Data Science and Machine Learning":0,"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},{"Question":"I'm using PAMIE to control IE to automatically browse to a list of URLs. I want to find which URLs return IE's malware warning and which ones don't. I'm new to PAMIE, and PAMIE's documentation is non-existent or cryptic at best. How can I get a page's content from PAMIE so I can work with it in Python?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":256,"Q_Id":3073151,"Users Score":0,"Answer":"Browsing the CPamie.py file did the trick. Turns out, I didn't even need the page content - PAMIE's findText method lets you match any string on the page. Works great!","Q_Score":0,"Tags":"python,pamie","A_Id":3098190,"CreationDate":"2010-06-18T21:17:00.000","Title":"How do I get the page content from PAMIE?","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},{"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},{"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},{"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},{"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},{"Question":"Is there a free open-source solution taking raw e-mail message (as a piece of text) and returning each header field, each attachment and the message body as separate fields?","AnswerCount":3,"Available Count":1,"Score":0.1325487884,"is_accepted":false,"ViewCount":873,"Q_Id":3078189,"Users Score":2,"Answer":"Yes... For each language you pointed out, I've used the one in Python myself.  Try perusing the library documentation for your chosen library.\n(Note: You may be expecting a \"nice\", high-level library for this parsing...  That's a tricky area, email has evolved and grown without much design, there are a lot of dark corners, and API's reflect that).","Q_Score":2,"Tags":"java,php,python,email,parsing","A_Id":3078197,"CreationDate":"2010-06-20T04:15:00.000","Title":"Is there an open-source eMail message (headers, attachments, etc.) parser?","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},{"Question":"Portal Technology Assessment in which we will be creating a placement portal for the campuses and industry to help place students. The portal will handle large volumes of data and people logging in, approximately 1000 users\/day in a concurrent mode.\nWhat technology should i use? PHP with CakePHP as a framework, Ruby on Rails, ASP.NET, Python, or should I opt for cloud computing? Which of those are the most cost beneficial?","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":182,"Q_Id":3078364,"Users Score":1,"Answer":"Language choice is important as you must choose language that you and your team feel the most comfortable with as you must develop mid-large size application. Of course use framework with Python it must be Django, with ASP.NET .NET or MVC.NET whatever you feel better with with Ruby ROR and with PHP there are too large amount of frameworks.\n1000 concurrent users is not that much, especially it depends what users will do. Places where users will get large amount of data are better to Cache with with any caching engine you want. You need to design application this what so you can easily swap between real DB calls and calls to cache. For that use Data Objects like for Logins create an Object array of course if you need it. Save some information in cookies when user logins for example his last login, password in case he wants to change it, email and such so you will make less calls to DB in read mode ( select queries ).\nuse cookie less domain for static content like images, js and css files. setup on this domain the fastest system you can with simplest server you can, probably something based on Linux.\nFor servers, best advice is to either get large machine and set Virtual Boxes on it with vmware or other Linux based solution or to get few servers which is better because if on big server down you lost everything if one of 1 is down you still can do some stuff. Especially if you set railroad mode. Railroad mode is simple you set up Application server (IIS or Apache) on one server and make it master while you set up SQL on the same server and make it slave. On other server you set up SQL as master and Application server as slave. So server one serves IIS\/Apache and Other one SQL, if one down you just need to change line in host.etc in order to set something somewhere else ( i don't know how to do that in Linux ).\nlast server for static content.\nCloud Computing, you will use if you want it or not. You will share resources with some applications as Google API for jquery and jqueryUI for instance but you create unique application and  i don't believe making core of application based on cloud computing will do any good. Use large site's CDNs for good.","Q_Score":3,"Tags":"python,lamp","A_Id":3078415,"CreationDate":"2010-06-20T05:58:00.000","Title":"How to make a cost effective but scalable 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":0},{"Question":"Portal Technology Assessment in which we will be creating a placement portal for the campuses and industry to help place students. The portal will handle large volumes of data and people logging in, approximately 1000 users\/day in a concurrent mode.\nWhat technology should i use? PHP with CakePHP as a framework, Ruby on Rails, ASP.NET, Python, or should I opt for cloud computing? Which of those are the most cost beneficial?","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":182,"Q_Id":3078364,"Users Score":2,"Answer":"Any of those will do, it really depends on what you know. If you're comfortable with Python, use Django. If you like Ruby go with ROR. These modern frameworks are built to scale, assuming you're not going to be developing something on the scale of facebook then they should suffice.\nI personally recommend nginx as your main server to host static content and possibly reverse-proxy to Django\/mod_wsgi\/Apache2.\nAnother important aspect is caching, make sure to use something like memcached and make sure the framework has some sort of plugin or it's easily attachable.","Q_Score":3,"Tags":"python,lamp","A_Id":3078371,"CreationDate":"2010-06-20T05:58:00.000","Title":"How to make a cost effective but scalable 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":0},{"Question":"How can I check if a specific ip address or proxy is alive or dead","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":4148,"Q_Id":3078704,"Users Score":0,"Answer":"An IP address corresponds to a device. You can't \"connect\" to a device in the general sense. You can connect to services on the device identified by ports. So, you find the ip address and port of the proxy server you're interested in and then try connecting to it using a simple socket.connect. If it connects fine, you can alteast be sure that something is running on that port of that ip address. Then you go ahead and use it and if things are not as you expect, you can make further decisions.","Q_Score":2,"Tags":"python,sockets,proxy","A_Id":3078730,"CreationDate":"2010-06-20T09:03:00.000","Title":"how to check if an ip address or proxy is working 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},{"Question":"How can I check if a specific ip address or proxy is alive or dead","AnswerCount":3,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":4148,"Q_Id":3078704,"Users Score":3,"Answer":"Because there may be any level of filtering or translation between you and the remote host, the only way to determine whether you can connect to a specific host is to actually try to connect. If the connection succeeds, then you can, else you can't.\nPinging isn't sufficient because ICMP ECHO requests may be blocked yet TCP connections might go through fine.","Q_Score":2,"Tags":"python,sockets,proxy","A_Id":3078719,"CreationDate":"2010-06-20T09:03:00.000","Title":"how to check if an ip address or proxy is working 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},{"Question":"I have a C++ project which is using boost. The whole project is built using scons + Visual Studio 2008. We've installed Visual Studio 2010 and it turned out scons was attempting to use the later compiler instead of the old one - and failed to build the project as boost and visual studio 2010 don't like each other very much - yet. We'd like to suppress this and force scons to use the 2008 version. Is this possible? How do we do this?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":2641,"Q_Id":3079344,"Users Score":17,"Answer":"You can modify the scons Environment() by just choosing\nthe version you want:\nenv = Environment(MSVC_VERSION=)\nFrom the scons manpage:\n\nMSVC_VERSION   Sets the preferred \n  version of Microsoft Visual C\/C++ to\n  use.\nIf $MSVC_VERSION is not set, SCons\n  will (by default) select the latest\n  version of Visual C\/C++ installed on\n  your system.  If the specified version\n  isn't installed, tool initialization\n  will fail.  This variable  must be \n  passed  as  an argument to the\n  Environment() constructor; setting it\n  later has no effect.  Set it to an\n  unexpected value (e.g. \"XXX\") to see\n  the valid values on your system.","Q_Score":9,"Tags":"python,scons","A_Id":3083882,"CreationDate":"2010-06-20T13:16:00.000","Title":"Forcing scons to use older compiler?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Is there something like JRuby but for Ruby and Python?\nNot that it would actually be useful to me, but just wondering.","AnswerCount":4,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":662,"Q_Id":3079531,"Users Score":8,"Answer":"If you develop for the .NET Framework Version 4.0, you can write code in IronRuby that calls methods that were written in IronPython and vice versa.","Q_Score":8,"Tags":"python,ruby","A_Id":3079547,"CreationDate":"2010-06-20T14:15:00.000","Title":"Can I use Ruby and Python together?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I have wondered about this on and off but I never really got a definite answer. Is it possible within the boost.python framework to link against another boost.python module. \nFor example I have exported class A within boost_python_module(libA) and function B(A a) within boost_python_module(libB). Is it possible to specify in libB to link to A of libA. \nThe other way of looking at this problem would be that right now I  have to  generate all my bindings in one shot within one module. Is it possible to generate bindings incrementally over several boost_python_module.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1552,"Q_Id":3080185,"Users Score":0,"Answer":"I don't know well shared library, but what works for me is to import all my modules, which can reference with each others, within python: import libA; import libB.\nIt is of course possible to put these imports in an __init__.py file, so that whitin python you just have to do: import myLib.","Q_Score":5,"Tags":"c++,boost,boost-python","A_Id":3139385,"CreationDate":"2010-06-20T17:19:00.000","Title":"How to link to existing boost 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},{"Question":"Am trying to provide a response from a Managers perspective to the question: What overall performance penalty will we incur if we write the application in IronPython instead of C#?\nThis question is directed at those who might have already undertaken some testing, benchmarking or have completed a migration from C# to IronPython, in order to quantify the penalty.","AnswerCount":4,"Available Count":1,"Score":-0.0996679946,"is_accepted":false,"ViewCount":8794,"Q_Id":3081661,"Users Score":-2,"Answer":"Based on my understanding both languages will be compiled into MSIL so theoretically the performance of the application should be identical or very close, but there is a lot more to it, the human factor.\nI can assure you that a program I write in C# could be a lot faster that the same program in iron-python not because C# is faster but because I'm more familiar with C# and I know what choices to make, so if your team is more familiar with C# your application has a better chance at performance if it is written in C# or the other way around.\nThis is just a personal theory so take it with a grain of salt.","Q_Score":7,"Tags":"ironpython","A_Id":3082237,"CreationDate":"2010-06-21T01:27:00.000","Title":"Speed of code execution: IronPython vs 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},{"Question":"I was wondering if it was possible to pull a private mercurial repo to a server without access to hg. I have SSH access, but do not have the ability to install HG. I was thinking some kind of Python script that used http access or something, but I wasn't sure. I was also thinking this might only be possible with public repos. I am currently hosting the projet on BitBucket. Thanks for any input!","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":3457,"Q_Id":3082107,"Users Score":1,"Answer":"If you don't have mercurial available locally then you may as well pull the tarball instead, available behind the \"get source\" option towards the top-right corner of various pages, underneath \"Forks\/Queues\".","Q_Score":3,"Tags":"python,mercurial,bitbucket","A_Id":3082132,"CreationDate":"2010-06-21T04:25:00.000","Title":"How to pull a BitBucket repository without access to hg","Data Science and Machine Learning":0,"Database and SQL":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},{"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},{"Question":"I have a VPS Linux webserver with PHP installed.\nI want to code some search engine or data mining stuff in one application which I am thinking of building in python.\nI want to know if it is possible to use python and php together like calling functions of python in php and vice versa.\nAs it is my VPS server, I can install anything on that.\nHas anyone tried using python in php? Are there any performance issues in real time??","AnswerCount":5,"Available Count":1,"Score":-0.0399786803,"is_accepted":false,"ViewCount":31647,"Q_Id":3084303,"Users Score":-1,"Answer":"Better you have to do, use api, different application like one application on python server having python application and one server having php application with api. Like you store or delete data by using api in android or ios.","Q_Score":14,"Tags":"php,python","A_Id":69296576,"CreationDate":"2010-06-21T11:41:00.000","Title":"Is it possible to use Python with 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},{"Question":"I have  read in the documentation that there are 4 or 5 ways in which i can python for web pages. Like\n\nWith CGI\nMod_python : mod_python does have some problems. Unlike the PHP interpreter, the Python interpreter uses caching when executing files, so changes to a file will require the web server to be restarted\nFastCGI and SCGI\nmod_wsgi\n\nSO which way should i go . does it means that python is not for webistes if there are too many problems while using it\nI have to build the live business website with thousands of users so i should not use it if that has many probelms","AnswerCount":6,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":825,"Q_Id":3089450,"Users Score":0,"Answer":"You could also use Google App Engine with Python and Django","Q_Score":2,"Tags":"python","A_Id":3089472,"CreationDate":"2010-06-22T00:41:00.000","Title":"How to use python on webserver for web pages","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"Buildbots Periodic scheduler triggers builds at fixed intervals (e.g. every 30 minutes). But there are certain times (e.g. at night, during the weekend or while regular maintenance is performed) where I'd like it to relax.\nIs there a way to have a more fine-grained description for the Periodic scheduler? Or should I rather use the Nightly scheduler and explicitly list all build trigger times I need for the whole week?","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":56,"Q_Id":3093598,"Users Score":1,"Answer":"If you use Nightly, then you can specify that the scheduler only trigger if there are interesting changes to build. Presumably, you won't have commits during that period either, so it will not trigger builds then.","Q_Score":0,"Tags":"python,continuous-integration,build-automation,buildbot,nightly-build","A_Id":12307055,"CreationDate":"2010-06-22T13:36:00.000","Title":"Exceptions from Buildbots PeriodicScheduler intervals?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"Buildbots Periodic scheduler triggers builds at fixed intervals (e.g. every 30 minutes). But there are certain times (e.g. at night, during the weekend or while regular maintenance is performed) where I'd like it to relax.\nIs there a way to have a more fine-grained description for the Periodic scheduler? Or should I rather use the Nightly scheduler and explicitly list all build trigger times I need for the whole week?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":56,"Q_Id":3093598,"Users Score":0,"Answer":"One way to solve this would of course be to write a piece of python code that generates the build times for up the nightly scheduler according to some rules.","Q_Score":0,"Tags":"python,continuous-integration,build-automation,buildbot,nightly-build","A_Id":6169869,"CreationDate":"2010-06-22T13:36:00.000","Title":"Exceptions from Buildbots PeriodicScheduler intervals?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I'm working on an IronPython project on VS2010 and I've notice that for the python project (which is setup as a Console project, but really just contains a number of scripts that are hosted in a C# app), everything that is in the project directory will show up in the VS solution explorer under that project.  So, for example, the .svn folder shows up.  Which I obviously don't want or need to be there.\nIs there any way to tell it to hide specific items? I sure can't find one.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":284,"Q_Id":3094693,"Users Score":0,"Answer":"You should be able to just right click the folder, choose \"Exclude from Project\"\nThen, make sure \"Show all files\" is NOT on at the top, by the solution.","Q_Score":2,"Tags":"visual-studio-2010,ironpython","A_Id":3094718,"CreationDate":"2010-06-22T15:37:00.000","Title":"Hide .svn folders in a VS2010 IronPython 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":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm working on an IronPython project on VS2010 and I've notice that for the python project (which is setup as a Console project, but really just contains a number of scripts that are hosted in a C# app), everything that is in the project directory will show up in the VS solution explorer under that project.  So, for example, the .svn folder shows up.  Which I obviously don't want or need to be there.\nIs there any way to tell it to hide specific items? I sure can't find one.","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":284,"Q_Id":3094693,"Users Score":2,"Answer":"Currently we have a directory based project system - which as you have seen includes all of the files in the project dir.  We were planning on having an exclude option but the feedback we've been hearing so far is that we should move to a normal VS project model where you need to explicitly add the files.  The next CTP release (which should be out in a week or so) will change to a normal project model.\nThere does still seem to be some interest in the directory based model so we may bring it back via an option in a future version.","Q_Score":2,"Tags":"visual-studio-2010,ironpython","A_Id":3098784,"CreationDate":"2010-06-22T15:37:00.000","Title":"Hide .svn folders in a VS2010 IronPython 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":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"somewhat open ended question here as I am mostly looking for opinions.  I am grabbing some data from craigslist for apt ads in my area since I am looking to move.  My goal is to be able to compare items to see when something is a duplicate so that I don't spend all day looking at the same 3 ads.  The problem is that they change things around a little to get past CL's filters.\nI already have some regex to look for address and phone numbers to compare, but that isn't the most reliable.  Is anyone familiar with an easy-ish method to compare the whole document and maybe show something simple like \"80% similar\"?  I can't think of anything offhand, so I suspect I'll have to start from scratch on my own solution, but figured it would be worth asking the collective genius of stackoverflow :)\nPreferred languages\/methods would be python\/php\/perl, but if it's a great solution I'm pretty open.\nUpdate: one thing worth noting is that since I will be storing the scraped data of the rss feed for apts in my area (los angeles) in a local DB, the preferred method would include a way to compare it to everything I currently know.  This could be a bit of a showstopper since that could become a very long process as the post counts grow.","AnswerCount":5,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":387,"Q_Id":3095057,"Users Score":0,"Answer":"If you wanted to do this a lot and with some reliability, you might want to use a semi-advanced approach like a \"bag of words\" technique. I actually sat down and wrote a sketch of a more-or-less working (if horribly unoptimized) algorithm to do it, but I'm not sure if it would really be appropriate to include here. There are pre-made libraries that you can use for text classification instead.","Q_Score":4,"Tags":"php,python,sql,regex,perl","A_Id":3209792,"CreationDate":"2010-06-22T16:23:00.000","Title":"What is the easiest method to compare large amounts of similar text?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"somewhat open ended question here as I am mostly looking for opinions.  I am grabbing some data from craigslist for apt ads in my area since I am looking to move.  My goal is to be able to compare items to see when something is a duplicate so that I don't spend all day looking at the same 3 ads.  The problem is that they change things around a little to get past CL's filters.\nI already have some regex to look for address and phone numbers to compare, but that isn't the most reliable.  Is anyone familiar with an easy-ish method to compare the whole document and maybe show something simple like \"80% similar\"?  I can't think of anything offhand, so I suspect I'll have to start from scratch on my own solution, but figured it would be worth asking the collective genius of stackoverflow :)\nPreferred languages\/methods would be python\/php\/perl, but if it's a great solution I'm pretty open.\nUpdate: one thing worth noting is that since I will be storing the scraped data of the rss feed for apts in my area (los angeles) in a local DB, the preferred method would include a way to compare it to everything I currently know.  This could be a bit of a showstopper since that could become a very long process as the post counts grow.","AnswerCount":5,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":387,"Q_Id":3095057,"Users Score":2,"Answer":"You could calculate the Levenshtein difference between both strings - after some sane normalizing like minimizing duplicate whitespace and what not. After you run through enough \"duplicates\" you should get an idea of what your threshold is - then you can run Levenshtein on all new incoming data and if its less-than-equal to your threshold than you can consider it a duplicate.","Q_Score":4,"Tags":"php,python,sql,regex,perl","A_Id":3209571,"CreationDate":"2010-06-22T16:23:00.000","Title":"What is the easiest method to compare large amounts of similar text?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"What are the pros and cons of importing a Python module and\/or function inside of a function, with respect to efficiency of speed and of memory?\nDoes it re-import every time the function is run, or perhaps just once at the beginning whether or not the function is run?","AnswerCount":6,"Available Count":5,"Score":1.0,"is_accepted":false,"ViewCount":145145,"Q_Id":3095071,"Users Score":7,"Answer":"Importing inside a function will effectively import the module once.. the first time the function is run.\nIt ought to import just as fast whether you import it at the top, or when the function is run. This isn't generally a good reason to import in a def. Pros? It won't be imported if the function isn't called.. This is actually a reasonable reason if your module only requires the user to have a certain module installed if they use specific functions of yours...\nIf that's not he reason you're doing this, it's almost certainly a yucky idea.","Q_Score":222,"Tags":"python,python-import","A_Id":3095108,"CreationDate":"2010-06-22T16:24:00.000","Title":"In Python, what happens when you import inside of a 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":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"What are the pros and cons of importing a Python module and\/or function inside of a function, with respect to efficiency of speed and of memory?\nDoes it re-import every time the function is run, or perhaps just once at the beginning whether or not the function is run?","AnswerCount":6,"Available Count":5,"Score":1.0,"is_accepted":false,"ViewCount":145145,"Q_Id":3095071,"Users Score":8,"Answer":"Might I suggest in general that instead of asking, \"Will X improve my performance?\" you use profiling to determine where your program is actually spending its time and then apply optimizations according to where you'll get the most benefit?\nAnd then you can use profiling to assure that your optimizations have actually benefited you, too.","Q_Score":222,"Tags":"python,python-import","A_Id":3096179,"CreationDate":"2010-06-22T16:24:00.000","Title":"In Python, what happens when you import inside of a 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":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"What are the pros and cons of importing a Python module and\/or function inside of a function, with respect to efficiency of speed and of memory?\nDoes it re-import every time the function is run, or perhaps just once at the beginning whether or not the function is run?","AnswerCount":6,"Available Count":5,"Score":0.0996679946,"is_accepted":false,"ViewCount":145145,"Q_Id":3095071,"Users Score":3,"Answer":"It imports once when the function is called for the first time.\nI could imagine doing it this way if I had a function in an imported module that is used very seldomly and is the only one requiring the import. Looks rather far-fetched, though...","Q_Score":222,"Tags":"python,python-import","A_Id":3095106,"CreationDate":"2010-06-22T16:24:00.000","Title":"In Python, what happens when you import inside of a 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":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"What are the pros and cons of importing a Python module and\/or function inside of a function, with respect to efficiency of speed and of memory?\nDoes it re-import every time the function is run, or perhaps just once at the beginning whether or not the function is run?","AnswerCount":6,"Available Count":5,"Score":1.0,"is_accepted":false,"ViewCount":145145,"Q_Id":3095071,"Users Score":20,"Answer":"It imports once when the function executes first time.\nPros:\n\nimports related to the function they're used in\neasy to move functions around the package\n\nCons:\n\ncouldn't see what modules this module might depend on","Q_Score":222,"Tags":"python,python-import","A_Id":3095095,"CreationDate":"2010-06-22T16:24:00.000","Title":"In Python, what happens when you import inside of a 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":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"What are the pros and cons of importing a Python module and\/or function inside of a function, with respect to efficiency of speed and of memory?\nDoes it re-import every time the function is run, or perhaps just once at the beginning whether or not the function is run?","AnswerCount":6,"Available Count":5,"Score":1.0,"is_accepted":false,"ViewCount":145145,"Q_Id":3095071,"Users Score":55,"Answer":"The very first time you import goo from anywhere (inside or outside a function), goo.py (or other importable form) is loaded and sys.modules['goo'] is set to the module object thus built.  Any future import within the same run of the program (again, whether inside or outside a function) just look up sys.modules['goo'] and bind it to barename goo in the appropriate scope.  The dict lookup and name binding are very fast operations.\nAssuming the very first import gets totally amortized over the program's run anyway, having the \"appropriate scope\" be module-level means each use of goo.this, goo.that, etc, is two dict lookups -- one for goo and one for the attribute name.  Having it be \"function level\" pays one extra local-variable setting per run of the function (even faster than the dictionary lookup part!) but saves one dict lookup (exchanging it for a local-variable lookup, blazingly fast) for each goo.this (etc) access, basically halving the time such lookups take.\nWe're talking about a few nanoseconds one way or another, so it's hardly a worthwhile optimization.  The one potentially substantial advantage of having the import within a function is when that function may well not be needed at all in a given run of the program, e.g., that function deals with errors, anomalies, and rare situations in general; if that's the case, any run that does not need the functionality will not even perform the import (and that's a saving of microseconds, not just nanoseconds), only runs that do need the functionality will pay the (modest but measurable) price.\nIt's still an optimization that's only worthwhile in pretty extreme situations, and there are many others I would consider before trying to squeeze out microseconds in this way.","Q_Score":222,"Tags":"python,python-import","A_Id":3095167,"CreationDate":"2010-06-22T16:24:00.000","Title":"In Python, what happens when you import inside of a 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":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Short of essentially rewriting copytree to accept an ignore callback, what is a simple way to achieve this in versions prior to python 2.6?  (I don't want to stray from my debian packages)","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":456,"Q_Id":3105747,"Users Score":0,"Answer":"You can copy the source for copytree from the 2.6 tree, and put it into your project's source tree.","Q_Score":0,"Tags":"python,python-2.5,shutil,copytree","A_Id":3105771,"CreationDate":"2010-06-23T21:37:00.000","Title":"Python: shutil.copytree , lack of ignore arg in python 2.5","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"My test framework is currently based on a test-runner utility which itself is derived from the Eclipse pydev python test-runner. I'm switching to use Nose, which has many of the features of my custom test-runner but seems to be better quality code.\nMy test suite includes a number of abstract test-classes which previously never ran. The standard python testrunner (and my custom one) only ran instances of unittest.TestCase and unittest.TestSuite. \nI've noticed that since I switched to Nose it's running just about anything which starts withthe name \"test\" which is annoying... because the naming convention we used for the test-mixins also looks like a test class to Nose. Previously these never ran as tests because they were not instances of TestCase or TestSuite.\nObviously I could re-name the methods to exclude the word \"test\" from their names... that would take a while because the test framework is very big and has a lot of inheritance. On the other hand it would be neat if there was a way to make Nose only see TestCases and TestSuites as being runnable... and nothing else. \nCan this be done?","AnswerCount":5,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":2498,"Q_Id":3110967,"Users Score":6,"Answer":"You could try to play with -m option for nosetests. From documentation:\n\nA test class is a class defined in a\n  test module that matches testMatch or\n  is a subclass of unittest.TestCase\n\n-m sets that testMatch, this way you can disable testing anything starting with test.\nAnother thing is that you can add __test__ = False to your test case class declaration, to mark it \u201cnot a test\u201d.","Q_Score":6,"Tags":"python,unit-testing,nose","A_Id":3118573,"CreationDate":"2010-06-24T14:37:00.000","Title":"Is it possible to make Nose only run tests which are sub-classes of TestCase or TestSuite (like unittest.main())","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I'm beginning to learn some Hadoop\/MapReduce, coming mostly from a PHP background, with a little bit of Java and Python. \nBut, it seems like most implementations of MapReduce out there are in Java, Ruby, C++ or Python. \nI've looked, and it looks like there are some Hadoop\/MapReduce in PHP, but the overwhelming body of the literature seems to be dedicated to those 4 languages.\nIs there a good reason why PHP is a 2nd class language in cloud computing projects like those that involve Hadoop\/MapReduce? This is particularly surprising, considering that, outside of cloud computing world, PHP seems like its the most commonly supported language, to the detriment of the 3 above (sans C++) languages. \nIf this is arbitrary--if PHP is just as good at handling these operations as, say, Python, what libraries\/projects should I look into?","AnswerCount":3,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":906,"Q_Id":3113573,"Users Score":10,"Answer":"PHP is designed primarily as a language for displaying output to a browser. Most jobs being run on MapReduce\/Hadoop clusters have nothing to do with displaying output.\nThey instead tend to lean much more heavily towards data processing. PHP is not the most commonly supported language for data processing, by far. Thus, it's logical that the most common supported languages for data processing-related technologies don't include PHP.","Q_Score":3,"Tags":"java,php,python,hadoop,mapreduce","A_Id":3113643,"CreationDate":"2010-06-24T20:18:00.000","Title":"PHP vs. Other Languages in Hadoop\/MapReduce implementations, and in the Cloud generally","Data Science and Machine Learning":0,"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},{"Question":"I'm beginning to learn some Hadoop\/MapReduce, coming mostly from a PHP background, with a little bit of Java and Python. \nBut, it seems like most implementations of MapReduce out there are in Java, Ruby, C++ or Python. \nI've looked, and it looks like there are some Hadoop\/MapReduce in PHP, but the overwhelming body of the literature seems to be dedicated to those 4 languages.\nIs there a good reason why PHP is a 2nd class language in cloud computing projects like those that involve Hadoop\/MapReduce? This is particularly surprising, considering that, outside of cloud computing world, PHP seems like its the most commonly supported language, to the detriment of the 3 above (sans C++) languages. \nIf this is arbitrary--if PHP is just as good at handling these operations as, say, Python, what libraries\/projects should I look into?","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":906,"Q_Id":3113573,"Users Score":1,"Answer":"The reason is PHP lack of support for multi-threading and process communication.","Q_Score":3,"Tags":"java,php,python,hadoop,mapreduce","A_Id":3113644,"CreationDate":"2010-06-24T20:18:00.000","Title":"PHP vs. Other Languages in Hadoop\/MapReduce implementations, and in the Cloud generally","Data Science and Machine Learning":0,"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},{"Question":"With Python, I could get the name of the exception easily as follows.\n\nrun the code, i.e. x = 3\/0 to get the exception from python\n\"ZeroDivisionError: integer division or modulo by zero\" tells me this is ZeroDivisionError\nModify the code i.e. try: x=3\/0 except ZeroDivisionError: DO something\n\nIs there any similar way to find the exception name with C++?\nWhen I run the x = 3\/0, the compiled binary just throws 'Floating point exception', which is not so useful compared to python.","AnswerCount":4,"Available Count":2,"Score":0.049958375,"is_accepted":false,"ViewCount":940,"Q_Id":3113929,"Users Score":1,"Answer":"If you want to know the name of the exception class, you could use RTTI. However, the vast majority of C++ code will throw an exception derived from std::exception.\nHowever, all you get is the exception data contained in std::exception::what, and you can get the name of the exception class from RTTI and catch that explicitly if you need more information (and it contains more information).","Q_Score":2,"Tags":"c++,python,exception-handling","A_Id":3113950,"CreationDate":"2010-06-24T21:15:00.000","Title":"How can I know the name of the exception 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},{"Question":"With Python, I could get the name of the exception easily as follows.\n\nrun the code, i.e. x = 3\/0 to get the exception from python\n\"ZeroDivisionError: integer division or modulo by zero\" tells me this is ZeroDivisionError\nModify the code i.e. try: x=3\/0 except ZeroDivisionError: DO something\n\nIs there any similar way to find the exception name with C++?\nWhen I run the x = 3\/0, the compiled binary just throws 'Floating point exception', which is not so useful compared to python.","AnswerCount":4,"Available Count":2,"Score":0.049958375,"is_accepted":false,"ViewCount":940,"Q_Id":3113929,"Users Score":1,"Answer":"If this is a debugging issue, you may be able to set your compiler to break when it hits an exception, which can be infinitely useful.","Q_Score":2,"Tags":"c++,python,exception-handling","A_Id":3114002,"CreationDate":"2010-06-24T21:15:00.000","Title":"How can I know the name of the exception 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},{"Question":"Has anyone ever worked with MIL-STD-1553 in Python?  How did you do it?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1487,"Q_Id":3119027,"Users Score":3,"Answer":"If the 1553 interface has a Windows DLL, you can use the ctypes library to access it. I've done this for Python and my organization's 1553 products. \nTo start, I would write a quick test that accesses a DLL function that doesn't access the 1553 hardware, or accesses the hardware in a very simple manner. If that succeeds, then you know that you can access the DLL. Once you know you can access the DLL then you can work on getting the rest of the DLL functions to work in Python.","Q_Score":3,"Tags":"python","A_Id":3120074,"CreationDate":"2010-06-25T14:59:00.000","Title":"Tips on Python MIL-STD-1553","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"Are there any equivalents in objective-c to the following python urllib2 functions?\nRequest, urlopen, HTTPError, HTTPCookieProRequest, urlopen, HTTPError, HTTPCookieProcessor\nAlso, how would I able to to this and change the method from \"get\" to \"post\"?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":632,"Q_Id":3120430,"Users Score":1,"Answer":"NSMutableHTTPURLRequest, a category of NSMutableURLRequest, is how you set up an HTTP request.  Using that class you will specify a method (GET or POST), headers and a url.\nNSURLConnection is how you open the connection.  You will pass in a request and delegate, and the delegate will receive data, errors and messages related to the connection as they become available.\nNSHTTPCookieStorage is how you manage existing cookies.  There are a number of related classes in the NSHTTPCookie family.\nWith urlopen, you open a connection and read from it.  There is no direct equivalent to that unless you use something lower level like CFReadStreamCreateForHTTPRequest.  In Objective-C everything is passive, where you are notified when events occur on the stream.","Q_Score":0,"Tags":"python,objective-c","A_Id":3120602,"CreationDate":"2010-06-25T18:23:00.000","Title":"Is there an Objective-C equivalent to Python urllib and urllib2?","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},{"Question":"I'm planning some Symbian related development on S60 3.1 platform. It seems like generally available language options are Python and C++. However Nokia's official forum seems very much tilted towards C++.\nI want to know what are the advantages and disadvantages of using Python for S60 over Symbian C++? And is it even possible to do Python programming for S60 3.1 platform?","AnswerCount":6,"Available Count":3,"Score":0.0333209931,"is_accepted":false,"ViewCount":1021,"Q_Id":3123340,"Users Score":1,"Answer":"C++ is very, very fast, and the Qt library is for C++. If you're programming on a mobile phone, Python will be very slow and you'll have to spend ages writing bindings for it.","Q_Score":1,"Tags":"c++,python,symbian,pys60","A_Id":3123427,"CreationDate":"2010-06-26T09:15:00.000","Title":"PyS60 vs Symbian 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":0,"Web Development":0},{"Question":"I'm planning some Symbian related development on S60 3.1 platform. It seems like generally available language options are Python and C++. However Nokia's official forum seems very much tilted towards C++.\nI want to know what are the advantages and disadvantages of using Python for S60 over Symbian C++? And is it even possible to do Python programming for S60 3.1 platform?","AnswerCount":6,"Available Count":3,"Score":0.0333209931,"is_accepted":false,"ViewCount":1021,"Q_Id":3123340,"Users Score":1,"Answer":"I answer this as a user.\nPyS60 is slow and not so much app and sample to start with.\nC++ is good, native, fast, but if you mind deevelop app for most device (current N-series), you will not want to go with Qt, I have a N78 and tested Qt in N82 too, it's slow (more than Python, sadly but true)","Q_Score":1,"Tags":"c++,python,symbian,pys60","A_Id":3124371,"CreationDate":"2010-06-26T09:15:00.000","Title":"PyS60 vs Symbian 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":0,"Web Development":0},{"Question":"I'm planning some Symbian related development on S60 3.1 platform. It seems like generally available language options are Python and C++. However Nokia's official forum seems very much tilted towards C++.\nI want to know what are the advantages and disadvantages of using Python for S60 over Symbian C++? And is it even possible to do Python programming for S60 3.1 platform?","AnswerCount":6,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":1021,"Q_Id":3123340,"Users Score":0,"Answer":"What is the purpose of your programming? Are you planning distribute your app through Ovi Store? If so, you should use a tool that could be tested and signed by Symbian Signed. \nWhat does it mean? As far as I know, they don't provide such functionality for Python. So you have to choose native Symbian C++ or Qt. \nBy the way, Qt signing procedure is not quite clear for now. It seems Ovi Store and Symbian Signed are only allow Qt apps for a certain devices (Nokia X6, Nokia N97 mini, maybe some other). I suppose it is a subject for a change, and quite fast change, but you should consider this too.","Q_Score":1,"Tags":"c++,python,symbian,pys60","A_Id":3131900,"CreationDate":"2010-06-26T09:15:00.000","Title":"PyS60 vs Symbian 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":0,"Web Development":0},{"Question":"I have a somewhat unique request. What I am looking to do is listen on a specific port for all traffic coming through via IRC protocol. I then want to log all of those messages\/commands\/ect. I do not, however, want to join the channel. I just want to listen and log. Is there an easy built in way to do this? I have been looking at the irc.IRC and irc.IRCClient classes in twisted but they both seem too high level to do this. Is the only way to do this to simply descend to the base Server class, or can I still leverage some of the higher level functionality of twisted?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":617,"Q_Id":3128025,"Users Score":0,"Answer":"I don't think you can do this if you just connect to a server... the servers don't send you messages for channels you haven't joined.  Or are you the host of the server?","Q_Score":0,"Tags":"python,twisted,logging,irc","A_Id":3128285,"CreationDate":"2010-06-27T16:41:00.000","Title":"How to Log All IRC data on Channel Using Twisted?","Data Science and Machine Learning":0,"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},{"Question":"I have a somewhat unique request. What I am looking to do is listen on a specific port for all traffic coming through via IRC protocol. I then want to log all of those messages\/commands\/ect. I do not, however, want to join the channel. I just want to listen and log. Is there an easy built in way to do this? I have been looking at the irc.IRC and irc.IRCClient classes in twisted but they both seem too high level to do this. Is the only way to do this to simply descend to the base Server class, or can I still leverage some of the higher level functionality of twisted?","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":617,"Q_Id":3128025,"Users Score":1,"Answer":"We addressed this issue in a somewhat round about way. We worked off a generic hexdumping proxy server constructed in twisted and then created finer detail parsing algorithms off of that.","Q_Score":0,"Tags":"python,twisted,logging,irc","A_Id":5207277,"CreationDate":"2010-06-27T16:41:00.000","Title":"How to Log All IRC data on Channel Using Twisted?","Data Science and Machine Learning":0,"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},{"Question":"We all knows that C# is a static language while Python is a dynamic language. But I want to know what are the features that Python has and c# does not. Also, is it advisable\/beneficial to use IronPython with c# in the same application? \nAlso what points I should focus to learn before I try to convince my boss to use IronPython?","AnswerCount":2,"Available Count":2,"Score":1.0,"is_accepted":false,"ViewCount":995,"Q_Id":3131703,"Users Score":7,"Answer":"One of IronPython's key advantages is in its function as an extensibility layer to application frameworks written in a .NET language. It is relatively simple to integrate an IronPython interpreter into an existing .NET application framework. Once in place, downstream developers can use scripts written in IronPython that interact with .NET objects in the framework, thereby extending the functionality in the framework's interface, without having to change any of the framework's code base.\nIronPython makes extensive use of reflection. When passed in a reference to a .NET object, it will automatically import the types and methods available to that object. This results in a highly intuitive experience when working with .NET objects from within an IronPython script.\nSource - Wikipedia","Q_Score":2,"Tags":"c#,architecture,ironpython","A_Id":3131716,"CreationDate":"2010-06-28T10:46:00.000","Title":"Why should C# developer learn 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},{"Question":"We all knows that C# is a static language while Python is a dynamic language. But I want to know what are the features that Python has and c# does not. Also, is it advisable\/beneficial to use IronPython with c# in the same application? \nAlso what points I should focus to learn before I try to convince my boss to use IronPython?","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":995,"Q_Id":3131703,"Users Score":7,"Answer":"In other words, what points I can give to my boss to convince him to use IronPython?\n\nDon't. If you don't know why you should use a new tool and for what, don't try to convice anybody to use it. At work, you should try to solve problems with the best tools for the task, not throw the fanciest tools avaiable at your problems just because they're fancy.\nLearn IronPython, maybe make a small side project in it, find out what the strenghts are. Then if you think these strengths are useful for the project you're working on (e.g. for \"glue code\", plugins, macros etc.), convice your boss to use them.","Q_Score":2,"Tags":"c#,architecture,ironpython","A_Id":3131741,"CreationDate":"2010-06-28T10:46:00.000","Title":"Why should C# developer learn 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},{"Question":"I've been playing mostly with PHP and Python.\nI've been reading about Interfaces in OO programming and can't see an advantage in using it.\nMultiple objects can implement the same interface, but multiple inheritance doesn't provide this as well?\nWhy do I need to create an Interface \"with no implementation\" - mainly a \"contract\" - if I can just check if a method exists in an object in Python, that inherits from multiple classes?\nDo Interfaces were created in another languages because they don't provide multiple inheritance? Or am I missing something more important here?","AnswerCount":9,"Available Count":3,"Score":1.0,"is_accepted":false,"ViewCount":1276,"Q_Id":3134531,"Users Score":13,"Answer":"First, and foremost, try not to compare and contrast between Python and Java.  They are different languages, with different semantics.  Compare and contrast will only lead to confusing questions like this where you're trying to compare something Python doesn't use with something Java requires.  \nIt's a lot like comparing the number 7 and the color green.  They're both nouns.  Beyond that, you're going to have trouble comparing the two.\nHere's the bottom line.\nPython does not need interfaces.\nJava requires them.\n\nMultiple objects can implement the same interface, but multiple inheritance doesn't provide this as well?\n\nThe two concepts have almost nothing to do with each other.\nI can define a large number of classes which share a common interface.  In Python, because of \"duck typing\", I don't have to carefully be sure they all have a common superclass.\nAn interface is a declaration of \"intent\" for disjoint class hierarchies.  It provides a common specification (that can be checked by the compiler) that is not part of the simple class hierarchy.  It allows multiple class hierarchies to implement some common features and be polymorphic with respect to those features.\nIn Python you can use multiple inheritance with our without interfaces.  Multiple inheritance can include interface classes or not include interface classes.  \nJava doesn't even have multiple inheritance.  Instead it uses a completely different technique called \"mixins\".\n\nWhy do I need to create an Interface \"with no implementation\" - mainly a \"contract\" - if I can just check if a method exists in an object in Python, that inherits from multiple classes?\n\nIf you create an interface in Python, it can be a kind of formal contract.  A claim that all subclasses will absolutely do what the interface claims.\nOf course, a numbskull is perfectly free to lie.  They can inherit from an interface and mis-implement everything.  Nothing prevents bad behavior from sociopaths.\nYou create an interface in Java to allow multiple classes of objects to have a common behavior.  Since you don't tell the compiler much in Python, the concept doesn't even apply.\n\nDo Interfaces were created in another languages because they don't provide multiple inheritance? \n\nSince the concepts aren't related, it's hard to answer this.\nIn Java, they do use \"mixin\" instead of multiple inheritance.  The \"interface\" allows some mixing-in of additional functionality.  That's one use for an interface.\nAnother use of an Interface to separate \"is\" from \"does\".  The class hierarchy defines what an objects IS.  The interface hierarchy defines what a class DOES.\nIn most cases, IS and DOES are isomorphic, so there's no distinction.\nIn some cases, what an  object IS and what an object DOES are different.","Q_Score":9,"Tags":"php,python,oop,interface","A_Id":3134623,"CreationDate":"2010-06-28T17:12:00.000","Title":"Are Interfaces just \"Syntactic Sugar\"?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've been playing mostly with PHP and Python.\nI've been reading about Interfaces in OO programming and can't see an advantage in using it.\nMultiple objects can implement the same interface, but multiple inheritance doesn't provide this as well?\nWhy do I need to create an Interface \"with no implementation\" - mainly a \"contract\" - if I can just check if a method exists in an object in Python, that inherits from multiple classes?\nDo Interfaces were created in another languages because they don't provide multiple inheritance? Or am I missing something more important here?","AnswerCount":9,"Available Count":3,"Score":0.1106561105,"is_accepted":false,"ViewCount":1276,"Q_Id":3134531,"Users Score":5,"Answer":"Even in duck-typed languages like Python, an interface can be a clearer statement of your intent.  If you have a number of implementations, and they share a set of methods, an interface can be a good way to document the external behavior of those methods, give the concept a name, and make the concept concrete.\nWithout the explicit interface, there's an important concept in your system that has no physical representation.  This doesn't mean you have to use interfaces, but interfaces provide that concreteness.","Q_Score":9,"Tags":"php,python,oop,interface","A_Id":3134569,"CreationDate":"2010-06-28T17:12:00.000","Title":"Are Interfaces just \"Syntactic Sugar\"?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've been playing mostly with PHP and Python.\nI've been reading about Interfaces in OO programming and can't see an advantage in using it.\nMultiple objects can implement the same interface, but multiple inheritance doesn't provide this as well?\nWhy do I need to create an Interface \"with no implementation\" - mainly a \"contract\" - if I can just check if a method exists in an object in Python, that inherits from multiple classes?\nDo Interfaces were created in another languages because they don't provide multiple inheritance? Or am I missing something more important here?","AnswerCount":9,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":1276,"Q_Id":3134531,"Users Score":0,"Answer":"It's generally implemented to replace multiple inheritance (C#). \nI think some languages\/programmers use them as a way of enforcing requirements for object structure as well.","Q_Score":9,"Tags":"php,python,oop,interface","A_Id":3134554,"CreationDate":"2010-06-28T17:12:00.000","Title":"Are Interfaces just \"Syntactic Sugar\"?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm looking for a way to implement SSH Dynamic Port Forwarding ('ssh -D') under Python. The problem is that it has to work under Windows, i.e., running SSH with popen\/pexec\/etc. won't work. Any ideas?\ncheers,\nBruno Nery.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":1634,"Q_Id":3141063,"Users Score":1,"Answer":"There are ssh executables for Windows, so you can uses the subprocess.Popen approach. This is not exactly elegant, a pure Python approach would be better.","Q_Score":4,"Tags":"python,windows,ssh,tunneling,ssh-tunnel","A_Id":3141104,"CreationDate":"2010-06-29T13:28:00.000","Title":"SSH Dynamic Port Forwarding ('ssh -D') 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},{"Question":"I'm lucky enough to have full control over the architecture of my company's app, and I've decided to scrap our prototype written in Ruby\/Rails and start afresh in Python. This is for a few reasons: I want to learn Python, I prefer the syntax and I've basically said \"F**k it, let's do it.\"\nSo, baring in mind this is going to be a pretty intensive app, I'd like to hear your opinions on the following:\n\nGeneric web frameworks\nORM\/Database Layer (perhaps to work with MongoDB)\nRESTful API w\/ oAuth\/xAuth authentication\nTesting\/BDD support\nMessage queue (I'd like to keep this in Python if possible)\n\nThe API is going to need to interface with a Clojure app to handle some internal data stuff, and interface with the message queue, so if it's not Python it'd be great to have some libraries to it.\nTDD\/BDD is very important to me, so the more tested, the better!\nIt'll be really interesting to read your thoughts on this. Much appreciated.\nMy best,\nJamie","AnswerCount":4,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":4392,"Q_Id":3143115,"Users Score":4,"Answer":"I'm new to python myself, and plan to get more in depth with it this year. I've had a few false starts at this, but always professional needs bring me back to PHP. The few times I've done some development, I've had really good experiences with web2py as a python framework. It's quite well done, and complete in features, while still being extremely lightweight. The database layer seems to be very flexible and mature. \nAs for TDD\/BDD and the rest of your questions, I don't have any experience with python options, but would be interested to hear what others say.","Q_Score":20,"Tags":"python,orm,rest,frameworks","A_Id":3143591,"CreationDate":"2010-06-29T17:18:00.000","Title":"Architecting from scratch in Python: what 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":1},{"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},{"Question":"Is it possible to use Python (specifically Pygments) with PHP? Currently, I have a phpBB forum that I'm developing for and JS Syntax Highlighters just haven't been working for me. There's already a GeSHI mod, but I want to develop something myself just for experience.\nAlso, would there be performance issues?","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":2098,"Q_Id":3153961,"Users Score":0,"Answer":"If you're interested in diving into Python, you could write an external script or server application to update new posts with syntax-highlighted code.  If it were me, I'd retain the original code in one database column and place the syntax-highlighted version in another.\nA simple script to update new posts in batches could run as a cron job at whatever interval you find ideal.\nTo support a near real-time scenario, you could write a server application that sits and waits to be notified of new posts one at a time.  For example, upon processing a new post, the PHP application could send the highlighting application a message through an AMQP queue.","Q_Score":1,"Tags":"php,python,phpbb,pygments","A_Id":5054521,"CreationDate":"2010-06-30T22:46:00.000","Title":"Using Pygments with PHP (Python 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},{"Question":"Is it possible to use Python (specifically Pygments) with PHP? Currently, I have a phpBB forum that I'm developing for and JS Syntax Highlighters just haven't been working for me. There's already a GeSHI mod, but I want to develop something myself just for experience.\nAlso, would there be performance issues?","AnswerCount":3,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":2098,"Q_Id":3153961,"Users Score":1,"Answer":"Pretty much the only way to perform that integration (with PHP as the dominant language) is to shell out.  This means starting python manually every time you need it.  \nThat can be a little slow if you need to do it a lot.  You can mitigate this by creating the syntax hilite when posts are created or edited, not when viewing.","Q_Score":1,"Tags":"php,python,phpbb,pygments","A_Id":3154550,"CreationDate":"2010-06-30T22:46:00.000","Title":"Using Pygments with PHP (Python 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},{"Question":"I wrote a function that copies the \/etc\/skel directory on a linux machine during a \"create new user\" RPC call. Now, there is quite a few things about this I want to test, for example the files in \/etc\/skel and the targets of symlinks should not have changed permissions afterwards, whereas the copied files including the actual symlinks should have a changed owner. Now, i can create my test directory and files using mkdtemp and stuff, but I can't chown those to another user without root privileges. How would you write a test for this?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":177,"Q_Id":3155748,"Users Score":2,"Answer":"You could make an object which does the chmod, and inject a mock when testing. This mock would not really do the chmod, but make it possible to test if it was called with the right parameters.","Q_Score":0,"Tags":"python,linux,testing","A_Id":3155835,"CreationDate":"2010-07-01T07:17:00.000","Title":"How to test a function that deals with setting file ownership without being root","Data Science and Machine Learning":0,"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},{"Question":"hi all, how you must configure Apache 2.2 or mod_python?, to avoid the following error:\nMOD_PYTHON ERROR\nProcessId:      5399\nInterpreter:    '127.0.1.1'\nServerName:     '127.0.1.1'\nDocumentRoot:   '\/var\/www'\nURI:            '\/cgi-bin\/wps\/'\nLocation:       None\nDirectory:      '\/usr\/lib\/cgi-bin\/'\nFilename:       '\/usr\/lib\/cgi-bin\/wps\/'\nPathInfo:       ''\nPhase:          'PythonHandler'\nHandler:        'pywps'\nTraceback (most recent call last):\n  File \"\/usr\/lib\/python2.6\/dist-packages\/mod_python\/importer.py\", line 1537, in HandlerDispatch\n    default=default_handler, arg=req, silent=hlist.silent)\n  File \"\/usr\/lib\/python2.6\/dist-packages\/mod_python\/importer.py\", line 1206, in _process_target\n    object = apache.resolve_object(module, object_str, arg, silent=silent)\n  File \"\/usr\/lib\/python2.6\/dist-packages\/mod_python\/apache.py\", line 696, in resolve_object\n    raise AttributeError, s\nAttributeError: module '\/usr\/local\/lib\/python2.6\/dist-packages\/pywps\/init.pyc' contains no 'handler'\nthis is for a configuration (ubuntu (10.4)) for AMD64.\nthanks for your answers","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1196,"Q_Id":3168963,"Users Score":0,"Answer":"In my case, changing \n\nPythonHandler pywps\n\nto \n\nPythonHandler wps\n\nin the .htaccess (or the apache configuration file) fixed the problem. \nI think that the file pywps.py has been renamed to wps.py, and this gives problems, since the sample configuration file has been left with the old name.","Q_Score":0,"Tags":"python,apache2,mod-python,ubuntu-10.04","A_Id":11032693,"CreationDate":"2010-07-02T20:34:00.000","Title":"correct configuration for apache and mod_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},{"Question":"I have to develop an application where I need to send SMS to the users on a particular action by the users. \nI have heard of kannel with PHP, is there some help for the same in Python as well or is there any other better open source sms gateway which I can use with my application? \nPlease suggest.\nThanks in advance.","AnswerCount":6,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":4227,"Q_Id":3172291,"Users Score":3,"Answer":"Typically you would use normal HTTP GET or POST requests against an SMS Gateway, such as Clickatell and many many others.","Q_Score":5,"Tags":"python,django,sms","A_Id":3172331,"CreationDate":"2010-07-03T17:47:00.000","Title":"How to send SMS using Python\/Django 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},{"Question":"What would be the best way to execute shell commands on remote servers and get output without actually logging in. \nMaybe with shh keys. Preferably with python.","AnswerCount":4,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":15038,"Q_Id":3173977,"Users Score":0,"Answer":"Paramiko is really good and convenient for transferring files and executing commands in remote server. \nBut, the problem is that we won't be able to catch the output of the command. It will be difficult to understand whether the command executed properly or not.","Q_Score":4,"Tags":"python","A_Id":17816896,"CreationDate":"2010-07-04T07:02:00.000","Title":"Remote server command execute","Data Science and Machine Learning":0,"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},{"Question":"I want my Python script to access a URL through an IP specified in the script instead of through the default DNS for the domain. Basically I want the equivalent of adding an entry to my \/etc\/hosts file, but I want the change to apply only to my script instead of globally on the whole server.  Any ideas?","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":911,"Q_Id":3183617,"Users Score":2,"Answer":"Whether this works or not will depend on whether the far end site is using HTTP\/1.1 named-based virtual hosting or not.\nIf they're not, you can simply replace the hostname part of the URL with their IP address, per @Greg's answer.\nIf they are, however, you have to ensure that the correct Host: header is sent as part of the HTTP request.  Without that, a virtual hosting web server won't know which site's content to give you.  Refer to your HTTP client API (Curl?) to see if you can add or change default request headers.","Q_Score":2,"Tags":"python,dns,urllib,hosts","A_Id":3184895,"CreationDate":"2010-07-06T05:08:00.000","Title":"Alternate host\/IP for 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},{"Question":"I want my Python script to access a URL through an IP specified in the script instead of through the default DNS for the domain. Basically I want the equivalent of adding an entry to my \/etc\/hosts file, but I want the change to apply only to my script instead of globally on the whole server.  Any ideas?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":911,"Q_Id":3183617,"Users Score":0,"Answer":"You can use an explicit IP number to connect to a specific machine by embedding that into the URL: http:\/\/127.0.0.1\/index.html is equivalent to http:\/\/localhost\/index.html \nThat said, it isn't a good idea to use IP numbers instead of DNS entries. IPs change a lot more often than DNS entries, meaning your script has a greater chance of breaking if you hard-code the address instead of letting it resolve normally.","Q_Score":2,"Tags":"python,dns,urllib,hosts","A_Id":3183666,"CreationDate":"2010-07-06T05:08:00.000","Title":"Alternate host\/IP for 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},{"Question":"I've written a python script which does some curses and pysqlite stuff, but I've noticed that in occasions where I've been running this script over ssh when that ssh session is killed for whatever reason the python script doesn't actually exit, instead it ends up as being a child of init and just stays there forever. I can't kill -9 them or anything. They also increase the reported system load by 1. Currently I have 8 of these mostly dead processes hanging around, and the server has a load average of 8.abit. I take it this is because there is some sort of resource that these scripts are waiting on, but lsof shows nothing actually open by them, all data files they were using are listed as deleted etc... and they are using no cpu time whatsoever.\nI'm doing some signal checking in the script, calling out to do some refresh routines on a HUP, but nothing else, not forking or anything and I'm at a loss as to why the scripts are not just shuffling off when I close my ssh session.\nThanks  Chris","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":281,"Q_Id":3184974,"Users Score":1,"Answer":"Well, the reason they're not shutting down when your ssh session terminates is because HUP is the signal used by a parent to inform its children that they should shut down. If you're overriding the behavior of this signal, then your processes will not automatically shut down when the SSH session is closed. As for why you cannot kill -9 them, however, I'm at a loss. The only thing I've seen that causes that behavior is processes blocked on misbehaving filesystems (nfs & unionfs being the two I've encountered the problem with).","Q_Score":0,"Tags":"python,ssh,exit,signals","A_Id":3186685,"CreationDate":"2010-07-06T09:20:00.000","Title":"Python scripts (curses + pysqlite) hanging after parent shell goes away","Data Science and Machine Learning":0,"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},{"Question":"Is it possible to write a firewall in python? Say it would block all traffic?","AnswerCount":6,"Available Count":4,"Score":0.0996679946,"is_accepted":false,"ViewCount":31230,"Q_Id":3189138,"Users Score":3,"Answer":"I'm sure it's probably possible, but ill-advised.  As mcandre mentions, most OSes couple the low level networking capabilities you need for a firewall tightly into the kernel and thus this task is usually done in C\/C++ and integrates tightly with the kernel.  The microkernel OSes (Mach et al) might be more amenable than linux. You may be able to mix some python and C, but I think the more interesting discussion here is going to be around \"why should I\"\/\"why shouldn't I\" implement a firewall in python as opposed to just is it technically possible.","Q_Score":13,"Tags":"python,firewall","A_Id":3189187,"CreationDate":"2010-07-06T18:34:00.000","Title":"Is it possible to write a firewall 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},{"Question":"Is it possible to write a firewall in python? Say it would block all traffic?","AnswerCount":6,"Available Count":4,"Score":0.0665680765,"is_accepted":false,"ViewCount":31230,"Q_Id":3189138,"Users Score":2,"Answer":"\"Yes\" - that's usually the answer to \"is it possible...?\" questions.\nHow difficult and specific implementations are something else entirely. I suppose technically in a don't do this sort of way, if you were hell-bent on making a quick firewall in Python, you could use the socket libraries and open connections to and from yourself on every port. I have no clue how effective that would be, though it seems like it wouldn't be. Of course, if you're simply interested in rolling your own, and doing this as a learning experience, then cool, you have a long road ahead of you and plenty of education.\nOTOH, if you're actually worried about network security there are tons of other products out there that you can use, from iptables on *nix, to ZoneAlarm on windows. Plenty of them are both free and secure so there's really no reason to roll your own except on an \"I want to learn\" basis.","Q_Score":13,"Tags":"python,firewall","A_Id":3189232,"CreationDate":"2010-07-06T18:34:00.000","Title":"Is it possible to write a firewall 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},{"Question":"Is it possible to write a firewall in python? Say it would block all traffic?","AnswerCount":6,"Available Count":4,"Score":0.1325487884,"is_accepted":false,"ViewCount":31230,"Q_Id":3189138,"Users Score":4,"Answer":"I'm sure in theory you could achieve what you want, but I believe in practice your idea is not doable (if you wonder why, it's because it's too hard to \"interface\" a high level language with the low level kernel).\nWhat you could do instead is some Python tool that controls the firewall of the operating system so you could add rules, delete , etc. (in a similar way to what iptables does in Linux).","Q_Score":13,"Tags":"python,firewall","A_Id":3189540,"CreationDate":"2010-07-06T18:34:00.000","Title":"Is it possible to write a firewall 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},{"Question":"Is it possible to write a firewall in python? Say it would block all traffic?","AnswerCount":6,"Available Count":4,"Score":0.0996679946,"is_accepted":false,"ViewCount":31230,"Q_Id":3189138,"Users Score":3,"Answer":"Interesting thread.  I stumbled on it looking for Python NFQUEUE examples.\nMy take is you could create a great firewall in python and use the kernel.\nE.g.\nAdd a linux fw rule through IP tables that forward sys packets (the first) to NFQUEUE for python FW to decide what to do.\nIf you like it mark the tcp stream\/flow with a FW mark using NFQUEUE and then have an iptables rule that just allows all traffic streams with the mark.\nThis way you can have a powerful high-level python program deciding to allow or deny traffic, and the speed of the kernel to forward all other packets in the same flow.","Q_Score":13,"Tags":"python,firewall","A_Id":15045900,"CreationDate":"2010-07-06T18:34:00.000","Title":"Is it possible to write a firewall 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},{"Question":"Are there any downsides in Python to using a library that is just a binding to a C library? Does that hurt the portability of your application? Anything else I should look out for?","AnswerCount":3,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":146,"Q_Id":3190013,"Users Score":0,"Answer":"Portability is one thing. There are even differences between python 2.x and 3.x that can make things difficult with C extensions, if the writer didn't update them.\nAnother thing is that pure python code gives you a bit more possibilities to read, understand and even modify (although it is usually a bad sign if you need to do that for other peoples modules)","Q_Score":1,"Tags":"python","A_Id":3190568,"CreationDate":"2010-07-06T20:35:00.000","Title":"What are the pros and cons in Python of using a c library vs a native python one","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},{"Question":"Are there any downsides in Python to using a library that is just a binding to a C library? Does that hurt the portability of your application? Anything else I should look out for?","AnswerCount":3,"Available Count":3,"Score":0.2605204458,"is_accepted":false,"ViewCount":146,"Q_Id":3190013,"Users Score":4,"Answer":"C library is likely to have better performance, but needs to be recompiled for each platform.\nYou can't use C libraries on Google App Engine","Q_Score":1,"Tags":"python","A_Id":3190053,"CreationDate":"2010-07-06T20:35:00.000","Title":"What are the pros and cons in Python of using a c library vs a native python one","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},{"Question":"Are there any downsides in Python to using a library that is just a binding to a C library? Does that hurt the portability of your application? Anything else I should look out for?","AnswerCount":3,"Available Count":3,"Score":1.2,"is_accepted":true,"ViewCount":146,"Q_Id":3190013,"Users Score":4,"Answer":"Of course using a C library hurts portability. It also prohibites you (in general) to use Jython or IronPython. I would only use a C library if I had no other option. This could happen if direct access to hardware is necessary or if special efficiency requirements apply.","Q_Score":1,"Tags":"python","A_Id":3190035,"CreationDate":"2010-07-06T20:35:00.000","Title":"What are the pros and cons in Python of using a c library vs a native python one","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},{"Question":"I am looking for a good scripting language to link to my program.\nI am looking for 2 important attributes:\n\nScripting language should be hard linked into the executable (not requiring 3rd party \ninstallations). This is important to me to simplify distribution.\nScripting should allow some run-time debugging option (When running a script inside my program I would like to easily run it inside a debugger while it is running in the context of my program)\n\nCan python,lua or some other language supply me with this?","AnswerCount":7,"Available Count":3,"Score":1.0,"is_accepted":false,"ViewCount":932,"Q_Id":3193012,"Users Score":13,"Answer":"Both Lua and Python can provide the features you mention, so choosing one of them will depend on other criteria.\nLua is a lighter weight solution, it will have a much smaller disk footprint and likely a smaller memory overhead than Python too. For some uses it may be faster. Python has a much richer standard library, more mature third party libraries and a more expressive language.\nBoth have been embedded into major applications. Python can be found in Blender, OpenOffice and Civilization 4. Lua can be found in World of Warcraft and Adobe Lightroom. I'd recommend looking at a few tutorials for each and the facilities available to embed them in your application and just choose the one that fits your brain best.","Q_Score":7,"Tags":"python,programming-languages,scripting,lua,dynamic-languages","A_Id":3193910,"CreationDate":"2010-07-07T08:18:00.000","Title":"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":1,"Web Development":0},{"Question":"I am looking for a good scripting language to link to my program.\nI am looking for 2 important attributes:\n\nScripting language should be hard linked into the executable (not requiring 3rd party \ninstallations). This is important to me to simplify distribution.\nScripting should allow some run-time debugging option (When running a script inside my program I would like to easily run it inside a debugger while it is running in the context of my program)\n\nCan python,lua or some other language supply me with this?","AnswerCount":7,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":932,"Q_Id":3193012,"Users Score":0,"Answer":"I'll add Tcl to the mix. It's designed to be easily embedded into other programs.","Q_Score":7,"Tags":"python,programming-languages,scripting,lua,dynamic-languages","A_Id":3217793,"CreationDate":"2010-07-07T08:18:00.000","Title":"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":1,"Web Development":0},{"Question":"I am looking for a good scripting language to link to my program.\nI am looking for 2 important attributes:\n\nScripting language should be hard linked into the executable (not requiring 3rd party \ninstallations). This is important to me to simplify distribution.\nScripting should allow some run-time debugging option (When running a script inside my program I would like to easily run it inside a debugger while it is running in the context of my program)\n\nCan python,lua or some other language supply me with this?","AnswerCount":7,"Available Count":3,"Score":0.0285636566,"is_accepted":false,"ViewCount":932,"Q_Id":3193012,"Users Score":1,"Answer":"I really like Lua for embedding, but just as another alternative, JavaScript is easily embeddable in C, C++ (SpiderMonkey and V8) and Java (Rhino) programs.","Q_Score":7,"Tags":"python,programming-languages,scripting,lua,dynamic-languages","A_Id":3195618,"CreationDate":"2010-07-07T08:18:00.000","Title":"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":1,"Web Development":0},{"Question":"I know Python apps are faster to write, but it seems Java is the 800 lb gorilla for mobile and  GUI development.\nAre there any mobile platforms that run Python, or should I go the Java route?","AnswerCount":3,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":5062,"Q_Id":3198646,"Users Score":2,"Answer":"Java is certainly available on more platforms.  I would pick a target platform (or set of targets) and see what language(s) would require the least number of redundant implementations. \nAlso, when you get to a certain level of complexity, the language often doesn't factor into speed.  For initial prototypes, sure some languages are lightning fast to develop in, but by the time you've taken care of all the exception cases and tripled the entire schedule due to QA, you'll find that the prototype development speed wasn't all that big a deal.\nOf course, depending on the complexity of your app, this may prove to be untrue--a small simple app can be delivered in near \"prototype time\".","Q_Score":0,"Tags":"java,python,user-interface,mobile","A_Id":3198745,"CreationDate":"2010-07-07T20:45:00.000","Title":"Python or Java? Whats better for mobile development, and GUI 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":0,"Web Development":1},{"Question":"I know Python apps are faster to write, but it seems Java is the 800 lb gorilla for mobile and  GUI development.\nAre there any mobile platforms that run Python, or should I go the Java route?","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":5062,"Q_Id":3198646,"Users Score":0,"Answer":"The first question is whether you really need to develop an app, which requires per-platform work, vs a webapp.\nIf you really need an app, then you might likely need a separate language for each platform! For Android you'd want to use Java, and for iPhone\/iPad you'd want to use Objective-C. A good argument for really trying to go the webapp route.","Q_Score":0,"Tags":"java,python,user-interface,mobile","A_Id":3199234,"CreationDate":"2010-07-07T20:45:00.000","Title":"Python or Java? Whats better for mobile development, and GUI 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":0,"Web Development":1},{"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},{"Question":"Assuming that x is an integer, the construct if x: is functionally the same as if x != 0: in Python. Some languages' style guides explicitly forbid against the former -- for example, ActionScript\/Flex's style guide states that you should never implicitly cast an int to bool for this sort of thing.\nDoes Python have a preference? A link to a PEP or other authoritative source would be best.","AnswerCount":7,"Available Count":4,"Score":0.0,"is_accepted":false,"ViewCount":6685,"Q_Id":3216681,"Users Score":0,"Answer":"Might I suggest that the amount of bickering over this question is enough to answer it?\nSome argue that it \"if x\" should only be used for Z, others for Y, others for X.\nIf such a simple statement is able to create such a fuss, to me it is clear that the statement is not clear enough.  Write what you mean.\nIf you want to check that x is equal to 0, then write \"if x == 0\".  If you want to check if x exists, write \"if x is not None\".\nThen there is no confusion, no arguing, no debate.","Q_Score":5,"Tags":"python,coding-style,conditional","A_Id":3232563,"CreationDate":"2010-07-09T21:28:00.000","Title":"Which of `if x:` or `if x != 0:` is preferred 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},{"Question":"Assuming that x is an integer, the construct if x: is functionally the same as if x != 0: in Python. Some languages' style guides explicitly forbid against the former -- for example, ActionScript\/Flex's style guide states that you should never implicitly cast an int to bool for this sort of thing.\nDoes Python have a preference? A link to a PEP or other authoritative source would be best.","AnswerCount":7,"Available Count":4,"Score":0.0855049882,"is_accepted":false,"ViewCount":6685,"Q_Id":3216681,"Users Score":3,"Answer":"There's no hard and fast rule here.  Here are some examples where I would use each:\nSuppose that I'm interfacing to some function that returns -1 on error and 0 on success.  Such functions are pretty common in C, and they crop up in Python frequently when using a library that wraps C functions.  In that case, I'd use if x:.\nOn the other hand, if I'm about to divide by x and I want to make sure that x isn't 0, then I'm going to be explicit and write if x != 0.\nAs a rough rule of thumb, if I treat x as a bool throughout a function, then I'm likely to use if x: -- even if I can prove that x will be an int.  If in the future I decide I want to pass a bool (or some other type!) to the function, I wouldn't need to modify it.\nOn the other hand, if I'm genuinely using x like an int, then I'm likely to spell out the 0.","Q_Score":5,"Tags":"python,coding-style,conditional","A_Id":3216964,"CreationDate":"2010-07-09T21:28:00.000","Title":"Which of `if x:` or `if x != 0:` is preferred 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},{"Question":"Assuming that x is an integer, the construct if x: is functionally the same as if x != 0: in Python. Some languages' style guides explicitly forbid against the former -- for example, ActionScript\/Flex's style guide states that you should never implicitly cast an int to bool for this sort of thing.\nDoes Python have a preference? A link to a PEP or other authoritative source would be best.","AnswerCount":7,"Available Count":4,"Score":-0.057080742,"is_accepted":false,"ViewCount":6685,"Q_Id":3216681,"Users Score":-2,"Answer":"Wouldn't if x is not 0: be the preferred method in Python, compared to if x != 0:?\nYes, the former is a bit longer to write, but I was under the impression that is and is not are preferred over == and !=. This makes Python easier to read as a natural language than as a programming language.","Q_Score":5,"Tags":"python,coding-style,conditional","A_Id":3216911,"CreationDate":"2010-07-09T21:28:00.000","Title":"Which of `if x:` or `if x != 0:` is preferred 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},{"Question":"Assuming that x is an integer, the construct if x: is functionally the same as if x != 0: in Python. Some languages' style guides explicitly forbid against the former -- for example, ActionScript\/Flex's style guide states that you should never implicitly cast an int to bool for this sort of thing.\nDoes Python have a preference? A link to a PEP or other authoritative source would be best.","AnswerCount":7,"Available Count":4,"Score":0.057080742,"is_accepted":false,"ViewCount":6685,"Q_Id":3216681,"Users Score":2,"Answer":"Typically, I read: \nif(x) to be a question about existence. \nif( x != 0) to be a question about a number.","Q_Score":5,"Tags":"python,coding-style,conditional","A_Id":3216691,"CreationDate":"2010-07-09T21:28:00.000","Title":"Which of `if x:` or `if x != 0:` is preferred 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},{"Question":"Well just getting into the flow of thing with Python. Reading a few books, finding it fairly easy as I already have some experience with C++\/Java from school and Python is definetly my favorite thus far.\nAnyway, I am getting a whole bunch of information on python, but haven't been putting it to much use. Thus, what I was wondering was if there are any sort of practice problems online that I can use? If anyone could point me in any sort of direction, I'd greatly appreciate it.","AnswerCount":8,"Available Count":1,"Score":0.049958375,"is_accepted":false,"ViewCount":142555,"Q_Id":3217222,"Users Score":2,"Answer":"I found python in 1988 and fell in love with it.  Our group at work had been dissolved and we were looking for other jobs on site, so I had a couple of months to play around doing whatever I wanted to.  I spent the time profitably learning and using python.  I suggest you spend time thinking up and writing utilities and various useful tools.  I've got 200-300 in my python tools library now (can't even remember them all).  I learned python from Guido's tutorial, which is a good place to start (a C programmer will feel right at home).  \npython is also a great tool for making models -- physical, math, stochastic, etc.  Use numpy and scipy.  It also wouldn't hurt to learn some GUI stuff -- I picked up wxPython and learned it, as I had some experience using wxWidgets in C++.  wxPython has some impressive demo stuff!","Q_Score":43,"Tags":"python","A_Id":3217317,"CreationDate":"2010-07-10T00:00:00.000","Title":"Beginner Python Practice?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Lets say I am designing a tool foobuzzle (foobuzzle's exact job is to set up SRPM files for cross-compiling a variety of codes into their own compartmentalized prefix directories, but this is not important).  I would like foobuzzle to take in an input file (buzzle_input) specified by an (intelligent, code-savvy) client, who will tell foobuzzle how they would like it to perform these operations.\nI am writing foobuzzle in Python, and it seems to make sense for the user to provide buzzle_input configuration information in either Python or bash.  Which would you choose?  How would you implement it?  I am expecting that Python will need some global environment variables that may need to be set up by executing some other scripts, probably from within the buzzle_input script.\nThis is not production code, just an internal tool a small team of developers will be using to help manage a fairly large cross-compiled environment of C\/C++\/FORTRAN codes.\nMy best guess is to use something to wrap the foobuzzle script so that the $PYTHONPATH variable picks up the current working directory, and to have the foobuzzle_input script imported and executed as set up.  Is there a cleaner way to do this without wrapping foobuzzle?  Any special considerations for executing the bash scripts (assume safety is not really a concern and that these scripts will not be run with system administrator privileges).","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":276,"Q_Id":3218599,"Users Score":1,"Answer":"My interpretation of your context, is that you have a Python script that performs various make- or autoconf-like operations, and you want to allow clients to write their own Makefiles for Foobuzzle.\nThe problem with directories I don't understand. import will always search the local directory? And you can os.chdir() when you hop around to change current working directory, like make does.\nHaving it as a bash script has the pro that nobody needs to learn Python or, specifically, the Python-like Foobuzzle DSL. But it is a lot less powerful: you're basically limited to sending and receiving text only. You can't write support functions that the bash code can call (unless you generate that into bash as well), proper error handling might be tough, etc.\nDepending on how powerful the configuration needs to be, I would use Python. I'd probably load the file itself and use eval() on it, giving me full control over its namespace. I could pass various utility and helper functions, for example, or provide objects they can manipulate directly.\nIf it's really simple though, specifying flags and names, that sort of thing, then you could just have it as .ini files and use ConfigParser() in the standard library.","Q_Score":0,"Tags":"python,bash","A_Id":3218680,"CreationDate":"2010-07-10T09:10:00.000","Title":"How do I execute Python\/bash code in the current directory as part of a 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":1,"Web Development":0},{"Question":"Friends, \nI've got some exp in c++ and now kind of starting my way to J2EE (to survive:))). Meanwhile, I've got a plan to venture in to a web portal my own. But with very little experience in web technology, I'd need to start from scratch. I'm little confused on which way to go and I'm here. \nPHP, Python or JSP, considering the fact that, anyway I've got to learn J2EE at my work.\nWould that be worth to learn PHP or Python to develop a portal which I expect to get 80-100K \nhits per day \"IF\" everything goes well OR jsp would be sufficient? \nMany thanks","AnswerCount":7,"Available Count":6,"Score":0.0,"is_accepted":false,"ViewCount":1073,"Q_Id":3223557,"Users Score":0,"Answer":"I expect this question to be closed as being subjective.  But, I'll put in my 2 cents.\nJSP would likely dovetail well with J2EE.  (I've heard that it can be a bit rigid, but I have no experience to provide any insight on the matter.)\nPHP is a good candidate, because it's popular.  You can find a lot of info on the web.\nPython isn't as popular for webdev, so finding examples won't be as easy.\nI also second Dave Markle's opinion.  If you want to learn webdev, HTML, CSS and JavaScript will be crucial as well.  You may never want to be a front-end developer, but you can't get away from dealing with those technologies at some point.","Q_Score":5,"Tags":"php,python,jsp","A_Id":3223599,"CreationDate":"2010-07-11T15:28:00.000","Title":"Which web technology to learn for an experienced C++ developer?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"Friends, \nI've got some exp in c++ and now kind of starting my way to J2EE (to survive:))). Meanwhile, I've got a plan to venture in to a web portal my own. But with very little experience in web technology, I'd need to start from scratch. I'm little confused on which way to go and I'm here. \nPHP, Python or JSP, considering the fact that, anyway I've got to learn J2EE at my work.\nWould that be worth to learn PHP or Python to develop a portal which I expect to get 80-100K \nhits per day \"IF\" everything goes well OR jsp would be sufficient? \nMany thanks","AnswerCount":7,"Available Count":6,"Score":0.0285636566,"is_accepted":false,"ViewCount":1073,"Q_Id":3223557,"Users Score":1,"Answer":"Hit's per day isn't a really useful metric for estimating performance. You really need to be concerned with the peak load and the acceptable response time.\n80-100k hits per day is an average of about 1 hit per second. The hits are not going to be evenly spread out, so for normal traffic you might expect a peak load of 10 hits per second.\nIf you are going to promote the site with newsletters or commercials, expect to peack at 100's of hits per second.\nIf you selling $1 air tickets, expect to peak at 1000's of hits per second.\nNow the language you choose for the site isn't nearly as important as your choice of database (not necessarily relational) and the way you store the data in the database.\nScaling up frontends is relatively easy, so having really fast efficient HTML generation shouldn't be a primary concern. Pick a platform that is going to be efficient for development time.","Q_Score":5,"Tags":"php,python,jsp","A_Id":3225166,"CreationDate":"2010-07-11T15:28:00.000","Title":"Which web technology to learn for an experienced C++ developer?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"Friends, \nI've got some exp in c++ and now kind of starting my way to J2EE (to survive:))). Meanwhile, I've got a plan to venture in to a web portal my own. But with very little experience in web technology, I'd need to start from scratch. I'm little confused on which way to go and I'm here. \nPHP, Python or JSP, considering the fact that, anyway I've got to learn J2EE at my work.\nWould that be worth to learn PHP or Python to develop a portal which I expect to get 80-100K \nhits per day \"IF\" everything goes well OR jsp would be sufficient? \nMany thanks","AnswerCount":7,"Available Count":6,"Score":0.0285636566,"is_accepted":false,"ViewCount":1073,"Q_Id":3223557,"Users Score":1,"Answer":"Considering you're used to c++, should look at aspx and c# - probably closer to your current experience.\nThat said, PHP is a doddle, so it shouldn't present any challenges. Bear in mind that if you want to get the most from the language, you absolutely have to learn a little bit about configuring apache, and frameworks (cake, codeigniter, zend etc).","Q_Score":5,"Tags":"php,python,jsp","A_Id":3223588,"CreationDate":"2010-07-11T15:28:00.000","Title":"Which web technology to learn for an experienced C++ developer?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"Friends, \nI've got some exp in c++ and now kind of starting my way to J2EE (to survive:))). Meanwhile, I've got a plan to venture in to a web portal my own. But with very little experience in web technology, I'd need to start from scratch. I'm little confused on which way to go and I'm here. \nPHP, Python or JSP, considering the fact that, anyway I've got to learn J2EE at my work.\nWould that be worth to learn PHP or Python to develop a portal which I expect to get 80-100K \nhits per day \"IF\" everything goes well OR jsp would be sufficient? \nMany thanks","AnswerCount":7,"Available Count":6,"Score":1.2,"is_accepted":true,"ViewCount":1073,"Q_Id":3223557,"Users Score":13,"Answer":"Before learning either of these, spend some real time and learn HTML and CSS in depth.  Also learn Javascript and JQuery (or your favorite client side library).  The O'Reilly books on the topic are pretty much all good IMO.\nI say that because I think that you'll find that for most modern web sites, a lot of richness is moving to the client side, and away from the server side.  Under this model, your code in PHP or JSP is probably going to look pretty similar (ie, fetch data from the database and serve it to your view or into JSON for the client to consume).","Q_Score":5,"Tags":"php,python,jsp","A_Id":3223581,"CreationDate":"2010-07-11T15:28:00.000","Title":"Which web technology to learn for an experienced C++ developer?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"Friends, \nI've got some exp in c++ and now kind of starting my way to J2EE (to survive:))). Meanwhile, I've got a plan to venture in to a web portal my own. But with very little experience in web technology, I'd need to start from scratch. I'm little confused on which way to go and I'm here. \nPHP, Python or JSP, considering the fact that, anyway I've got to learn J2EE at my work.\nWould that be worth to learn PHP or Python to develop a portal which I expect to get 80-100K \nhits per day \"IF\" everything goes well OR jsp would be sufficient? \nMany thanks","AnswerCount":7,"Available Count":6,"Score":0.0,"is_accepted":false,"ViewCount":1073,"Q_Id":3223557,"Users Score":0,"Answer":"There are many options.\n\nSince you already know (and is learning about) Java, one option is to use GWT for both server and client. This can help you in that you do not need to learn another language (JS\/HTML\/Python\/PHP etc). If your portal is going to be big, using Java can help you organise the application better - usually JS\/HTML based applications are not very suitable for proper organisation, even if you use good JS Libraries like jQuery or YUI. Having a good organisation can help a lot - during updation and modification later. \nIf your planned venture is a single\/two person venture or if it is time bound - where time to market is everything - then I would not suggest the earlier approach - especially if your server side part is expected to be big. \nJava is a slow language to write code in. A project which you will take say 6 months to write in Python will take you close to 1 year + in Java. In such a scneario, I would prefer Python - it is a proper language - unlike PHP, and you create code with good organisation there too - albeit a little less organised than using Java. \nPlease note that if your client side code is much more complex than your server side code, then going with GWT will do you no harm. But if your server side code is very complex compared to the client side, then I would suggest Python.\nAnother point is to use existing Web Frameworks to ease your work. For Python, Django is an excellent choice. This itself will decrease your work time by 50% or more, while making your code much more secure and scalable.","Q_Score":5,"Tags":"php,python,jsp","A_Id":3223646,"CreationDate":"2010-07-11T15:28:00.000","Title":"Which web technology to learn for an experienced C++ developer?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"Friends, \nI've got some exp in c++ and now kind of starting my way to J2EE (to survive:))). Meanwhile, I've got a plan to venture in to a web portal my own. But with very little experience in web technology, I'd need to start from scratch. I'm little confused on which way to go and I'm here. \nPHP, Python or JSP, considering the fact that, anyway I've got to learn J2EE at my work.\nWould that be worth to learn PHP or Python to develop a portal which I expect to get 80-100K \nhits per day \"IF\" everything goes well OR jsp would be sufficient? \nMany thanks","AnswerCount":7,"Available Count":6,"Score":0.0,"is_accepted":false,"ViewCount":1073,"Q_Id":3223557,"Users Score":0,"Answer":"It really isn't that similar to C++, but I would recommend PHP. You really can't expect a server-side scripting language to be similar to a compiled language like C++. Personally, I find PHP to be an ugly, messy looking language, but once you get into it, it's very rewarding. Other languages have too many drawbacks. ASP.Net is too Microsoft-centric, Python and Ruby on Rails are too obscure, and are also non-curly bracket languages, meaning it will require a lot of adjustment to change to them. Hope this helps.","Q_Score":5,"Tags":"php,python,jsp","A_Id":3224044,"CreationDate":"2010-07-11T15:28:00.000","Title":"Which web technology to learn for an experienced C++ developer?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I'm using ftplib to transfer files.  Everything is working great.  Now I'm trying to get the size of the target file before downloading.\n\nFirst, I tried just getting size with ftp.size(filename).  Server complained that I can't do that in ascii mode.\nThen I tried setting binary mode using ftp.sendcmd(\"binary\") and ftp.sendcmd(\"bin\").  In both cases the server complained \"500 binary Not understood\"\n\nCan ftplib get size of a file before downloading in this instance?  I don't control the FTP server and can't change how it's behaving.\nThanks","AnswerCount":3,"Available Count":1,"Score":0.2605204458,"is_accepted":false,"ViewCount":12384,"Q_Id":3231910,"Users Score":4,"Answer":"Ftplib can get the size of a file before downloading. As the documentation says:\n\nFTP.size(filename)\n  Request the size of\n  the file named filename on the server.\n  On success, the size of the file is\n  returned as an integer, otherwise None\n  is returned. Note that the SIZE\n  command is not standardized, but is\n  upported by many common server\n  implementations\n\nApparently your server doesn't support this feature.","Q_Score":12,"Tags":"python,ftplib","A_Id":3232065,"CreationDate":"2010-07-12T20:17:00.000","Title":"Python ftplib can't get size of file before download?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"is there any way to connect GIMP with python or PHP and use its libraries? It seems that all i can find on the web is pygimp which is not supported anymore.\nps. i do my development on mac and i use linux as a production server","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":3456,"Q_Id":3237252,"Users Score":1,"Answer":"One important thing regarding running gimp python plugin in batch mode.\nOption -i means no interface. But in gimp documentation there is another option with same explanation --no-interface. User could though that they have same effect.\nBut when you try to run batch script on remote linux machine, with option -i you will get 'no display'. With option --no-interface, batch script will run without error. My colleague discovered that this is undocumented gimp 2.6.11 feature.\nRegards, Karlo.","Q_Score":3,"Tags":"php,python,gimp","A_Id":11170196,"CreationDate":"2010-07-13T12:43:00.000","Title":"Connect GIMP with PHP 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":0,"Web Development":0},{"Question":"is there any way to connect GIMP with python or PHP and use its libraries? It seems that all i can find on the web is pygimp which is not supported anymore.\nps. i do my development on mac and i use linux as a production server","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":3456,"Q_Id":3237252,"Users Score":1,"Answer":"Probably not directly, but I'll bet you can access some functions via 'exec()' on the command line.  What are you trying to do?  Can the GD or ImageMagic tools help?","Q_Score":3,"Tags":"php,python,gimp","A_Id":3237353,"CreationDate":"2010-07-13T12:43:00.000","Title":"Connect GIMP with PHP 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":0,"Web Development":0},{"Question":"Someone told me once, that programmers tend to learn one scripting language properly and ignore or dislike other scripting languages. Do you have similar experiences?\n I'm using Python as my choice for scripting for  few years, however, I'm sure that there are many existing and emerging languages that could impress the Pythonistas. Can you recommend scripting languages that would be interesting and useful to learn besides of Python?","AnswerCount":13,"Available Count":10,"Score":0.0153834017,"is_accepted":false,"ViewCount":3435,"Q_Id":3243529,"Users Score":1,"Answer":"I can't say that I agree with wiping Ruby off the map... Ruby fixed every problem that perl had as far as syntax goes... I loved Python first but let ruby get a little more mature and it will get in the the fray more and more... Why do I support Ruby strongly? just step away from python for a few months and then give Ruby a chance... I was a Ruby hater when I was a python guy. But I can't hardly stand to use python at this point. One day someone is gonna clean up the GC and toss in some native threads and everybody better watch out. \noff the rant, Python is a full featured, not just good, Great Language... Perl... what a mess... I don't know how Perl can look at itself in the mirror standing next to any other mainstream scripting language... PHP is much prettier... At least Perl is fast, right...(CPAN never hurt it either) if Speed is the real issue there are other interpreters that juice it up a bit... Jython, jRuby, PyPy... the list goes one, screw Bash...","Q_Score":9,"Tags":"python,programming-languages,scripting","A_Id":5289422,"CreationDate":"2010-07-14T05:13:00.000","Title":"Learn a scripting language besides 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},{"Question":"Someone told me once, that programmers tend to learn one scripting language properly and ignore or dislike other scripting languages. Do you have similar experiences?\n I'm using Python as my choice for scripting for  few years, however, I'm sure that there are many existing and emerging languages that could impress the Pythonistas. Can you recommend scripting languages that would be interesting and useful to learn besides of Python?","AnswerCount":13,"Available Count":10,"Score":0.0461211021,"is_accepted":false,"ViewCount":3435,"Q_Id":3243529,"Users Score":3,"Answer":"I'll give an honest answer from my perspective.\nNo.\nHaving started scripting using batch, bash, and Perl, discovering Python was discovering precisely what I'd want from a scripting language (and more, but that's off topic). It integrates with familiar Unix interfaces, is modular, doesn't force any particular paradigm, cross platform and under active development. The same can be said of no other scripting language I know of.\nThe only other scripting languages I'd consider using is Lua or Scheme, for their smaller footprints and suitability for embedding, Python can be a little hefty. However they're hardly suitable for the more general purpose shell and other forms of scripting.\nUpdate0\nI just noticed mentions of Ruby and PHP in other answers, these both slipped my mind, because I'd never consider using them. Ruby is slower and not quite as popular, and PHP is more C\/Perl like, with flatter interfaces, which comes with performance boons of its own. Using these alternatives to Python is a matter of taste.","Q_Score":9,"Tags":"python,programming-languages,scripting","A_Id":3243558,"CreationDate":"2010-07-14T05:13:00.000","Title":"Learn a scripting language besides 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},{"Question":"Someone told me once, that programmers tend to learn one scripting language properly and ignore or dislike other scripting languages. Do you have similar experiences?\n I'm using Python as my choice for scripting for  few years, however, I'm sure that there are many existing and emerging languages that could impress the Pythonistas. Can you recommend scripting languages that would be interesting and useful to learn besides of Python?","AnswerCount":13,"Available Count":10,"Score":0.0153834017,"is_accepted":false,"ViewCount":3435,"Q_Id":3243529,"Users Score":1,"Answer":"If you are already familiar with Python, you are unlikely to find something compelling in the same niche, although Ruby does have a very strong and vocal following that seems to like it very much. Perhaps you should consider a scripting language that fills a different role, such as BASH shell script for quick, simple scripts that don't need the complexity of Python or JavaScript which runs in the browser.","Q_Score":9,"Tags":"python,programming-languages,scripting","A_Id":3243568,"CreationDate":"2010-07-14T05:13:00.000","Title":"Learn a scripting language besides 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},{"Question":"Someone told me once, that programmers tend to learn one scripting language properly and ignore or dislike other scripting languages. Do you have similar experiences?\n I'm using Python as my choice for scripting for  few years, however, I'm sure that there are many existing and emerging languages that could impress the Pythonistas. Can you recommend scripting languages that would be interesting and useful to learn besides of Python?","AnswerCount":13,"Available Count":10,"Score":0.0461211021,"is_accepted":false,"ViewCount":3435,"Q_Id":3243529,"Users Score":3,"Answer":"To answer your first question: Do people learn one language and then ignore or dislike others?\nWell, if you know one language well, you will need to see great advantages to move to another.\nI started out using perl and eventually thought that there must be easier way to do some things. I picked up python and stopped using perl almost at once. \nA little while later I thought I'd try ruby and learned a bit about that. The advantages over using python weren't big enough to switch, so I decided to stick with python. If I had started out using ruby, I'd probably be using that still. \nIf you are using python, I don't think you will easily find another scripting language that will win you over. \nOn the other hand, if you learn functional programming, you will probably learn a few new things, some of them will even be useful in your python programming, since a few things in python seems to be inspired by functional programming and knowing how to use them will make you a better programmer in general and a better python programmer too.","Q_Score":9,"Tags":"python,programming-languages,scripting","A_Id":3243929,"CreationDate":"2010-07-14T05:13:00.000","Title":"Learn a scripting language besides 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},{"Question":"Someone told me once, that programmers tend to learn one scripting language properly and ignore or dislike other scripting languages. Do you have similar experiences?\n I'm using Python as my choice for scripting for  few years, however, I'm sure that there are many existing and emerging languages that could impress the Pythonistas. Can you recommend scripting languages that would be interesting and useful to learn besides of Python?","AnswerCount":13,"Available Count":10,"Score":0.0614608973,"is_accepted":false,"ViewCount":3435,"Q_Id":3243529,"Users Score":4,"Answer":"The only relatively unbiased answer you can really look for is probably statistical, and you would still have to account for the natural tendency of people to follow the path of least resistance once one is found or carved.\nHow many people learnt Python to a decent level, found the language resonates with the way they want to work, then move to something else because the language or the ecosystem, or both, don't support their needs?\nI'd say probably a single digit percentage of the educated userbase, wouldn't be surprised if it amounted to less than 5%.\nUnless you have work related prospects that involve a different language, or you need to move sideways for similar reasons, I'd say you're probably best off learning something complimentary to Python rather than similar or equivalent.\nC++ for low-level or computationally intensive tasks, CUDA if your field can take advantage of it (med-viz, CGI etc.), whatever flavour of shell\/sysadmin oriented scripting and hacks float where you work (bash, tcl, awk or whatever else) and so on.\nPersonally the reason I haven't bothered past a first glance with ruby, php, or a number of other languages is simply that it's better ROI to keep working on my python skills than picking up something that offers mostly the same qualities just in different forms.\nIf you really want to learn something else for the sake of opening your mind up a bit, and want to stick to \"scripting\", then LUA was an interesting toy for me for a while, mostly for the ridiculous performance you can squeeze out of a relatively easy integration process, and because it is a rather different set of tracks compared to Python. That, and the fact WoW plugins had to be written in LUA ;)","Q_Score":9,"Tags":"python,programming-languages,scripting","A_Id":3244435,"CreationDate":"2010-07-14T05:13:00.000","Title":"Learn a scripting language besides 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},{"Question":"Someone told me once, that programmers tend to learn one scripting language properly and ignore or dislike other scripting languages. Do you have similar experiences?\n I'm using Python as my choice for scripting for  few years, however, I'm sure that there are many existing and emerging languages that could impress the Pythonistas. Can you recommend scripting languages that would be interesting and useful to learn besides of Python?","AnswerCount":13,"Available Count":10,"Score":0.0461211021,"is_accepted":false,"ViewCount":3435,"Q_Id":3243529,"Users Score":3,"Answer":"I would learn a statically typed language with very powerful type expression capabilities and awesome concurrency.\nOne of the following would be a good choice (in order of my preference):\n\nScala\nF#\nHaskell\nOcaml\nErlang\n\nTyped languages like the above make you think different. Also these languages have REPLs so they can be used as a scripting language although truthfully I'm not really sure what the definition is of \"scripting\" language is.\nPython is missing good concurrency builtin to the language so knowing how to deal with concurrency for many python programmers is a challenge.\nI have found that strongly typed languages scale better for big projects for many reasons:\n\nBecause types are so important they become an invaluable way to communicate the problem\nRefactoring in these languages is much much easier.\nAutomatic Serialization is sometimes easier too (although for Haskell thats less true).\nA lot less time spent on writing assertions on type checking.\nBrowsing the code is easier because most IDEs will allow you click on and go to different types","Q_Score":9,"Tags":"python,programming-languages,scripting","A_Id":5289622,"CreationDate":"2010-07-14T05:13:00.000","Title":"Learn a scripting language besides 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},{"Question":"Someone told me once, that programmers tend to learn one scripting language properly and ignore or dislike other scripting languages. Do you have similar experiences?\n I'm using Python as my choice for scripting for  few years, however, I'm sure that there are many existing and emerging languages that could impress the Pythonistas. Can you recommend scripting languages that would be interesting and useful to learn besides of Python?","AnswerCount":13,"Available Count":10,"Score":0.0153834017,"is_accepted":false,"ViewCount":3435,"Q_Id":3243529,"Users Score":1,"Answer":"Ruby\/Groovy\/Perl if you'd like to stick to traditional scripting practices.\nOtherwise I'd heartily recommend you Clojure and Scala - two of the more innovative programing languages of the past few years.","Q_Score":9,"Tags":"python,programming-languages,scripting","A_Id":3243557,"CreationDate":"2010-07-14T05:13:00.000","Title":"Learn a scripting language besides 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},{"Question":"Someone told me once, that programmers tend to learn one scripting language properly and ignore or dislike other scripting languages. Do you have similar experiences?\n I'm using Python as my choice for scripting for  few years, however, I'm sure that there are many existing and emerging languages that could impress the Pythonistas. Can you recommend scripting languages that would be interesting and useful to learn besides of Python?","AnswerCount":13,"Available Count":10,"Score":1.0,"is_accepted":false,"ViewCount":3435,"Q_Id":3243529,"Users Score":6,"Answer":"Ruby - what it enables and does with blocks is really interesting, and quite foreign to python based programming\nErlang - the functional language has a lot of interesting examples and it will definitely make your head work differently afterwards (in a good way)\nJavascript - yes, I'm serious. ALthough there's a fair number of grips to be had with this prototype language, it does some really interesting things with that prototyping and just slightly differently than Ruby and\/or Python. And a ton of folks are pouring big money into making Javascript a outstandingly fast scripting language.","Q_Score":9,"Tags":"python,programming-languages,scripting","A_Id":3243565,"CreationDate":"2010-07-14T05:13:00.000","Title":"Learn a scripting language besides 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},{"Question":"Someone told me once, that programmers tend to learn one scripting language properly and ignore or dislike other scripting languages. Do you have similar experiences?\n I'm using Python as my choice for scripting for  few years, however, I'm sure that there are many existing and emerging languages that could impress the Pythonistas. Can you recommend scripting languages that would be interesting and useful to learn besides of Python?","AnswerCount":13,"Available Count":10,"Score":1.0,"is_accepted":false,"ViewCount":3435,"Q_Id":3243529,"Users Score":6,"Answer":"I would recommend learning Haskell and a dialect of Lisp such as Scheme or Common Lisp, if you master either of those you'll gain insight into how things are accomplished with the functional paradigm and it'll help out your Python as well.\nHere are some languages categorized by paradigms I'd learn:\nImperative\/Procedural languages:\n\nC\n\nFunctional paradigm languages:\n\nHaskell\nCommon Lisp\/Scheme\n\nSimilar object oriented languages:\n\nRuby\nECMAScript\n\nOther:\n\nPerl\n\nI would advise you to stay away from PHP unless you really need the work. You would probably want to run back to Python.","Q_Score":9,"Tags":"python,programming-languages,scripting","A_Id":3243541,"CreationDate":"2010-07-14T05:13:00.000","Title":"Learn a scripting language besides 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},{"Question":"Someone told me once, that programmers tend to learn one scripting language properly and ignore or dislike other scripting languages. Do you have similar experiences?\n I'm using Python as my choice for scripting for  few years, however, I'm sure that there are many existing and emerging languages that could impress the Pythonistas. Can you recommend scripting languages that would be interesting and useful to learn besides of Python?","AnswerCount":13,"Available Count":10,"Score":0.0461211021,"is_accepted":false,"ViewCount":3435,"Q_Id":3243529,"Users Score":3,"Answer":"Learn a Lisp. Whether it's \"scripting\" or not, Eric Raymond had the right of it when he wrote:\n\n\"Lisp is worth learning for the\n  profound enlightenment experience you\n  will have when you finally get it;\n  that experience will make you a better\n  programmer for the rest of your days,\n  even if you never actually use Lisp\n  itself a lot.\"\n\nThe programming paradigm needed to be highly effective in Lisp is sufficiently unlike what you use with Python day-to-day that the perspective it gives is very, very much worth it.\nAnd within Lisps, my choice? Clojure; like other Lisps, its macro system gives you capabilities comparable (actually superior) to the excellent metaprogramming in Python, but Clojure in particular has a focus on batteries-included practicality (and an intelligent, opinionated design) which will be familiar to anyone fond of GvR's instincts. Moreover, Clojure's strengths are extremely disjoint from Python's -- in particular, it shines at highly-multithreaded, CPU-bound concurrent programming, which is one of Python's weaknesses -- so having both in your toolbox increases the chance you'll have the right tool when a tricky job comes along.\n(Is it scripting? In my view, that's pretty academic these days; if you have a REPL where you can type code and get an immediate response, modify the state of a running program, or experiment with an API, I see a language as \"scripting\" enough).","Q_Score":9,"Tags":"python,programming-languages,scripting","A_Id":3540040,"CreationDate":"2010-07-14T05:13:00.000","Title":"Learn a scripting language besides 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},{"Question":"is there any frame-work or tool to test java-applets in python","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":312,"Q_Id":3246506,"Users Score":0,"Answer":"I don't understand exactly what you mean or why you want to test Java in Python but Jython may be helpful.","Q_Score":0,"Tags":"python","A_Id":3246550,"CreationDate":"2010-07-14T13:22:00.000","Title":"java-applet gui testing 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":1},{"Question":"They seem to share a lot of the same characteristics but as far as I can tell, Python 2.5 is faster than 1.8.7 by a lot.\nIs there a deeper underlying reason behind this?","AnswerCount":6,"Available Count":3,"Score":1.0,"is_accepted":false,"ViewCount":9141,"Q_Id":3252568,"Users Score":6,"Answer":"Because Ruby 1.8 was not really designed with performance in mind, while Python was more optimized. In particular, Ruby 1.8 did real interpretation rather than compiling for a virtual machine like most languages these days. Ruby 1.9 (with the YARV VM) is about as fast as Python 3 (maybe a little bit slower, but much closer), and other implementations are even faster.","Q_Score":13,"Tags":"python,ruby,performance,programming-languages","A_Id":3252589,"CreationDate":"2010-07-15T04:56:00.000","Title":"Why is Python faster than 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":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"They seem to share a lot of the same characteristics but as far as I can tell, Python 2.5 is faster than 1.8.7 by a lot.\nIs there a deeper underlying reason behind this?","AnswerCount":6,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":9141,"Q_Id":3252568,"Users Score":0,"Answer":"More people have been working on Python development for more years, so more optimization has been done. The languages are similarly flexible and expressive, so their performance should converge as all the good optimization ideas get used in both. As noted above, Ruby 1.9 substantially narrows the performance gap with Python.","Q_Score":13,"Tags":"python,ruby,performance,programming-languages","A_Id":3253302,"CreationDate":"2010-07-15T04:56:00.000","Title":"Why is Python faster than 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":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"They seem to share a lot of the same characteristics but as far as I can tell, Python 2.5 is faster than 1.8.7 by a lot.\nIs there a deeper underlying reason behind this?","AnswerCount":6,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":9141,"Q_Id":3252568,"Users Score":0,"Answer":"It depends on the implementation. Crystal is basically C compiled Ruby that can even call C libraries. Then you also have Elixir on the Beam side and let's not forget the Java and C# counterparts. But yes, Ruby, the defacto standard, is indeed slower than Python and is also aimed at web development.","Q_Score":13,"Tags":"python,ruby,performance,programming-languages","A_Id":67204842,"CreationDate":"2010-07-15T04:56:00.000","Title":"Why is Python faster than 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":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Ok so I know the basics of programming languages, I've studied python and liked it a lot. I'm studying now the intermediate parts of python and I'm catching the concepts already. I'm working with a project and at the same time solving computer problems that practices algorithm use. I've learned that python has limitations and wants to compensate that limitations by learning another programming language.\nWhat programming language do you suggest that synergizes well with python? I want something who can give me their actual experience while working with python and the language that complements well with it. Answers like \"try iron python or jython blah blah blah\" won't help, if you can give me it's pros and cons, it's maturity it's problems then that's good enough for me... Thanks a lot\nEDIT -\nSorry guys, I think I need to add some details in this. I'll be using python mainly for web programming or game development. So if you think this language A would help me in python for web programming then that's it.","AnswerCount":5,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":874,"Q_Id":3255925,"Users Score":0,"Answer":"Haskell or Ocaml, or maybe a Lisp dialect such as Common Lisp or Scheme.","Q_Score":2,"Tags":"python,paradigms","A_Id":3255961,"CreationDate":"2010-07-15T13:28:00.000","Title":"What other Language synergizes well with Python? Need Advice","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Ok so I know the basics of programming languages, I've studied python and liked it a lot. I'm studying now the intermediate parts of python and I'm catching the concepts already. I'm working with a project and at the same time solving computer problems that practices algorithm use. I've learned that python has limitations and wants to compensate that limitations by learning another programming language.\nWhat programming language do you suggest that synergizes well with python? I want something who can give me their actual experience while working with python and the language that complements well with it. Answers like \"try iron python or jython blah blah blah\" won't help, if you can give me it's pros and cons, it's maturity it's problems then that's good enough for me... Thanks a lot\nEDIT -\nSorry guys, I think I need to add some details in this. I'll be using python mainly for web programming or game development. So if you think this language A would help me in python for web programming then that's it.","AnswerCount":5,"Available Count":2,"Score":0.0399786803,"is_accepted":false,"ViewCount":874,"Q_Id":3255925,"Users Score":1,"Answer":"What is wrong with IronPython or Jython? You can learn how to write libraries in Java or .Net to alleviate some of Python's speed problems. Learning to write your own Python libraries will certainly help you better understand and overcome the limitations you mentioned.","Q_Score":2,"Tags":"python,paradigms","A_Id":3255977,"CreationDate":"2010-07-15T13:28:00.000","Title":"What other Language synergizes well with Python? Need Advice","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I can find lots of stuff showing me what a lambda function is, and how the syntax works and what not.  But other than the \"coolness factor\" (I can make a function in middle a call to another function, neat!) I haven't seen something that's overwelmingly compelling to say why I really need\/want to use them.\nIt seems to be more of a stylistic or structual choice in most examples I've seen.  And kinda breaks the \"Only one correct way to do something\" in python rule.  How does it make my programs, more correct, more reliable, faster, or easier to understand?  (Most coding standards I've seen tend to tell you to avoid overly complex statements on a single line.  If it makes it easier to read break it up.)","AnswerCount":16,"Available Count":5,"Score":1.0,"is_accepted":false,"ViewCount":54149,"Q_Id":3259322,"Users Score":9,"Answer":"Yes, you're right \u2014 it is a structural choice. It probably does not make your programs more correct by just using lambda expressions. Nor does it make them more reliable, and this has nothing to do with speed.\nIt is only about flexibility and the power of expression. Like list comprehension. You can do most of that defining named functions (possibly polluting namespace, but that's again purely stylistic issue).\nIt can aid to readability by the fact, that you do not have to define a separate named function, that someone else will have to find, read and understand that all it does is to call a method blah() on its argument.\nIt may be much more interesting when you use it to write functions that create and return other functions, where what exactly those functions do, depends on their arguments. This may be a very concise and readable way of parameterizing your code behaviour. You can just express more interesting ideas.\nBut that is still a structural choice. You can do that otherwise. But the same goes for object oriented programming ;)","Q_Score":86,"Tags":"python,lambda","A_Id":3259428,"CreationDate":"2010-07-15T19:41:00.000","Title":"Why use lambda functions?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I can find lots of stuff showing me what a lambda function is, and how the syntax works and what not.  But other than the \"coolness factor\" (I can make a function in middle a call to another function, neat!) I haven't seen something that's overwelmingly compelling to say why I really need\/want to use them.\nIt seems to be more of a stylistic or structual choice in most examples I've seen.  And kinda breaks the \"Only one correct way to do something\" in python rule.  How does it make my programs, more correct, more reliable, faster, or easier to understand?  (Most coding standards I've seen tend to tell you to avoid overly complex statements on a single line.  If it makes it easier to read break it up.)","AnswerCount":16,"Available Count":5,"Score":1.0,"is_accepted":false,"ViewCount":54149,"Q_Id":3259322,"Users Score":14,"Answer":"For me it's a matter of the expressiveness of the code.  When writing code that people will have to support, that code should tell a story in as concise and easy to understand manner as possible.  Sometimes the lambda expression is more complicated, other times it more directly tells what that line or block of code is doing.  Use judgment when writing.\nThink of it like structuring a sentence.  What are the important parts (nouns and verbs vs. objects and methods, etc.) and how should they be ordered for that line or block of code to convey what it's doing intuitively.","Q_Score":86,"Tags":"python,lambda","A_Id":3259370,"CreationDate":"2010-07-15T19:41:00.000","Title":"Why use lambda functions?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I can find lots of stuff showing me what a lambda function is, and how the syntax works and what not.  But other than the \"coolness factor\" (I can make a function in middle a call to another function, neat!) I haven't seen something that's overwelmingly compelling to say why I really need\/want to use them.\nIt seems to be more of a stylistic or structual choice in most examples I've seen.  And kinda breaks the \"Only one correct way to do something\" in python rule.  How does it make my programs, more correct, more reliable, faster, or easier to understand?  (Most coding standards I've seen tend to tell you to avoid overly complex statements on a single line.  If it makes it easier to read break it up.)","AnswerCount":16,"Available Count":5,"Score":1.0,"is_accepted":false,"ViewCount":54149,"Q_Id":3259322,"Users Score":6,"Answer":"Lambda, while useful in certain situations, has a large potential for abuse.  lambda's almost always make code more difficult to read.  And while it might feel satisfying to fit all your code onto a single line, it will suck for the next person who has to read your code.\nDirect from PEP8\n\"One of Guido's key insights is that code is read much more often than it is written.\"","Q_Score":86,"Tags":"python,lambda","A_Id":3734989,"CreationDate":"2010-07-15T19:41:00.000","Title":"Why use lambda functions?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I can find lots of stuff showing me what a lambda function is, and how the syntax works and what not.  But other than the \"coolness factor\" (I can make a function in middle a call to another function, neat!) I haven't seen something that's overwelmingly compelling to say why I really need\/want to use them.\nIt seems to be more of a stylistic or structual choice in most examples I've seen.  And kinda breaks the \"Only one correct way to do something\" in python rule.  How does it make my programs, more correct, more reliable, faster, or easier to understand?  (Most coding standards I've seen tend to tell you to avoid overly complex statements on a single line.  If it makes it easier to read break it up.)","AnswerCount":16,"Available Count":5,"Score":0.0374824318,"is_accepted":false,"ViewCount":54149,"Q_Id":3259322,"Users Score":3,"Answer":"Lambdas are anonymous functions (function with no name) that can be assigned to a variable or that can be passed as an argument to another function. The usefulness of lambda will be realized when you need a small piece of function that will be run one in a while or just once. Instead of writing the function in global scope or including it as part of your main program you can toss around few lines of code when needed to a variable or another function. Also when you pass the function as an argument to another function during the function call you can change the argument (the anonymous function) making the function itself dynamic. Suppose if the anonymous function uses variables outside its scope it is called closure. This is useful in callback functions.","Q_Score":86,"Tags":"python,lambda","A_Id":48674765,"CreationDate":"2010-07-15T19:41:00.000","Title":"Why use lambda functions?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I can find lots of stuff showing me what a lambda function is, and how the syntax works and what not.  But other than the \"coolness factor\" (I can make a function in middle a call to another function, neat!) I haven't seen something that's overwelmingly compelling to say why I really need\/want to use them.\nIt seems to be more of a stylistic or structual choice in most examples I've seen.  And kinda breaks the \"Only one correct way to do something\" in python rule.  How does it make my programs, more correct, more reliable, faster, or easier to understand?  (Most coding standards I've seen tend to tell you to avoid overly complex statements on a single line.  If it makes it easier to read break it up.)","AnswerCount":16,"Available Count":5,"Score":-0.012499349,"is_accepted":false,"ViewCount":54149,"Q_Id":3259322,"Users Score":-1,"Answer":"Lambdas allow you to create functions on the fly. Most of the examples I've seen don't do much more than create a function with parameters passed at the time of creation rather than execution. Or they simplify the code by not requiring a formal declaration of the function ahead of use.\nA more interesting use would be to dynamically construct a python function to evaluate a mathematical expression that isn't known until run time (user input). Once created, that function can be called repeatedly with different arguments to evaluate the expression (say you wanted to plot it). That may even be a poor example given eval(). This type of use is where the \"real\" power is - in dynamically creating more complex code, rather than the simple examples you often see which are not much more than nice (source) code size reductions.","Q_Score":86,"Tags":"python,lambda","A_Id":3259570,"CreationDate":"2010-07-15T19:41:00.000","Title":"Why use lambda functions?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm running complex tests that create many cookies for different sections of my web site.\nOccasionally I have to restart the browser in the middle a long test and since the Selenium server doesn't modify the base Firefox profile, the cookies evaporate.\nIs there any way I can save all of the cookies to a Python variable before terminating the browser and restore them after starting a new browser instance?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1991,"Q_Id":3265062,"Users Score":0,"Answer":"Yes, sure. Look at getCookie, getCookieByName and createCookie methods.","Q_Score":2,"Tags":"python,cookies,selenium,selenium-rc","A_Id":3314427,"CreationDate":"2010-07-16T13:02:00.000","Title":"How to save and restore all cookies with Selenium RC?","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},{"Question":"I'm trying to get a better understanding of the difference. I've found a lot of explanations online, but they tend towards the abstract differences rather than the practical implications.\nMost of my programming experiences has been with CPython (dynamic, interpreted), and Java (static, compiled). However, I understand that there are other kinds of interpreted and compiled languages. Aside from the fact that executable files can be distributed from programs written in compiled languages, are there any advantages\/disadvantages to each type? Oftentimes, I hear people arguing that interpreted languages can be used interactively, but I believe that compiled languages can have interactive implementations as well, correct?","AnswerCount":13,"Available Count":10,"Score":1.2,"is_accepted":true,"ViewCount":246100,"Q_Id":3265357,"Users Score":497,"Answer":"A compiled language is one where the program, once compiled, is expressed in the instructions of the target machine. For example, an addition \"+\" operation in your source code could be translated directly to the \"ADD\" instruction in machine code.\nAn interpreted language is one where the instructions are not directly executed by the target machine, but instead read and executed by some other program (which normally is written in the language of the native machine). For example, the same \"+\" operation would be recognised by the interpreter at run time, which would then call its own \"add(a,b)\" function with the appropriate arguments, which would then execute the machine code \"ADD\" instruction.\nYou can do anything that you can do in an interpreted language in a compiled language and vice-versa - they are both Turing complete. Both however have advantages and disadvantages for implementation and use.\nI'm going to completely generalise (purists forgive me!) but, roughly, here are the advantages of compiled languages:\n\nFaster performance by directly using the native code of the target machine\nOpportunity to apply quite powerful optimisations during the compile stage\n\nAnd here are the advantages of interpreted languages:\n\nEasier to implement (writing good compilers is very hard!!)\nNo need to run a compilation stage: can execute code directly \"on the fly\"\nCan be more convenient for dynamic languages\n\nNote that modern techniques such as bytecode compilation add some extra complexity - what happens here is that the compiler targets a \"virtual machine\" which is not the same as the underlying hardware. These virtual machine instructions can then be compiled again at a later stage to get native code (e.g. as done by the Java JVM JIT compiler).","Q_Score":312,"Tags":"java,python,compiler-construction,programming-languages,interpreter","A_Id":3265602,"CreationDate":"2010-07-16T13:35:00.000","Title":"Compiled vs. Interpreted 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},{"Question":"I'm trying to get a better understanding of the difference. I've found a lot of explanations online, but they tend towards the abstract differences rather than the practical implications.\nMost of my programming experiences has been with CPython (dynamic, interpreted), and Java (static, compiled). However, I understand that there are other kinds of interpreted and compiled languages. Aside from the fact that executable files can be distributed from programs written in compiled languages, are there any advantages\/disadvantages to each type? Oftentimes, I hear people arguing that interpreted languages can be used interactively, but I believe that compiled languages can have interactive implementations as well, correct?","AnswerCount":13,"Available Count":10,"Score":0.0307595242,"is_accepted":false,"ViewCount":246100,"Q_Id":3265357,"Users Score":2,"Answer":"It's rather difficult to give a practical answer because the difference is about the language definition itself. It's possible to build an interpreter for every compiled language, but it's not possible to build an compiler for every interpreted language. It's very much about the formal definition of a language. So that theoretical informatics stuff noboby likes at university.","Q_Score":312,"Tags":"java,python,compiler-construction,programming-languages,interpreter","A_Id":3265475,"CreationDate":"2010-07-16T13:35:00.000","Title":"Compiled vs. Interpreted 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},{"Question":"I'm trying to get a better understanding of the difference. I've found a lot of explanations online, but they tend towards the abstract differences rather than the practical implications.\nMost of my programming experiences has been with CPython (dynamic, interpreted), and Java (static, compiled). However, I understand that there are other kinds of interpreted and compiled languages. Aside from the fact that executable files can be distributed from programs written in compiled languages, are there any advantages\/disadvantages to each type? Oftentimes, I hear people arguing that interpreted languages can be used interactively, but I believe that compiled languages can have interactive implementations as well, correct?","AnswerCount":13,"Available Count":10,"Score":1.0,"is_accepted":false,"ViewCount":246100,"Q_Id":3265357,"Users Score":11,"Answer":"The biggest advantage of interpreted source code over compiled source code is PORTABILITY.\nIf your source code is compiled, you need to compile a different executable for each type of processor and\/or platform that you want your program to run on (e.g. one for Windows x86, one for Windows x64, one for Linux x64, and so on). Furthermore, unless your code is completely standards compliant and does not use any platform-specific functions\/libraries, you will actually need to write and maintain multiple code bases!\nIf your source code is interpreted, you only need to write it once and it can be interpreted and executed by an appropriate interpreter on any platform! It's portable! Note that an interpreter itself is an executable program that is written and compiled for a specific platform.\nAn advantage of compiled code is that it hides the source code from the end user (which might be intellectual property) because instead of deploying the original human-readable source code, you deploy an obscure binary executable file.","Q_Score":312,"Tags":"java,python,compiler-construction,programming-languages,interpreter","A_Id":23750310,"CreationDate":"2010-07-16T13:35:00.000","Title":"Compiled vs. Interpreted 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},{"Question":"I'm trying to get a better understanding of the difference. I've found a lot of explanations online, but they tend towards the abstract differences rather than the practical implications.\nMost of my programming experiences has been with CPython (dynamic, interpreted), and Java (static, compiled). However, I understand that there are other kinds of interpreted and compiled languages. Aside from the fact that executable files can be distributed from programs written in compiled languages, are there any advantages\/disadvantages to each type? Oftentimes, I hear people arguing that interpreted languages can be used interactively, but I believe that compiled languages can have interactive implementations as well, correct?","AnswerCount":13,"Available Count":10,"Score":0.0767717131,"is_accepted":false,"ViewCount":246100,"Q_Id":3265357,"Users Score":5,"Answer":"First, a clarification, Java is not fully static-compiled and linked in the way C++. It is compiled into bytecode, which is then interpreted by a JVM. The JVM can go and do just-in-time compilation to the native machine language, but doesn't have to do it.\nMore to the point: I think interactivity is the main practical difference. Since everything is interpreted, you can take a small excerpt of code, parse and run it against the current state of the environment. Thus, if you had already executed code that initialized a variable, you would have access to that variable, etc. It really lends itself way to things like the functional style.\nInterpretation, however, costs a lot, especially when you have a large system with a lot of references and context. By definition, it is wasteful because identical code may have to be interpreted and optimized twice (although most runtimes have some caching and optimizations for that). Still, you pay a runtime cost and often need a runtime environment. You are also less likely to see complex interprocedural optimizations because at present their performance is not sufficiently interactive.\nTherefore, for large systems that are not going to change much, and for certain languages, it makes more sense to precompile and prelink everything, do all the optimizations that you can do. This ends up with a very lean runtime that is already optimized for the target machine.\nAs for generating executables, that has little to do with it, IMHO. You can often create an executable from a compiled language. But you can also create an executable from an interpreted language, except that the interpreter and runtime is already packaged in the exectuable and hidden from you. This means that you generally still pay the runtime costs (although I am sure that for some language there are ways to translate everything to a tree executable).\nI disagree that all languages could be made interactive. Certain languages, like C, are so tied to the machine and the entire link structure that I'm not sure you can build a meaningful fully-fledged interactive version","Q_Score":312,"Tags":"java,python,compiler-construction,programming-languages,interpreter","A_Id":3265433,"CreationDate":"2010-07-16T13:35:00.000","Title":"Compiled vs. Interpreted 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},{"Question":"I'm trying to get a better understanding of the difference. I've found a lot of explanations online, but they tend towards the abstract differences rather than the practical implications.\nMost of my programming experiences has been with CPython (dynamic, interpreted), and Java (static, compiled). However, I understand that there are other kinds of interpreted and compiled languages. Aside from the fact that executable files can be distributed from programs written in compiled languages, are there any advantages\/disadvantages to each type? Oftentimes, I hear people arguing that interpreted languages can be used interactively, but I believe that compiled languages can have interactive implementations as well, correct?","AnswerCount":13,"Available Count":10,"Score":1.0,"is_accepted":false,"ViewCount":246100,"Q_Id":3265357,"Users Score":64,"Answer":"Start thinking in terms of a: blast from the past \nOnce upon a time, long long ago, there lived in the land of computing\ninterpreters and compilers. All kinds of fuss ensued over the merits of\none over the other. The general opinion at that time was something along the lines of:\n\nInterpreter: Fast to develop (edit and run). Slow to execute because each statement had to be interpreted into\nmachine code every time it was executed (think of what this meant for a loop executed thousands of times).\nCompiler: Slow to develop (edit, compile, link and run. The compile\/link steps could take serious time). Fast\nto execute. The whole program was already in native machine code.\n\nA one or two order of magnitude difference in the runtime\nperformance existed between an interpreted program and a compiled program. Other distinguishing \npoints, run-time mutability of the code for example, were also of some interest but the major\ndistinction revolved around the run-time performance issues.\nToday the landscape has evolved to such an extent that the compiled\/interpreted distinction is \npretty much irrelevant. Many\ncompiled languages call upon run-time services that are not\ncompletely machine code based. Also, most interpreted languages are \"compiled\" into byte-code\nbefore execution. Byte-code interpreters can be very efficient and rival some compiler generated\ncode from an execution speed point of view.\nThe classic difference is that compilers generated native machine code, interpreters read source code and\ngenerated machine code on the fly using some sort of run-time system. \nToday there are very few classic interpreters left - almost all of them\ncompile into byte-code (or some other semi-compiled state) which then runs on a virtual \"machine\".","Q_Score":312,"Tags":"java,python,compiler-construction,programming-languages,interpreter","A_Id":3266025,"CreationDate":"2010-07-16T13:35:00.000","Title":"Compiled vs. Interpreted 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},{"Question":"I'm trying to get a better understanding of the difference. I've found a lot of explanations online, but they tend towards the abstract differences rather than the practical implications.\nMost of my programming experiences has been with CPython (dynamic, interpreted), and Java (static, compiled). However, I understand that there are other kinds of interpreted and compiled languages. Aside from the fact that executable files can be distributed from programs written in compiled languages, are there any advantages\/disadvantages to each type? Oftentimes, I hear people arguing that interpreted languages can be used interactively, but I believe that compiled languages can have interactive implementations as well, correct?","AnswerCount":13,"Available Count":10,"Score":1.0,"is_accepted":false,"ViewCount":246100,"Q_Id":3265357,"Users Score":103,"Answer":"A language itself is neither compiled nor interpreted, only a specific implementation of a language is.  Java is a perfect example.  There is a bytecode-based platform (the JVM), a native compiler (gcj) and an interpeter for a superset of Java (bsh).  So what is Java now? Bytecode-compiled, native-compiled or interpreted?  \nOther languages, which are compiled as well as interpreted, are Scala, Haskell or Ocaml.  Each of these languages has an interactive interpreter, as well as a compiler to byte-code or native machine code.\nSo generally categorizing languages by \"compiled\" and \"interpreted\" doesn't make much sense.","Q_Score":312,"Tags":"java,python,compiler-construction,programming-languages,interpreter","A_Id":3265680,"CreationDate":"2010-07-16T13:35:00.000","Title":"Compiled vs. Interpreted 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},{"Question":"I'm trying to get a better understanding of the difference. I've found a lot of explanations online, but they tend towards the abstract differences rather than the practical implications.\nMost of my programming experiences has been with CPython (dynamic, interpreted), and Java (static, compiled). However, I understand that there are other kinds of interpreted and compiled languages. Aside from the fact that executable files can be distributed from programs written in compiled languages, are there any advantages\/disadvantages to each type? Oftentimes, I hear people arguing that interpreted languages can be used interactively, but I believe that compiled languages can have interactive implementations as well, correct?","AnswerCount":13,"Available Count":10,"Score":0.0153834017,"is_accepted":false,"ViewCount":246100,"Q_Id":3265357,"Users Score":1,"Answer":"Compile is the process of creating an executable program from code written in a compiled programming language. Compiling allows the computer to run and understand the program without the need of the programming software used to create it. When a program is compiled it is often compiled for a specific platform (e.g. IBM platform) that works with IBM compatible computers, but not other platforms (e.g. Apple platform).\nThe first compiler was developed by Grace Hopper while working on the Harvard Mark I computer. Today, most high-level languages will include their own compiler or have toolkits available that can be used to compile the program. A good example of a compiler used with Java is Eclipse and an example of a compiler used with C and C++ is the gcc command. Depending on how big the program is it should take a few seconds or minutes to compile and if no errors are encountered while being compiled an executable file is created.check this information","Q_Score":312,"Tags":"java,python,compiler-construction,programming-languages,interpreter","A_Id":45730878,"CreationDate":"2010-07-16T13:35:00.000","Title":"Compiled vs. Interpreted 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},{"Question":"I'm trying to get a better understanding of the difference. I've found a lot of explanations online, but they tend towards the abstract differences rather than the practical implications.\nMost of my programming experiences has been with CPython (dynamic, interpreted), and Java (static, compiled). However, I understand that there are other kinds of interpreted and compiled languages. Aside from the fact that executable files can be distributed from programs written in compiled languages, are there any advantages\/disadvantages to each type? Oftentimes, I hear people arguing that interpreted languages can be used interactively, but I believe that compiled languages can have interactive implementations as well, correct?","AnswerCount":13,"Available Count":10,"Score":1.0,"is_accepted":false,"ViewCount":246100,"Q_Id":3265357,"Users Score":28,"Answer":"The extreme and simple cases:\n\nA compiler will produce a binary executable in the target machine's native executable format. This binary file contains all required resources except for system libraries; it's ready to run with no further preparation and processing and it runs like lightning because the code is the native code for the CPU on the target machine.\nAn interpreter will present the user with a prompt in a loop where he can enter statements or code, and upon hitting RUN or the equivalent the interpreter will examine, scan, parse and interpretatively execute each line until the program runs to a stopping point or an error. Because each line is treated on its own and the interpreter doesn't \"learn\" anything from having seen the line before, the effort of converting human-readable language to machine instructions is incurred every time for every line, so it's dog slow. On the bright side, the user can inspect and otherwise interact with his program in all kinds of ways: Changing variables, changing code, running in trace or debug modes... whatever.\n\nWith those out of the way, let me explain that life ain't so simple any more. For instance, \n\nMany interpreters will pre-compile the code they're given so the translation step doesn't have to be repeated again and again. \nSome compilers compile not to CPU-specific machine instructions but to bytecode, a kind of artificial machine code for a ficticious machine. This makes the compiled program a bit more portable, but requires a bytecode interpreter on every target system.\nThe bytecode interpreters (I'm looking at Java here) recently tend to re-compile the bytecode they get for the CPU of the target section just before execution (called JIT). To save time, this is often only done for code that runs often (hotspots).\nSome systems that look and act like interpreters (Clojure, for instance) compile any code they get, immediately, but allow interactive access to the program's environment. That's basically the convenience of interpreters with the speed of binary compilation.\nSome compilers don't really compile, they just pre-digest and compress code. I heard a while back that's how Perl works. So sometimes the compiler is just doing a bit of the work and most of it is still interpretation.\n\nIn the end, these days, interpreting vs. compiling is a trade-off, with time spent (once) compiling often being rewarded by better runtime performance, but an interpretative environment giving more opportunities for interaction. Compiling vs. interpreting is mostly a matter of how the work of \"understanding\" the program is divided up between different processes, and the line is a bit blurry these days as languages and products try to offer the best of both worlds.","Q_Score":312,"Tags":"java,python,compiler-construction,programming-languages,interpreter","A_Id":3265505,"CreationDate":"2010-07-16T13:35:00.000","Title":"Compiled vs. Interpreted 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},{"Question":"I'm trying to get a better understanding of the difference. I've found a lot of explanations online, but they tend towards the abstract differences rather than the practical implications.\nMost of my programming experiences has been with CPython (dynamic, interpreted), and Java (static, compiled). However, I understand that there are other kinds of interpreted and compiled languages. Aside from the fact that executable files can be distributed from programs written in compiled languages, are there any advantages\/disadvantages to each type? Oftentimes, I hear people arguing that interpreted languages can be used interactively, but I believe that compiled languages can have interactive implementations as well, correct?","AnswerCount":13,"Available Count":10,"Score":1.0,"is_accepted":false,"ViewCount":246100,"Q_Id":3265357,"Users Score":8,"Answer":"A compiler and an interpreter do the same job: translating a programming language to another pgoramming language, usually closer to the hardware, often direct executable machine code.\nTraditionally, \"compiled\" means that this translation happens all in one go, is done by a developer, and the resulting executable is distributed to users. Pure example: C++.\nCompilation usually takes pretty long and tries to do lots of expensive optmization so that the resulting executable runs faster. End users don't have the tools and knowledge to compile stuff themselves, and the executable often has to run on a variety of hardware, so you can't do many hardware-specific optimizations. During development, the separate compilation step means a longer feedback cycle.\nTraditionally, \"interpreted\" means that the translation happens \"on the fly\", when the user wants to run the program. Pure example: vanilla PHP. A naive interpreter has to parse and translate every piece of code every time it runs, which makes it very slow. It can't do complex, costly optimizations because they'd take longer than the time saved in execution. But it can fully use the capabilities of the hardware it runs on. The lack of a separrate compilation step reduces feedback time during development.\nBut nowadays \"compiled vs. interpreted\" is not a black-or-white issue, there are shades in between. Naive, simple interpreters are pretty much extinct. Many languages use a two-step process where the high-level code is translated to a platform-independant bytecode (which is much faster to interpret). Then you have \"just in time compilers\" which compile code at most once per program run, sometimes cache results, and even intelligently decide to interpret code that's run rarely, and do powerful optimizations for code that runs a lot. During development, debuggers are capable of switching code inside a running program even for traditionally compiled languages.","Q_Score":312,"Tags":"java,python,compiler-construction,programming-languages,interpreter","A_Id":3265615,"CreationDate":"2010-07-16T13:35:00.000","Title":"Compiled vs. Interpreted 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},{"Question":"I'm trying to get a better understanding of the difference. I've found a lot of explanations online, but they tend towards the abstract differences rather than the practical implications.\nMost of my programming experiences has been with CPython (dynamic, interpreted), and Java (static, compiled). However, I understand that there are other kinds of interpreted and compiled languages. Aside from the fact that executable files can be distributed from programs written in compiled languages, are there any advantages\/disadvantages to each type? Oftentimes, I hear people arguing that interpreted languages can be used interactively, but I believe that compiled languages can have interactive implementations as well, correct?","AnswerCount":13,"Available Count":10,"Score":0.0307595242,"is_accepted":false,"ViewCount":246100,"Q_Id":3265357,"Users Score":2,"Answer":"The Python Book \u00a9 2015 Imagine Publishing Ltd, simply distunguishes the difference by the following hint mentioned in page 10 as:\n\nAn interpreted language such as Python is one where the source code is converted to machine code and then executed each time the program runs. This is different from a compiled language such as C, where the source code is only converted to machine code once \u2013 the resulting machine code is then executed each time the program runs.","Q_Score":312,"Tags":"java,python,compiler-construction,programming-languages,interpreter","A_Id":39558017,"CreationDate":"2010-07-16T13:35:00.000","Title":"Compiled vs. Interpreted 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},{"Question":"I recently learned JavaScript an all of the sudden I hear about Python...\nShould I go learn Python or just stick with my basic JavaScript knowledge?\nIf you have some \"facts\" I would love to hear them! Like efficiency, difficultylevel and so on, an so on...\nThanks :)","AnswerCount":12,"Available Count":9,"Score":0.049958375,"is_accepted":false,"ViewCount":65637,"Q_Id":3266223,"Users Score":3,"Answer":"Python\u2019s a good second language to learn after JavaScript, as they have a reasonable number of similarities, e.g.\n\nthey\u2019re both memory-managed\nthey have similar data structures \u2014 JavaScript\u2019s objects and arrays are much like Python\u2019s dictionaries and arrays\nthey\u2019re both used quite a lot for web-related work \u2014 JavaScript in the browser and in server-side contexts like node.js, Python in web frameworks like Django.\n\nHowever, Python\u2019s object-oriented... stuff is quite different to JavaScript\u2019s protoype-based object-oriented stuff.\nIf the only programming you do is manipulating web pages within the web browser, then Python won\u2019t be of any direct use to you (only JavaScript runs in browsers at the moment). But learning another programming language generally gives you new ways to think about the languages you already know. Learning Python could help you write better JavaScript.","Q_Score":25,"Tags":"javascript,python","A_Id":3266895,"CreationDate":"2010-07-16T15:06:00.000","Title":"Python over JavaScript? (Facts, please)","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I recently learned JavaScript an all of the sudden I hear about Python...\nShould I go learn Python or just stick with my basic JavaScript knowledge?\nIf you have some \"facts\" I would love to hear them! Like efficiency, difficultylevel and so on, an so on...\nThanks :)","AnswerCount":12,"Available Count":9,"Score":-0.0333209931,"is_accepted":false,"ViewCount":65637,"Q_Id":3266223,"Users Score":-2,"Answer":"If you need to ask, then I would say no since you don't have a need in mind for its usage.","Q_Score":25,"Tags":"javascript,python","A_Id":3266975,"CreationDate":"2010-07-16T15:06:00.000","Title":"Python over JavaScript? (Facts, please)","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I recently learned JavaScript an all of the sudden I hear about Python...\nShould I go learn Python or just stick with my basic JavaScript knowledge?\nIf you have some \"facts\" I would love to hear them! Like efficiency, difficultylevel and so on, an so on...\nThanks :)","AnswerCount":12,"Available Count":9,"Score":0.0,"is_accepted":false,"ViewCount":65637,"Q_Id":3266223,"Users Score":0,"Answer":"Along with Python generally being server-side and JavaScript client-side, Python was designed to not only be easy to learn, but also easy to read, and to encourage a more productive environment.","Q_Score":25,"Tags":"javascript,python","A_Id":3266781,"CreationDate":"2010-07-16T15:06:00.000","Title":"Python over JavaScript? (Facts, please)","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I recently learned JavaScript an all of the sudden I hear about Python...\nShould I go learn Python or just stick with my basic JavaScript knowledge?\nIf you have some \"facts\" I would love to hear them! Like efficiency, difficultylevel and so on, an so on...\nThanks :)","AnswerCount":12,"Available Count":9,"Score":0.0333209931,"is_accepted":false,"ViewCount":65637,"Q_Id":3266223,"Users Score":2,"Answer":"JavaScript is usually used as a client-side scripting language - that is, it gets downloaded and executed by your browser. Python, however, is usually not coupled to the web. it can be used as a server-side scripting language, and for scripts and applications of any kind. But it is not a client-side language, and is therefore not directly comparable to Javascript, which has an entirely different audience. \nLooking at the language level, Javascript is terrible and dysfunctional (hard to debug, clumsy object-orientation) while Python is beautiful and expressive. This is, of course, subjective :-)","Q_Score":25,"Tags":"javascript,python","A_Id":3266281,"CreationDate":"2010-07-16T15:06:00.000","Title":"Python over JavaScript? (Facts, please)","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I recently learned JavaScript an all of the sudden I hear about Python...\nShould I go learn Python or just stick with my basic JavaScript knowledge?\nIf you have some \"facts\" I would love to hear them! Like efficiency, difficultylevel and so on, an so on...\nThanks :)","AnswerCount":12,"Available Count":9,"Score":0.0,"is_accepted":false,"ViewCount":65637,"Q_Id":3266223,"Users Score":0,"Answer":"It depends.\nDo you want to program in a language that specifically targets web browsers? Stick with Javascript\nDo you want to write... well anything besides for web browsers? Learn Python.\nPython is an excellent beginner language that's not just a beginner language. Google uses it, NASA uses it, and many, many other organizations use Python.","Q_Score":25,"Tags":"javascript,python","A_Id":3266294,"CreationDate":"2010-07-16T15:06:00.000","Title":"Python over JavaScript? (Facts, please)","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I recently learned JavaScript an all of the sudden I hear about Python...\nShould I go learn Python or just stick with my basic JavaScript knowledge?\nIf you have some \"facts\" I would love to hear them! Like efficiency, difficultylevel and so on, an so on...\nThanks :)","AnswerCount":12,"Available Count":9,"Score":0.0166651236,"is_accepted":false,"ViewCount":65637,"Q_Id":3266223,"Users Score":1,"Answer":"IMO Python may be easier to learn (having taught both to intro classes).\nAlso, one major annoyance of JavaScript is that in runs in your browser. This inherently makes  it much harder to debug problems.\nIn terms of a production-level language, Python is more of a general purpose programming language, while JavaScript is targeted at building dynamic web applications.\nIf you want to get into programming, you should definitely learn a more general purpose language such as Java or Python.","Q_Score":25,"Tags":"javascript,python","A_Id":3266271,"CreationDate":"2010-07-16T15:06:00.000","Title":"Python over JavaScript? (Facts, please)","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I recently learned JavaScript an all of the sudden I hear about Python...\nShould I go learn Python or just stick with my basic JavaScript knowledge?\nIf you have some \"facts\" I would love to hear them! Like efficiency, difficultylevel and so on, an so on...\nThanks :)","AnswerCount":12,"Available Count":9,"Score":1.0,"is_accepted":false,"ViewCount":65637,"Q_Id":3266223,"Users Score":15,"Answer":"The two are generally used quite differently. Javascript is primarily used as a client side scripting language vs python which is a server based language. So in a website you could use both. But not sure if this is what you were wondering.","Q_Score":25,"Tags":"javascript,python","A_Id":3266248,"CreationDate":"2010-07-16T15:06:00.000","Title":"Python over JavaScript? (Facts, please)","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I recently learned JavaScript an all of the sudden I hear about Python...\nShould I go learn Python or just stick with my basic JavaScript knowledge?\nIf you have some \"facts\" I would love to hear them! Like efficiency, difficultylevel and so on, an so on...\nThanks :)","AnswerCount":12,"Available Count":9,"Score":0.0,"is_accepted":false,"ViewCount":65637,"Q_Id":3266223,"Users Score":0,"Answer":"JavaScript and Python are both great languages that are geared toward different problems.\nJavaScript knowledge is invaluable when dealing with the web, writing web pages, and poking around in html DOM.\nPython is a scripting language that is great for a host of things on any machine.","Q_Score":25,"Tags":"javascript,python","A_Id":3266266,"CreationDate":"2010-07-16T15:06:00.000","Title":"Python over JavaScript? (Facts, please)","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I recently learned JavaScript an all of the sudden I hear about Python...\nShould I go learn Python or just stick with my basic JavaScript knowledge?\nIf you have some \"facts\" I would love to hear them! Like efficiency, difficultylevel and so on, an so on...\nThanks :)","AnswerCount":12,"Available Count":9,"Score":0.0166651236,"is_accepted":false,"ViewCount":65637,"Q_Id":3266223,"Users Score":1,"Answer":"For what purpose? Javascript is king in some circles (web development, for instance).\nJavascript and Python are not mutually exclusive. Why not learn both?","Q_Score":25,"Tags":"javascript,python","A_Id":3266275,"CreationDate":"2010-07-16T15:06:00.000","Title":"Python over JavaScript? (Facts, please)","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"Hi I want to load the groups of a svg-file into several gtk pixbuffs\/subpixbufs\ntherefore I need the coordinates and width and height of them\nI'm currently just using rsvg and gtk \nis it possible to get those information with that modules ? Or do I need another module to read out that data from the svg-file?\nthanks alot","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":387,"Q_Id":3268600,"Users Score":1,"Answer":"I found out to simply use RSVG::Handle::get_dimensions_sub(id)","Q_Score":0,"Tags":"python,gtk,svg,rsvg","A_Id":3948330,"CreationDate":"2010-07-16T20:24:00.000","Title":"Get the coords and height\/width of a svg group into 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},{"Question":"What's the easiest Python library to use to extract properties from an AAC audio file (.m4a)?\nSpecifically, I'd like to extract the following properties:\n\nSample rate\nChannel count (mono or stereo)\nLength (in seconds)","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":1597,"Q_Id":3269200,"Users Score":1,"Answer":"Try using the command exiftool. Of course, if you're using linux. This command shows all the properties of audio files, video and pictures. Exiftool installed, simply use the command:\nexiftoll your_file_name.extension\neg\nexiftoll music.mp3","Q_Score":1,"Tags":"python,aac","A_Id":12114371,"CreationDate":"2010-07-16T22:10:00.000","Title":"Extract AAC audio properties 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},{"Question":"I have installed Iron Python on my Ubuntu 10.4 and Mono Develop, but there is no interaction between them. Is there any Iron Python plug-in for Monodevelop as in VS? If not, which is the best Iron-Python IDE for Ubuntu or Debian?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1522,"Q_Id":3269339,"Users Score":2,"Answer":"I'm not aware of one. The is a Python addin for MD, but not an IronPython addin.\nIt  wouldn't be hard to write an addin for MD - if anyone's interested, ask on the MonoDevelop mailing list and I can give some pointers to get started.","Q_Score":3,"Tags":".net,ironpython,monodevelop,ubuntu-10.04","A_Id":3284054,"CreationDate":"2010-07-16T22:44:00.000","Title":"Is there any Iron Python plug-in for Monodevelop?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I am working on a project that requires reading text files, extracting data from them, and then generating reports (text files). Since there are a lot of string parsing, I decided to do it in Perl or Python or PHP (preference in that order). But I don't want to expose the source code to my client. Is there any good compiler for compiling perl\/python\/php scripts into linux executables?\nI am not looking for a 100% perfect one, but I am looking for an at least 90% perfect one. By perfect, I mean the compiler doesn't require to write scripts with a limited subset of language features.","AnswerCount":8,"Available Count":4,"Score":0.049958375,"is_accepted":false,"ViewCount":2889,"Q_Id":3270464,"Users Score":2,"Answer":"There are 3 options of encrypting Perl code:\n\nUse PAR to create executable file with PAR::Filter::Obfuscate or PAR::Filter::Crypto\nUse Filter::Crypto::CryptFile (will require some modules installed on target OS)\nTurn into module and encrypt into Module::Crypt.\n\nAlso you can try B::C - it was removed from core Perl distribution and is now available on CPAN.","Q_Score":2,"Tags":"php,python,perl,compiler-construction,scripting-language","A_Id":3270788,"CreationDate":"2010-07-17T06:11:00.000","Title":"Good compilers for compiling perl\/python\/php scripts into linux executables?","Data Science and Machine Learning":0,"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},{"Question":"I am working on a project that requires reading text files, extracting data from them, and then generating reports (text files). Since there are a lot of string parsing, I decided to do it in Perl or Python or PHP (preference in that order). But I don't want to expose the source code to my client. Is there any good compiler for compiling perl\/python\/php scripts into linux executables?\nI am not looking for a 100% perfect one, but I am looking for an at least 90% perfect one. By perfect, I mean the compiler doesn't require to write scripts with a limited subset of language features.","AnswerCount":8,"Available Count":4,"Score":0.0,"is_accepted":false,"ViewCount":2889,"Q_Id":3270464,"Users Score":0,"Answer":"For Python You can call your code and give the *.pyc file to the client.","Q_Score":2,"Tags":"php,python,perl,compiler-construction,scripting-language","A_Id":3270490,"CreationDate":"2010-07-17T06:11:00.000","Title":"Good compilers for compiling perl\/python\/php scripts into linux executables?","Data Science and Machine Learning":0,"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},{"Question":"I am working on a project that requires reading text files, extracting data from them, and then generating reports (text files). Since there are a lot of string parsing, I decided to do it in Perl or Python or PHP (preference in that order). But I don't want to expose the source code to my client. Is there any good compiler for compiling perl\/python\/php scripts into linux executables?\nI am not looking for a 100% perfect one, but I am looking for an at least 90% perfect one. By perfect, I mean the compiler doesn't require to write scripts with a limited subset of language features.","AnswerCount":8,"Available Count":4,"Score":0.0996679946,"is_accepted":false,"ViewCount":2889,"Q_Id":3270464,"Users Score":4,"Answer":"I'm sorry, it's simply not worth spending your time on. For any language you choose (from among the ones you listed), for any compiler\/obfuscator someone chooses to come up with, I promise you I can get readable source code out of it (within an hour if it's Perl; longer if it's Python or PHP simply because I'm less acquainted with the implementations of those languages, not because it's intrinsically harder with those languages).\nI think you should take a better look at what your goals are and why you want to work for a client that you're assuming a priori wants to rip you off. And if you still want to go ahead with such a scheme, write in C or Fortran -- certainly not anything starting with \"P\".","Q_Score":2,"Tags":"php,python,perl,compiler-construction,scripting-language","A_Id":3270852,"CreationDate":"2010-07-17T06:11:00.000","Title":"Good compilers for compiling perl\/python\/php scripts into linux executables?","Data Science and Machine Learning":0,"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},{"Question":"I am working on a project that requires reading text files, extracting data from them, and then generating reports (text files). Since there are a lot of string parsing, I decided to do it in Perl or Python or PHP (preference in that order). But I don't want to expose the source code to my client. Is there any good compiler for compiling perl\/python\/php scripts into linux executables?\nI am not looking for a 100% perfect one, but I am looking for an at least 90% perfect one. By perfect, I mean the compiler doesn't require to write scripts with a limited subset of language features.","AnswerCount":8,"Available Count":4,"Score":0.0,"is_accepted":false,"ViewCount":2889,"Q_Id":3270464,"Users Score":0,"Answer":"For linux an executable is something which has +x set, so there's no need to compile scripts. To hide your sourcecode you could use an obfuscator. This makes your sourcecode unreadable.","Q_Score":2,"Tags":"php,python,perl,compiler-construction,scripting-language","A_Id":3270518,"CreationDate":"2010-07-17T06:11:00.000","Title":"Good compilers for compiling perl\/python\/php scripts into linux executables?","Data Science and Machine Learning":0,"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},{"Question":"I'm working on a plugin for some software that I'm planning on selling someday. The software I'm making it for has both a C++ SDK and a Python SDK.\nThe C++ SDK documentation appears incomplete in certain areas and isn't documented that well.\nThe Python SDK docs appear more complete and in general are much easier to work with.\nSo I'm trying to decide if I want to go through the potential trouble of building a C++ plugin instead of a Python plugin to sell. About the only thing that makes me want to do a C++ plugin is that in my mind, a \"C++ plugin\" might be an easier sell than a \"Python plugin\". A lot of programmers out there don't even considered writing Python to be real \"programming\".\nDo you think that potential customers might say \"Why would I pay money for a measly little Python script?\"?  As opposed to \"Oh it was written in C++ so the guy must be a decent programmer\"?\nWriting the Python plugin would be faster. Both plugins would look and behave exactly the same. The C++ plugin might be faster in certain spots, but for the type of plugin this is, that's not a huge deal.\nSo my question is, would a Python plugin be considered not as professional\/sellable as a C++ plugin, even if it looks and acts EXACTLY the same as a C++ plugin?","AnswerCount":4,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":815,"Q_Id":3277376,"Users Score":0,"Answer":"Python will also have the advantage\/disadvantage (depending on what you want) that the source code must be open. (I think delivering only the .pyc file is not really an option as the Python bytecode format is changing in every release.)\nOtherwise, let's say you are selling to people who don't really know what the difference is between Python\/C++: The outcome is the important thing. If your Python plugin runs and feels stable and fast, it is fine.\nIf they have heard about both languages, there really may be a difference. I must admit, if I had a choice between two plugins which do exactly the same and which are perfectly stable from all user reports, I probably would prefer the C++ plugin. It would be my intuition which would tell me that the C++ code is probably slightly more stable and faster. This is also for Unix tools and other stuff.","Q_Score":3,"Tags":"c++,python","A_Id":3277408,"CreationDate":"2010-07-18T21:42:00.000","Title":"Is Python-based software considered less-professional than C++\/compiled software?","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},{"Question":"I'm working on a plugin for some software that I'm planning on selling someday. The software I'm making it for has both a C++ SDK and a Python SDK.\nThe C++ SDK documentation appears incomplete in certain areas and isn't documented that well.\nThe Python SDK docs appear more complete and in general are much easier to work with.\nSo I'm trying to decide if I want to go through the potential trouble of building a C++ plugin instead of a Python plugin to sell. About the only thing that makes me want to do a C++ plugin is that in my mind, a \"C++ plugin\" might be an easier sell than a \"Python plugin\". A lot of programmers out there don't even considered writing Python to be real \"programming\".\nDo you think that potential customers might say \"Why would I pay money for a measly little Python script?\"?  As opposed to \"Oh it was written in C++ so the guy must be a decent programmer\"?\nWriting the Python plugin would be faster. Both plugins would look and behave exactly the same. The C++ plugin might be faster in certain spots, but for the type of plugin this is, that's not a huge deal.\nSo my question is, would a Python plugin be considered not as professional\/sellable as a C++ plugin, even if it looks and acts EXACTLY the same as a C++ plugin?","AnswerCount":4,"Available Count":3,"Score":1.2,"is_accepted":true,"ViewCount":815,"Q_Id":3277376,"Users Score":6,"Answer":"A lot of programmers out there don't even considered writing Python to be real \"programming\".\n\nA lot of \"programmers\" out there are incompetent, too.\n\nDo you think that potential customers might say \"Why would I pay money for a measly little Python script?\"?\n\nI'm sure it depends on the type of software, but I can tell you that my program's customers have little interest in what we use to develop our product, and I doubt most of them know that the software is written in C++.  They just care that it works.\n\nSo my question is, would a Python plugin be considered not as professional\/sellable as a C++ plugin, even if it looks and acts EXACTLY the same as a C++ plugin?\n\nNo.","Q_Score":3,"Tags":"c++,python","A_Id":3277400,"CreationDate":"2010-07-18T21:42:00.000","Title":"Is Python-based software considered less-professional than C++\/compiled software?","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},{"Question":"I'm working on a plugin for some software that I'm planning on selling someday. The software I'm making it for has both a C++ SDK and a Python SDK.\nThe C++ SDK documentation appears incomplete in certain areas and isn't documented that well.\nThe Python SDK docs appear more complete and in general are much easier to work with.\nSo I'm trying to decide if I want to go through the potential trouble of building a C++ plugin instead of a Python plugin to sell. About the only thing that makes me want to do a C++ plugin is that in my mind, a \"C++ plugin\" might be an easier sell than a \"Python plugin\". A lot of programmers out there don't even considered writing Python to be real \"programming\".\nDo you think that potential customers might say \"Why would I pay money for a measly little Python script?\"?  As opposed to \"Oh it was written in C++ so the guy must be a decent programmer\"?\nWriting the Python plugin would be faster. Both plugins would look and behave exactly the same. The C++ plugin might be faster in certain spots, but for the type of plugin this is, that's not a huge deal.\nSo my question is, would a Python plugin be considered not as professional\/sellable as a C++ plugin, even if it looks and acts EXACTLY the same as a C++ plugin?","AnswerCount":4,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":815,"Q_Id":3277376,"Users Score":0,"Answer":"I think it doesn't matter. It all come down to 'use the right tool for the right job'. Your primary goal should be to make the best plugin you can. So if you feel more at ease with Python use that. It will probably take you less time to write. The client probably doesn't mind it and just want the most stable, reliable, cheapest, easiest to use plugin. So concentrate on that not on the tool.","Q_Score":3,"Tags":"c++,python","A_Id":3277403,"CreationDate":"2010-07-18T21:42:00.000","Title":"Is Python-based software considered less-professional than C++\/compiled software?","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},{"Question":"I was thinking of improving my python and just recently read an article about the python-fuse library. I'm always interested about filesystem stuff so I thought this would be a good library to hack on. \nWhat I can't come up with is an idea of what I should implement with this. Do you guys have any suggestions or ideas that you can share?","AnswerCount":5,"Available Count":5,"Score":0.0798297691,"is_accepted":false,"ViewCount":461,"Q_Id":3278567,"Users Score":2,"Answer":"What about a versioned file-system? It has always seemed like a cool idea since I read about the implementation in Plan 9. You wouldn't have to write the versioning part as you could use an off-the-shelf version control like git. The contents of the repository could be exposed as a file hierarchy, older versions could be read-only directories and write access to files in the repository could trigger a commit.\nThe original versions of sshfs used a FUSE frontend that fired shell commands out the back to move around in the target file-system. You could implement something similar quite easily to output git commands and act on the repository.","Q_Score":2,"Tags":"python,project,fuse","A_Id":3396712,"CreationDate":"2010-07-19T05:05:00.000","Title":"interesting project that I can implement with fuse-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},{"Question":"I was thinking of improving my python and just recently read an article about the python-fuse library. I'm always interested about filesystem stuff so I thought this would be a good library to hack on. \nWhat I can't come up with is an idea of what I should implement with this. Do you guys have any suggestions or ideas that you can share?","AnswerCount":5,"Available Count":5,"Score":0.0,"is_accepted":false,"ViewCount":461,"Q_Id":3278567,"Users Score":0,"Answer":"I do not know if python is appropriate, but maybe you can provide URL handlers for fuse in Firefox. \nfor example: sshfs:\/\/host\/path would allow to explore remote ssh host via Firefox browser.","Q_Score":2,"Tags":"python,project,fuse","A_Id":3278603,"CreationDate":"2010-07-19T05:05:00.000","Title":"interesting project that I can implement with fuse-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},{"Question":"I was thinking of improving my python and just recently read an article about the python-fuse library. I'm always interested about filesystem stuff so I thought this would be a good library to hack on. \nWhat I can't come up with is an idea of what I should implement with this. Do you guys have any suggestions or ideas that you can share?","AnswerCount":5,"Available Count":5,"Score":0.0,"is_accepted":false,"ViewCount":461,"Q_Id":3278567,"Users Score":0,"Answer":"Maybe a filesystem where files behave like directories, so you can store files in files.\nOr a filesystem where you can store files with the same name in 1 directory.","Q_Score":2,"Tags":"python,project,fuse","A_Id":3278606,"CreationDate":"2010-07-19T05:05:00.000","Title":"interesting project that I can implement with fuse-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},{"Question":"I was thinking of improving my python and just recently read an article about the python-fuse library. I'm always interested about filesystem stuff so I thought this would be a good library to hack on. \nWhat I can't come up with is an idea of what I should implement with this. Do you guys have any suggestions or ideas that you can share?","AnswerCount":5,"Available Count":5,"Score":0.0399786803,"is_accepted":false,"ViewCount":461,"Q_Id":3278567,"Users Score":1,"Answer":"Mounting an xml file as a filesystem, where elements are directories, and their contents is stored as a plain file. The attributes are stored in an \"attributes\" file as newline separated  name: value pairs in each directory.\nThis would allow XML to be modified using the common shell tools. (sed, grep, mkdir, rm, rmdir, cat, vim,  etc...) An elegant solution would have to be found for multiple elements with the same name.\nSo it's a bit far field. You never said that it had to be a good idea.","Q_Score":2,"Tags":"python,project,fuse","A_Id":3289412,"CreationDate":"2010-07-19T05:05:00.000","Title":"interesting project that I can implement with fuse-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},{"Question":"I was thinking of improving my python and just recently read an article about the python-fuse library. I'm always interested about filesystem stuff so I thought this would be a good library to hack on. \nWhat I can't come up with is an idea of what I should implement with this. Do you guys have any suggestions or ideas that you can share?","AnswerCount":5,"Available Count":5,"Score":0.0798297691,"is_accepted":false,"ViewCount":461,"Q_Id":3278567,"Users Score":2,"Answer":"The typical 'cool' things with FUSE are exposing in a filesystem interface things that aren't files, and usually are stored somewhere else.\nExisting examples: Gmail filesystem, SSH filesystem.\nNon existing (that I know of) examples: a Twitter filesystem, that shows tweets as files. Or a Stack Overflow filesystem, questions and answers as files.","Q_Score":2,"Tags":"python,project,fuse","A_Id":3278611,"CreationDate":"2010-07-19T05:05:00.000","Title":"interesting project that I can implement with fuse-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},{"Question":"I want to make a python script that tests the bandwidth of a connection. I am thinking of downloading\/uploading a file of a known size using urllib2, and measuring the time it takes to perform this task. I would also like to measure the delay to a given IP address, such as is given by pinging the IP. Is this possible using urllib2?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1534,"Q_Id":3280391,"Users Score":0,"Answer":"You could download an empty file to measure the delay. You measure more the only the network delay, but the difference should be too big I expect.","Q_Score":4,"Tags":"python,urllib2,bandwidth","A_Id":3280448,"CreationDate":"2010-07-19T10:52:00.000","Title":"Bandwidth test, delay test using urllib2","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},{"Question":"On a linux box I've got a python script that's always started from predefined user. It may take a while for it to finish so I want to allow other users to stop it from the web.\nUsing kill fails with Operation not permitted. \nCan I somehow modify my long running python script so that it'll recive a signal from another user? Obviously, that another user is the one that starts a web server.\nMay be there's entirely different way to approach this problem I can't think of right now.","AnswerCount":4,"Available Count":3,"Score":0.049958375,"is_accepted":false,"ViewCount":332,"Q_Id":3281107,"Users Score":1,"Answer":"If you do not want to execute the kill command with the correct permissions, you can send any other signal to the other script. It is then the other scripts' responsibility to terminate. You cannot force it, unless you have the permissions to do so.  \nThis can happen with a network connection, or a 'kill' file whose existence is checked by the other script, or anything else the script is able to listen to.","Q_Score":3,"Tags":"python,linux,signals,kill","A_Id":3281123,"CreationDate":"2010-07-19T12:46:00.000","Title":"terminate script of another 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},{"Question":"On a linux box I've got a python script that's always started from predefined user. It may take a while for it to finish so I want to allow other users to stop it from the web.\nUsing kill fails with Operation not permitted. \nCan I somehow modify my long running python script so that it'll recive a signal from another user? Obviously, that another user is the one that starts a web server.\nMay be there's entirely different way to approach this problem I can't think of right now.","AnswerCount":4,"Available Count":3,"Score":0.049958375,"is_accepted":false,"ViewCount":332,"Q_Id":3281107,"Users Score":1,"Answer":"Off the top of my head, one solution would be threading the script and waiting for a kill signal via some form or another. Or rather than threading, you could have a file that the script checks every N times through a loop - then you just write a kill signal to that file (which of course has write permissions by the web user).\nI'm not terribly familiar with kill, other than killing my own scripts, so there may be a better solution.","Q_Score":3,"Tags":"python,linux,signals,kill","A_Id":3281132,"CreationDate":"2010-07-19T12:46:00.000","Title":"terminate script of another 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},{"Question":"On a linux box I've got a python script that's always started from predefined user. It may take a while for it to finish so I want to allow other users to stop it from the web.\nUsing kill fails with Operation not permitted. \nCan I somehow modify my long running python script so that it'll recive a signal from another user? Obviously, that another user is the one that starts a web server.\nMay be there's entirely different way to approach this problem I can't think of right now.","AnswerCount":4,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":332,"Q_Id":3281107,"Users Score":0,"Answer":"You could use sudo to perform the kill command as root, but that is horrible practice.\nHow about having the long-running script check some condition every x seconds, for example the existence of a file like \/tmp\/stop-xyz.txt? If that file is found, the script terminates itself immediately.  \n(Or any other means of inter-process communication - it doesn't matter.)","Q_Score":3,"Tags":"python,linux,signals,kill","A_Id":3281121,"CreationDate":"2010-07-19T12:46:00.000","Title":"terminate script of another 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},{"Question":"I have 5 python cgi pages. I can navigate from one page to another. All pages get their data from the same database table just that they use different queries.\nThe problem is that the application as a whole is slow. Though they connect to the same database, each page creates a new handle every time I visit it and handles are not shared by the pages.\nI want to improve performance.\nCan I do that by setting up sessions for the user?\nSuggestions\/Advices are welcome.\nThanks","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":179,"Q_Id":3289330,"Users Score":0,"Answer":"Django and Pylons are both frameworks that solve this problem quite nicely, namely by abstracting the DB-frontend integration.  They are worth considering.","Q_Score":1,"Tags":"python,cgi","A_Id":3289546,"CreationDate":"2010-07-20T11:15:00.000","Title":"Improving performance of cgi","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},{"Question":"I realize that in most cases, it's preferred in Python to just access attributes directly, since there's no real concept of encapsulation like there is in Java and the like. However, I'm wondering if there aren't any exceptions, particularly with abstract classes that have disparate implementations.\nLet's say I'm writing a bunch of abstract classes (because I am) and that they represent things having to do with version control systems like repositories and revisions (because they do). Something like an SvnRevision and an HgRevision and a GitRevision are very closely semantically linked, and I want them to be able to do the same things (so that I can have code elsewhere that acts on any kind of Repository object, and is agnostic of the subclass), which is why I want them to inherit from an abstract class. However, their implementations vary considerably.\nSo far, the subclasses that have been implemented share a lot of attribute names, and in a lot of code outside of the classes themselves, direct attribute access is used. For example, every subclass of Revision has an author attribute, and a date attribute, and so on. However, the attributes aren't described anywhere in the abstract class. This seems to me like a very fragile design.\nIf someone wants to write another implementation of the Revision class, I feel like they should be able to do so just by looking at the abstract class. However, an implementation of the class that satisfies all of the abstract methods will almost certainly fail, because the author won't know that they need attributes called 'author' and 'date' and so on, so code that tries to access Revision.author will throw an exception. Probably not hard to find the source of the problem, but irritating nonetheless, and it just feels like an inelegant design.\nMy solution was to write accessor methods for the abstract classes (get_id, get_author, etc.). I thought this was actually a pretty clean solution, since it eliminates arbitrary restrictions on how attributes are named and stored, and just makes clear what data the object needs to be able to access. Any class that implements all of the methods of the abstract class will work... that feels right.\nAnyways, the team I'm working with hates this solution (seemingly for the reason that accessors are unpythonic, which I can't really argue with). So... what's the alternative? Documentation? Or is the problem I'm imagining a non-issue? \nNote: I've considered properties, but I don't think they're a cleaner solution.","AnswerCount":5,"Available Count":3,"Score":0.1586485043,"is_accepted":false,"ViewCount":5980,"Q_Id":3292631,"Users Score":4,"Answer":"You've missed the point. It isn't the lack of encapsulation that removes the need for accessors, it's the fact that, by changing from a direct attribute to a property, you can add an accessor at a later time without changing the published interface in any way.\nIn many other languages, if you expose an attribute as public and then later want to wrap some code round it on access or mutation then you have to change the interface and anyone using the code has at the very least to recompile and possibly to edit their code also. Python isn't like that: you can flip flop between attribute or property just as much as you want and no code that uses the class will break.","Q_Score":10,"Tags":"python,inheritance,interface,attributes,abstract-class","A_Id":3292765,"CreationDate":"2010-07-20T17:26:00.000","Title":"Are accessors in Python ever justified?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I realize that in most cases, it's preferred in Python to just access attributes directly, since there's no real concept of encapsulation like there is in Java and the like. However, I'm wondering if there aren't any exceptions, particularly with abstract classes that have disparate implementations.\nLet's say I'm writing a bunch of abstract classes (because I am) and that they represent things having to do with version control systems like repositories and revisions (because they do). Something like an SvnRevision and an HgRevision and a GitRevision are very closely semantically linked, and I want them to be able to do the same things (so that I can have code elsewhere that acts on any kind of Repository object, and is agnostic of the subclass), which is why I want them to inherit from an abstract class. However, their implementations vary considerably.\nSo far, the subclasses that have been implemented share a lot of attribute names, and in a lot of code outside of the classes themselves, direct attribute access is used. For example, every subclass of Revision has an author attribute, and a date attribute, and so on. However, the attributes aren't described anywhere in the abstract class. This seems to me like a very fragile design.\nIf someone wants to write another implementation of the Revision class, I feel like they should be able to do so just by looking at the abstract class. However, an implementation of the class that satisfies all of the abstract methods will almost certainly fail, because the author won't know that they need attributes called 'author' and 'date' and so on, so code that tries to access Revision.author will throw an exception. Probably not hard to find the source of the problem, but irritating nonetheless, and it just feels like an inelegant design.\nMy solution was to write accessor methods for the abstract classes (get_id, get_author, etc.). I thought this was actually a pretty clean solution, since it eliminates arbitrary restrictions on how attributes are named and stored, and just makes clear what data the object needs to be able to access. Any class that implements all of the methods of the abstract class will work... that feels right.\nAnyways, the team I'm working with hates this solution (seemingly for the reason that accessors are unpythonic, which I can't really argue with). So... what's the alternative? Documentation? Or is the problem I'm imagining a non-issue? \nNote: I've considered properties, but I don't think they're a cleaner solution.","AnswerCount":5,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":5980,"Q_Id":3292631,"Users Score":0,"Answer":"The discussion already ended a year ago, but this snippet seemed telltale, it's worth discussing:\n\nHowever, an implementation of the\n  class that satisfies all of the\n  abstract methods will almost certainly\n  fail, because the author won't know\n  that they need attributes called\n  'author' and 'date' and so on, so code\n  that tries to access Revision.author\n  will throw an exception.\n\nUh, something is deeply wrong. (What S. Lott said, minus the personal comments).\nIf these are required members, aren't they referenced (if not required) in the constructor, and defined by docstring? or at very least, as required args of methods, and again documented?\nHow could users of the class not know what the required members are?\nTo be the devil's advocate, what if your constructor(s) requires you to supply all the members that will\/may be required, what issue does that cause?\nAlso, are you checking the parameters when passed, and throwing informative exceptions?\n(The ideological argument of accessor-vs-property is a sidebar. Properties are preferable but I don't think that's the issue with your class design.)","Q_Score":10,"Tags":"python,inheritance,interface,attributes,abstract-class","A_Id":6562247,"CreationDate":"2010-07-20T17:26:00.000","Title":"Are accessors in Python ever justified?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I realize that in most cases, it's preferred in Python to just access attributes directly, since there's no real concept of encapsulation like there is in Java and the like. However, I'm wondering if there aren't any exceptions, particularly with abstract classes that have disparate implementations.\nLet's say I'm writing a bunch of abstract classes (because I am) and that they represent things having to do with version control systems like repositories and revisions (because they do). Something like an SvnRevision and an HgRevision and a GitRevision are very closely semantically linked, and I want them to be able to do the same things (so that I can have code elsewhere that acts on any kind of Repository object, and is agnostic of the subclass), which is why I want them to inherit from an abstract class. However, their implementations vary considerably.\nSo far, the subclasses that have been implemented share a lot of attribute names, and in a lot of code outside of the classes themselves, direct attribute access is used. For example, every subclass of Revision has an author attribute, and a date attribute, and so on. However, the attributes aren't described anywhere in the abstract class. This seems to me like a very fragile design.\nIf someone wants to write another implementation of the Revision class, I feel like they should be able to do so just by looking at the abstract class. However, an implementation of the class that satisfies all of the abstract methods will almost certainly fail, because the author won't know that they need attributes called 'author' and 'date' and so on, so code that tries to access Revision.author will throw an exception. Probably not hard to find the source of the problem, but irritating nonetheless, and it just feels like an inelegant design.\nMy solution was to write accessor methods for the abstract classes (get_id, get_author, etc.). I thought this was actually a pretty clean solution, since it eliminates arbitrary restrictions on how attributes are named and stored, and just makes clear what data the object needs to be able to access. Any class that implements all of the methods of the abstract class will work... that feels right.\nAnyways, the team I'm working with hates this solution (seemingly for the reason that accessors are unpythonic, which I can't really argue with). So... what's the alternative? Documentation? Or is the problem I'm imagining a non-issue? \nNote: I've considered properties, but I don't think they're a cleaner solution.","AnswerCount":5,"Available Count":3,"Score":0.0399786803,"is_accepted":false,"ViewCount":5980,"Q_Id":3292631,"Users Score":1,"Answer":"\"they should be able to do so just by looking at the abstract class\"\n\nDon't know what this should be true.  A \"programmer's guide\", a \"how to extend\" document, plus some training seems appropriate to me.\n\n\"the author won't know that they need attributes called 'author' and 'date' and so on\".  \n\nIn that case, the documentation isn't complete.  Perhaps the abstract class needs a better docstring.  Or a \"programmer's guide\", or a \"how to extend\" document.\nAlso, it doesn't seem very difficult to (1) document these attributes in the docstring and (2) provide default values in the __init__ method.\nWhat's wrong with providing extra support for programmers?\nIt sounds like you have a social problem, not a technical one.  Writing code to solve a social problem seems like a waste of time and money.","Q_Score":10,"Tags":"python,inheritance,interface,attributes,abstract-class","A_Id":3292748,"CreationDate":"2010-07-20T17:26:00.000","Title":"Are accessors in Python ever justified?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"If I'm writing a library in C that includes a Python interface, is it OK to just write unit tests for the functions, etc in the Python interface? Assuming the Python interface is complete, it should imply the C code works.\nMostly I'm being lazy in that the Python unit test thing takes almost zero effort to use.\nthanks,\n-nick","AnswerCount":4,"Available Count":4,"Score":1.2,"is_accepted":true,"ViewCount":217,"Q_Id":3294526,"Users Score":5,"Answer":"Tests through the Python interface will be valuable acceptance tests for your library. They will not however be unit tests.\nUnit tests are written by the same coders, in the same language, on the same platform as the unit which they test. These should be written too!\nYou're right, though, unit testing in Python is far easier than C++ (or even C, which is what you said!).","Q_Score":3,"Tags":"python,c,unit-testing","A_Id":3298479,"CreationDate":"2010-07-20T21:30:00.000","Title":"trickle down 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":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"If I'm writing a library in C that includes a Python interface, is it OK to just write unit tests for the functions, etc in the Python interface? Assuming the Python interface is complete, it should imply the C code works.\nMostly I'm being lazy in that the Python unit test thing takes almost zero effort to use.\nthanks,\n-nick","AnswerCount":4,"Available Count":4,"Score":0.0,"is_accepted":false,"ViewCount":217,"Q_Id":3294526,"Users Score":0,"Answer":"Ideally, you'd write unit tests for each.\nYour Python library calls probably (hopefully?) don't have a one-to-one correspondence to your C library calls, because that wouldn't be a very Pythonic interface, so if you only unit test your Python interface, there would be variations and sequences of C library calls that weren't tested.","Q_Score":3,"Tags":"python,c,unit-testing","A_Id":3294592,"CreationDate":"2010-07-20T21:30:00.000","Title":"trickle down 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":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"If I'm writing a library in C that includes a Python interface, is it OK to just write unit tests for the functions, etc in the Python interface? Assuming the Python interface is complete, it should imply the C code works.\nMostly I'm being lazy in that the Python unit test thing takes almost zero effort to use.\nthanks,\n-nick","AnswerCount":4,"Available Count":4,"Score":0.049958375,"is_accepted":false,"ViewCount":217,"Q_Id":3294526,"Users Score":1,"Answer":"If you only care if the Python library works, then test that. This will give you significant confirmation that the C library is robust, but the maxim \"if you didn't test it, it doesn't work\" still mostly applies and I wouldn't export the library without the test harness.\nYou could, in theory, test that the processor microcode is doing its job properly but one usually doesn't.","Q_Score":3,"Tags":"python,c,unit-testing","A_Id":3294582,"CreationDate":"2010-07-20T21:30:00.000","Title":"trickle down 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":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"If I'm writing a library in C that includes a Python interface, is it OK to just write unit tests for the functions, etc in the Python interface? Assuming the Python interface is complete, it should imply the C code works.\nMostly I'm being lazy in that the Python unit test thing takes almost zero effort to use.\nthanks,\n-nick","AnswerCount":4,"Available Count":4,"Score":0.0,"is_accepted":false,"ViewCount":217,"Q_Id":3294526,"Users Score":0,"Answer":"I see two mains restrictions to unit testing thru the Python interface. Whether it is OK to testing with those restrictions or not depends on what the library does, how it is implemented, and on the alignment of the Python interface on the interface of the C library.\n\nthe library can only be exercised the way the Python library is using it. This is not a problem as far as the Python interface is the only client of the C library.\nthe Python unit tests do not have access to the internals of the C library as unit tests written in C would have: only what is exposed via the Python interface is reachable. Therefore\n\n\nif a problem arises after 10 calls to the Python interface, 10 calls will be needed to reproduce it, while a unit test written in C could create the fixture directly, without the 10 calls. This can make Python tests slower.\nthe Python unit tests couldn't be as isolated as C unit tests could be as they may not been able to reset the internals of the library","Q_Score":3,"Tags":"python,c,unit-testing","A_Id":3298110,"CreationDate":"2010-07-20T21:30:00.000","Title":"trickle down 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":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've got 2 problems with Eric4 IDE.\nCan't find an option in preferences to autosave my changed files before running script. It's very annoying that I have to save my file and then run script.\nSecond problem is running a script. I can't find any button to run a script\/project instantly. 'Run Script' button always opens a setting window.","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":2425,"Q_Id":3295448,"Users Score":2,"Answer":"One way to get around this, as it seems there is no built in way is to bind a key to save the file (ctrl+s), then run the script (F2), and finally hit enter (to close the settings window and run the code).","Q_Score":5,"Tags":"python,ide","A_Id":3296442,"CreationDate":"2010-07-21T00:27:00.000","Title":"Eric4 Python IDE - autosave and quick script\/project start, run","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I've got 2 problems with Eric4 IDE.\nCan't find an option in preferences to autosave my changed files before running script. It's very annoying that I have to save my file and then run script.\nSecond problem is running a script. I can't find any button to run a script\/project instantly. 'Run Script' button always opens a setting window.","AnswerCount":2,"Available Count":2,"Score":0.1973753202,"is_accepted":false,"ViewCount":2425,"Q_Id":3295448,"Users Score":2,"Answer":"This bothered me a lot too, and I know this is 2 years late but it might help some else who comes here looking for this very solution, like I did. Here are the actual answers, ERIC v4.4: \nPress F4 instead of F2.\nThe first time you have to use F2 to 'Start' the script, so dismiss the settings window. After that you can use F4 'Restart' and it will run with the settings you chose initially.\nThe Autosave option is well hidden unfortunately:\nSettings-->Preferences-->Debugger-->General-->!Scroll down to!-->Start Debugging-->Autosave changed scripts\nAnd you were spot on - these two things do have a huge impact on productivity.","Q_Score":5,"Tags":"python,ide","A_Id":10222754,"CreationDate":"2010-07-21T00:27:00.000","Title":"Eric4 Python IDE - autosave and quick script\/project start, run","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I'm confronted with the task of making a C++ app scriptable by users. The app has been in development for several years with no one wasting a thought on this before. It contains all sorts of niceties like multithreading, template wizardry and multiple inheritance. As the scripting language, Python is preferred, but Lua might be accepted if it is significantly easier to implement.\nQuestion 1\nFrom what I have learned so far, there are broadly speaking two ways to integrate Python\/Lua with C++ : \"extending\" and \"embedding\".\nIn this case, it looks like I need both. The scripting language need access to objects, methods and data from the app but needs to be called by the app once the user has written the script - without restarting anything.\nHow is this usually done in the real world?\nQuestion 2\nThere seems to be a bewildering array of of manual solutions and binding generators out there, all of them less than perfect. \n\nswig, pyste, Py++, ctypes, Boost.Python sip, PyCXX, pybindgen, robin, (Cython\/Pyrex, Weave)\nCppLua, Diluculum, Luabind, Luabridge, LuaCpp, Luna\/LunaWrapper, MLuaBind, MultiScript, OOLua, SLB, Sweet Lua, lux\n(this list from the lua wiki)\nCPB, tolua, tolua++, toLuaxx, luna and again swig\n\nMost commments on these found on the web are a little out of date. For example, swig is said to be difficult in non-trivial cases and to generate incomprehensible code. OTOH, it has recently gone to v2.0.\nSome of the above use pygccxml to let gcc analyze the C++ code and then genarate the binding. I find this idea appealing, as gcc probably understands the code better than i do  :-). Does this work well?\nTesting them all might easily cost me half of the time allocated for the whole project.\nSo, which ones do you recommend?","AnswerCount":5,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":1926,"Q_Id":3299067,"Users Score":0,"Answer":"My experience may not be much, but I figure it's at least worth what you paid for it ;)\nI've done some basic \"hello world\" python modules, and I couldn't really get into swig - it seemed like a lot of overhead for what I was doing. Of course it's also possible that it's just the right amount for your needs.","Q_Score":12,"Tags":"c++,python,binding,lua,scriptable","A_Id":3299189,"CreationDate":"2010-07-21T12:18:00.000","Title":"How do I make a nasty C++ program scriptable with Python and\/or Lua?","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},{"Question":"I'm confronted with the task of making a C++ app scriptable by users. The app has been in development for several years with no one wasting a thought on this before. It contains all sorts of niceties like multithreading, template wizardry and multiple inheritance. As the scripting language, Python is preferred, but Lua might be accepted if it is significantly easier to implement.\nQuestion 1\nFrom what I have learned so far, there are broadly speaking two ways to integrate Python\/Lua with C++ : \"extending\" and \"embedding\".\nIn this case, it looks like I need both. The scripting language need access to objects, methods and data from the app but needs to be called by the app once the user has written the script - without restarting anything.\nHow is this usually done in the real world?\nQuestion 2\nThere seems to be a bewildering array of of manual solutions and binding generators out there, all of them less than perfect. \n\nswig, pyste, Py++, ctypes, Boost.Python sip, PyCXX, pybindgen, robin, (Cython\/Pyrex, Weave)\nCppLua, Diluculum, Luabind, Luabridge, LuaCpp, Luna\/LunaWrapper, MLuaBind, MultiScript, OOLua, SLB, Sweet Lua, lux\n(this list from the lua wiki)\nCPB, tolua, tolua++, toLuaxx, luna and again swig\n\nMost commments on these found on the web are a little out of date. For example, swig is said to be difficult in non-trivial cases and to generate incomprehensible code. OTOH, it has recently gone to v2.0.\nSome of the above use pygccxml to let gcc analyze the C++ code and then genarate the binding. I find this idea appealing, as gcc probably understands the code better than i do  :-). Does this work well?\nTesting them all might easily cost me half of the time allocated for the whole project.\nSo, which ones do you recommend?","AnswerCount":5,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":1926,"Q_Id":3299067,"Users Score":0,"Answer":"Try Boost::Python, it has somewhat of a learning curve associated with it but it is the best tool for the job in my view, we have a huge real time system and developed the scripting library for the QA in Boost::Python.","Q_Score":12,"Tags":"c++,python,binding,lua,scriptable","A_Id":3299415,"CreationDate":"2010-07-21T12:18:00.000","Title":"How do I make a nasty C++ program scriptable with Python and\/or Lua?","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},{"Question":"I'm confronted with the task of making a C++ app scriptable by users. The app has been in development for several years with no one wasting a thought on this before. It contains all sorts of niceties like multithreading, template wizardry and multiple inheritance. As the scripting language, Python is preferred, but Lua might be accepted if it is significantly easier to implement.\nQuestion 1\nFrom what I have learned so far, there are broadly speaking two ways to integrate Python\/Lua with C++ : \"extending\" and \"embedding\".\nIn this case, it looks like I need both. The scripting language need access to objects, methods and data from the app but needs to be called by the app once the user has written the script - without restarting anything.\nHow is this usually done in the real world?\nQuestion 2\nThere seems to be a bewildering array of of manual solutions and binding generators out there, all of them less than perfect. \n\nswig, pyste, Py++, ctypes, Boost.Python sip, PyCXX, pybindgen, robin, (Cython\/Pyrex, Weave)\nCppLua, Diluculum, Luabind, Luabridge, LuaCpp, Luna\/LunaWrapper, MLuaBind, MultiScript, OOLua, SLB, Sweet Lua, lux\n(this list from the lua wiki)\nCPB, tolua, tolua++, toLuaxx, luna and again swig\n\nMost commments on these found on the web are a little out of date. For example, swig is said to be difficult in non-trivial cases and to generate incomprehensible code. OTOH, it has recently gone to v2.0.\nSome of the above use pygccxml to let gcc analyze the C++ code and then genarate the binding. I find this idea appealing, as gcc probably understands the code better than i do  :-). Does this work well?\nTesting them all might easily cost me half of the time allocated for the whole project.\nSo, which ones do you recommend?","AnswerCount":5,"Available Count":3,"Score":1.0,"is_accepted":false,"ViewCount":1926,"Q_Id":3299067,"Users Score":12,"Answer":"I wouldn't recommend swig as it's hard to get it to generate satisfactory binding in complex situations: been there, done that.  I had to write a horrible script that \"parsed\" the original C++ code to generate some acceptable C++ code that swig could chew and generate acceptable bindings.  So, in general: avoid ANY solution that relies on parsing the original C++ program.\nBetween Lua and Python: I have found Lua MUCH, MUCH better documented and more cleanly implemented.  Python has a GIL (global lock), whereas with Lua, you can have an interpreter instance in each thread, for example.\nSo, if you can choose, I'd recommend Lua. It is smaller language, easier to comprehend, easier to embed (much cleaner and smaller API, with excellent documentation).  I have used luabind for a small project of mine and found it easy to use.","Q_Score":12,"Tags":"c++,python,binding,lua,scriptable","A_Id":3299174,"CreationDate":"2010-07-21T12:18:00.000","Title":"How do I make a nasty C++ program scriptable with Python and\/or Lua?","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},{"Question":"I've installed pydev to my eclipse 3.5.2. Everything was working smoothly, create projects, execute, test, autocomplete.\nBut then I realized that importing modules from \/usr\/lib\/pymodules\/python2.6, such as django, causes error \"Unresolved import: xxxx\". Of course, PYTHONPATH SYSTEM includes the directories I want. What's more, inside package explorer i can c the modules under \"System Libs\".\nI just can't import them :S. Is this a bug? Or I just missing something.\nThanks.","AnswerCount":3,"Available Count":3,"Score":0.0665680765,"is_accepted":false,"ViewCount":9880,"Q_Id":3300903,"Users Score":1,"Answer":"It seems like some sort of cache issue in PyDev... in which case you could try to remove the interpreter, add it again and restart Eclipse.","Q_Score":2,"Tags":"python,eclipse,pydev","A_Id":8374480,"CreationDate":"2010-07-21T15:21:00.000","Title":"Pydev, eclipse and pythonpath problem","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I've installed pydev to my eclipse 3.5.2. Everything was working smoothly, create projects, execute, test, autocomplete.\nBut then I realized that importing modules from \/usr\/lib\/pymodules\/python2.6, such as django, causes error \"Unresolved import: xxxx\". Of course, PYTHONPATH SYSTEM includes the directories I want. What's more, inside package explorer i can c the modules under \"System Libs\".\nI just can't import them :S. Is this a bug? Or I just missing something.\nThanks.","AnswerCount":3,"Available Count":3,"Score":1.2,"is_accepted":true,"ViewCount":9880,"Q_Id":3300903,"Users Score":1,"Answer":"If you're using virtualenv you should setup an interpreter using the python build inside.\nie., default python interpreter for th project will be \/usr\/bin\/python\nbut change it to something like \"{project name} python\" and point it to your virtual env path.  In my case it's ~\/.virtualenvs\/acme\/bin\/python","Q_Score":2,"Tags":"python,eclipse,pydev","A_Id":3459938,"CreationDate":"2010-07-21T15:21:00.000","Title":"Pydev, eclipse and pythonpath problem","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I've installed pydev to my eclipse 3.5.2. Everything was working smoothly, create projects, execute, test, autocomplete.\nBut then I realized that importing modules from \/usr\/lib\/pymodules\/python2.6, such as django, causes error \"Unresolved import: xxxx\". Of course, PYTHONPATH SYSTEM includes the directories I want. What's more, inside package explorer i can c the modules under \"System Libs\".\nI just can't import them :S. Is this a bug? Or I just missing something.\nThanks.","AnswerCount":3,"Available Count":3,"Score":0.1325487884,"is_accepted":false,"ViewCount":9880,"Q_Id":3300903,"Users Score":2,"Answer":"In eclipse you can add django folder in you python path.\nWindow->Preferences-> PyDev-> Interpreters->Python Interpreter -> Lirararies -> New Folder\nAnd browse till the parent folder of modules you are searching.","Q_Score":2,"Tags":"python,eclipse,pydev","A_Id":32353403,"CreationDate":"2010-07-21T15:21:00.000","Title":"Pydev, eclipse and pythonpath problem","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I needed to have a directly executable python script, so i started the file with #!\/usr\/bin\/env python. However, I also need unbuffered output, so i tried #!\/usr\/bin\/env python -u, but that fails with python -u: no such file or directory.\nI found out that #\/usr\/bin\/python -u works, but I need it to get the python in PATH to support virtual env environments.\nWhat are my options?","AnswerCount":9,"Available Count":2,"Score":1.0,"is_accepted":false,"ViewCount":27298,"Q_Id":3306518,"Users Score":13,"Answer":"Passing arguments to the shebang line is not standard and in as you have experimented do not work in combination with env in Linux. The solution with bash is to use the builtin command \"set\" to set the required options. I think you can do the same to set unbuffered output of stdin with a python command.\nmy2c","Q_Score":90,"Tags":"python,arguments,shebang","A_Id":3306575,"CreationDate":"2010-07-22T07:07:00.000","Title":"Cannot pass an argument to python with \"#!\/usr\/bin\/env 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},{"Question":"I needed to have a directly executable python script, so i started the file with #!\/usr\/bin\/env python. However, I also need unbuffered output, so i tried #!\/usr\/bin\/env python -u, but that fails with python -u: no such file or directory.\nI found out that #\/usr\/bin\/python -u works, but I need it to get the python in PATH to support virtual env environments.\nWhat are my options?","AnswerCount":9,"Available Count":2,"Score":1.0,"is_accepted":false,"ViewCount":27298,"Q_Id":3306518,"Users Score":17,"Answer":"When you use shebang on Linux, the entire rest of the line after the interpreter name is interpreted as a single argument. The python -u gets passed to env as if you'd typed: \/usr\/bin\/env 'python -u'. The \/usr\/bin\/env searches for a binary called python -u, which there isn't one.","Q_Score":90,"Tags":"python,arguments,shebang","A_Id":8921497,"CreationDate":"2010-07-22T07:07:00.000","Title":"Cannot pass an argument to python with \"#!\/usr\/bin\/env 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},{"Question":"I'm planning on moving to Python and I have a couple of additional questions along with the title:\n\ndid you have more fun with python?\nare you as productive as when you're using PHP?\nwhat made you change to python?\nWould you do a project again in PHP? If so, why?\n\nYour answers would really be useful for us PHP devs wanting something more I guess :)\nThanks in advance!","AnswerCount":8,"Available Count":6,"Score":0.0748596907,"is_accepted":false,"ViewCount":9531,"Q_Id":3319261,"Users Score":3,"Answer":"I run a self-developed private social site for 100+ users. Python was absolutely fantastic for making and running this.\n\n\ndid you have more fun with python?\n\n\nMost definitely.\n\n\nare you as productive as when you're using PHP?\n\n\nMostly yes. Python coding style, at least for me is so much quicker and easier. But python does sometimes lack in included libraries and documentation over PHP. (But PHP seems second to none in that reguard). Also requires a tad more to get running under apache.\n\n\nwhat made you change to python?\n\n\nEasier to manage code, and quicker development (A good IDE helps there, I use WingIDE for python), as well as improving my python skills for when I switch to non-web based projects.\n\n\nWould you do a project again in PHP? If so, why?\n\n\nPerhaps if I were working on a large scale professional project. PHP is so ubiquitous on the web A company would have a much easier time finding a replacement PHP programmer.","Q_Score":21,"Tags":"php,python","A_Id":3323632,"CreationDate":"2010-07-23T14:46:00.000","Title":"PHP devs that moved to Python, is the experience better?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm planning on moving to Python and I have a couple of additional questions along with the title:\n\ndid you have more fun with python?\nare you as productive as when you're using PHP?\nwhat made you change to python?\nWould you do a project again in PHP? If so, why?\n\nYour answers would really be useful for us PHP devs wanting something more I guess :)\nThanks in advance!","AnswerCount":8,"Available Count":6,"Score":0.0996679946,"is_accepted":false,"ViewCount":9531,"Q_Id":3319261,"Users Score":4,"Answer":"I'll try my best to answer your questions as best I can:\n\nDid you have more fun with python?\n\nI really enjoy how minimalist python is, having modules with non-redundant naming conventions is really nice.  I found this to be especially convenient when reading\/debugging other peoples code.  \nI also love all of the python tricks to do some very elegant things in a single line of code such as list comprehensions and the itertools library.  \nI tend to develop my applications using mod_wsgi and it took some time to wrap my head around writing thread-safe web applications, but it was really worth it.  \nI also find unicode to be much less frustrating with python especially with python 3k.\n\nare you as productive as when you're using PHP?\n\nFor simple websites python can be less fun to setup and use.  One nice feature of PHP that I miss with python is mixing PHP and HTML in the same file.  Python has a lot of nice template languages that make this easy as well, but they have to be installed.  \n\nwhat made you change to python?\n\nI became frustrated with a lot of the little nuances of PHP such as strange integer and string conversions and so forth.  I also started to feel that PHP was getting very bloated with a lot of methods with inconsistent naming schemes.  I was referring to the PHP documentation quite frequently despite having a large portion of the php library memorized.\n\nWould you do a project again in PHP? If so, why?\n\nI would develop a PHP project again, it has a lot of nice features and a great community.  Plus I have a lot of experience with PHP.  I'd prefer to use python, but if the client wants PHP I'm not going to force something they don't want.","Q_Score":21,"Tags":"php,python","A_Id":3319941,"CreationDate":"2010-07-23T14:46:00.000","Title":"PHP devs that moved to Python, is the experience better?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm planning on moving to Python and I have a couple of additional questions along with the title:\n\ndid you have more fun with python?\nare you as productive as when you're using PHP?\nwhat made you change to python?\nWould you do a project again in PHP? If so, why?\n\nYour answers would really be useful for us PHP devs wanting something more I guess :)\nThanks in advance!","AnswerCount":8,"Available Count":6,"Score":0.024994793,"is_accepted":false,"ViewCount":9531,"Q_Id":3319261,"Users Score":1,"Answer":"I've never really worked with PHP (nothing major) and come from the .NET world. The project I am currently on requires a lot of Python work and I must say I love it. Very easy and \"cool\" language, ie. FUN!\n.NET will always be my wife but Python is my mistress ;)","Q_Score":21,"Tags":"php,python","A_Id":3319485,"CreationDate":"2010-07-23T14:46:00.000","Title":"PHP devs that moved to Python, is the experience better?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm planning on moving to Python and I have a couple of additional questions along with the title:\n\ndid you have more fun with python?\nare you as productive as when you're using PHP?\nwhat made you change to python?\nWould you do a project again in PHP? If so, why?\n\nYour answers would really be useful for us PHP devs wanting something more I guess :)\nThanks in advance!","AnswerCount":8,"Available Count":6,"Score":0.024994793,"is_accepted":false,"ViewCount":9531,"Q_Id":3319261,"Users Score":1,"Answer":"yes\nyes\ncuriosity, search for better languages, etc. (actually, I learned them somewhat in parallel many years ago)\nyes, if a project requires it explicitly\n\ndisclaimer: I never really moved from php.","Q_Score":21,"Tags":"php,python","A_Id":3319291,"CreationDate":"2010-07-23T14:46:00.000","Title":"PHP devs that moved to Python, is the experience better?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm planning on moving to Python and I have a couple of additional questions along with the title:\n\ndid you have more fun with python?\nare you as productive as when you're using PHP?\nwhat made you change to python?\nWould you do a project again in PHP? If so, why?\n\nYour answers would really be useful for us PHP devs wanting something more I guess :)\nThanks in advance!","AnswerCount":8,"Available Count":6,"Score":0.0748596907,"is_accepted":false,"ViewCount":9531,"Q_Id":3319261,"Users Score":3,"Answer":"Well, I started with PHP, and have delved into Python recently.  I wouldn't say that I've \"moved to\", but I do use both (still PHP more, but a fair bit of Python as well).\nI wouldn't say that I have more \"fun\" with Python.  There are a lot of really cool and easy things that I really wish I could take to PHP.  So I guess it could be considered \"fun\".  But I still enjoy PHP, so...\nI'm more productive with PHP.  I know PHP inside and out.  I know most of the little nuances involved in writing effective PHP code.  I don't know Python that well (I've maybe written 5k lines of Python)...  I know enough to do what I need to, but not nearly as in-depth as PHP. \nI wanted to try something new.  I never liked Python, but then one day I decided to learn the basics, and that changed my views on it.  Now I really like some parts (and can see how it influences what PHP I write)...\nI am still doing PHP projects.  It's my best language.  And IMHO it's better than Python at some web tasks (like high traffic sites).  PHP has a built in multi-threaded FastCGI listener.  Python you need to find one (there are a bunch out there).  But in my benchmarks, Python was never able to get anywhere near as as fast as PHP with FastCGI (The best Py performed it was 25% slower than PHP.  The worst was several hundered times, depending on the FCGI library).  But that's based on my experience (which admittedly isn't much).  I know PHP, so I feel more comfortable committing a large site to it than I would PY...","Q_Score":21,"Tags":"php,python","A_Id":3319318,"CreationDate":"2010-07-23T14:46:00.000","Title":"PHP devs that moved to Python, is the experience better?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm planning on moving to Python and I have a couple of additional questions along with the title:\n\ndid you have more fun with python?\nare you as productive as when you're using PHP?\nwhat made you change to python?\nWould you do a project again in PHP? If so, why?\n\nYour answers would really be useful for us PHP devs wanting something more I guess :)\nThanks in advance!","AnswerCount":8,"Available Count":6,"Score":0.024994793,"is_accepted":false,"ViewCount":9531,"Q_Id":3319261,"Users Score":1,"Answer":"did you have more fun with python?\n\n\nYes. Lot more.\n\n\nare you as productive as when you're using PHP?\n\n\nNo. I think more.\n\n\nwhat made you change to python?\n\n\nDjango.\n\n\nWould you do a project again in PHP? If so, why?\n\n\nOnly if it is required.","Q_Score":21,"Tags":"php,python","A_Id":3325047,"CreationDate":"2010-07-23T14:46:00.000","Title":"PHP devs that moved to Python, is the experience better?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am compiling on Ubuntu 10.04 LTS. The Perforce Python API uses their C++ API for some of it. So, I point the setup.py at the C++'s API directory using the --apidir= they say to use. When it starts to compile the C++, I get a whole load of errors (temporary error list link is now gone). No one else has had these errors as far as I can tell. So, my question is, is it my idiocy, or Perforce's?\nP.S. The reason I don't have the flag in the command is because I setup the setup.cfg file to point at the API.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":290,"Q_Id":3324490,"Users Score":0,"Answer":"Woops! Forgot I still needed to install python-dev...","Q_Score":0,"Tags":"c++,python,perforce","A_Id":3324560,"CreationDate":"2010-07-24T09:08:00.000","Title":"Perforce P4Python API Bug","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},{"Question":"I have couple of ideas in my brain which I would like to bring out before it's too late. Basically I want to develop a web application which I could sell it to clients. So which technology shall I use to accomplish this? I have been a C and C++ software developer but it's been a very long time since I have developed one. So the things I would like to know is:\n\nScalability and Performance?\nEasy way to develop web application in a faster manner?\nAny Framework?\nApplication server?\nand which programming language?","AnswerCount":5,"Available Count":2,"Score":0.0399786803,"is_accepted":false,"ViewCount":3428,"Q_Id":3324683,"Users Score":1,"Answer":"I kinda think this is almost more like a religious problem, than a real technical issue. For almost every programming language you can find a big website that's using it.\n.NET -> Microsoft\nRuby -> Twitter (yes, they have a few issues, but still)\nPHP -> Facebook\nJava -> Lots of finance companies\nDon't know about Phyton, but I'm sure there is.\nMore important is a good scalable architecture. That is where Twitter kinda screwed it up it seems. \nPersonally I use ASP.NET. Works fine, is somewhat easy and has a nice IDE. And the market is not so fragmented. Before I used Java with Websphere. Was running on a Sergenti Sun Box, so could definitely handle a lot.\nI would more see into what you can get yourself into the quickest. If you know C++ C# or Java are easy to learn.","Q_Score":0,"Tags":"c#,java,python","A_Id":3324710,"CreationDate":"2010-07-24T10:16:00.000","Title":"Which technology should I use to develop a high performance 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},{"Question":"I have couple of ideas in my brain which I would like to bring out before it's too late. Basically I want to develop a web application which I could sell it to clients. So which technology shall I use to accomplish this? I have been a C and C++ software developer but it's been a very long time since I have developed one. So the things I would like to know is:\n\nScalability and Performance?\nEasy way to develop web application in a faster manner?\nAny Framework?\nApplication server?\nand which programming language?","AnswerCount":5,"Available Count":2,"Score":1.0,"is_accepted":false,"ViewCount":3428,"Q_Id":3324683,"Users Score":6,"Answer":"Usually the programming language doesn't really matter. All have their own strengths and weaknesses. All come up with their own best-practices and frameworks.\nIt's really up to you what's your preference. If you  are coming from Microsoft C\/C++ I'd use .NET, if you are from Linux world I'd use Java.\nBack in the 90s Java was well known as a slow framework, however there was much of myth and the framework architecture is dramatically changed since that. Today, there is no generally slow or fast framework.\nYou can find thousands of sites in the web that tell you that the one or the other is faster. However, at the end of the day it depends on how you implemented your solution and how you utilized the best features of the framework.\nGreets\nFlo","Q_Score":0,"Tags":"c#,java,python","A_Id":3324720,"CreationDate":"2010-07-24T10:16:00.000","Title":"Which technology should I use to develop a high performance 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},{"Question":"Is there any difference in speed of copying files from one location to another betwen python or delphi or c++ ? \nI guess that all 3 laguages uses same or similar win api calls and that there is not much performance difference.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":78,"Q_Id":3324870,"Users Score":1,"Answer":"Pythons shutil module does not use the Windows API, but instead uses an open\/read\/write loop. This may or may not be slower than using CopyFile(Ex). Please measure it, everything else is just guessing.","Q_Score":0,"Tags":"python,windows,performance,comparison","A_Id":3324905,"CreationDate":"2010-07-24T11:17:00.000","Title":"python file copying","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},{"Question":"I currently work with Python for a while and I came to the point where I questioned myself whether I should use \"Properties\" in Python as often as in C#.\nIn C# I've mostly created properties for the majority of my classes.\nIt seems that properties are not that popular in python, am I wrong?\nHow to use properties in Python?\nregards,","AnswerCount":3,"Available Count":1,"Score":0.1325487884,"is_accepted":false,"ViewCount":3192,"Q_Id":3324920,"Users Score":2,"Answer":"If you make an attribute public in C# then later need to change it into a property you also need to recompile all code that uses the original class. This is bad, so make any public attributes into properties from day one 'just in case'.\nIf you have an attribute that is used from other code then later need to change it into a property then you just change it and nothing else needs to happen. So use ordinary attributes until such time as you find you need something more complicated.","Q_Score":10,"Tags":"c#,python,properties","A_Id":3325757,"CreationDate":"2010-07-24T11:33:00.000","Title":"Use of properties in python like in example 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},{"Question":"I want to know why Python is not fully object-oriented. For example, it does not support private, public, protected access level modifiers.\nWhat are the advantages and disadvantages of this? By these expressions, Python is suitable for what applications (Desktop, Scientific, Web or other)?","AnswerCount":7,"Available Count":5,"Score":0.057080742,"is_accepted":false,"ViewCount":80955,"Q_Id":3325343,"Users Score":2,"Answer":"What exactly is full object oriented?  Alan Kay said \"Actually I made up the term \"object-oriented\", and I can tell you I did not have C++ in mind.\".  Admittedly, he probably did not have python in mind either, but it is worth noting that Smalltalk also protects classes by convention, no mandate.","Q_Score":63,"Tags":"python,oop","A_Id":3325399,"CreationDate":"2010-07-24T13:47:00.000","Title":"Why is Python not fully object-oriented?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to know why Python is not fully object-oriented. For example, it does not support private, public, protected access level modifiers.\nWhat are the advantages and disadvantages of this? By these expressions, Python is suitable for what applications (Desktop, Scientific, Web or other)?","AnswerCount":7,"Available Count":5,"Score":0.057080742,"is_accepted":false,"ViewCount":80955,"Q_Id":3325343,"Users Score":2,"Answer":"I believe Python is more of a very practical, pragmatic language. \nConcepts which offer value to the developer are put in, without too much consideration about theological concepts like \"proper OO design\" and stuff. It's a language for people who have real work to do.\nI think Python is suitable for all kinds of environments, though Desktop is a bit difficult due to the lack of a single framework. For all applications it's handy to use a framework,\nlike NumPy for computational stuff, Twisted or Django for web stuff, and WxWidgets or other for Desktop stuff.","Q_Score":63,"Tags":"python,oop","A_Id":3325363,"CreationDate":"2010-07-24T13:47:00.000","Title":"Why is Python not fully object-oriented?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to know why Python is not fully object-oriented. For example, it does not support private, public, protected access level modifiers.\nWhat are the advantages and disadvantages of this? By these expressions, Python is suitable for what applications (Desktop, Scientific, Web or other)?","AnswerCount":7,"Available Count":5,"Score":0.1137907297,"is_accepted":false,"ViewCount":80955,"Q_Id":3325343,"Users Score":4,"Answer":"I think Python is designed to be a hybrid.  You can write in object oriented or functional styles.  \nThe hallmarks of object-orientation are abstraction, encapsulation, inheritance, and polymorphism.  Which of these are missing from Python?\nObject-orientation is a continuum.  We might say that Smalltalk is the purest of the pure, and all others occupy different places on the scale.  \nNo one can say what the value of being 100% pure is.  It's possible to write very good object-oriented code in languages that aren't Smalltalk, Python included.\nPython is useful in all those areas: scientific (NumPy), web (Django), and desktop.","Q_Score":63,"Tags":"python,oop","A_Id":3325355,"CreationDate":"2010-07-24T13:47:00.000","Title":"Why is Python not fully object-oriented?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to know why Python is not fully object-oriented. For example, it does not support private, public, protected access level modifiers.\nWhat are the advantages and disadvantages of this? By these expressions, Python is suitable for what applications (Desktop, Scientific, Web or other)?","AnswerCount":7,"Available Count":5,"Score":-1.0,"is_accepted":false,"ViewCount":80955,"Q_Id":3325343,"Users Score":-5,"Answer":"A language is said to Full Objective Oriented if it has no primitive data types. Each data type we need to construct.","Q_Score":63,"Tags":"python,oop","A_Id":4521644,"CreationDate":"2010-07-24T13:47:00.000","Title":"Why is Python not fully object-oriented?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to know why Python is not fully object-oriented. For example, it does not support private, public, protected access level modifiers.\nWhat are the advantages and disadvantages of this? By these expressions, Python is suitable for what applications (Desktop, Scientific, Web or other)?","AnswerCount":7,"Available Count":5,"Score":1.2,"is_accepted":true,"ViewCount":80955,"Q_Id":3325343,"Users Score":100,"Answer":"Python doesn't support strong encapsulation, which is only one of many features associated with the term \"object-oriented\".\nThe answer is simply philosophy. Guido doesn't like hiding things, and many in the Python community agree with him.","Q_Score":63,"Tags":"python,oop","A_Id":3325353,"CreationDate":"2010-07-24T13:47:00.000","Title":"Why is Python not fully object-oriented?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I was wondering if i could possible write an app, that could be a list of all my friends and just simply posting a message to their walls on the friends i select. Not a message, a wall post. So it appears that i went to their wall and wrote a message, they have no idea that an app is pushing the message to them.\nalso could it be written in python :) its what i know. php is so icky, but doable if it is the only option.\nPlease and thank you.","AnswerCount":6,"Available Count":2,"Score":0.1325487884,"is_accepted":false,"ViewCount":1795,"Q_Id":3327244,"Users Score":4,"Answer":"Check out the Facebook API. It will more than likely show that the wall post came from your application. As far as the language you implement in, I think you could use Python.","Q_Score":3,"Tags":"php,python,facebook","A_Id":3327259,"CreationDate":"2010-07-24T22:55:00.000","Title":"Facebook wall writing 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},{"Question":"I was wondering if i could possible write an app, that could be a list of all my friends and just simply posting a message to their walls on the friends i select. Not a message, a wall post. So it appears that i went to their wall and wrote a message, they have no idea that an app is pushing the message to them.\nalso could it be written in python :) its what i know. php is so icky, but doable if it is the only option.\nPlease and thank you.","AnswerCount":6,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":1795,"Q_Id":3327244,"Users Score":3,"Answer":"There are a couple of Facebook APIs that could tie in to. I'm at work and any website that makes mention of facebook is blocked so I can't provide links, but Google 'Facebook API'.","Q_Score":3,"Tags":"php,python,facebook","A_Id":3327248,"CreationDate":"2010-07-24T22:55:00.000","Title":"Facebook wall writing 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},{"Question":"I'm learning Python and would like to start a small project. It seems that making IRC bots is a popular project amongst beginners so I thought I would implement one. Obviously, there are core functionalities like being able to connect to a server and join a channel but what are some good functionalities that are usually included in the bots? Thanks for your ideas.","AnswerCount":5,"Available Count":4,"Score":0.0399786803,"is_accepted":false,"ViewCount":3546,"Q_Id":3328315,"Users Score":1,"Answer":"Again, this is an utterly personal suggestion, but I would really like to see eggdrop rewritten in Python.\nSuch a project could use Twisted to provide the base IRC interaction, but would then need to support add-on scripts.\nThis would be great for allowing easy IRC bot functionality to be built upon using python, instead of TCL, scripts.","Q_Score":4,"Tags":"python,irc","A_Id":3329252,"CreationDate":"2010-07-25T06:40:00.000","Title":"IRC bot functionalities","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},{"Question":"I'm learning Python and would like to start a small project. It seems that making IRC bots is a popular project amongst beginners so I thought I would implement one. Obviously, there are core functionalities like being able to connect to a server and join a channel but what are some good functionalities that are usually included in the bots? Thanks for your ideas.","AnswerCount":5,"Available Count":4,"Score":0.0,"is_accepted":false,"ViewCount":3546,"Q_Id":3328315,"Users Score":0,"Answer":"That is very subjective and totally depends upon where the bot will be used. I'm sure others will have nice suggestions. But whatever you do, please do not query users arbitrarily. And do not spam the main chat periodically.","Q_Score":4,"Tags":"python,irc","A_Id":3328343,"CreationDate":"2010-07-25T06:40:00.000","Title":"IRC bot functionalities","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},{"Question":"I'm learning Python and would like to start a small project. It seems that making IRC bots is a popular project amongst beginners so I thought I would implement one. Obviously, there are core functionalities like being able to connect to a server and join a channel but what are some good functionalities that are usually included in the bots? Thanks for your ideas.","AnswerCount":5,"Available Count":4,"Score":0.0399786803,"is_accepted":false,"ViewCount":3546,"Q_Id":3328315,"Users Score":1,"Answer":"I'm also in the process of writing a bot in node.js. Here are some of my goals\/functions:\n\nmap '@' command so the bot detects the last URI in message history and uses the w3 html validation service\nsetup a trivia game by invoking !ask, asks a question with 3 hints, have the ability to load custom questions based on category\nget the weather with weather [zip\/name]\nhook up jseval command to evaluate javascript, same for python and perl and haskell\nseen command that reports the last time the bot has \"seen\" a person online\ntranslate command to translate X language string to Y language string\nmap dict to a dictionary service\nmap wik to wiki service","Q_Score":4,"Tags":"python,irc","A_Id":3328322,"CreationDate":"2010-07-25T06:40:00.000","Title":"IRC bot functionalities","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},{"Question":"I'm learning Python and would like to start a small project. It seems that making IRC bots is a popular project amongst beginners so I thought I would implement one. Obviously, there are core functionalities like being able to connect to a server and join a channel but what are some good functionalities that are usually included in the bots? Thanks for your ideas.","AnswerCount":5,"Available Count":4,"Score":0.0,"is_accepted":false,"ViewCount":3546,"Q_Id":3328315,"Users Score":0,"Answer":"Make a google search to get a library that implements IRC protocol for you. That way you only need to add the features, those are already something enough to bother you.\nCommon functions:\n\nConduct a search from a wiki or google\nNotify people on project\/issue updates\nLeave a message\nToy for spamming the channel\nPick a topic\nCategorize messages\nSearch from channel logs","Q_Score":4,"Tags":"python,irc","A_Id":3328376,"CreationDate":"2010-07-25T06:40:00.000","Title":"IRC bot functionalities","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},{"Question":"What does '\\r' mean? What does it do? I have never seen it before and its giving me headaches. It doesnt seem to have any purpose, since 'a\\ra' prints as 'aa', but its not the same as the string 'aa'. Im using python 2.6","AnswerCount":4,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":11032,"Q_Id":3329775,"Users Score":10,"Answer":"It's an old control character from typewriters.\nIt means \"carriage return\". In this time, when you pressed \"enter\", you were going to the next line, then the carriage went back to the beginning of the line (hence the carriage return).\nThen with computers, different OSes made different choices to represent new lines.\nOn windows, you have \"\\r\\n\" (carriage return + new line).\nOn unices, you have \"\\n\" only (no need to do a carriage return, it was sort of implied by the new line).\nOn old mac OS, you had \"\\r\" only.\nNowadays, it's not used except for newlines (or I don't know other usages).","Q_Score":3,"Tags":"python,syntax","A_Id":3329797,"CreationDate":"2010-07-25T15:35:00.000","Title":"What does this stand for?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I believe eggdrop is the most active\/popular bot and it's written in tcl ( and according to wiki the core is C but I haven't confirmed that ).\nI'm wondering if there would be any performance benefit of recoding it's functionality in node.js or Python, in addition to making it more accessible since Python and JS are arguably more popular languages and not many are familiar with tcl.\nSo, how would they stack up vs tcl in general, performance-wise?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":964,"Q_Id":3331027,"Users Score":6,"Answer":"As you suspected, eggdrop is not written in tcl, it is written in C, however it does use tcl as its scripting\/extension language.\nI would expect that in the case of an eggdrop, the performance difference between using tcl as a scripting language, and using Python, Lua, JS, or virtually anything else would be negligible, as eggdrops generally aren't performing high load tasks.\nIn the event it really was an issue, your question would need more specifics.  Performance for what task under what conditions?  Memory use?  CPU efficiency?  Latency?  And the answer would probably be \"measure and find out\".  Given the typical use of an eggdrop, it doesn't take particularly efficient code to respond to the occasional IRC trigger command once every few minutes or hours.\nAs a more general case, I'm sure you could find benchmark comparisons of specific algorithms or tasks performed by various scripting languages on particular operating systems or environments, at which point it wouldn't really have anything to do with IRC or eggdrop.","Q_Score":3,"Tags":"python,tcl,irc,node.js,eggdrop","A_Id":3331115,"CreationDate":"2010-07-25T21:13:00.000","Title":"How would an irc bot written in tcl stack up against a python\/node.js clone?","Data Science and Machine Learning":0,"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},{"Question":"I'm looking into Pylons and was wondering, should I use Paste as the webserver or can I use Apache? \nAre there advantages to using Paste?\nWould you recommend against using Apache?\nHow should I host the sites?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":511,"Q_Id":3333113,"Users Score":0,"Answer":"I'm using Nginx (with fastcgi) or Apache for hosting Pylons sites, mostly because lack of some \"production\" features in Paste, but for development Paste is very usefull and handy.","Q_Score":5,"Tags":"python,web-services,pylons","A_Id":3358288,"CreationDate":"2010-07-26T07:57:00.000","Title":"Should I use Pylon's Paste to host my Pylons website? Or can I use 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":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},{"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},{"Question":"I have an esoteric question involving Python metaclasses.  I am creating a Python package for web-server-side code that will make it easy to access arbitrary Python classes via client-side proxies.  My proxy-generating code needs a catalog of all of the Python classes that I want to include in my API.  To create this catalog, I am using the __metaclass__ special attribute to put a hook into the class-creation process.  Specifically, all of the classes in the \"published\" API will subclass a particular base class, PythonDirectPublic, which itself has a __metaclass__ that has been set up to record information about the class creation.\nSo far so good.  Where it gets complicated is that I want my PythonDirectPublic itself to inherit from a third-party class (enthought.traits.api.HasTraits).  This third-party class also uses a __metaclass__.\nSo what's the right way of managing two metaclasses?  Should my metaclass be a subclass of Enthought's metaclass?  Or should I just invoke Enthought's metaclass inside my metaclass's __new__ method to get the type object that I will return?  Or is there some other mystical incantation to use in this particular circumstance?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":715,"Q_Id":3346262,"Users Score":1,"Answer":"Specifically, all of the classes in the \"published\" API will subclass a particular base class, PythonDirectPublic\n\nRather than adding another metaclass, you could recursively use the result of PythonDirectPublic.subclasses().","Q_Score":9,"Tags":"python,metaclass,traits","A_Id":4833132,"CreationDate":"2010-07-27T17:34:00.000","Title":"Python: Metaclasses all the way down","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a text file which contains a time stamp on each line. My goal is to find the time range. All the times are in order so the first line will be the earliest time and the last line will be the latest time. I only need the very first and very last line. What would be the most efficient way to get these lines in python?\nNote: These files are relatively large in length, about 1-2 million lines each and I have to do this for several hundred files.","AnswerCount":12,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":139998,"Q_Id":3346430,"Users Score":10,"Answer":"Can you use unix commands? I think using head -1 and tail -n 1 are probably the most efficient methods. Alternatively, you could use a simple fid.readline() to get the first line and fid.readlines()[-1], but that may take too much memory.","Q_Score":77,"Tags":"python,file,seek","A_Id":3346499,"CreationDate":"2010-07-27T17:58:00.000","Title":"What is the most efficient way to get first and last line of a text 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},{"Question":"I'm having problems with my PythonPath on windows XP, and I'm wondering if I'm doing something wrong.\nSay that I have a project (created with Pydev) that has an src directory. Under src I have a single package, named common, and in it a single class module, named service.py with a class name Service\nSay now that I have another project (also created with Pydev) with an src directory and a common package. In the common package, I have a single script, client.py, that imports service.\nSo in other words, two separate disk locations, but same package.\nI've noticed that even if I set my PYTHONPATH to include both src directories, the import fails unless the files are both in the same directory. I get the dreaded no module found. \nAm I misunderstanding how python resolves module names? I'm used to Java and its classpath hell.","AnswerCount":3,"Available Count":1,"Score":0.1325487884,"is_accepted":false,"ViewCount":1088,"Q_Id":3346482,"Users Score":2,"Answer":"If you really must have a split package like this, read up on the module level attribute __path__.\nIn short, make one of the 'src' directories the main one, and give it an __init__.py that appends the path of other 'src' to the __path__ list. Python will now look in both places when looking up submodules of 'src'.\nI really don't recommend this for the long term though. It is kind of brittle and breaks if you move things around.","Q_Score":3,"Tags":"python,pythonpath","A_Id":3346786,"CreationDate":"2010-07-27T18:05:00.000","Title":"PYTHONPATH hell with overlapping package structures","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am looking for a command-line tool that removes all comments from an input\nfile and returns the stripped output. It'd be nice it supports popular\nprogramming languages like c, c++, python, php, javascript, html, css, etc.  It\nhas to be syntax-aware as opposed to regexp-based, since the latter will catch\nthe pattern in source code strings as well. Is there any such tool?\nI am fully aware that comments are useful information and often leaving them\nas they are is a good idea. It's just that my focus is on different use cases.","AnswerCount":6,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":3169,"Q_Id":3349156,"Users Score":0,"Answer":"No such tool exists yet.","Q_Score":5,"Tags":"php,python,c","A_Id":3599951,"CreationDate":"2010-07-28T00:56:00.000","Title":"General utility to remove\/strip all comments from source code in various 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},{"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},{"Question":"Is it possible to create read only files in python which can not be changed later and in which users can not change its attribute from read-only to normal file?\nPlease suggest.\nThanks in advance.","AnswerCount":3,"Available Count":3,"Score":0.0665680765,"is_accepted":false,"ViewCount":3100,"Q_Id":3351484,"Users Score":1,"Answer":"This is just impossible.\nAny user with administrative rights can remove readonly restrictions of any kind.\nAnother option might be \"Write a python program to kill all users over the worls so that they would not be able to change file attributes or security settings\" :-)","Q_Score":0,"Tags":"python,file","A_Id":3351513,"CreationDate":"2010-07-28T09:22:00.000","Title":"Creating read only text files 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},{"Question":"Is it possible to create read only files in python which can not be changed later and in which users can not change its attribute from read-only to normal file?\nPlease suggest.\nThanks in advance.","AnswerCount":3,"Available Count":3,"Score":1.2,"is_accepted":true,"ViewCount":3100,"Q_Id":3351484,"Users Score":3,"Answer":"This is not python specific.\nIf the files are made by a different user that the one viewing it the script can make it read-only. As the file is owned by the python user, the viewing user cannot just change the attributes.\nSo it's very much an OS question, and not a Python question.\nOh, and there is no way to prevent an administrator changing the file, or for the file to be readable but not copyable.","Q_Score":0,"Tags":"python,file","A_Id":3351517,"CreationDate":"2010-07-28T09:22:00.000","Title":"Creating read only text files 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},{"Question":"Is it possible to create read only files in python which can not be changed later and in which users can not change its attribute from read-only to normal file?\nPlease suggest.\nThanks in advance.","AnswerCount":3,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":3100,"Q_Id":3351484,"Users Score":0,"Answer":"Take a look at os.chmod() function and execute it with appropriate parameters (filename, stat.S_IWUSR | stat.S_IRGRP | stat.S_IROTH) for your just created file.\nOn linux other users then you will not be able to change file or change attributes to writable.\nSome root user or someone logged into you account will be able to change it though.","Q_Score":0,"Tags":"python,file","A_Id":3352472,"CreationDate":"2010-07-28T09:22:00.000","Title":"Creating read only text files 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},{"Question":"I have a C# application that needs to be run several thousand times.  Currently it precomputes a large table of constant values at the start of the run for reference.  As these values will be the same from run to run I would like to compute them independently in a simple python script and then just have the C# app import the file at the start of each run.\nThe table consists of a sorted 2D array (500-3000+ rows\/columns) of simple (int x, double y) tuples.  I am looking for recommendations concerning the best\/simplest way to store and then import this data.  For example, I could store the data in a text file like this \"(x1,y1)|(x2,y2)|(x3,y3)|...|(xn,yn)\"  This seems like a very ugly solution to a problem that seems to lend itself to a specific data structure or library I am currently unaware of.  Any suggestions would be welcome.","AnswerCount":6,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":1046,"Q_Id":3355832,"Users Score":2,"Answer":"You may consider running IronPython - then you can pass values back and forth across C#\/Python","Q_Score":4,"Tags":"c#,python,file","A_Id":3355927,"CreationDate":"2010-07-28T17:52:00.000","Title":"Suggestions for passing large table between Python and C#","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},{"Question":"I have a C# application that needs to be run several thousand times.  Currently it precomputes a large table of constant values at the start of the run for reference.  As these values will be the same from run to run I would like to compute them independently in a simple python script and then just have the C# app import the file at the start of each run.\nThe table consists of a sorted 2D array (500-3000+ rows\/columns) of simple (int x, double y) tuples.  I am looking for recommendations concerning the best\/simplest way to store and then import this data.  For example, I could store the data in a text file like this \"(x1,y1)|(x2,y2)|(x3,y3)|...|(xn,yn)\"  This seems like a very ugly solution to a problem that seems to lend itself to a specific data structure or library I am currently unaware of.  Any suggestions would be welcome.","AnswerCount":6,"Available Count":2,"Score":0.0333209931,"is_accepted":false,"ViewCount":1046,"Q_Id":3355832,"Users Score":1,"Answer":"CSV is fine suggestion, but may be clumsy with values being int and double. Generally tab or semicomma are best separators.","Q_Score":4,"Tags":"c#,python,file","A_Id":3356036,"CreationDate":"2010-07-28T17:52:00.000","Title":"Suggestions for passing large table between Python and C#","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},{"Question":"I am trying to load a CCITT T.3 compressed tiff into python, and get the pixel matrix from it. It should just be a logical matrix. \nI have tried using pylibtiff and PIL, but when I load it with them, the matrix it returns is empty. I have read in a lot of places that these two tools support loading CCITT but not accessing the pixels. \nI am open to converting the image, as long as I can get the logical matrix from it and do it in python code. The crazy thing is is that if I open one of my images in paint, save it without altering it, then try to load it with pylibtiff, it works. Paint re-compresses it to the LZW compression. \nSo I guess my real question is: Is there a way to either natively load CCITT images to matricies or convert the images to LZW using python?? \nThanks,\ntylerthemiler","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1297,"Q_Id":3355962,"Users Score":0,"Answer":"How about running tiffcp with subprocess to convert to LZW (-c lzw switch), then process normally with pylibtiff? There are Windows builds of tiffcp lying around on the web. Not exactly Python-native solution, but still...","Q_Score":2,"Tags":"python,compression,tiff,imaging,image-formats","A_Id":3357139,"CreationDate":"2010-07-28T18:06:00.000","Title":"What is the best way to load a CCITT T.3 compressed tiff using 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},{"Question":"What are the Pro's and Con's of using win32api for I\/O and other things instead of simply Python, if both have a specific function for it\nI mean, using PyWin32 vs Win32Api","AnswerCount":2,"Available Count":2,"Score":0.3799489623,"is_accepted":false,"ViewCount":390,"Q_Id":3358126,"Users Score":4,"Answer":"The most obvious thing seems to be losing cross-platform compatibilty. Python runs on a number of different platforms, none of which has a win32 API except MS Windows.","Q_Score":1,"Tags":"python,winapi,io","A_Id":3358136,"CreationDate":"2010-07-28T22:42:00.000","Title":"win32api vs 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},{"Question":"What are the Pro's and Con's of using win32api for I\/O and other things instead of simply Python, if both have a specific function for it\nI mean, using PyWin32 vs Win32Api","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":390,"Q_Id":3358126,"Users Score":5,"Answer":"con\n\n(lack of) portability\nharder\/more error prone\n\npro\n\nperformance (potentially, it must be measured, as will depend on more than just the api calls)","Q_Score":1,"Tags":"python,winapi,io","A_Id":3358143,"CreationDate":"2010-07-28T22:42:00.000","Title":"win32api vs 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},{"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},{"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},{"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},{"Question":"I'm a big fan of PHP and it's obviously a very weakly-typed language. I realize some of the benefits include the general independence of changing variable types on the fly and such.\nWhat I'm wondering about are the drawbacks. What can you get out of a strongly-typed language like C that you otherwise can't get from a weakly-typed one like PHP? Also with type setting (like double($variable)), one could argue that even a weakly-typed language can act just like a strongly-typed one.\nSo. Weak-type. What are some benefits I didn't include? More importantly, what are the drawbacks?","AnswerCount":7,"Available Count":3,"Score":0.057080742,"is_accepted":false,"ViewCount":11418,"Q_Id":3376252,"Users Score":2,"Answer":"Many a book has been written about this sort of thing. There's an inherent tradeoff; with a weakly-typed language a lot of annoyances simply cease to be. For instance, in Python you never have to worry about dividing a float by an int; adding an int to a list; typing functions' arguments (did you know, OCaml has special +. operators for adding floats because (+) sends ints to ints!); forgetting that a variable can be null... those sorts of problems simply vanish. \nIn their place come a whole host of new runtime bugs: Python's [0]*5 gives, wait for it, [0,0,0,0,0]! OCaml, for all the annoyance of strong typing, catches many many bugs with its compiler; and this is precisely why it's good. It's a tradeoff.","Q_Score":17,"Tags":"php,python,c,types","A_Id":3376298,"CreationDate":"2010-07-31T00:24:00.000","Title":"What are the benefits (and drawbacks) of a weakly typed 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},{"Question":"I'm a big fan of PHP and it's obviously a very weakly-typed language. I realize some of the benefits include the general independence of changing variable types on the fly and such.\nWhat I'm wondering about are the drawbacks. What can you get out of a strongly-typed language like C that you otherwise can't get from a weakly-typed one like PHP? Also with type setting (like double($variable)), one could argue that even a weakly-typed language can act just like a strongly-typed one.\nSo. Weak-type. What are some benefits I didn't include? More importantly, what are the drawbacks?","AnswerCount":7,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":11418,"Q_Id":3376252,"Users Score":0,"Answer":"You have to understand that PHP was created for the context of web applications. Everything in the context of the web is a string. Therefore it is very rare where strong typing would be beneficial.","Q_Score":17,"Tags":"php,python,c,types","A_Id":18869364,"CreationDate":"2010-07-31T00:24:00.000","Title":"What are the benefits (and drawbacks) of a weakly typed 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},{"Question":"I'm a big fan of PHP and it's obviously a very weakly-typed language. I realize some of the benefits include the general independence of changing variable types on the fly and such.\nWhat I'm wondering about are the drawbacks. What can you get out of a strongly-typed language like C that you otherwise can't get from a weakly-typed one like PHP? Also with type setting (like double($variable)), one could argue that even a weakly-typed language can act just like a strongly-typed one.\nSo. Weak-type. What are some benefits I didn't include? More importantly, what are the drawbacks?","AnswerCount":7,"Available Count":3,"Score":0.1418931938,"is_accepted":false,"ViewCount":11418,"Q_Id":3376252,"Users Score":5,"Answer":"I have been using both strong typed (like Java) and weak typed (like JavaScript) languages for some time now.  What I have found is that the convenience of the weak typed languages are great for small applications.  Unfortunately, as the application grows in size, it becomes impossible to manage.  There becomes too much to keep track of in your head and you have to start depending on your IDE and the compiler more and more or your coding grinds to a halt.  That is when strong typed languages start to become more useful - with the application grows very large.\nTwo examples that constantly drive me nuts in the weak typed JavaScript are using external libraries that are not thoroughly documented and refactoring.\nExternal libraries: When dealing with a strongly typed language, the code from the library itself provides self documentation.  When I create a variable of type Person, the IDE can inspect the code and tell there is a getFirstName(), getLastName() and getFullName().  In weak typed languages, this is not the case as a variable could be anything, have any kind of variable or function and have function arguments that could also be anything (they are not explicitly defined).  As a result, a developer has to lean heavily on documentation, web searches, discussion forums and their memory of past usages.  I find it can take hours of looking things up in JavaScript for external libraries while with Java I just hit the \".\" key and it pops up all my options with documentation attached.  When you encounter libraries that are not 100% fully documented, it can be really frustrating with weak typed languages.  I recently found myself asking \"What is argument 'plot' in function 'draw'?\" when using jqplot, a fairly well but not completely documented JavaScript library.  I had to spend an hour or two digging through source code before finally giving up and finding an alternative solution.\nRefactoring: With strongly typed languages, I find myself able to refactor quickly by just changing the file I need to change and then going to fix the compiler errors.  Some tools will even refactor for you with a simple click of a button.  With weak typed languages, you have to do a search and then replace with care and then test, test, TEST and then test some more.  You are seldom entirely sure you have found and fixed everything you broke, especially in large applications.\nFor simple needs and small applications, these two concerns are minimal to non-existent.  But if you are working with an application with 100's of thousands or millions of lines of code, weak typed languages will drive you nuts.\nI think many developers get upset about this and turn it into an emotional discussion is because we sometimes get it in our heads that there is one right and one wrong approach.  But each approach has its merits - its own advantages and disadvantages.  Once you recognize that you set the emotion aside and choose the best for you for what you need right now.","Q_Score":17,"Tags":"php,python,c,types","A_Id":28466502,"CreationDate":"2010-07-31T00:24:00.000","Title":"What are the benefits (and drawbacks) of a weakly typed 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},{"Question":"After working for on JAVA for a long time now i feel like also learn some other language just for a change. This time i want to spend some time learning and reading one of the dynamic languages. \nWhich is the most appropriate one that covers  most of the features offered by dynamic languages and the syntax which probably is fun and also one that is closer to the syntax used by most of the dynamic languages.\nBR,\nKeshav","AnswerCount":7,"Available Count":4,"Score":0.0855049882,"is_accepted":false,"ViewCount":367,"Q_Id":3379174,"Users Score":3,"Answer":"Learn [one of] these:\n\nRuby\nPython\nClojure (a modern Lisp)\nJavaScript (yes, this is a great dynamic language!)\n\nDon't transition via a semi-dynamic, semi-Java language. Just jump in and try a dynamic language. In order to really understand what else is going on, you have to get out of the Java world by jumping in, not by sticking your toes into the water.\nYes, I know Clojure is on the JVM and that Ruby and Python have implementations on the JVM as well. But the runtime implementation of a language does not define the language. Learn the language, and you can pick a favorite runtime.","Q_Score":0,"Tags":"python,ruby,dynamic-languages","A_Id":3379213,"CreationDate":"2010-07-31T17:43:00.000","Title":"Which is the most preferred language to start with dynamic 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},{"Question":"After working for on JAVA for a long time now i feel like also learn some other language just for a change. This time i want to spend some time learning and reading one of the dynamic languages. \nWhich is the most appropriate one that covers  most of the features offered by dynamic languages and the syntax which probably is fun and also one that is closer to the syntax used by most of the dynamic languages.\nBR,\nKeshav","AnswerCount":7,"Available Count":4,"Score":0.0,"is_accepted":false,"ViewCount":367,"Q_Id":3379174,"Users Score":0,"Answer":"Try Jython, if you like Java, this way you can both ;-)","Q_Score":0,"Tags":"python,ruby,dynamic-languages","A_Id":3379189,"CreationDate":"2010-07-31T17:43:00.000","Title":"Which is the most preferred language to start with dynamic 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},{"Question":"After working for on JAVA for a long time now i feel like also learn some other language just for a change. This time i want to spend some time learning and reading one of the dynamic languages. \nWhich is the most appropriate one that covers  most of the features offered by dynamic languages and the syntax which probably is fun and also one that is closer to the syntax used by most of the dynamic languages.\nBR,\nKeshav","AnswerCount":7,"Available Count":4,"Score":0.057080742,"is_accepted":false,"ViewCount":367,"Q_Id":3379174,"Users Score":2,"Answer":"Ahah, nice troll :) (with ruby and python tags).\nIn my humble opinion, after trying many languages, my favorite is Ruby with Ruby on Rails.","Q_Score":0,"Tags":"python,ruby,dynamic-languages","A_Id":3379188,"CreationDate":"2010-07-31T17:43:00.000","Title":"Which is the most preferred language to start with dynamic 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},{"Question":"After working for on JAVA for a long time now i feel like also learn some other language just for a change. This time i want to spend some time learning and reading one of the dynamic languages. \nWhich is the most appropriate one that covers  most of the features offered by dynamic languages and the syntax which probably is fun and also one that is closer to the syntax used by most of the dynamic languages.\nBR,\nKeshav","AnswerCount":7,"Available Count":4,"Score":1.0,"is_accepted":false,"ViewCount":367,"Q_Id":3379174,"Users Score":7,"Answer":"Python is always fun.Go for it.","Q_Score":0,"Tags":"python,ruby,dynamic-languages","A_Id":3379183,"CreationDate":"2010-07-31T17:43:00.000","Title":"Which is the most preferred language to start with dynamic 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},{"Question":"i developed an aplication built on twitter api , but i get erorrs like   a mesage that i've parsed and deleted to be parsed again at the next execution  ,   could that be because i left the twitter connection opened or is just a fault of the twitter API.   I also tried to delete all direct messages because it seemed too full for me but instead the Api has just reset the count of my messages , the messages haven't been deleted:((","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":105,"Q_Id":3385990,"Users Score":2,"Answer":"Twitter's API is over HTTP, which is a stateless protocol. you don't really need to close the connection, since connections made and closed for each request","Q_Score":1,"Tags":"python,twitter","A_Id":3388478,"CreationDate":"2010-08-02T07:59:00.000","Title":"twitter connection needs to be closed?","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},{"Question":"HI all\nI am trying to use SWIG to export C++ code to Python.\nThe C sample I read on the web site does work but I have problem with C++ code.\nHere are the lines I call\n\nswig -c++ -python SWIG_TEST.i\ng++ -c -fPIC SWIG_TEST.cpp SWIG_TEST_wrap.cxx -I\/usr\/include\/python2.4\/\ngcc --shared SWIG_TEST.o SWIG_TEST_wrap.o -o _SWIG_TEST.so -lstdc++\n\nWhen I am finished I receive the following error message\n\nImportError: .\/_SWIG_TEST.so: undefined symbol: Py_InitModule4\n\nDo you know what it is?","AnswerCount":3,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":886,"Q_Id":3387663,"Users Score":4,"Answer":"It looks like you aren't linking to the Python runtime library.  Something like adding -lpython24 to your gcc line.  (I don't have a Linux system handy at the moment).","Q_Score":2,"Tags":"c++,python,swig","A_Id":3393617,"CreationDate":"2010-08-02T12:20:00.000","Title":"using SWIG with 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":0,"Web Development":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},{"Question":"I wanted to make a website that would let users record a small video message through their broswer and save it to my website.\nAs I have never used flash, i wanted to know what softwares would be required and what programming languages would I need? I mean, what should I go about learning to implement such a site. I would prefer open-source solutions wherever possible.\nCan something like this be implemented using python and html5?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":549,"Q_Id":3391222,"Users Score":1,"Answer":"There are many video solutions.  Here are two:\nTake a look at Flash Media Server (FMS).  You will need to some server-side code to place the video into a folder as it streams up.  \nAlso, if you're looking into free open-source take a look at Red5.","Q_Score":1,"Tags":"python,flash,video-capture,html5-video","A_Id":3393137,"CreationDate":"2010-08-02T19:49:00.000","Title":"Flash video record on website 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":0,"System Administration and DevOps":0,"Web Development":1},{"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},{"Question":"I have a c# application that defines a membership provider used in a Asp.Net MVC application.\nAnd i have an apache httpd server that does authentication with mod_wsgi.\nThe objective is to share the membership provider between the two, so that the authentication information be the same.\nHow can i achieve this behaviour ?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":145,"Q_Id":3395409,"Users Score":1,"Answer":"Trivially.\n\nApache serves static content.\nCertain URI's will be routed to mod_wsgi to Python.\nPython will then execute (via subprocess) a C# program, providing command-line arguments, and reading the standard output response from the C# program.\nPython does whatever else is required to serve the web pages.\n\nThis presumes your C# application runs at the command line, reads command-line parameters and writes its result to standard output.  This is an easy thing to build.  It may not be the way it works today, but any program that runs from the command line is trivial to integrate.\nYour C# application, BTW, can also be rewritten into Python.  It isn't magic.  It's just code.  Read the code, understand the code, and translate the code.  You'll be a lot happier replacing the C# with something simpler.","Q_Score":0,"Tags":"c#,python,apache,mod-wsgi","A_Id":3395446,"CreationDate":"2010-08-03T09:58:00.000","Title":"using c# inside an apache 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},{"Question":"Is it just me or is having to run multiple instances of a web server to scale a hack?\nAm I wrong in this?\nClarification\nI am referring to how I read people run multiple instances of a web service on a single server.  I am not talking about a cluster of servers.","AnswerCount":6,"Available Count":5,"Score":0.0333209931,"is_accepted":false,"ViewCount":584,"Q_Id":3399367,"Users Score":1,"Answer":"Even if Ruby\/Python interpreters were perfect, and could utilize all avail CPU with single process, you would still reach maximal capability of single server sooner or later and have to scale across several machines, going back to running several instances of your app.","Q_Score":1,"Tags":"python,ruby-on-rails","A_Id":3399696,"CreationDate":"2010-08-03T18:06:00.000","Title":"having to run multiple instances of a web service for ruby\/python seems like a hack to me","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"Is it just me or is having to run multiple instances of a web server to scale a hack?\nAm I wrong in this?\nClarification\nI am referring to how I read people run multiple instances of a web service on a single server.  I am not talking about a cluster of servers.","AnswerCount":6,"Available Count":5,"Score":0.0333209931,"is_accepted":false,"ViewCount":584,"Q_Id":3399367,"Users Score":1,"Answer":"With no details, it is very difficult to see what you are getting at. That being said, it is quite possible that you are simply not using the right approach for your problem.\nSometimes multiple separate instances are better. Sometimes, your Python services are actually better deployed behind a single Apache instance (using mod_wsgi) which may elect to use more than a single process. I don't know about Ruby to opinionate there.\nIn short, if you want to make your service scalable then the way to do so depends heavily on additional details. Is it scaling up or scaling out? What is the operating system and available or possibly installable server software? Is the service itself easily parallelized and how much is it database dependent? How is the database deployed?","Q_Score":1,"Tags":"python,ruby-on-rails","A_Id":3399437,"CreationDate":"2010-08-03T18:06:00.000","Title":"having to run multiple instances of a web service for ruby\/python seems like a hack to me","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"Is it just me or is having to run multiple instances of a web server to scale a hack?\nAm I wrong in this?\nClarification\nI am referring to how I read people run multiple instances of a web service on a single server.  I am not talking about a cluster of servers.","AnswerCount":6,"Available Count":5,"Score":0.0,"is_accepted":false,"ViewCount":584,"Q_Id":3399367,"Users Score":0,"Answer":"Your assumption that Tomcat's and IIS's single process per server is superior is flawed.  The choice of a multi-threaded server and a multi-process server depends on a lot of variables.\nOne main thing is the underlying operating system.  Unix systems have always had great support for multi-processing because of the copy-on-write nature of the fork system call.  This makes multi-processes a really attractive option because web-serving is usually very shared-nothing and you don't have to worry about locking.  Windows on the other hand had much heavier processes and lighter threads so programs like IIS would gravitate to a multi-threading model.\nAs for the question to wether it's a hack to run multiple servers really depends on your perspective.  If you look at Apache, it comes with a variety of pluggable engines to choose from.  The MPM-prefork one is the default because it allows the programmer to easily use non-thread-safe C\/Perl\/database libraries without having to throw locks and semaphores all over the place.  To some that might be a hack to work around poorly implemented libraries. To me it's a brilliant way of leaving it to the OS to handle the problems and letting me get back to work.\nAlso a multi-process model comes with a few features that would be very difficult to implement in a multi-threaded server.  Because they are just processes, zero-downtime rolling-updates are trivial.  You can do it with a bash script.  \nIt also has it's short-comings.  In a single-server model setting up a singleton that holds some global state is trivial, while on a multi-process model you have to serialize that state to a database or Redis server.  (Of course if your single-process server outgrows a single server you'll have to do that anyway.)\nIs it a hack? Yes and no.  Both original implementations (MRI, and CPython) have Global Interpreter Locks that will prevent a multi-core server from operating at it's 100% potential.  On the other hand multi-process has it's advantages (especially on the Unix-side of the fence).\nThere's also nothing inherent in the languages themselves that makes them require a GIL, so you can run your application with Jython, JRuby, IronPython or IronRuby if you really want to share state inside a single process.","Q_Score":1,"Tags":"python,ruby-on-rails","A_Id":3402337,"CreationDate":"2010-08-03T18:06:00.000","Title":"having to run multiple instances of a web service for ruby\/python seems like a hack to me","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"Is it just me or is having to run multiple instances of a web server to scale a hack?\nAm I wrong in this?\nClarification\nI am referring to how I read people run multiple instances of a web service on a single server.  I am not talking about a cluster of servers.","AnswerCount":6,"Available Count":5,"Score":1.2,"is_accepted":true,"ViewCount":584,"Q_Id":3399367,"Users Score":4,"Answer":"Not really, people were running multiple frontends across a cluster of servers before multicore cpus became widespread\nSo there has been all the infrastructure for supporting sessions properly across multiple frontends for quite some time before it became really advantageous to run a bunch of threads on one machine.\nInfact using asynchronous style frontends gives better performance on the same hardware than a multithreaded approach, so I would say that not running multiple instances in favour of a multithreaded monster is a hack","Q_Score":1,"Tags":"python,ruby-on-rails","A_Id":3399409,"CreationDate":"2010-08-03T18:06:00.000","Title":"having to run multiple instances of a web service for ruby\/python seems like a hack to me","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"Is it just me or is having to run multiple instances of a web server to scale a hack?\nAm I wrong in this?\nClarification\nI am referring to how I read people run multiple instances of a web service on a single server.  I am not talking about a cluster of servers.","AnswerCount":6,"Available Count":5,"Score":0.1325487884,"is_accepted":false,"ViewCount":584,"Q_Id":3399367,"Users Score":4,"Answer":"Since we are now moving towards more cores, rather than faster processors - in order to scale more and more, you will need to be running more instances. \nSo yes, I reckon you are wrong. \nThis does not by any means condone brain-dead programming with the excuse that you can just scale it horizontally, that just seems retarded.","Q_Score":1,"Tags":"python,ruby-on-rails","A_Id":3399416,"CreationDate":"2010-08-03T18:06:00.000","Title":"having to run multiple instances of a web service for ruby\/python seems like a hack to me","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I'm a mechanical engineering student, and I'm building a physical simulation using PyODE.\ninstead of running everything from one file, I wanted to organize stuff in modules so I had:\n\nmain.py\ncallback.py\nhelper.py\n\nI ran into problems when I realized that helper.py needed to reference variables from main, but main was the one importing helper!\nso my solution was to create a 4th file, which houses variables and imports only external modules (such as time and random).\nso I now have:\n\nmain.py\ncallback.py\nhelper.py\nparameters.py\n\nand all scripts have: import parameters and use: parameters.foo or parameters.bar.\nIs this an acceptable practice or is this a sure fire way to make python programmers puke? :)\nPlease let me know if this makes sense, or if there is a more sensible way of doing it!\nThanks,\n-Leav","AnswerCount":6,"Available Count":4,"Score":0.0,"is_accepted":false,"ViewCount":260,"Q_Id":3400847,"Users Score":0,"Answer":"Seems like what you want is to organize various dependencies between components. You will be better off expressing these dependencies in an object-oriented manner. Rather than doing it by importing modules and global states, encode these states in objects and pass those around.\nRead up on objects and classes and how to write them in Python; I'd probably start there.","Q_Score":3,"Tags":"python","A_Id":3401173,"CreationDate":"2010-08-03T21:23:00.000","Title":"A python module for global parameters - is this good practice?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm a mechanical engineering student, and I'm building a physical simulation using PyODE.\ninstead of running everything from one file, I wanted to organize stuff in modules so I had:\n\nmain.py\ncallback.py\nhelper.py\n\nI ran into problems when I realized that helper.py needed to reference variables from main, but main was the one importing helper!\nso my solution was to create a 4th file, which houses variables and imports only external modules (such as time and random).\nso I now have:\n\nmain.py\ncallback.py\nhelper.py\nparameters.py\n\nand all scripts have: import parameters and use: parameters.foo or parameters.bar.\nIs this an acceptable practice or is this a sure fire way to make python programmers puke? :)\nPlease let me know if this makes sense, or if there is a more sensible way of doing it!\nThanks,\n-Leav","AnswerCount":6,"Available Count":4,"Score":1.2,"is_accepted":true,"ViewCount":260,"Q_Id":3400847,"Users Score":1,"Answer":"I try to design my code so that it looks much like a pyramid. That, I have found, leads to cleaner code.","Q_Score":3,"Tags":"python","A_Id":3401021,"CreationDate":"2010-08-03T21:23:00.000","Title":"A python module for global parameters - is this good practice?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm a mechanical engineering student, and I'm building a physical simulation using PyODE.\ninstead of running everything from one file, I wanted to organize stuff in modules so I had:\n\nmain.py\ncallback.py\nhelper.py\n\nI ran into problems when I realized that helper.py needed to reference variables from main, but main was the one importing helper!\nso my solution was to create a 4th file, which houses variables and imports only external modules (such as time and random).\nso I now have:\n\nmain.py\ncallback.py\nhelper.py\nparameters.py\n\nand all scripts have: import parameters and use: parameters.foo or parameters.bar.\nIs this an acceptable practice or is this a sure fire way to make python programmers puke? :)\nPlease let me know if this makes sense, or if there is a more sensible way of doing it!\nThanks,\n-Leav","AnswerCount":6,"Available Count":4,"Score":0.0996679946,"is_accepted":false,"ViewCount":260,"Q_Id":3400847,"Users Score":3,"Answer":"Separate 'global' files for constants, configurations, and includes needed everywhere are fine. But when they contain actual mutable variables then they're not such a good idea. Consider having the files communicate with function return values and arguments instead. This promotes encapsulation and will keep your code from becoming a tangled mess. \nClear communication between files makes them easier to understand and makes what's going on more obvious. When you're using variables and nobody knows where they came from, things can get pretty annoying. :)","Q_Score":3,"Tags":"python","A_Id":3400902,"CreationDate":"2010-08-03T21:23:00.000","Title":"A python module for global parameters - is this good practice?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm a mechanical engineering student, and I'm building a physical simulation using PyODE.\ninstead of running everything from one file, I wanted to organize stuff in modules so I had:\n\nmain.py\ncallback.py\nhelper.py\n\nI ran into problems when I realized that helper.py needed to reference variables from main, but main was the one importing helper!\nso my solution was to create a 4th file, which houses variables and imports only external modules (such as time and random).\nso I now have:\n\nmain.py\ncallback.py\nhelper.py\nparameters.py\n\nand all scripts have: import parameters and use: parameters.foo or parameters.bar.\nIs this an acceptable practice or is this a sure fire way to make python programmers puke? :)\nPlease let me know if this makes sense, or if there is a more sensible way of doing it!\nThanks,\n-Leav","AnswerCount":6,"Available Count":4,"Score":0.0665680765,"is_accepted":false,"ViewCount":260,"Q_Id":3400847,"Users Score":2,"Answer":"Uhm, i think it does not make sence if this happens: \"realized that helper.py needed to reference variables from main\", your helper functions should be independent from your \"main code\", otherwise i think its ugly and more like a design failure.","Q_Score":3,"Tags":"python","A_Id":3400871,"CreationDate":"2010-08-03T21:23:00.000","Title":"A python module for global parameters - is this good practice?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Python has a subversion bindings called 'pysvn' that can be used to manipulate subversion repository. Does something similar exists for IronPython?\nMy test platform in Windows 7 64-bit with Visual Studio 2010.","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":248,"Q_Id":3408610,"Users Score":1,"Answer":"I believe you can import pysvn in IronPython, but you have to add python site-packages directory to IRONPYTHONPATH.","Q_Score":2,"Tags":".net,visual-studio-2010,ironpython,pysvn","A_Id":3408897,"CreationDate":"2010-08-04T18:31:00.000","Title":"is it possible to access subversion from 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},{"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},{"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},{"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},{"Question":"Why is this such a bad idea? (According to many people)","AnswerCount":3,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":797,"Q_Id":3410296,"Users Score":3,"Answer":"I don't think it's a bad idea. Lots of people use IPython which is a shell written in Python :)\nIn fact you may want to base your effort around IPython. scipy does this, for example","Q_Score":2,"Tags":"python,shell","A_Id":3410409,"CreationDate":"2010-08-04T22:17:00.000","Title":"Writing a Shell 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},{"Question":"Besides the obvious (one is a type, the other a class)? What should be preferred? Any notable difference in use cases, perhaps?","AnswerCount":2,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":19774,"Q_Id":3410309,"Users Score":6,"Answer":"In terms of python 2.7 and 3:\nio.BytesIO is an in-memory file-like object that doesn't do any alteration to newlines, and is similar to open(filename, \"wb\"). It deal with bytes() strings, which in py2.7 is an alias for str.\nio.StringIO is an in-memory file-like object that does do alterations to newlines, and is similar to open(filename, \"w\"). It deal with unicode() strings, which in py3.x is an alias for str.\npy2.7's old StringIO.StringIO is an in-memory file-like object that does not do alterations to newlines, and is similar to open(filename, \"w\"). It deals with both unicode() and bytes() in the same way that most obsolete python 2 string methods do: by allowing you to mix them without error, but only as long as you're lucky.\nThus py2.7's old StringIO.StringIO class is actually more similar to io.BytesIO than io.StringIO, as it is operating in terms of bytes()\/str() and doesn't do newline conversions.\n\nWhat should be preferred?\n\nDon't use StringIO.StringIO, instead use io.BytesIO or io.StringIO, depending on the use-case. This is forward compatible with python 3 and commits to bytes or unicode, rather than \"both, maybe\".","Q_Score":30,"Tags":"python,string","A_Id":49795277,"CreationDate":"2010-08-04T22:18:00.000","Title":"What is the difference between StringIO and io.StringIO in Python2.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":0,"Web Development":0},{"Question":"I am totally new to programming as though I have my PhD as a molecular biologist for the last 10 years. Can someone please tell me: Would it be too hard to handle if I enrolled simultaneously in C++ and python? I am a full time employee too. Both courses start and finish on the same dates and is for 3 months. For a variety of complicated reasons, this fall is the only time I can learn both languages. Please advise.\nGillingsT\nUpdate:\nA little more detail about myself: as I said I did a PhD in Molecular Genetic. I now wish to be able to obtain programming skills so that I can apply it to do bioinformatics- like sequence manipulation and pathway analysis. I was told that Python is great for that but our course does not cover basics for beginners. I approached a Comp Sci Prof. who suggested that I learn C++ first before learning Python. So I got into this dilemma (added to other logistics).","AnswerCount":8,"Available Count":6,"Score":0.049958375,"is_accepted":false,"ViewCount":4081,"Q_Id":3416342,"Users Score":2,"Answer":"If you are new to programming, I would say start with the C++ class.  If you get the hang of it and enjoy programming, you can always learn Python later.  There are a wealth of good books and Internet resources on pretty much any programming language out there that you should be able to teach yourself any language in your spare time.  I would recommend learning that first language in a formal classroom, however, to help make it easier to learn the general concepts behind programming.\nEdit: To clarify the point I was trying to make, my recommendation is to take whichever course is geared more towards beginning programmers.  The important things to learn first are the basic fundamentals of programming.  These apply towards almost any language.  Thanks to the wealth of resources available online or in your bookstore\/library, you can teach yourself practically any programming language that you want to learn.  First, however, you must grasp the basics, and intro C\/C++ classes typically (in my experiences, at least) do a good job of teaching programming fundamentals as well as the language itself.\nSince you are a beginning programmer, I would not recommend trying to learn two languages at once (especially if you are trying to learn fundamentals at the same time).  That's a lot of very similar (yet very different) information to keep track of in your head, almost like trying to learn two brand new spoken languages at the same time.  You may be able to handle it perfectly fine but at least for most programmers that I know, it is much easier to get a good grasp on one language first and then start learning the second.","Q_Score":0,"Tags":"c++,python","A_Id":3416435,"CreationDate":"2010-08-05T15:29:00.000","Title":"C++ and python simultaneously. Is it doable","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I am totally new to programming as though I have my PhD as a molecular biologist for the last 10 years. Can someone please tell me: Would it be too hard to handle if I enrolled simultaneously in C++ and python? I am a full time employee too. Both courses start and finish on the same dates and is for 3 months. For a variety of complicated reasons, this fall is the only time I can learn both languages. Please advise.\nGillingsT\nUpdate:\nA little more detail about myself: as I said I did a PhD in Molecular Genetic. I now wish to be able to obtain programming skills so that I can apply it to do bioinformatics- like sequence manipulation and pathway analysis. I was told that Python is great for that but our course does not cover basics for beginners. I approached a Comp Sci Prof. who suggested that I learn C++ first before learning Python. So I got into this dilemma (added to other logistics).","AnswerCount":8,"Available Count":6,"Score":0.0,"is_accepted":false,"ViewCount":4081,"Q_Id":3416342,"Users Score":0,"Answer":"You've got to find out what people in your field are programming with so you can leverage existing libraries\/APIs\/projects.  It won't do you any good re-inventing the wheel in C++ or Python if there's some wicked-cool FORTRAN library out there that is standard in your field.  (And, if that is the case, God help you, I'm sorry.)  Anyway, the CS prof you talked to might not have any idea what computational molecular geneticists use.","Q_Score":0,"Tags":"c++,python","A_Id":3648941,"CreationDate":"2010-08-05T15:29:00.000","Title":"C++ and python simultaneously. Is it doable","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I am totally new to programming as though I have my PhD as a molecular biologist for the last 10 years. Can someone please tell me: Would it be too hard to handle if I enrolled simultaneously in C++ and python? I am a full time employee too. Both courses start and finish on the same dates and is for 3 months. For a variety of complicated reasons, this fall is the only time I can learn both languages. Please advise.\nGillingsT\nUpdate:\nA little more detail about myself: as I said I did a PhD in Molecular Genetic. I now wish to be able to obtain programming skills so that I can apply it to do bioinformatics- like sequence manipulation and pathway analysis. I was told that Python is great for that but our course does not cover basics for beginners. I approached a Comp Sci Prof. who suggested that I learn C++ first before learning Python. So I got into this dilemma (added to other logistics).","AnswerCount":8,"Available Count":6,"Score":0.0,"is_accepted":false,"ViewCount":4081,"Q_Id":3416342,"Users Score":0,"Answer":"I come from a computational maths background, and have written sizeable (commercial and accademic) programs in both C++ and python. They are very different languages and I would probably learn one first (or only one).\nWhich one would depend on what you want to be able to do with the language.\nIf you want to build something useful with your language that is not (overly) compute or data heavy, go with python, you'll get something useful quicker. \nIf you need to do something useful that is either compute heavy or data heavy, then you'll probably need to go with C++. But it will take you longer to get to something to do what you need --- It will take a while to learn C++, then additional time to code data-heavy or compute-heavy code effectively.\nNow some will say that python can handle data\/compute heavy jobs well enough.. but in molecular biology \"heavy\" can mean very heavy. \nHaving said this, my suggestion is go with python if you can.","Q_Score":0,"Tags":"c++,python","A_Id":3648912,"CreationDate":"2010-08-05T15:29:00.000","Title":"C++ and python simultaneously. Is it doable","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I am totally new to programming as though I have my PhD as a molecular biologist for the last 10 years. Can someone please tell me: Would it be too hard to handle if I enrolled simultaneously in C++ and python? I am a full time employee too. Both courses start and finish on the same dates and is for 3 months. For a variety of complicated reasons, this fall is the only time I can learn both languages. Please advise.\nGillingsT\nUpdate:\nA little more detail about myself: as I said I did a PhD in Molecular Genetic. I now wish to be able to obtain programming skills so that I can apply it to do bioinformatics- like sequence manipulation and pathway analysis. I was told that Python is great for that but our course does not cover basics for beginners. I approached a Comp Sci Prof. who suggested that I learn C++ first before learning Python. So I got into this dilemma (added to other logistics).","AnswerCount":8,"Available Count":6,"Score":1.0,"is_accepted":false,"ViewCount":4081,"Q_Id":3416342,"Users Score":7,"Answer":"You'll get holes in the head.\nPython's data structures and memory management are radically different from C++.  \nWhichever language you \"get\" first, you'll love.  The other you'll hate.  Indeed, you'll be confused at the weird things one language lacks that the other has.  One language will be reasonable, logical, unsurprising.  The other will be a mess of ad-hoc decisions and quirks.\nIf you learn one all the way through -- by itself -- you'll probably be happier.  \nI find that most folks can more easily add a language to a base of expertise.  \n[Not all, however.  Some folks are so mired in the first language they ever learned that they challenge every feature of a new language as being nonsensical.  I had a guy in a Java class who only wanted to complain about the numerous ways that Java wasn't Fortran.  All the type-specific stuff in Java gave him fits.  A lot of discussions had to be curtailed with \"That's the way it is.  If you don't like it, take it up with Gosling.  My job isn't to justify Java; my job is to get you to be able to work with java.  Can we move on, now?\"]","Q_Score":0,"Tags":"c++,python","A_Id":3416441,"CreationDate":"2010-08-05T15:29:00.000","Title":"C++ and python simultaneously. Is it doable","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I am totally new to programming as though I have my PhD as a molecular biologist for the last 10 years. Can someone please tell me: Would it be too hard to handle if I enrolled simultaneously in C++ and python? I am a full time employee too. Both courses start and finish on the same dates and is for 3 months. For a variety of complicated reasons, this fall is the only time I can learn both languages. Please advise.\nGillingsT\nUpdate:\nA little more detail about myself: as I said I did a PhD in Molecular Genetic. I now wish to be able to obtain programming skills so that I can apply it to do bioinformatics- like sequence manipulation and pathway analysis. I was told that Python is great for that but our course does not cover basics for beginners. I approached a Comp Sci Prof. who suggested that I learn C++ first before learning Python. So I got into this dilemma (added to other logistics).","AnswerCount":8,"Available Count":6,"Score":0.024994793,"is_accepted":false,"ViewCount":4081,"Q_Id":3416342,"Users Score":1,"Answer":"I think that given the circumstances (fulltime employee, etc) studying one language will be hard enough. Pick one, then study another. You'll learn basics from either language.\nAs for \"which language to pick\"... I specialize in C++, and know a bit of python. C++ is much more difficult, more flexible, and more suitable for making \"traditional\" executables. \nI'd recommend to start with C++. You'll learn more concepts (some of them doesn't exist in python), and learning python after C++ won't be a problem.","Q_Score":0,"Tags":"c++,python","A_Id":3416466,"CreationDate":"2010-08-05T15:29:00.000","Title":"C++ and python simultaneously. Is it doable","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I am totally new to programming as though I have my PhD as a molecular biologist for the last 10 years. Can someone please tell me: Would it be too hard to handle if I enrolled simultaneously in C++ and python? I am a full time employee too. Both courses start and finish on the same dates and is for 3 months. For a variety of complicated reasons, this fall is the only time I can learn both languages. Please advise.\nGillingsT\nUpdate:\nA little more detail about myself: as I said I did a PhD in Molecular Genetic. I now wish to be able to obtain programming skills so that I can apply it to do bioinformatics- like sequence manipulation and pathway analysis. I was told that Python is great for that but our course does not cover basics for beginners. I approached a Comp Sci Prof. who suggested that I learn C++ first before learning Python. So I got into this dilemma (added to other logistics).","AnswerCount":8,"Available Count":6,"Score":0.0,"is_accepted":false,"ViewCount":4081,"Q_Id":3416342,"Users Score":0,"Answer":"I think you pretty much answered this question yourself:\n\nI was told that Python is great for that but our course does not cover basics for beginners.\n\nIn other words, the Python course is not an introductory course -- it assumes you already know how the basics of programming.  That's probably why the professor suggested you take the C++ course first.","Q_Score":0,"Tags":"c++,python","A_Id":3648838,"CreationDate":"2010-08-05T15:29:00.000","Title":"C++ and python simultaneously. Is it doable","Data Science and Machine Learning":0,"Database and SQL":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},{"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},{"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},{"Question":"I am trying to teach myself Python, and I have realized that the only way I really learn stuff is by reading the actual programs. Tutorials\/manuals just cause me to feel deeply confused. \nIt's just my learning style, and I'm like that with everything I've studied (including natural languages -- I've managed to teach myself three of them by just getting into the actual 'flow of it').\nClassical music once had the concept of a 'gamut' -- playing the entire range of an instrument in an artful manner. I'm guessing that there may be a few well-written scripts out there that really show off every feature of the language. It doesn't matter what they do, I just want to start studying Python by reading programs themselves.\nI remember coming across a similar method years ago when I studied some LISP. It was a book, published by Springer Verlag, consisting solely of AI programs, to be read for their didactic merit.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":2872,"Q_Id":3428245,"Users Score":18,"Answer":"I would recommend studying the Standard Python Library (all the parts of it that are coded in Python, that is) -- it's not uniformly excellent in elegance, but it sets a pretty high standard.  Plus, the study has the extra benefit of making you very familiar with the library itself (an absolutely crucial part of mastering Python), in addition to showing you a lot good to excellent Python style code;-).\nEdit: I have to point out (or my wife and co-author Anna has threatened to not cook the yummy steak I see waiting;-) that the Python Cookbook, 2nd printed edition, also has a lot of code examples, in the best style Anna and I could make them, and with substantial discussion of style variations and alternatives.  However, it's stuck back in time to the days of Python 2.4 (sorry, no time to do a third edition for now...), and that's a real block for some people (though I think that having learned good Python 2.4 style, moving to good 2.7 or 3.1 style is really an \"incremental\" matter, that's definitely a subjective opinion).  \"Declaring my interest\": Anna and I still get some royalties if you buy the book, and, more importantly, the Python Software Foundation (near and dear to both our hearts -- our Prius's vanity license plate reads \"P\u2665THON\"...!-) gets more -- so obviously we're biased in the book's favor;-).  If you don't want to spend money, you can read some parts of the book online and for free on Google Books (O'Reilly gets to pick and choose which parts are thus freely readable, so please don't complain to me [[or Anna]] about those choices...!-).\nI wish I could recommend the online edition of the Cookbook, which does have recipes that are very recent as well as the classic old ones among which we picked and chose most of the printed edition's ones -- but, unfortunately, there are lots of style issues with too many of the online recipes to recommend them collectively as \"good style examples\" (and that goes for the good recipes too: most of the recipes we picked for the book, we also heavily edited to improve style (and readability, and performance, but those often go hand-in-hand with Python).","Q_Score":13,"Tags":"python","A_Id":3428288,"CreationDate":"2010-08-06T22:29:00.000","Title":"Elegant 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},{"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},{"Question":"Suppose you have a MD5 hash encoded in base64.  Then each\ncharacter needs only 6 bits to store each character in the\nresultant 22-byte string (excluding the ending '==').  Thus, each\nbase64 md5 hash can shrink down to 6*22 = 132 bits, which\nrequires 25% less memory space compared to the original 8*22=176\nbits string.\nIs there any Python module or function that lets you store base64\ndata in the way described above?","AnswerCount":4,"Available Count":3,"Score":1.2,"is_accepted":true,"ViewCount":1820,"Q_Id":3430016,"Users Score":1,"Answer":"David gave an answer that works on all base64 strings.\nJust use base64.decodestring in base64 module. That is,\nimport base64\nbinary = base64.decodestring(base64_string)\nis a more memory efficient representation of the original base64 string.  If you\nare truncating trailing '==' in your base64 md5, use it like\nbase64.decodestring(md5+'==')","Q_Score":4,"Tags":"python,algorithm,data-structures,md5,base64","A_Id":3452248,"CreationDate":"2010-08-07T10:08:00.000","Title":"Most memory-efficient way of holding base64 data 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},{"Question":"Suppose you have a MD5 hash encoded in base64.  Then each\ncharacter needs only 6 bits to store each character in the\nresultant 22-byte string (excluding the ending '==').  Thus, each\nbase64 md5 hash can shrink down to 6*22 = 132 bits, which\nrequires 25% less memory space compared to the original 8*22=176\nbits string.\nIs there any Python module or function that lets you store base64\ndata in the way described above?","AnswerCount":4,"Available Count":3,"Score":0.1973753202,"is_accepted":false,"ViewCount":1820,"Q_Id":3430016,"Users Score":4,"Answer":"\"store base64 data\"\n\nDon't.\nDo. Not. Store. Base64. Data.\nBase64 is built by encoding something to make it bigger.\nStore the original something.  Never store the base64 encoding of something.","Q_Score":4,"Tags":"python,algorithm,data-structures,md5,base64","A_Id":3430256,"CreationDate":"2010-08-07T10:08:00.000","Title":"Most memory-efficient way of holding base64 data 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},{"Question":"Suppose you have a MD5 hash encoded in base64.  Then each\ncharacter needs only 6 bits to store each character in the\nresultant 22-byte string (excluding the ending '==').  Thus, each\nbase64 md5 hash can shrink down to 6*22 = 132 bits, which\nrequires 25% less memory space compared to the original 8*22=176\nbits string.\nIs there any Python module or function that lets you store base64\ndata in the way described above?","AnswerCount":4,"Available Count":3,"Score":1.0,"is_accepted":false,"ViewCount":1820,"Q_Id":3430016,"Users Score":8,"Answer":"The most efficient way to store base64 encoded data is to decode it and store it as binary. base64 is a transport encoding - there's no sense in storing data in it, especially in memory, unless you have a compelling reason otherwise.\nAlso, nitpick: The output of a hash function is not a hex string - that's just a common representation. The output of a hash function is some number of bytes of binary data. If you're using the md5, sha, or hashlib modules, for example, you don't need to encode it as anything in the first place - just call .digest() instead of .hexdigest() on the hash object.","Q_Score":4,"Tags":"python,algorithm,data-structures,md5,base64","A_Id":3430100,"CreationDate":"2010-08-07T10:08:00.000","Title":"Most memory-efficient way of holding base64 data 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},{"Question":"I created a module in Python which provides about a dozen functionalities. While it will be mostly used from within Python, there is a good fraction of legacy users which will be calling it from Perl.\nWhat is the best way to make a plug in to this module? My thoughts are:\n\nProvide the functionalities as command line utilities and make system calls\nCreate some sort of server and handle RPC calls (say, via JSON RPC)\n\nAny advise?","AnswerCount":3,"Available Count":2,"Score":1.0,"is_accepted":false,"ViewCount":9275,"Q_Id":3441766,"Users Score":9,"Answer":"In the short run the easiest solution is to use Inline::Python.  Closely followed by calling a command-line script.\nIn the long run, using a server to provide RPC functionality or simply calling a command-line script will give you the most future proof solution.\nWhy?\nBecuase that way you aren't tied to Perl or Python as the language used to build the systems that consume the services provided by your library.  Either method creates a clear, language independent interface that you can use with whatever development environment you adopt.\nDepending on your needs any of the presented options may be the \"best choice\".  Depending on how your needs evolve over time, a different choice may be revealed as \"best\".\nMy approach to this would be to ask a couple of questions:\nHow often do you change development tools.  You've switched to Python from Perl.  Did you start with Tcl and go to Perl?  Are you going to switch to the exciting new language X in 1, 5 or 10 years?  If you change tools 'often' (whatever that means) emphasize cross tool compatibility.\nHow fast is fast enough?  Is the start up time for command line solutions ok?  Does Inline::Python slow things down too much (you are still initializing a Python interpreter, it's just embedded in your Perl interpreter)?\nBased on the answers to these questions, I would do the simplest thing that is likely to work.\nMy guess is that means in order:\n\nInline::Python\nCommand line scripts\nBuild an RPC server","Q_Score":9,"Tags":"python,perl,interop","A_Id":3446205,"CreationDate":"2010-08-09T15:50:00.000","Title":"Calling a Python module from 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},{"Question":"I created a module in Python which provides about a dozen functionalities. While it will be mostly used from within Python, there is a good fraction of legacy users which will be calling it from Perl.\nWhat is the best way to make a plug in to this module? My thoughts are:\n\nProvide the functionalities as command line utilities and make system calls\nCreate some sort of server and handle RPC calls (say, via JSON RPC)\n\nAny advise?","AnswerCount":3,"Available Count":2,"Score":0.1973753202,"is_accepted":false,"ViewCount":9275,"Q_Id":3441766,"Users Score":3,"Answer":"Provide the functionalities as command line utilities and make system calls\n\nWorks really nicely.  This is the way programs like Python (and Perl) are meant to use used.","Q_Score":9,"Tags":"python,perl,interop","A_Id":3441920,"CreationDate":"2010-08-09T15:50:00.000","Title":"Calling a Python module from 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},{"Question":"Can I call a test method from within the test class in python? For example:\n\n\nclass Test(unittest.TestCase):\n    def setUp(self):\n        #do stuff\n\n    def test1(self):\n        self.test2()\n\n    def test2(self):\n        #do stuff\n\n\nupdate: I forgot the other half of my question. Will setup or teardown be called only after the method that the tester calls? Or will it get called between test1 entering and after calling test2 from test1?","AnswerCount":5,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":3578,"Q_Id":3444827,"Users Score":0,"Answer":"Yes to both:\n\nsetUp will be called between each test\ntest2 will be called twice. \n\nIf you would like to call a function inside a test, then omit the test prefix.","Q_Score":7,"Tags":"python,unit-testing","A_Id":3444963,"CreationDate":"2010-08-09T22:59:00.000","Title":"python unittest methods","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Can I call a test method from within the test class in python? For example:\n\n\nclass Test(unittest.TestCase):\n    def setUp(self):\n        #do stuff\n\n    def test1(self):\n        self.test2()\n\n    def test2(self):\n        #do stuff\n\n\nupdate: I forgot the other half of my question. Will setup or teardown be called only after the method that the tester calls? Or will it get called between test1 entering and after calling test2 from test1?","AnswerCount":5,"Available Count":3,"Score":0.0399786803,"is_accepted":false,"ViewCount":3578,"Q_Id":3444827,"Users Score":1,"Answer":"All methods whose name begins with the string 'test' are considered unit tests (i.e. they get run when you call unittest.main()). So you can call methods from within the Test class, but you should name it something that does not start with the string 'test' unless you want it to be also run as a unit test.","Q_Score":7,"Tags":"python,unit-testing","A_Id":3444872,"CreationDate":"2010-08-09T22:59:00.000","Title":"python unittest methods","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Can I call a test method from within the test class in python? For example:\n\n\nclass Test(unittest.TestCase):\n    def setUp(self):\n        #do stuff\n\n    def test1(self):\n        self.test2()\n\n    def test2(self):\n        #do stuff\n\n\nupdate: I forgot the other half of my question. Will setup or teardown be called only after the method that the tester calls? Or will it get called between test1 entering and after calling test2 from test1?","AnswerCount":5,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":3578,"Q_Id":3444827,"Users Score":0,"Answer":"sure, why not -- however that means test2 will be called twice -- once by test1 and then again as its own test, since all functions named test will be called.","Q_Score":7,"Tags":"python,unit-testing","A_Id":3444874,"CreationDate":"2010-08-09T22:59:00.000","Title":"python unittest methods","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm considering moving from PHP to Python (for personal projects), and I really don't like seeing \/cgi-bin\/ in my URL.\nI got the Python to execute outside of cgi-bin, but I just wanted to make sure there were no possible security issues that could pop up, and that there were no major impacts on the speed.\nSo are there any major issues I need to be aware of?\nThanks in advance for any help.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":313,"Q_Id":3452388,"Users Score":1,"Answer":"Being as how it's nominally just a URL, there aren't any impacts on speed per-se. However, it is standard practice, just like it's standard practice to make the entry page to a website index.html, but it's not required by any stretch (as evidenced by default.aspx, home.php, etc)\nI would change it as a security through obscurity reference myself, were I inclined to change those things on my system.\nWhile you won't incur any Apache security issues, there may be issues with server-side code or hard-coded modules that don't query for path, and assume code is running from cgi-bin ... just something to consider.","Q_Score":0,"Tags":"python,cgi,cgi-bin","A_Id":3452427,"CreationDate":"2010-08-10T18:55:00.000","Title":"Running CGI outside of cgi-bin. Good idea?","Data Science and Machine Learning":0,"Database and SQL":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},{"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},{"Question":"is this possible to view contents and Functions of a DLL file...\nfew times ago i was playing with OlyDBG then i found there is option for viewing contents of dll...\nso suggest me any good tool or soft for this...   \nand suppose i have a DLL named \"Python27.dll\"...\nnow i need to view the content of this DLL so what do i do...\nthanx...","AnswerCount":4,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":3117,"Q_Id":3454647,"Users Score":0,"Answer":"I've done some work with ctypes, and loading dlls in windows, but I don't think DLL have any sort of introspection.  This really isn't a big deal, because all of the function calls in DLLs are static.  If your trying to use a undocumented DLL, you would not only need to know the names of the functions, but also the parameters of the functions.  You would have to reverse engineer the DLL, no small task.\nSo, in my opinion, I would say no.","Q_Score":4,"Tags":"c#,python,c,dll,import","A_Id":3454709,"CreationDate":"2010-08-11T01:17:00.000","Title":"Viewing Contents Of a DLL 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},{"Question":"I have a web service that is required to handle significant concurrent utilization and volume and I need to test it. Since the service is fairly specialized, it does not lend itself well to a typical testing framework. The test would need to simulate multiple clients concurrently posting to a URL, parsing the resulting Http response, checking that a database has been appropriately updated and making sure certain emails have been correctly sent\/received. \nThe current opinion at my company is that I should write this framework using Python. I have never used Python with multiple threads before and as I was doing my research I came across the Global Interpreter Lock which seems to be the basis of most of Python's concurrency handling. It seems to me that the GIL would prevent Python from being able to achieve true concurrency even on a multi-processor machine. Is this true? Does this scenario change if I use a compiler to compile Python to native code? Am I just barking up the wrong tree entirely and is Python the wrong tool for this job?","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":1336,"Q_Id":3458249,"Users Score":0,"Answer":"Assuming general network conditions, as long you have sufficient system resources Python's regular threading module will allow you to simulate concurrent workload at an higher rate than any a real workload.","Q_Score":3,"Tags":"python","A_Id":3458457,"CreationDate":"2010-08-11T12:36:00.000","Title":"Concurrency Testing For A Web Service 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},{"Question":"I have a web service that is required to handle significant concurrent utilization and volume and I need to test it. Since the service is fairly specialized, it does not lend itself well to a typical testing framework. The test would need to simulate multiple clients concurrently posting to a URL, parsing the resulting Http response, checking that a database has been appropriately updated and making sure certain emails have been correctly sent\/received. \nThe current opinion at my company is that I should write this framework using Python. I have never used Python with multiple threads before and as I was doing my research I came across the Global Interpreter Lock which seems to be the basis of most of Python's concurrency handling. It seems to me that the GIL would prevent Python from being able to achieve true concurrency even on a multi-processor machine. Is this true? Does this scenario change if I use a compiler to compile Python to native code? Am I just barking up the wrong tree entirely and is Python the wrong tool for this job?","AnswerCount":3,"Available Count":2,"Score":0.1973753202,"is_accepted":false,"ViewCount":1336,"Q_Id":3458249,"Users Score":3,"Answer":"The Global Interpreter Lock prevents threads simultaneously executing Python code. This doesn't change when Python is compiled to bytecode, because the bytecode is still run by the Python interpreter, which will enforce the GIL. threading works by switching threads every sys.getcheckinterval() bytecodes.\nThis doesn't apply to multiprocessing, because it creates multiple Python processes instead of threads. You can have as many of those as your system will support, running truly concurrently.\nSo yes, you can do this with Python, either with threading or multiprocessing.","Q_Score":3,"Tags":"python","A_Id":3458598,"CreationDate":"2010-08-11T12:36:00.000","Title":"Concurrency Testing For A Web Service 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},{"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},{"Question":"I would like to write a code internal to my method that print which method\/class has invoked it.\n(My assumption is that I can't change anything but my method..)\nHow about other programming languages? \nEDIT: Thanks guys, how about JavaScript? python? C++?","AnswerCount":8,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":754,"Q_Id":3468101,"Users Score":0,"Answer":"In Python, you should use the traceback or inspect modules. These will modules will shield you from the implementation details of the interpreter, which can differ even today (e.g. IronPython, Jython) and may change even more in the future. The way these modules do it under the standard Python interpreter today, however, is with sys._getframe(). In particular, sys._getframe(1).f_code.co_name provides the information you want.","Q_Score":12,"Tags":"java,javascript,python,programming-languages,classloader","A_Id":3469617,"CreationDate":"2010-08-12T13:25:00.000","Title":"Java or any other language: Which method\/class invoked mine?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'd like to compare the performance of different languages and\/or different frameworks within the same language. This is aimed at server-side languages used for web development. I know an apples to apples comparison is not possible, but I'd like it to be as unbiased as possible. Here are some ideas :\n\nSimple \"Hello World\" page\nObject initialization\nFunction\/method calls\n\n\nMethod bodies will range from empty to large\n\nFile access (read and write)\nDatabase access\n\nThey can either be measured by Requests per second or I can use a for loop and loop many times. Some of these benchmarks should measure the overhead the language has (ie: empty function call) rather than how fast they perform a certain task. I'll take some precautions:\n\nThey'll run on the same machine, on fresh installations with as few processes on the background as possible.\nI'll try and set up the server as officially recommended; I will not attempt any optimizations.\n\nHow can I improve on this?","AnswerCount":4,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":463,"Q_Id":3468227,"Users Score":2,"Answer":"What I have done is to write many unit tests so you can test the layers.\nFor example, write a SOAP web service in PHP, Python and C#.  \nWrite a REST web service in the same languages (same web services, just two ways to get to them). This one should be able to return JSON and XML as a minimum.\nWrite unit tests in C# and Python to serve as clients, and test the REST with the various result types (XML\/JSON).  This is important as later you may need to test to see which is best end-to-end, and JSON may be faster to parse than XML, for you (it should be).\nSo, the REST\/SOAP services should go to the same controller, to simplify your life.\nThis controller needs tests, as you may need to later remove it's impact on your tests, but, you can also write tests to see how fast it goes to the database.\nI would use one database for this, unless you want to evaluate various databases, but for a web test, just do that for phase 2. :)\nSo, what you end up with is lots of tests, each test needs to be able to determine how long it took for it to actually run.\nYou then have lots of numbers, and you can start to analyze to see what works best for you.\nFor example, I had learned (a couple of years ago when I did this) that JSON was faster than XML, REST was faster than SOAP.\nYou may find that some things are much harder to do in some languages and so drop them from contention as you go through this process.\nWriting the tests is the easy part, getting meaningful answers from the numbers will be the harder part, as your biases may color your analysis, so be careful of that.\nI would do this with some real application so that the work isn't wasted, just duplicated.","Q_Score":1,"Tags":"php,asp.net,python,frameworks,benchmarking","A_Id":3468630,"CreationDate":"2010-08-12T13:37:00.000","Title":"How can I benchmark different languages \/ frameworks?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I'd like to compare the performance of different languages and\/or different frameworks within the same language. This is aimed at server-side languages used for web development. I know an apples to apples comparison is not possible, but I'd like it to be as unbiased as possible. Here are some ideas :\n\nSimple \"Hello World\" page\nObject initialization\nFunction\/method calls\n\n\nMethod bodies will range from empty to large\n\nFile access (read and write)\nDatabase access\n\nThey can either be measured by Requests per second or I can use a for loop and loop many times. Some of these benchmarks should measure the overhead the language has (ie: empty function call) rather than how fast they perform a certain task. I'll take some precautions:\n\nThey'll run on the same machine, on fresh installations with as few processes on the background as possible.\nI'll try and set up the server as officially recommended; I will not attempt any optimizations.\n\nHow can I improve on this?","AnswerCount":4,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":463,"Q_Id":3468227,"Users Score":0,"Answer":"You will spend a lot of time and come to realization that it was all wasted.\nAfter you complete your tests you will learn that loops of 1000000 empty iterations are far from the real life and come to apache benchmark.\nThen you come no know of opcode cachers which will ruin all your previous results.\nThen you will learn that single DB query will take 1000 times longer time than API call, so, your comparisons of database access methods are really waste.\nThen you will learn of memcache which will allow you just jump over some terrible bottlenecks you've discovered already, etc etc etc","Q_Score":1,"Tags":"php,asp.net,python,frameworks,benchmarking","A_Id":3468464,"CreationDate":"2010-08-12T13:37:00.000","Title":"How can I benchmark different languages \/ frameworks?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I'm currently using PHP. I plan to start using Django for some of my next project.\nBut I don't have any experience with Python. After some searching, I still can't find a Python opcode cacher.\n(There are lots of opcode cacher for PHP: APC, eAccelerator, Xcache, ...)","AnswerCount":3,"Available Count":2,"Score":1.0,"is_accepted":false,"ViewCount":2395,"Q_Id":3468243,"Users Score":9,"Answer":"It's automatic in Python -- a compiled .pyc file will appear magically.","Q_Score":2,"Tags":"python,opcode,opcode-cache","A_Id":3468276,"CreationDate":"2010-08-12T13:40:00.000","Title":"Python doesn't have opcode cacher?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I'm currently using PHP. I plan to start using Django for some of my next project.\nBut I don't have any experience with Python. After some searching, I still can't find a Python opcode cacher.\n(There are lots of opcode cacher for PHP: APC, eAccelerator, Xcache, ...)","AnswerCount":3,"Available Count":2,"Score":0.1325487884,"is_accepted":false,"ViewCount":2395,"Q_Id":3468243,"Users Score":2,"Answer":"Python doesn't need one the same way PHP needs it. Python doesn't throw the bytecode away after execution, it keeps it around (as .pyc files).","Q_Score":2,"Tags":"python,opcode,opcode-cache","A_Id":3468296,"CreationDate":"2010-08-12T13:40:00.000","Title":"Python doesn't have opcode cacher?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"Hey all, I have a site that looks up info for the end user, is written in Python, and requires several urlopen commands. As a result it takes a bit for a page to load. I was wondering if there was a way to make it faster? Is there an easy Python way to cache or a way to make the urlopen scripts fun last? \nThe urlopens access the Amazon API to get prices, so the site needs to be somewhat up to date. The only option I can think of is to make a script to make a mySQL db and run it ever now and then, but that would be a nuisance.\nThanks!","AnswerCount":5,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":805,"Q_Id":3468248,"Users Score":0,"Answer":"How often do the price(s) change? If they're pretty constant (say once a day, or every hour or so), just go ahead and write a cron script (or equivalent) that retrieves the values and stores it in a database or text file or whatever it is you need.\nI don't know if you can check the timestamp data from the Amazon API - if they report that sort of thing.","Q_Score":3,"Tags":"python,sql,caching,urlopen","A_Id":3468315,"CreationDate":"2010-08-12T13:40:00.000","Title":"Caching options in Python or speeding up urlopen","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},{"Question":"I have a jpg image.\nI need to know \"overall average\" the color of the image. At first glance there can use the histogram of the image (channel RGB).\nAt work I use mostly JavaScript and PHP (a little Python) therefore welcomed the decision in these languages. Maybe ther are library for working with images that address similar problems.\nI do not need to dynamically determine the color of the picture. I need just once go through the entire array of images and determine the color of each separately (this information I will remember for future use).","AnswerCount":7,"Available Count":1,"Score":0.0285636566,"is_accepted":false,"ViewCount":37896,"Q_Id":3468500,"Users Score":1,"Answer":"A shorter solution for true color image would be to scale it down to 1x1 pixel size and sample the color at that pixel:\n$scaled = imagescale($img, 1, 1, IMG_BICUBIC);\n$meanColor = imagecolorat($img, 0, 0);\n...but I haven't tested this myself.","Q_Score":49,"Tags":"php,javascript,python,image-processing","A_Id":17615110,"CreationDate":"2010-08-12T14:02:00.000","Title":"Detect \"overall average\" color of the picture","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I want to save the MessageID of a sent email, so I can later use it in a References: header to facilitate threading.\nI see in root\/django\/trunk\/django\/core\/mail.py (line ~55) where the MessageID is created.\nI'm trying to think of the best way to collect this value, other than just copy\/pasting into a new backend module and returning it. Maybe that is the best way?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":2548,"Q_Id":3470989,"Users Score":12,"Answer":"Ok, I see I was browsing tragically old code. I should be able to call django.core.mail.message.make_msgid() and populate the header myself before calling send.","Q_Score":7,"Tags":"python,django,email-headers","A_Id":3471052,"CreationDate":"2010-08-12T18:54:00.000","Title":"What's the easiest\/cleanest way to get the MessageID of a sent 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":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Is anyone aware of a pure python implementation of BLAST alignment?  I am trying to study this algorithm...","AnswerCount":2,"Available Count":1,"Score":0.2913126125,"is_accepted":false,"ViewCount":3698,"Q_Id":3479569,"Users Score":3,"Answer":"In fact a complete implementation of the BLAST algorithm is a quite hard. It has a lot of steps and optimizations. What could you do is: take a look of the BLAST Book from O'Reilly, for a very good explanation, take a look of the NCBI Blast code base, that it is big and hard to understand at the first glace, or, I sugest you to take a look at other BLAST implementation or may be, others algorithms like BLAT and Genoogle (http:\/\/genoogle.pih.bio.br\/)","Q_Score":7,"Tags":"python,alignment,blast","A_Id":5816012,"CreationDate":"2010-08-13T18:09:00.000","Title":"Python implementation of BLAST alignment algorithm?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I am using Komodo edit on a Python file on Windows.\nWhen I type import s it successfully lists all the importable files starting with s, including one of my modules in one of my directories.\nWhen I type import t it lists all the importable files starting with t, EXCLUDING one of my modules in the same directory.\nEven though Komodo can't find it, the Python interpreter finds and runs both files fine. It is purely a problem with Komodo's Code Intelligence.\nThe name of the missing module is 9 lower-case letters (nothing fancy). It doesn't clash with any other modules. It is in the same directory as the module that can be found.\nAny suggestions about why one module is found and another isn't?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1865,"Q_Id":3481949,"Users Score":2,"Answer":"Problem solved itself when I closed Komodo, saving the project, and reopened it.\nSounds like Komodo's internal representation was out-of-date or corrupted.\nI'll leave the question here for the next person who stumbles over it.","Q_Score":2,"Tags":"python,komodo,komodoedit","A_Id":3482353,"CreationDate":"2010-08-14T04:01:00.000","Title":"Komodo Edit auto-complete won't find a 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},{"Question":"I'm new to Python, with a background in statically typed languages including lots and lots of Java.\nI decided on PyDev in eclipse as an IDE after checking features\/popularity etc.\nI was stunned that auto-complete doesn't seem to work properly for builtins. For example if I try automcomplete on datafile after:\ndatafile = open(directory+\"\/\"+account, 'r')\ndatafile.\nNo useful methods are suggested (e.g. realines). Only things like call.\nI am used to learning a language by jumping into class definitions and using lots of auto-complete to quickly view what a class will do. My PyDev 'interpreter' is set up fine with 'forced builtins'.\nIs it possible to get auto-complete for builtins with PyDev? Am I approaching the IDE wrong, i.e. should have an interpreter running on the side and test stuff with it? So far the IDEs have seemed weak, e.g. IDLE segfaulted on my new mac after 2 minutes. I'd love to know what experienced Python developers do when exploring unfamiliar (builtin) modules, as this is making me reconsider my initial attraction to Python. I like a language you can learn by easy exploration!\nThanks,","AnswerCount":7,"Available Count":1,"Score":0.1418931938,"is_accepted":false,"ViewCount":3018,"Q_Id":3482622,"Users Score":5,"Answer":"Just to keep it up to date so that new readers are not confused about the current state of Pydev - the example you gave now works in Pydev. (btw, one should avoid operating on paths manualy - use os.path.join instead)","Q_Score":5,"Tags":"python,ide,autocomplete,duck-typing,built-in","A_Id":9430038,"CreationDate":"2010-08-14T08:38:00.000","Title":"Autocompletion in dynamic language IDEs, specifically Python in 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},{"Question":"Would you recommend Iron Ruby, Iron Python, or PowerShell for making a C# application a script host?\nAfter some quick tinkering, right now I'm leaning towards powershell for two main reasons (note these a purely my opinions and if they are wrong, I'd love to know!!!):\n1) It's simple to create a runspace with classes in your application; therefor it's easy to make your application scriptable. \n2) I've heard some rumors that IronRuby and IronPython are losing support from Microsoft, so they may be a poor long term solution?\nAs this is my first time adding scripting to an application though, I'd welcome all the advice I can get from people who have been down this road before.\nSpecifically, besides letting me know whether you agree with my two points above, I'd like to know if IronRuby and IronPython are much easier to use (for a user, not developer) than powershell, and if in your experience using the DLR is as easy as just passing an object to a powershell runspace? And if I added support for the DLR and IR\/IP scripting would my application still be backwards compatible with XP?","AnswerCount":3,"Available Count":3,"Score":1.0,"is_accepted":false,"ViewCount":3780,"Q_Id":3484232,"Users Score":7,"Answer":"number 2 is true (the dynamic lang teams have been losing headcount for awhile now) and an excellent reason.  Ruby and Python aren't MS languages, and as such Iron * is just 'get it working on .NET'.  PowerShell is a Microsoft creation, Microsoft-controlled, and Microsoft-supported.\nMore importantly, multiple Microsoft products have taken deep dependencies on PowerShell (Exchange, SharePoint, etc.) so there's very little question of PowerShell's ongoing support as a language.\nLast, PowerShell considers being the scripting lang for other applications as one of its first-class support targets.","Q_Score":12,"Tags":"c#,powershell,ironpython,ironruby,dynamic-language-runtime","A_Id":3484368,"CreationDate":"2010-08-14T16:47:00.000","Title":"Would you recommend Iron Ruby, Iron Python, or PowerShell for making a C# application a script host?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"Would you recommend Iron Ruby, Iron Python, or PowerShell for making a C# application a script host?\nAfter some quick tinkering, right now I'm leaning towards powershell for two main reasons (note these a purely my opinions and if they are wrong, I'd love to know!!!):\n1) It's simple to create a runspace with classes in your application; therefor it's easy to make your application scriptable. \n2) I've heard some rumors that IronRuby and IronPython are losing support from Microsoft, so they may be a poor long term solution?\nAs this is my first time adding scripting to an application though, I'd welcome all the advice I can get from people who have been down this road before.\nSpecifically, besides letting me know whether you agree with my two points above, I'd like to know if IronRuby and IronPython are much easier to use (for a user, not developer) than powershell, and if in your experience using the DLR is as easy as just passing an object to a powershell runspace? And if I added support for the DLR and IR\/IP scripting would my application still be backwards compatible with XP?","AnswerCount":3,"Available Count":3,"Score":1.0,"is_accepted":false,"ViewCount":3780,"Q_Id":3484232,"Users Score":12,"Answer":"I'm not convinced PowerShell has \"being a scripting language for applications\" anywhere in it's long-term goals. It's first a shell, second an integration & automation engine, and third a shell scripting language ... since it's not redistributable at all, I'm not sure where embedded scripting fits in.  \nIt's certainly very easy to host PowerShell -- assuming that it's pre-installed on your target PCs-- so it's a very viable option, but I think that in general it's just as easy to do it with IronRuby or IronPython.\nI doubt the DLR itself is going away, so I think using a DLR language is still a good choice for this: you'd be set up to accept other DLR languages with much less effort, and the DLR and languages are redistributable.\nAlso, the work to host PowerShell only gets you PowerShell -- whereas you can leverage the same work to get IronPython and IronRuby working. Who knows, since PowerShell is a dynamic language, maybe it will be ported to the DLR with proper dynamics support in a future version ... but it's unlikely to ever be redistributable, because Microsoft doesn't consider it a dev tool, but rather a core part of the OS.\nBottom line: using the DLR is much more portable -- and not just to XP but even to Mono (and thus to Linux, OS X, iOS, Android, etc... and even to the web or Windows Phone via Silverlight).","Q_Score":12,"Tags":"c#,powershell,ironpython,ironruby,dynamic-language-runtime","A_Id":3496609,"CreationDate":"2010-08-14T16:47:00.000","Title":"Would you recommend Iron Ruby, Iron Python, or PowerShell for making a C# application a script host?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"Would you recommend Iron Ruby, Iron Python, or PowerShell for making a C# application a script host?\nAfter some quick tinkering, right now I'm leaning towards powershell for two main reasons (note these a purely my opinions and if they are wrong, I'd love to know!!!):\n1) It's simple to create a runspace with classes in your application; therefor it's easy to make your application scriptable. \n2) I've heard some rumors that IronRuby and IronPython are losing support from Microsoft, so they may be a poor long term solution?\nAs this is my first time adding scripting to an application though, I'd welcome all the advice I can get from people who have been down this road before.\nSpecifically, besides letting me know whether you agree with my two points above, I'd like to know if IronRuby and IronPython are much easier to use (for a user, not developer) than powershell, and if in your experience using the DLR is as easy as just passing an object to a powershell runspace? And if I added support for the DLR and IR\/IP scripting would my application still be backwards compatible with XP?","AnswerCount":3,"Available Count":3,"Score":0.1325487884,"is_accepted":false,"ViewCount":3780,"Q_Id":3484232,"Users Score":2,"Answer":"I'm in a similar position.  I decided to use IronPython scripting but ever since I saw Anders Hejlsberg's talk \"The Future of C#\", I've had a feeling IronPython was doomed. \nIt was in Microsoft's interest to get the DLR developed but they ultimately want us to use tools and languages they control.  After all, aren't you using C# and not Java?  So what will a Microsoft dynamic language look like?  How about dynamic, interpreted C# (Iron C#)?  Hejlsberg's talk made it clear it isn't that far away.  He even had a console window with a REPL interface.  That said, there's always a possibility for Iron VB.  Talk about closing the loop.\nOn the plus side for us programmers, Iron C# also solves another problem that I'm having trouble with -- the existence of two parallel object environments, one of .Net objects, one of Python objects.  It takes work to get from one to the other.  I assume an Iron C# would utilize the .Net class structure.\nMy advice: Stick with Iron Python and .Net classes.  When Iron VB or Iron C# happens, it'll be a quick, maybe automatic, language translation.  Besides, if enough of us use IronPython, Microsoft may change their mindset.","Q_Score":12,"Tags":"c#,powershell,ironpython,ironruby,dynamic-language-runtime","A_Id":3504982,"CreationDate":"2010-08-14T16:47:00.000","Title":"Would you recommend Iron Ruby, Iron Python, or PowerShell for making a C# application a script host?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"i'm new to python , and trying to write a script in order to send SMS's , \nafter quick googling i found this lib: libgmail, and successfully installed it ,\nthis is the code i use to send SMS:\n!\/usr\/bin\/env python\nimport libgmail\nga = libgmail.GmailAccount(\"username@gmail.com\", \"password\")\nmyCellEmail = \"phonenumber@message.carrier.end\"\nga.login()\nmsg=libgmail.GmailComposedMessage(myCellEmail, \"\", \"Hello World! From python-libgmail!\")\nga.sendMessage(msg)\ni get the following error when trying to run it:\nTraceback (most recent call last):\n  File \"C:\\Users\\Amit\\Desktop\\SMS\\sms.py\", line 14, in \n    ga.login()\n  File \"C:\\Python27\\lib\\site-packages\\libgmail.py\", line 305, in login\n    pageData = self._retrievePage(req)\n  File \"C:\\Python27\\lib\\site-packages\\libgmail.py\", line 340, in _retrievePage\n    req = ClientCookie.Request(urlOrRequest)\n  File \"build\\bdist.win32\\egg\\mechanize_request.py\", line 31, in init\n  File \"build\\bdist.win32\\egg\\mechanize_rfc3986.py\", line 62, in is_clean_uri\nTypeError: expected string or buffer\nif you have any ideas , please share ..\nthanks a lot \namitos80","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":571,"Q_Id":3487447,"Users Score":0,"Answer":"As far as I know libgmail is not compatible with the current Gmail interface. If I am not mistaken libgmail is not actively maintained either. You might want to look at alternative options.","Q_Score":1,"Tags":"python,scripting,sms,libgmail","A_Id":3487491,"CreationDate":"2010-08-15T12:59:00.000","Title":"cant send SMS vla libgmail - 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},{"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},{"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},{"Question":"With Ruby you can do gem install  from the command line to install a module...even if it is not on your machine.\nCan you do that with python.  Does someone know of a module?\nSeth","AnswerCount":2,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":1036,"Q_Id":3490543,"Users Score":4,"Answer":"no it does not have a ruby installer that I know of. It does have easy_install and pip though. Your google-fu is lacking.","Q_Score":3,"Tags":"python,rubygems","A_Id":3490551,"CreationDate":"2010-08-16T04:09:00.000","Title":"Does python have a ruby installer like gem that lets you install modules from the command line even if they are not on your machine?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I have about 200,000 text files that are placed in a bz2 file. The issue I have is that when I scan the bz2 file to extract the data I need, it goes extremely slow. It has to look through the entire bz2 file to fine the single file I am looking for. Is there anyway to speed this up?\nAlso, I thought about possibly organizing the files in the tar.bz2 so I can instead have it know where to look. Is there anyway to organize files that are put into a bz2?\nMore Info\/Edit:\nI need to query the compressed file for each textfile. Is there a better compression method that supports such a large number of files and is as thoroughly compressed?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":965,"Q_Id":3494020,"Users Score":0,"Answer":"Bzip2 compresses in large blocks (900 KiB by default, I believe). One method that would speed up the scanning of the tar file dramatically, but would reduce compression performance, would be to compress each file individually and then tar the results together. This is essentially what Zip-format files are (though using zlib compression rather than bzip2). But you could then easily grab the tar index and only have to decompress the specific file(s) you are looking for.\nI don't think most tar programs offer much ability to organize files in any meaningful way, though you could write a program to do this for your special case (I know Python has tar-writing libraries though I've only used them once or twice). However, you'd still have the problem of having to decompress most of the data before you found what you were looking for.","Q_Score":3,"Tags":"python,tar,bzip2,tarfile","A_Id":3494091,"CreationDate":"2010-08-16T14:22:00.000","Title":"Organizing files in tar bz2 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":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"We have a decent set of unit tests on our code and those unit tests run in under 2 minutes. We also use TeamCity to do a build and to run tests after each check in.  However, we still get issues where a developer \"forgets\" to run all the tests before a commit resulting in TeamCity failure which if this check in was done at 6PM may stay broken over night.  \n\"Forgets\" is a generic term, there a couple other common reasons why even remembering to run the tests could result in TeamCity failure. Such as. \n-> A developer only checks in some of the modified files in his\/her workspace.\n-> A file was modified outside of eclipse such that eclipse's team synchronize perspective does not detect it as dirty.\nHow do you deal with this in your organization? \nWe are thinking of introducing \"check in procedure\" for developers which will be an automated tool that will automatically run all unit tests and then commit all of the \"dirty\" files in your workspace.  Have you had any experience with such process?  Are you aware of any tools which may facilitate this process?   Our dev environment is Python using Eclipse's PyDev plugin.","AnswerCount":5,"Available Count":2,"Score":0.1586485043,"is_accepted":false,"ViewCount":2165,"Q_Id":3494585,"Users Score":4,"Answer":"I think it is more of a social problem rather than a deficiency of the automated systems. \nYes, you can improve the systems in place, but they will be no match for someone thinking of the implications of their commit, and testing it before they hit commit.","Q_Score":6,"Tags":"python,unit-testing,build-automation,teamcity","A_Id":3494671,"CreationDate":"2010-08-16T15:22:00.000","Title":"Remembering to run tests before commit","Data Science and Machine Learning":0,"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},{"Question":"We have a decent set of unit tests on our code and those unit tests run in under 2 minutes. We also use TeamCity to do a build and to run tests after each check in.  However, we still get issues where a developer \"forgets\" to run all the tests before a commit resulting in TeamCity failure which if this check in was done at 6PM may stay broken over night.  \n\"Forgets\" is a generic term, there a couple other common reasons why even remembering to run the tests could result in TeamCity failure. Such as. \n-> A developer only checks in some of the modified files in his\/her workspace.\n-> A file was modified outside of eclipse such that eclipse's team synchronize perspective does not detect it as dirty.\nHow do you deal with this in your organization? \nWe are thinking of introducing \"check in procedure\" for developers which will be an automated tool that will automatically run all unit tests and then commit all of the \"dirty\" files in your workspace.  Have you had any experience with such process?  Are you aware of any tools which may facilitate this process?   Our dev environment is Python using Eclipse's PyDev plugin.","AnswerCount":5,"Available Count":2,"Score":1.0,"is_accepted":false,"ViewCount":2165,"Q_Id":3494585,"Users Score":7,"Answer":"In one of the teams I was working before we had an agreement that anyone who breaks the tests buys bacon sandwiches for the whole team the next morning. Its extreme, but it works perfectly!","Q_Score":6,"Tags":"python,unit-testing,build-automation,teamcity","A_Id":3494863,"CreationDate":"2010-08-16T15:22:00.000","Title":"Remembering to run tests before commit","Data Science and Machine Learning":0,"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},{"Question":"I am using Emacs 23.1.1 on GNU\/Linux with autocomplete.el 1.3 and Ropemacs 0.6.\nIn Lisp programming, autocomplete.el shows the documentation (known as 'QuickHelp' in autocomplete.el) of the suggested completions. Python completion with ropemacs works, but does not show quick help for the Python completion. Is it possible to enable it and did somebody make it work?","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":607,"Q_Id":3506105,"Users Score":3,"Answer":"Ropemacs does the job : Use the function rope-show-doc over the symbol or use the keybinding C-c d. Simple :)","Q_Score":7,"Tags":"python,emacs","A_Id":6899728,"CreationDate":"2010-08-17T19:20:00.000","Title":"Quickhelp for Python in Emacs autocomplete.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":0,"Web Development":0},{"Question":"I am using Emacs 23.1.1 on GNU\/Linux with autocomplete.el 1.3 and Ropemacs 0.6.\nIn Lisp programming, autocomplete.el shows the documentation (known as 'QuickHelp' in autocomplete.el) of the suggested completions. Python completion with ropemacs works, but does not show quick help for the Python completion. Is it possible to enable it and did somebody make it work?","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":607,"Q_Id":3506105,"Users Score":1,"Answer":"I stopped using all the autocomplete stuff in all my developing environments. They rarely do what I want. Either the lists is too long, or too short, or not sorted well. Therefore I use dabbrev-expand in all my modes global-set-key to tab.\nThis works even quote well for text. Usually it is enough to get a good expansion from the local buffer where you are in. If I start typing in an empty buffer I open a second one which expand can use to look up its suggestions. This is not language sensitive, not does depend on the object you want to call a method of, but its still a big boost, and you get used to it. Maybe its not, you don't get \"quick help\" this way.","Q_Score":7,"Tags":"python,emacs","A_Id":6889131,"CreationDate":"2010-08-17T19:20:00.000","Title":"Quickhelp for Python in Emacs autocomplete.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":0,"Web Development":0},{"Question":"I may be posting a premature question, and maybe I'm just freaking out for no reason, but the way Oracle is handling Java is not very promising. I am a nerd who fell in love with Java from the first sight, and use it all the time in my personal\/freelance projects but now I am thinking of a replacement.\nI am fluent in C#\/VB.NET too but I am looking for something more like:\n\nOpen Source\nCompiled\nCross-Platform\nObject Oriented\nLarge standard library\nExtensive documentation\nWeb development is a major plus\n\nI was thinking about a compromise: Python\/Django for web development (or PHP), and Qt for thick client development. Anyone with better thoughts?","AnswerCount":10,"Available Count":3,"Score":1.0,"is_accepted":false,"ViewCount":3718,"Q_Id":3506252,"Users Score":6,"Answer":"Might be worth loking at the other JVM languages - Clojure and Scala are the two I personally think are most promising.\nYes you are on the JVM, but you're pretty independent from Java the langauage and don't have to use any Sun\/Oracle implementations if you don't want to.\nHaving said that - I think that you are worrying a little too much about Java, too many players (including Oracle!) have too much invested to let it go too far off course.","Q_Score":3,"Tags":"java,python,qt,programming-languages,replace","A_Id":3506325,"CreationDate":"2010-08-17T19:35:00.000","Title":"What languages would be a good replacement for 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":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I may be posting a premature question, and maybe I'm just freaking out for no reason, but the way Oracle is handling Java is not very promising. I am a nerd who fell in love with Java from the first sight, and use it all the time in my personal\/freelance projects but now I am thinking of a replacement.\nI am fluent in C#\/VB.NET too but I am looking for something more like:\n\nOpen Source\nCompiled\nCross-Platform\nObject Oriented\nLarge standard library\nExtensive documentation\nWeb development is a major plus\n\nI was thinking about a compromise: Python\/Django for web development (or PHP), and Qt for thick client development. Anyone with better thoughts?","AnswerCount":10,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":3718,"Q_Id":3506252,"Users Score":0,"Answer":"C# is the only thing that will meet your needs and not feel hopelessly archaic, or frustrate with limited library. For open source\/non-windows, use mono. It's a good, mature implementation of most of what's important in the CLR. \nSome things (WPF, WCF, etc) are \"missing\" from mono, but these aren't so much part of the platform as they are windows-specific proprietary toolkits. Some of them are being implemented slowly in mono, some aren't. Coming from java you won't miss them because you're looking for a platform and good standard libraries to build upon, not a gui toolkit or whiz-bang communication framework.\nAs far as a platform to build stuff with that's \"like\" java and offers similar levels of functionality, C# + CLR is the clearest option.","Q_Score":3,"Tags":"java,python,qt,programming-languages,replace","A_Id":3509044,"CreationDate":"2010-08-17T19:35:00.000","Title":"What languages would be a good replacement for 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":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I may be posting a premature question, and maybe I'm just freaking out for no reason, but the way Oracle is handling Java is not very promising. I am a nerd who fell in love with Java from the first sight, and use it all the time in my personal\/freelance projects but now I am thinking of a replacement.\nI am fluent in C#\/VB.NET too but I am looking for something more like:\n\nOpen Source\nCompiled\nCross-Platform\nObject Oriented\nLarge standard library\nExtensive documentation\nWeb development is a major plus\n\nI was thinking about a compromise: Python\/Django for web development (or PHP), and Qt for thick client development. Anyone with better thoughts?","AnswerCount":10,"Available Count":3,"Score":0.0199973338,"is_accepted":false,"ViewCount":3718,"Q_Id":3506252,"Users Score":1,"Answer":"I too would like another Java-like technology to come along.  Lately I've been doing Flex\/Actionscript.  While I really enjoy it, Actionscript technology seriously lacks the elegance that Java has.  Adobe can write some good cross platform APIs, but they just don't have the head capital to build elegant languages and compilers.  I've also tried Ruby, but the VM for Ruby is really bad.  I've gone back to Java after my flirtation with other technologies and I think it's because the language is good enough, but the JVM is by far the best out there.\nSo do you want to stay with the JVM or do you really want to the leave the JVM altogether?  Staying on the JVM there are lots of options: JRuby, Scala, Groovy, Javascript, Clojure are the big players.  However, there are tons of great languages that can take advantage of the JVM's features.\nLeaving the JVM there are still good options like python, ruby, and erlang.  But you give up some of the nice features of the JVM like performance (big one), and the ability to drop down to a nice language like Java if you need speed.  Those others mean using C or nothing at all.\nI finally stopped worrying about Java's future.  Sun did all it could to screw it up and it still turned out pretty darn good.  I think Opensource has a lot more influence over Java's success than Oracle or Sun could ever have had.","Q_Score":3,"Tags":"java,python,qt,programming-languages,replace","A_Id":3506402,"CreationDate":"2010-08-17T19:35:00.000","Title":"What languages would be a good replacement for 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":0,"System Administration and DevOps":0,"Web Development":1},{"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},{"Question":"How can I know if the user is connected to the local machine via ssh in my python script?","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":416,"Q_Id":3507980,"Users Score":0,"Answer":"Am I correct in assuming you're running your script on some sort of UNIX\/Linux system?  If so, you can just type \"users\" on the command-line, and it will show you the currently logged in users.\nAlso, if you call the \"lastlog\" command, that will show you all the users on the system and the last time they all logged in to the machine.","Q_Score":1,"Tags":"python,ssh","A_Id":3508010,"CreationDate":"2010-08-18T00:13:00.000","Title":"How can I know if the user is connected to the local machine via ssh in my 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},{"Question":"How can I know if the user is connected to the local machine via ssh in my python script?","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":416,"Q_Id":3507980,"Users Score":0,"Answer":"Check any of the SSH variables SSH_CONNECTION, SSH_CLIENT, or SSH_TTY.  However, these can be unset by the user.  \nCheck the output of who am i.  It will end with the remote system identification in brackets if you are connected remotely.  Make sure to handle x-term sessions which will have a colon (:) in the remote system id.","Q_Score":1,"Tags":"python,ssh","A_Id":3508136,"CreationDate":"2010-08-18T00:13:00.000","Title":"How can I know if the user is connected to the local machine via ssh in my 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},{"Question":"I'm not sure if it's because sys.stderr.write is faster.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":72,"Q_Id":3510747,"Users Score":6,"Answer":"imaplib is much older (it was in Python1.5.2) than the logging module (Python2.3), so perhaps noone has needed to update it to use logging yet","Q_Score":1,"Tags":"python,logging","A_Id":3510824,"CreationDate":"2010-08-18T09:41:00.000","Title":"Why does python libs (eg imaplib) does not use logging but use sys.stderr.write?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Are there any languages which feature static type checking like in C++ with modern syntax like in Python, and does not have GIL?\nI belive, Python 3 with ability to explicitly declare type of each variable would be 'almost there', but GIL makes me sad.\nJava is nice, but I need something more 'embedable' without bulky JRE.\nUpdate: Anything .NET-related or non-open source is a no-go.\nUpdate2: I need explicit+strong typing to write safer code in the expense of development speed. GIL is important as the code is going to be quite computing extensive and will run on multicore servers, so it has to effectively use multiple CPU.\nUpdate3: Target platform is Linux(Debian) on x86","AnswerCount":5,"Available Count":2,"Score":0.0798297691,"is_accepted":false,"ViewCount":887,"Q_Id":3511922,"Users Score":2,"Answer":"After reading your updated spec:\n\nI need explicit+strong typing to write safer code in the expense of development speed. GIL is important as the code is going to be quite computing extensive and will run on multicore servers, so it has to effectively use multiple CPU\n\nWhat exactly does \"computing extensive\" mean? What problem domain? What do others who work in this problem domain use? If you are serious with this specification, you can't do much other things than using C++ in connection with well-tested libraries for multithreading and numerical computing.\nmy $0.02\nrbo","Q_Score":4,"Tags":"java,python,gil","A_Id":3512342,"CreationDate":"2010-08-18T12:15:00.000","Title":"Looking for strong\/explicit-typed language without 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},{"Question":"Are there any languages which feature static type checking like in C++ with modern syntax like in Python, and does not have GIL?\nI belive, Python 3 with ability to explicitly declare type of each variable would be 'almost there', but GIL makes me sad.\nJava is nice, but I need something more 'embedable' without bulky JRE.\nUpdate: Anything .NET-related or non-open source is a no-go.\nUpdate2: I need explicit+strong typing to write safer code in the expense of development speed. GIL is important as the code is going to be quite computing extensive and will run on multicore servers, so it has to effectively use multiple CPU.\nUpdate3: Target platform is Linux(Debian) on x86","AnswerCount":5,"Available Count":2,"Score":0.1586485043,"is_accepted":false,"ViewCount":887,"Q_Id":3511922,"Users Score":4,"Answer":"Anything in the ML family might work for you. Ocaml is a great place to start, but it does have a stop-the-world GC last I looked. Haskell is famous as a lab for innovative concurrency models. Python's comprehensions came from Haskell, where they'rr a convenient syntax for some very fundamental ideas.  And Erlang is strongly dynamcally typed, fun to write in, and does concurrency better than anybody else.","Q_Score":4,"Tags":"java,python,gil","A_Id":3512157,"CreationDate":"2010-08-18T12:15:00.000","Title":"Looking for strong\/explicit-typed language without 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},{"Question":"I want to run a cpu intensive program in Python across multiple cores and am trying to figure out how to write C extensions to do this.  Are there any code samples or tutorials on this?","AnswerCount":5,"Available Count":1,"Score":-0.0798297691,"is_accepted":false,"ViewCount":6155,"Q_Id":3514495,"Users Score":-2,"Answer":"multiprocessing is easy. if thats not fast enough, your question is complicated.","Q_Score":12,"Tags":"python,python-c-extension","A_Id":3514728,"CreationDate":"2010-08-18T16:46:00.000","Title":"How to use C extensions in python to get around 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},{"Question":"So I have a C program to interface with an i2c device. I need to interface to that device from python. I'm just wondering if it's worth porting the program into a python module or if the amount of effort involved in porting won't outweigh just executing the program using subprocess. I know I'm sure it's different for every application, but I'd like to know if it's even worth my time to learn the python C extensions and port this program.\nUpdate: I have full access to the source of both the C as well as the python. But there is already substantial work done on the python side and I'd like to keep changes to that as minimal is possible, if that matters. And I'd also like to minimize the changes that have to be made to the C. It's doable, but I didn't write it and it involves a lot of by addressing that I'd rather not have to redo.","AnswerCount":5,"Available Count":3,"Score":0.0399786803,"is_accepted":false,"ViewCount":471,"Q_Id":3517011,"Users Score":1,"Answer":"Don't use the Python C API, there are much easier alternatives, most notably cython.  \ncython is a Python-like language, which compiles into C code for the Python c library.  Basically it's C with Python syntax and features (e.g. nice for loops, exceptions, etc.).  cython is clearly the most recommendable way to write C extensions for python.\nYou might also want to take a look at ctypes, a module to dynamically load C libraries and call functions from them.  If your i2c-code is available as shared library, you can get away with no native binding at all, which eases development and distribution.","Q_Score":1,"Tags":"python,c,python-module,i2c","A_Id":3517141,"CreationDate":"2010-08-18T21:49:00.000","Title":"Extending python with C 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},{"Question":"So I have a C program to interface with an i2c device. I need to interface to that device from python. I'm just wondering if it's worth porting the program into a python module or if the amount of effort involved in porting won't outweigh just executing the program using subprocess. I know I'm sure it's different for every application, but I'd like to know if it's even worth my time to learn the python C extensions and port this program.\nUpdate: I have full access to the source of both the C as well as the python. But there is already substantial work done on the python side and I'd like to keep changes to that as minimal is possible, if that matters. And I'd also like to minimize the changes that have to be made to the C. It's doable, but I didn't write it and it involves a lot of by addressing that I'd rather not have to redo.","AnswerCount":5,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":471,"Q_Id":3517011,"Users Score":0,"Answer":"I've had good luck using ctypes. Whatever you choose, though, you may not gain any time this time but the next time around your effort will be much faster than doing the whole thing in C.","Q_Score":1,"Tags":"python,c,python-module,i2c","A_Id":3517152,"CreationDate":"2010-08-18T21:49:00.000","Title":"Extending python with C 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},{"Question":"So I have a C program to interface with an i2c device. I need to interface to that device from python. I'm just wondering if it's worth porting the program into a python module or if the amount of effort involved in porting won't outweigh just executing the program using subprocess. I know I'm sure it's different for every application, but I'd like to know if it's even worth my time to learn the python C extensions and port this program.\nUpdate: I have full access to the source of both the C as well as the python. But there is already substantial work done on the python side and I'd like to keep changes to that as minimal is possible, if that matters. And I'd also like to minimize the changes that have to be made to the C. It's doable, but I didn't write it and it involves a lot of by addressing that I'd rather not have to redo.","AnswerCount":5,"Available Count":3,"Score":0.0798297691,"is_accepted":false,"ViewCount":471,"Q_Id":3517011,"Users Score":2,"Answer":"One of the first Python programs I wrote was a script that called functions from a C library, which sounds close to what you're doing. I used ctypes, and I was impressed as to how easy it was: I could access each library function from python by writing just a few lines of python (no C at all!). I'd tried the Python C API before, and it required a lot more boilerplate. I havent tried SWIG or Cython.","Q_Score":1,"Tags":"python,c,python-module,i2c","A_Id":3517190,"CreationDate":"2010-08-18T21:49:00.000","Title":"Extending python with C 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},{"Question":"I'd like to be able to enter an interactive session, preferably with IPython, if a unit test fails.  Is there an easy way to do this?\nedit: by \"interactive session\" I mean a full Python REPL rather than a pdb shell.\nedit edit: As a further explanation: I'd like to be able to start an interactive session that has access to the context in which the test failure occurred.  So for example, the test's self variable would be available.","AnswerCount":3,"Available Count":1,"Score":-0.1325487884,"is_accepted":false,"ViewCount":1014,"Q_Id":3517410,"Users Score":-2,"Answer":"Are you really sure you want to do this?  Your unit tests should do one thing, should be well-named, and should clearly print what failed.  If you do all of that, the failure message will pinpoint what went wrong; no need to go look at it interactively.  In fact, one of the big advantages of TDD is that it helps you avoid having to go into the debugger at all to diagnose problems.","Q_Score":3,"Tags":"python,unit-testing,interactive,ipython","A_Id":3517604,"CreationDate":"2010-08-18T22:58:00.000","Title":"drop into an interactive session to examine a failed unit test","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've develop webmail client for any mail server.\nI want to implement message conversion for it \u2014 for example same emails fwd\/reply\/reply2all should be shown together like gmail does... \nMy question is: what's the key to find those emails which are either reply\/fwd or related to the original mail....","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":1161,"Q_Id":3530851,"Users Score":3,"Answer":"The In-Reply-To header of the child should have the value of the Message-Id header of the parent(s).","Q_Score":0,"Tags":"python,imap,pop3,imaplib,poplib","A_Id":3566252,"CreationDate":"2010-08-20T12:34:00.000","Title":"How to maintain mail conversion (reply \/ forward \/ reply to all like gmail) of email using Python pop\/imap lib?","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},{"Question":"I've develop webmail client for any mail server.\nI want to implement message conversion for it \u2014 for example same emails fwd\/reply\/reply2all should be shown together like gmail does... \nMy question is: what's the key to find those emails which are either reply\/fwd or related to the original mail....","AnswerCount":2,"Available Count":2,"Score":0.1973753202,"is_accepted":false,"ViewCount":1161,"Q_Id":3530851,"Users Score":2,"Answer":"Google just seems to chain messages based on the subject line (so does Apple Mail by the way.)","Q_Score":0,"Tags":"python,imap,pop3,imaplib,poplib","A_Id":3530868,"CreationDate":"2010-08-20T12:34:00.000","Title":"How to maintain mail conversion (reply \/ forward \/ reply to all like gmail) of email using Python pop\/imap lib?","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},{"Question":"Working on different projects I have the choice of selecting different programming languages, as long as the task is done.\nI was wondering what the real difference is, in terms of performance, between writing a program in Python, versus doing it in C.\nThe tasks to be done are pretty varied, e.g. sorting textfiles, disk access, network access, textfile parsing.\nIs there really a noticeable difference between sorting a textfile using the same algorithm in C versus Python, for example?\nAnd in your experience, given the power of current CPU's (i7), is it really a noticeable difference (Consider that its a program that doesnt bring the system to its knees).","AnswerCount":14,"Available Count":11,"Score":1.0,"is_accepted":false,"ViewCount":14463,"Q_Id":3533759,"Users Score":7,"Answer":"Is there really a noticeable difference between sorting a textfile using the same algorithm in C versus Python, for example?\n\nYes.\nThe noticeable differences are these\n\nThere's much less Python code.  \nThe Python code is much easier to read.\nPython supports really nice unit testing, so the Python code tends to be higher quality.\nYou can write the Python code more quickly, since there are fewer quirky language features.  No preprocessor, for example, really saves a lot of hacking around.  Super-experience C programmers hardly notice it.  But all that #include sandwich stuff and making the .h files correct is remarkably time-consuming.\nPython can be easier to package and deploy, since you don't need a big fancy make script to do a build.","Q_Score":13,"Tags":"python,c,performance","A_Id":3533838,"CreationDate":"2010-08-20T18:27:00.000","Title":"Performance differences between Python and 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":1,"Web Development":0},{"Question":"Working on different projects I have the choice of selecting different programming languages, as long as the task is done.\nI was wondering what the real difference is, in terms of performance, between writing a program in Python, versus doing it in C.\nThe tasks to be done are pretty varied, e.g. sorting textfiles, disk access, network access, textfile parsing.\nIs there really a noticeable difference between sorting a textfile using the same algorithm in C versus Python, for example?\nAnd in your experience, given the power of current CPU's (i7), is it really a noticeable difference (Consider that its a program that doesnt bring the system to its knees).","AnswerCount":14,"Available Count":11,"Score":0.0,"is_accepted":false,"ViewCount":14463,"Q_Id":3533759,"Users Score":0,"Answer":"C is definitely faster than Python because Python is written in C.\nC is middle level language and hence faster but there not much a great difference between C & Python regarding executable time it takes.\nbut it is really very easy to write code in Python than C and it take much shorter time to write code and learn Python than C.\nBecause its easy to write its easy to test also.","Q_Score":13,"Tags":"python,c,performance","A_Id":15903255,"CreationDate":"2010-08-20T18:27:00.000","Title":"Performance differences between Python and 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":1,"Web Development":0},{"Question":"Working on different projects I have the choice of selecting different programming languages, as long as the task is done.\nI was wondering what the real difference is, in terms of performance, between writing a program in Python, versus doing it in C.\nThe tasks to be done are pretty varied, e.g. sorting textfiles, disk access, network access, textfile parsing.\nIs there really a noticeable difference between sorting a textfile using the same algorithm in C versus Python, for example?\nAnd in your experience, given the power of current CPU's (i7), is it really a noticeable difference (Consider that its a program that doesnt bring the system to its knees).","AnswerCount":14,"Available Count":11,"Score":-0.0142847425,"is_accepted":false,"ViewCount":14463,"Q_Id":3533759,"Users Score":-1,"Answer":"The excess time to write the code in C compared to Python will be exponentially greater than the difference between C and Python execution speed.","Q_Score":13,"Tags":"python,c,performance","A_Id":3539538,"CreationDate":"2010-08-20T18:27:00.000","Title":"Performance differences between Python and 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":1,"Web Development":0},{"Question":"Working on different projects I have the choice of selecting different programming languages, as long as the task is done.\nI was wondering what the real difference is, in terms of performance, between writing a program in Python, versus doing it in C.\nThe tasks to be done are pretty varied, e.g. sorting textfiles, disk access, network access, textfile parsing.\nIs there really a noticeable difference between sorting a textfile using the same algorithm in C versus Python, for example?\nAnd in your experience, given the power of current CPU's (i7), is it really a noticeable difference (Consider that its a program that doesnt bring the system to its knees).","AnswerCount":14,"Available Count":11,"Score":-0.0142847425,"is_accepted":false,"ViewCount":14463,"Q_Id":3533759,"Users Score":-1,"Answer":"You will find C is much slower. Your developers will have to keep track of memory allocation, and use libraries (such as glib) to handle simple things such as dictionaries, or lists, which python has built-in.\nMoreover, when an error occurs, your C program will typically just crash, which means you'll need to get the error to happen in a debugger. Python would give you a stack trace (typically).\nYour code will be bigger, which means it will contain more bugs. So not only will it take longer to write, it will take longer to debug, and will ship with more bugs. This means that customers will notice the bugs more often.\nSo your developers will spend longer fixing old bugs and thus new features will get done more slowly. \nIn the mean-time, your competitors will be using a sensible programming language and their products will be increasing in features and usability, rapidly yours will look bad. Your customers will leave and you'll go out of business.","Q_Score":13,"Tags":"python,c,performance","A_Id":3536830,"CreationDate":"2010-08-20T18:27:00.000","Title":"Performance differences between Python and 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":1,"Web Development":0},{"Question":"Working on different projects I have the choice of selecting different programming languages, as long as the task is done.\nI was wondering what the real difference is, in terms of performance, between writing a program in Python, versus doing it in C.\nThe tasks to be done are pretty varied, e.g. sorting textfiles, disk access, network access, textfile parsing.\nIs there really a noticeable difference between sorting a textfile using the same algorithm in C versus Python, for example?\nAnd in your experience, given the power of current CPU's (i7), is it really a noticeable difference (Consider that its a program that doesnt bring the system to its knees).","AnswerCount":14,"Available Count":11,"Score":0.0,"is_accepted":false,"ViewCount":14463,"Q_Id":3533759,"Users Score":0,"Answer":"Across all programs, it isn't really possible to say whether things will be quicker or slower on average in Python or C.\nFor the programs that I've implemented in both languages, using similar algorithms, I've seen no improvement (and sometimes a performance degradation) for string- and IO-heavy code, when reimplementing python code in C. The execution time is dominated by allocation and manipulation of strings (which functionality python implements very efficiently) and waiting for IO operations (which incurs the same overhead in either language), so the extra overhead of python makes very little difference.\nBut for programs that do even simple operations on image files, say (images being large enough for processing time to be noticeable compared to IO), C is enormously quicker. For this sort of task the bulk of the time running the python code is spent doing Python Stuff, and this dwarfs the time spent on the underlying operations (multiply, add, compare, etc.). When reimplemented as C, the bureaucracy goes away, the computer spends its time doing real honest work, and for that reason the thing runs much quicker.\nIt's not uncommon for the python code to run in (say) 5 seconds where the C code runs in (say) 0.05. So that's a 100x increase -- but in absolute terms, this is not so big a deal. It takes so much less longer to write python code than it does to write C code that your program would have to be run some huge number of times to turn a time profit. I often reimplement in C, for various reasons, but if you don't have this requirement then it's probably not worth bothering. You won't get that part of your life back, and next year computers will be quicker.","Q_Score":13,"Tags":"python,c,performance","A_Id":3534845,"CreationDate":"2010-08-20T18:27:00.000","Title":"Performance differences between Python and 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":1,"Web Development":0},{"Question":"Working on different projects I have the choice of selecting different programming languages, as long as the task is done.\nI was wondering what the real difference is, in terms of performance, between writing a program in Python, versus doing it in C.\nThe tasks to be done are pretty varied, e.g. sorting textfiles, disk access, network access, textfile parsing.\nIs there really a noticeable difference between sorting a textfile using the same algorithm in C versus Python, for example?\nAnd in your experience, given the power of current CPU's (i7), is it really a noticeable difference (Consider that its a program that doesnt bring the system to its knees).","AnswerCount":14,"Available Count":11,"Score":0.0142847425,"is_accepted":false,"ViewCount":14463,"Q_Id":3533759,"Users Score":1,"Answer":"It really depends a lot on what your doing and if the algorithm in question is available in Python via a natively compiled library. If it is, then I believe you'll be looking at performance numbers close enough that Python is most likely your answer -- assuming it's your preferred language. If you must implement the algorithm yourself, depending on the amount of logic required and the size of your data set, C\/C++ may be the better option. It's hard to provide a less nebulous answer without more information.","Q_Score":13,"Tags":"python,c,performance","A_Id":3534210,"CreationDate":"2010-08-20T18:27:00.000","Title":"Performance differences between Python and 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":1,"Web Development":0},{"Question":"Working on different projects I have the choice of selecting different programming languages, as long as the task is done.\nI was wondering what the real difference is, in terms of performance, between writing a program in Python, versus doing it in C.\nThe tasks to be done are pretty varied, e.g. sorting textfiles, disk access, network access, textfile parsing.\nIs there really a noticeable difference between sorting a textfile using the same algorithm in C versus Python, for example?\nAnd in your experience, given the power of current CPU's (i7), is it really a noticeable difference (Consider that its a program that doesnt bring the system to its knees).","AnswerCount":14,"Available Count":11,"Score":0.057080742,"is_accepted":false,"ViewCount":14463,"Q_Id":3533759,"Users Score":4,"Answer":"If your text files that you are sorting and parsing are large, use C. If they aren't, it doesn't matter. You can write poor code in any language though. I have seen simple code in C for calculating areas of triangles run 10x slower than other C code, because of poor memory management, use of structures, pointers, etc. \nYour I\/O algorithm should be independent of your compute algorithm. If this is the case, then using C for the compute algorithm can be much faster.","Q_Score":13,"Tags":"python,c,performance","A_Id":3534052,"CreationDate":"2010-08-20T18:27:00.000","Title":"Performance differences between Python and 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":1,"Web Development":0},{"Question":"Working on different projects I have the choice of selecting different programming languages, as long as the task is done.\nI was wondering what the real difference is, in terms of performance, between writing a program in Python, versus doing it in C.\nThe tasks to be done are pretty varied, e.g. sorting textfiles, disk access, network access, textfile parsing.\nIs there really a noticeable difference between sorting a textfile using the same algorithm in C versus Python, for example?\nAnd in your experience, given the power of current CPU's (i7), is it really a noticeable difference (Consider that its a program that doesnt bring the system to its knees).","AnswerCount":14,"Available Count":11,"Score":0.057080742,"is_accepted":false,"ViewCount":14463,"Q_Id":3533759,"Users Score":4,"Answer":"The first rule of computer performance questions: Your mileage will vary.  If small performance differences are important to you, the only way you will get valid information is to test with your configuration, your data, and your benchmark.  \"Small\" here is, say, a factor of two or so.\nThe second rule of computer performance questions: For most applications, performance doesn't matter -- the easiest way to write the app gives adequate performance, even when the problem scales.  If that is the case (and it is usually the case) don't worry about performance.\nThat said:\n\nC compiles down to machine executable and thus has the potential to execute as at least as fast as any other language\nPython is generally interpreted and thus may take more CPU than a compiled language\nVery few applications are \"CPU bound.\"  I\/O (to disk, display, or memory) is not greatly affected by compiled vs interpreted considerations and frequently is a major part of computer time spent on an application\nPython works at a higher level of abstraction than C, so your development and debugging time may be shorter\n\nMy advice: Develop in the language you find the easiest with which to work.  Get your program working, then check for adequate performance.  If, as usual, performance is adequate, you're done.  If not, profile your specific app to find out what is taking longer than expected or tolerable.  See if and how you can fix that part of the app, and repeat as necessary.\nYes, sometimes you might need to abandon work and start over to get the performance you need.  But having a working (albeit slow) version of the app will be a big help in making progress.  When you do reach and conquer that performance goal you'll be answering performance questions in SO rather than asking them.","Q_Score":13,"Tags":"python,c,performance","A_Id":3533974,"CreationDate":"2010-08-20T18:27:00.000","Title":"Performance differences between Python and 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":1,"Web Development":0},{"Question":"Working on different projects I have the choice of selecting different programming languages, as long as the task is done.\nI was wondering what the real difference is, in terms of performance, between writing a program in Python, versus doing it in C.\nThe tasks to be done are pretty varied, e.g. sorting textfiles, disk access, network access, textfile parsing.\nIs there really a noticeable difference between sorting a textfile using the same algorithm in C versus Python, for example?\nAnd in your experience, given the power of current CPU's (i7), is it really a noticeable difference (Consider that its a program that doesnt bring the system to its knees).","AnswerCount":14,"Available Count":11,"Score":1.0,"is_accepted":false,"ViewCount":14463,"Q_Id":3533759,"Users Score":10,"Answer":"In general IO bound work will depend more on the algorithm then the language. In this case I would go with Python because it will have first class strings and lots of easy to use libraries for manipulating files, etc.","Q_Score":13,"Tags":"python,c,performance","A_Id":3533800,"CreationDate":"2010-08-20T18:27:00.000","Title":"Performance differences between Python and 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":1,"Web Development":0},{"Question":"Working on different projects I have the choice of selecting different programming languages, as long as the task is done.\nI was wondering what the real difference is, in terms of performance, between writing a program in Python, versus doing it in C.\nThe tasks to be done are pretty varied, e.g. sorting textfiles, disk access, network access, textfile parsing.\nIs there really a noticeable difference between sorting a textfile using the same algorithm in C versus Python, for example?\nAnd in your experience, given the power of current CPU's (i7), is it really a noticeable difference (Consider that its a program that doesnt bring the system to its knees).","AnswerCount":14,"Available Count":11,"Score":1.0,"is_accepted":false,"ViewCount":14463,"Q_Id":3533759,"Users Score":11,"Answer":"C will absolutely crush Python in almost any performance category, but C is far more difficult to write and maintain and high performance isn't always worth the trade off of increased time and difficulty in development.\nYou say you're doing things like text file processing, but what you omit is how much text file processing you're doing. If you're processing 10 million files an hour, you might benefit from writing it in C. But if you're processing 100 files an hour, why not use python? Do you really need to be able to process a text file in 10ms vs 50ms? If you're planning for the future, ask yourself, \"Is this something I can just throw more hardware at later?\"\nWriting solid code in C is hard. Be sure you can justify that investment in effort.","Q_Score":13,"Tags":"python,c,performance","A_Id":3534125,"CreationDate":"2010-08-20T18:27:00.000","Title":"Performance differences between Python and 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":1,"Web Development":0},{"Question":"Working on different projects I have the choice of selecting different programming languages, as long as the task is done.\nI was wondering what the real difference is, in terms of performance, between writing a program in Python, versus doing it in C.\nThe tasks to be done are pretty varied, e.g. sorting textfiles, disk access, network access, textfile parsing.\nIs there really a noticeable difference between sorting a textfile using the same algorithm in C versus Python, for example?\nAnd in your experience, given the power of current CPU's (i7), is it really a noticeable difference (Consider that its a program that doesnt bring the system to its knees).","AnswerCount":14,"Available Count":11,"Score":1.2,"is_accepted":true,"ViewCount":14463,"Q_Id":3533759,"Users Score":37,"Answer":"Use python until you have a performance problem. If you ever have one figure out what the problem is (often it isn't what you would have guessed up front). Then solve that specific performance problem which will likely be an algorithm or data structure change. In the rare case that your problem really needs C then you can write just that portion in C and use it from your python code.","Q_Score":13,"Tags":"python,c,performance","A_Id":3533877,"CreationDate":"2010-08-20T18:27:00.000","Title":"Performance differences between Python and 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":1,"Web Development":0},{"Question":"Does python have a full fledged email library with things for pop, smtp, pop3 with ssl, mime?\nI want to create a web mail interface that pulls emails from email servers, and then shows the emails, along with attachments, can display the sender, subject, etc. (handles all the encoding issues etc).\nIt's one thing to be available in the libraries and another for them to be production ready. I'm hoping someone who has used them to pull emails w\/attachments etc. in a production environment can comment on this.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":513,"Q_Id":3538430,"Users Score":2,"Answer":"It has all the components you need, in a more modular and flexible arrangement than you appear to envisage -- the standard library's email package deals with the message once you have received it, and separate modules each deal with means of sending and receiving, such as pop, smtp, imap.  SSL is an option for each of them (if the counterpart, e.g. mail server, supports it, of course), being basically just \"a different kind of socket\".\nHave you looked at the rich online docs for all of these standard library modules?","Q_Score":0,"Tags":"python,email,smtp,mime,pop3","A_Id":3538453,"CreationDate":"2010-08-21T18:16:00.000","Title":"Does python have a robust pop3, smtp, mime library where I could build a webmail 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":0},{"Question":"I'm working from inside an ipython shell and often need to reload the script files that contain my functions-under-construction.\nInside my main.py I have:\ndef myreload():\n    execfile(\"main.py\")\n    execfile(\"otherfile.py\")\nCalling myreload() works fine if I have already ran in the same ipython session the execfile commands directly.\nHowever, for some reason, if the session is fresh and I just called execfile(\"main.py\"), then myreload() doesn't actually make the functions from inside otherfile.py available. It doesn't throw any error though.\nAny ideas?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":2290,"Q_Id":3540368,"Users Score":2,"Answer":"Functions create a new scope. execfile() runs the script in the current scope. What you are doing will not work.","Q_Score":2,"Tags":"python,ipython,execfile","A_Id":3540375,"CreationDate":"2010-08-22T05:54:00.000","Title":"Python shell and execfile scope","Data Science and Machine Learning":0,"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},{"Question":"I'm a school teacher who spent the summer writing a vocab training program in python that uses text available from wikipedia and gutenberg. Now all I have to do is figure out a way to filter out curse words so that I can distribute to students.\nNormally I would just have an array (list) of those curse words and do a simple filter. The problem though is that the py file itself it openable by these students, seeing those words. If I put it in a separate file, somehow encrypted, then they could just delete that file and the output wouldn't be filtered.\nAny ideas for workarounds?","AnswerCount":5,"Available Count":2,"Score":1.0,"is_accepted":false,"ViewCount":674,"Q_Id":3542095,"Users Score":6,"Answer":"If all the students are running the same version of Python (e.g. at a computer lab), you can distribute pyc files.  This is just obfuscation, but it will deter casual users.","Q_Score":1,"Tags":"python,filter","A_Id":3542173,"CreationDate":"2010-08-22T15:46:00.000","Title":"How to \"hide\" curse words in a py 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},{"Question":"I'm a school teacher who spent the summer writing a vocab training program in python that uses text available from wikipedia and gutenberg. Now all I have to do is figure out a way to filter out curse words so that I can distribute to students.\nNormally I would just have an array (list) of those curse words and do a simple filter. The problem though is that the py file itself it openable by these students, seeing those words. If I put it in a separate file, somehow encrypted, then they could just delete that file and the output wouldn't be filtered.\nAny ideas for workarounds?","AnswerCount":5,"Available Count":2,"Score":0.0399786803,"is_accepted":false,"ViewCount":674,"Q_Id":3542095,"Users Score":1,"Answer":"Why not distribute the compiled python .*pyc files instead?  They could still lookup the strings if they wanted, but it will likely deter casual browsing of the file, which may be sufficient for your needs.","Q_Score":1,"Tags":"python,filter","A_Id":3542374,"CreationDate":"2010-08-22T15:46:00.000","Title":"How to \"hide\" curse words in a py 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},{"Question":"Does anyone know where I could find reviews or reports on tasks that people implemented in two or more scripting languages to see which was more suited to a specific job? I want to know which languages are best suited to which types of operation so that I can make the most of them.\n\"Types of operation\" could be sockets, the file system, logic evaluation, regex, or drawing.\nI'm mostly interested in Python, PHP, Perl, and Ruby.","AnswerCount":3,"Available Count":1,"Score":0.1325487884,"is_accepted":false,"ViewCount":1097,"Q_Id":3543193,"Users Score":2,"Answer":"The best thing to do would be to create your own benchmarks for the specific tasks you are interested in. Pick languages that you like working in and then write benchmarks for the system you will be using and the task you will be performing. If you are very concerned about speed I would also recommend looking at the individual operations and how to optimize them in each of the languages (examples: argument order, memory usage...)","Q_Score":0,"Tags":"php,python,ruby,perl,benchmarking","A_Id":3543230,"CreationDate":"2010-08-22T20:19:00.000","Title":"Benchmarks of scripting languages doing the same task?","Data Science and Machine Learning":0,"Database and SQL":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},{"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},{"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},{"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},{"Question":"I want to be able to use the PIL library on a web hosting machine. The machine has Python 2.4.3 installed, but not the PIL library. I tried downloading the PIL source and putting the PIL folder into my directory. It kind of works, except when I need to do some actual image processing, which brings up an ImportError, saying that \"The _imaging C module is not installed\". Googling this, it seems like I would need to throw an _imaging.so file into the PIL folder, but I couldn't find a precompiled one online.\nAt this point, I'm not sure if I'm even on the right track. What should I do from here? Any help is appreciated.\nThanks.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":192,"Q_Id":3560246,"Users Score":1,"Answer":"You need to compile that module. Running the setup.py install command should do it for you, provided the host has a working compiler and the required libraries. You can use virtualenv to have it installed somewhere where you have rights to put files (by default it would try to install it system-wide).\nIf it doesn't have a working compiler and right libraries and header files, then you need to either compile it on another computer with the same architecture and copy it, or find the packages for whatever operating system your host is running and extract the right files from them.\nBy the way, just asking them to install PIL could work too!","Q_Score":0,"Tags":"python,web-hosting,python-imaging-library","A_Id":3560296,"CreationDate":"2010-08-24T19:25:00.000","Title":"Using PIL on web hosting machine","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"We are using Hudson and coverage.py to report the code coverage of our test suite. Hudson breaks down coverage into:\n\npackages\nfiles\nclasses\nlines\nconditionals\n\nCoverage.py only reports coverage on files executed\/imported during the tests, and so it seems is oblivious to any files not executed during the tests. Is there ever an instance where files would not report 100% coverage?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":517,"Q_Id":3562643,"Users Score":3,"Answer":"Currently, coverage.py doesn't know how to find files that are never executed and report them as not covered, but that will be coming in the next release.  So now, the file coverage will always be 100%.  This is an area where Hudson (using the Cobertura plugin) and coverage.py don't mesh very well.","Q_Score":5,"Tags":"python,hudson,code-coverage,coverage.py,python-coverage","A_Id":3562678,"CreationDate":"2010-08-25T03:19:00.000","Title":"When would my Python test suite file coverage not be 100%?","Data Science and Machine Learning":0,"Database and SQL":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},{"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},{"Question":"So I have a class in a module that has some static methods. A couple of these static methods just do crc checks and stuff, and they're not really useful outside of the class (I would just make them private static methods in java or C++). I'm wondering if I should instead make them global class functions (outside of the class). \nIs there any benefit for doing it either way? The class is being imported by from module import class so I'm not worried about having those modules pulled in as well. But should I just make them class methods so that from module import * is safer or something?","AnswerCount":3,"Available Count":2,"Score":0.1973753202,"is_accepted":false,"ViewCount":2735,"Q_Id":3570823,"Users Score":3,"Answer":"Make them module-level functions, and prefix them with a single underscore so that consumers understand that they are for private use.","Q_Score":9,"Tags":"python,global,static-methods","A_Id":3570851,"CreationDate":"2010-08-25T22:48:00.000","Title":"Static method vs module function 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},{"Question":"So I have a class in a module that has some static methods. A couple of these static methods just do crc checks and stuff, and they're not really useful outside of the class (I would just make them private static methods in java or C++). I'm wondering if I should instead make them global class functions (outside of the class). \nIs there any benefit for doing it either way? The class is being imported by from module import class so I'm not worried about having those modules pulled in as well. But should I just make them class methods so that from module import * is safer or something?","AnswerCount":3,"Available Count":2,"Score":0.1973753202,"is_accepted":false,"ViewCount":2735,"Q_Id":3570823,"Users Score":3,"Answer":"If they are not useful outside of the class, what is the motivation to make them module methods? Keeping them as static method makes the name space cleaner. \nThe only advantage to move it outside maybe so that people can reference them without using qualified them the class name. Say you have a log method that got reference in a ton of places, this may make sense as a stylistic choice.","Q_Score":9,"Tags":"python,global,static-methods","A_Id":3571114,"CreationDate":"2010-08-25T22:48:00.000","Title":"Static method vs module function 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},{"Question":"I have been developing under Python\/Snowleopard happily for the part 6 months. I just upgraded Python to 2.6.5 and a whole bunch of libraries, including psycopg2 and Turbogears. I can start up tg-admin and run some queries with no problems. Similarly, I can run my web site from the command line with no problems. \nHowever, if I try to start my application under Aptana Studio, I get the following exception while trying to import psychopg2:\n('dlopen(\/Library\/Frameworks\/Python.framework\/Versions\/2.6\/lib\/python2.6\/site-packages\/psycopg2\/_psycopg.so, 2): Symbol not found: _PQbackendPID\\n  Referenced from: \/Library\/Frameworks\/Python.framework\/Versions\/2.6\/lib\/python2.6\/site-packages\/psycopg2\/_psycopg.so\\n  Expected in: flat namespace\\n in \/Library\/Frameworks\/Python.framework\/Versions\/2.6\/lib\/python2.6\/site-packages\/psycopg2\/_psycopg.so',)\nThis occurs after running the following code:\n    try:\n        import psycopg2 as psycopg\n    except ImportError as ex:\n         print \"import failed :-( xxxxxxxx = \"\n         print ex.args\nI have confirmed that the same version of python is being run as follows:\n        import sys\n        print \"python version: \", sys.version_info\nDoes anyone have any ideas? I've seem some references alluding to this being a 64-bit issue.\n- dave","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":296,"Q_Id":3571495,"Users Score":0,"Answer":"Problem solved (to a point). I was running 64 bit python from Aptana Studio and 32 bit python on the command line. By forcing Aptana to use 32 bit python, the libraries work again and all is happy.","Q_Score":0,"Tags":"python,turbogears,psycopg","A_Id":3571749,"CreationDate":"2010-08-26T01:41:00.000","Title":"Psycopg2 under osx works on commandline but fails in Aptana studio","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},{"Question":"They didn't mention this in python documentation. And recently I'm testing a website simply refreshing the site using urllib2.urlopen() to extract certain content, I notice sometimes when I update the site urllib2.urlopen() seems not get the newly added content. So I wonder it does cache stuff somewhere, right?","AnswerCount":5,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":12290,"Q_Id":3586295,"Users Score":0,"Answer":"If you make changes and test the behaviour from browser and from urllib, it is easy to make a stupid mistake.\nIn browser you are logged in, but in urllib.urlopen your app can redirect you always to the same login page, so if you just see the page size or the top of your common layout, you could think that your changes have no effect.","Q_Score":13,"Tags":"python,urllib2,urlopen","A_Id":38239971,"CreationDate":"2010-08-27T16:34:00.000","Title":"Does urllib2.urlopen() cache stuff?","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},{"Question":"They didn't mention this in python documentation. And recently I'm testing a website simply refreshing the site using urllib2.urlopen() to extract certain content, I notice sometimes when I update the site urllib2.urlopen() seems not get the newly added content. So I wonder it does cache stuff somewhere, right?","AnswerCount":5,"Available Count":3,"Score":1.2,"is_accepted":true,"ViewCount":12290,"Q_Id":3586295,"Users Score":10,"Answer":"So I wonder it does cache stuff somewhere, right? \n\nIt doesn't. \nIf you don't see new data, this could have many reasons. Most bigger web services use server-side caching for performance reasons, for example using caching proxies like Varnish and Squid or application-level caching.\nIf the problem is caused by server-side caching, usally there's no way to force the server to give you the latest data.\n\nFor caching proxies like squid, things are different. Usually, squid adds some additional headers to the HTTP response (response().info().headers).\nIf you see a header field called X-Cache or X-Cache-Lookup, this means that you aren't connected to the remote server directly, but through a transparent proxy.\nIf you have something like: X-Cache: HIT from proxy.domain.tld, this means that the response you got is cached. The opposite is X-Cache MISS from proxy.domain.tld, which means that the response is fresh.","Q_Score":13,"Tags":"python,urllib2,urlopen","A_Id":3586796,"CreationDate":"2010-08-27T16:34:00.000","Title":"Does urllib2.urlopen() cache stuff?","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},{"Question":"They didn't mention this in python documentation. And recently I'm testing a website simply refreshing the site using urllib2.urlopen() to extract certain content, I notice sometimes when I update the site urllib2.urlopen() seems not get the newly added content. So I wonder it does cache stuff somewhere, right?","AnswerCount":5,"Available Count":3,"Score":-0.0798297691,"is_accepted":false,"ViewCount":12290,"Q_Id":3586295,"Users Score":-2,"Answer":"I find it hard to believe that urllib2 does not do caching, because in my case, upon restart of the program the data is refreshed. If the program is not restarted, the data appears to be cached forever. Also retrieving the same data from Firefox never returns stale data.","Q_Score":13,"Tags":"python,urllib2,urlopen","A_Id":3936916,"CreationDate":"2010-08-27T16:34:00.000","Title":"Does urllib2.urlopen() cache stuff?","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},{"Question":"I'm writing a game which requires users to log in to their accounts in order to be able to play. What's the best way of transmitting passwords from client to server and storing them?\nI'm using Python and Twisted, if that's of any relevance.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":447,"Q_Id":3595835,"Users Score":1,"Answer":"The best way is to authenticate via SSL\/TLS. The best way of storing passwords is to store them hashed with some complex hash like sha1(sha1(password)+salt) with salt.","Q_Score":0,"Tags":"python,security,passwords,network-programming","A_Id":3595865,"CreationDate":"2010-08-29T17:38:00.000","Title":"Handling Password Authentication over a Network","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},{"Question":"I'm just starting out learning python (for webapp usage) but I'm confused as to the best way for using it with html files and dynamic data.\nI know php has the  tags which are great - does python have something like this or equivalent, if not how should I be doing it?","AnswerCount":4,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":1597,"Q_Id":3597143,"Users Score":4,"Answer":"There are a few php style python options out there. Mod_python used to ship with one, and spyce had an alternate implementation, but that modality is out of favor with pythonistas. Instead, use a templating language. Genshi and jinja2 are both popular, but there are lots to choose from.\nSince you are new to web programming with python, you would probably be best off choosing an entire framework get started. Django, turbogears, and cherrypy are a few to check out. These frameworks will all include all the tools you need to make a modern website, including a templating language.","Q_Score":3,"Tags":"python,web-applications","A_Id":3597157,"CreationDate":"2010-08-30T00:19:00.000","Title":"PHP style inline tags 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":1},{"Question":"I'm hosting an IronPython engine instance in my C# (Silverlight 4) app to execute some Python scripts on the fly. These scripts can return values of either IronPython.Modules.PythonDateTime+datetime, IronPython.Modules.PythonDateTime+date or IronPython.Modules.PythonDateTime+time types. I need to convert these to System.DateTime values in C# without losing resolution. How do I do this?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":334,"Q_Id":3599800,"Users Score":2,"Answer":"I don't think there's a good way to do this other than pulling the elements of the date time out from properties like year, month, day, etc... and constructing a new DateTime instance from those.  You could file feature request on ironpython.codeplex.com to have an explicit conversion to DateTime.  That's pretty trivial to implement for at least some of these because they're using a DateTime behind the scenes.","Q_Score":1,"Tags":"silverlight,silverlight-4.0,ironpython,dynamic-language-runtime","A_Id":3605304,"CreationDate":"2010-08-30T11:13:00.000","Title":"Type conversion from IronPython.Modules.PythonDateTime to System.DateTime","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I would like to know the basic principles and etiquette of writing a well structured code.","AnswerCount":18,"Available Count":5,"Score":1.0,"is_accepted":false,"ViewCount":3967,"Q_Id":3603858,"Users Score":15,"Answer":"Well, if you want it in layman's terms:\nI reccomend people to write the shortest readable program that works. \nThere are a lot more rules about how to format code, name variables, design classes, separate responsibilities. But you should not forget that all of those rules are only there to make sure that your code is easy to check for errors, and to ensure it is maintainable by someone else than the original author. If keep the above reccomendation in mind, your progam will be just that.","Q_Score":45,"Tags":"python,matlab,structure","A_Id":3604355,"CreationDate":"2010-08-30T20:09:00.000","Title":"Good practices in writing MATLAB 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":0},{"Question":"I would like to know the basic principles and etiquette of writing a well structured code.","AnswerCount":18,"Available Count":5,"Score":1.2,"is_accepted":true,"ViewCount":3967,"Q_Id":3603858,"Users Score":22,"Answer":"These are the most important two things to keep in mind when you are writing code:\n\nDon't write code that you've already written.\nDon't write code that you don't need to write.","Q_Score":45,"Tags":"python,matlab,structure","A_Id":3604376,"CreationDate":"2010-08-30T20:09:00.000","Title":"Good practices in writing MATLAB 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":0},{"Question":"I would like to know the basic principles and etiquette of writing a well structured code.","AnswerCount":18,"Available Count":5,"Score":0.022218565,"is_accepted":false,"ViewCount":3967,"Q_Id":3603858,"Users Score":2,"Answer":"Personally, I've found that I learned more about programming style from working through SICP which is the MIT Intro to Comp SCI text (I'm about a quarter of the way through.) Than any other book. That being said, If you're going to be working in Python, the Google style guide is an excellent place to start.\nI read somewhere that most programs (scripts anyways) should never be more than a couple of lines long. All the requisite functionality should be abstracted into functions or classes. I tend to agree.","Q_Score":45,"Tags":"python,matlab,structure","A_Id":3604396,"CreationDate":"2010-08-30T20:09:00.000","Title":"Good practices in writing MATLAB 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":0},{"Question":"I would like to know the basic principles and etiquette of writing a well structured code.","AnswerCount":18,"Available Count":5,"Score":0.0111106539,"is_accepted":false,"ViewCount":3967,"Q_Id":3603858,"Users Score":1,"Answer":"Make it readable, make it intuitive, make it understandable, and make it commented.","Q_Score":45,"Tags":"python,matlab,structure","A_Id":3607452,"CreationDate":"2010-08-30T20:09:00.000","Title":"Good practices in writing MATLAB 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":0},{"Question":"I would like to know the basic principles and etiquette of writing a well structured code.","AnswerCount":18,"Available Count":5,"Score":0.022218565,"is_accepted":false,"ViewCount":3967,"Q_Id":3603858,"Users Score":2,"Answer":"Many good points have been made above.  I definitely second all of the above.  I would also like to add that spelling and consistency in coding be something you practice (and also in real life).\nI've worked with some offshore teams and though their English is pretty good, their spelling errors caused a lot of confusion.  So for instance, if you need to look for some function (e.g., getFeedsFromDatabase) and they spell database wrong or something else, that can be a big or small headache, depending on how many dependencies you have on that particular function.  The fact that it gets repeated over and over within the code will first off, drive you nuts, and second, make it difficult to parse.\nAlso, keep up with consistency in terms of naming variables and functions.  There are many protocols to go by but as long as you're consistent in what you do, others you work with will be able to better read your code and be thankful for it.","Q_Score":45,"Tags":"python,matlab,structure","A_Id":3604559,"CreationDate":"2010-08-30T20:09:00.000","Title":"Good practices in writing MATLAB 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":0},{"Question":"Can Mechanize access sites being locally hosted by Apache?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":257,"Q_Id":3603883,"Users Score":0,"Answer":"Yes. It can use any URL available so long as it is reachable. Just make sure it's properly formatted!","Q_Score":0,"Tags":"python,mechanize","A_Id":3603922,"CreationDate":"2010-08-30T20:12:00.000","Title":"Can python's mechanize use localhost sites?","Data Science and Machine Learning":0,"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},{"Question":"Question is simple, i have a object file and i want to read the symbols of the object file via code.  I am aware that the linux command \"nm\" would be able to do this, but i want to be able to do it inside code.\nAlso note id like to do this either via C or Python.\nRegards\nPaul","AnswerCount":3,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1506,"Q_Id":3607254,"Users Score":0,"Answer":"On linux object files are written in ELF file format.So i think you have to start with understanding the ELF file format and how OS write object file using this format.That can give you a idea how you can read object file and symbol table by your own program.To get some initial idea you can look into the source code of readelf tool.","Q_Score":0,"Tags":"python,c,linux","A_Id":3607298,"CreationDate":"2010-08-31T08:21:00.000","Title":"How to read symbols of an object file using 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},{"Question":"Newbie question: Python 2.6, Ubuntu 10.04, I can import both pycurl and curl, the former having different names for functions (set_option vs. setopt).\nWhat's the difference between the two modules?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1716,"Q_Id":3609952,"Users Score":6,"Answer":"curl is a module which uses pycurl. It provides the curl.Curl class which provides a high-level interface to the pycurl functions.\nI haven't found much documentation on how to use it, but reading  \/usr\/share\/pyshared\/curl\/__init__.py may make it pretty self-obvious.\nThere are also some examples in \/usr\/share\/doc\/python-pycurl\/examples which use curl.Curl.","Q_Score":5,"Tags":"python,ubuntu,curl,pycurl","A_Id":3609988,"CreationDate":"2010-08-31T14:25:00.000","Title":"What's the difference between pycurl and curl 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},{"Question":"I'm trying to get a sense of the similarities between languages in syntax. How similar are Python, jQuery and C? I started programming in Actionscript 3 and then moved on to Javascript , then went on and learned Prototype, and then I started using jQuery and found that the syntax is very different. So is jQuery more like C and Python?","AnswerCount":3,"Available Count":3,"Score":0.1973753202,"is_accepted":false,"ViewCount":2839,"Q_Id":3615122,"Users Score":3,"Answer":"For jQuery, the answer is pretty simple: jQuery isn't a language, therefore it doesn't have syntax.\nFor Python and C, the answer from a high-level point of view is also very simple: Python's syntax is directly inspired by C's syntax. (Or more precisely, both Python's and C's syntax are inspired by ALGOL's syntax.) There is really only one significant difference from a high-level point of view: C uses opening and closing curly braces to delimit blocks, Python uses indentation.\nOtherwise, the two high-level syntaxes are almost the same: both have unary and binary operators, even with similar precedence (unline Smalltalk, for example, which doesn't have operators), both distinguish between statements and expressions (unlike Ruby, for example, which doesn't have statements), both use semicolons between statements (although technically, the semicolon is a statement terminator in C and a statement separator in Python), both use similar syntax for numeric literals and string literals as well as array\/list indexing.\nThere are a couple of syntactic differences related to the different semantics: in Python, variables are untyped (only objects are typed), so there is no type annotation syntax for variable declarations (in fact, there is no syntax for variable declarations at all). There is syntax for type annotations of function parameters and function return values, but in Python the types come after the parameter name, and the type annotations are optional. With variables being untyped, the concept of type casting doesn't make sense, so there is no syntax for that. Neither is there any pointer-related syntax, since Python doesn't have those.\nPython has a couple more literals than C: lists, sets, dictionaries, in particular. However, they follow in the C tradition: in C, an array is declared and indexed using square brackets, so Python uses square brackets for array literals.","Q_Score":4,"Tags":"javascript,jquery,python,c,syntax","A_Id":3618018,"CreationDate":"2010-09-01T04:54:00.000","Title":"How similar are Python, jQuery, C syntax wise?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to get a sense of the similarities between languages in syntax. How similar are Python, jQuery and C? I started programming in Actionscript 3 and then moved on to Javascript , then went on and learned Prototype, and then I started using jQuery and found that the syntax is very different. So is jQuery more like C and Python?","AnswerCount":3,"Available Count":3,"Score":0.1973753202,"is_accepted":false,"ViewCount":2839,"Q_Id":3615122,"Users Score":3,"Answer":"Syntax wise, JavaScript (the language jQuery is implemented in) is similar to C. Python uses a different syntax which does not rely on semicolons and braces, but instead on indentation.\nSemantically, JavaScript is closer to Python, so this would be easier to learn. I don't understand how you \"moved\" from ActionScript 3 to JavaScript to Prototype; ActionScript has the same syntax and is also otherwise very similar to JavaScript, and Protoype\/jQuery are just applications written in JavaScript (so it's the same language, but different frameworks!)","Q_Score":4,"Tags":"javascript,jquery,python,c,syntax","A_Id":3615135,"CreationDate":"2010-09-01T04:54:00.000","Title":"How similar are Python, jQuery, C syntax wise?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to get a sense of the similarities between languages in syntax. How similar are Python, jQuery and C? I started programming in Actionscript 3 and then moved on to Javascript , then went on and learned Prototype, and then I started using jQuery and found that the syntax is very different. So is jQuery more like C and Python?","AnswerCount":3,"Available Count":3,"Score":1.2,"is_accepted":true,"ViewCount":2839,"Q_Id":3615122,"Users Score":8,"Answer":"C is much different from the languages you've asked about.  Remember that C isn't an interpreted language and will not be treated as such in your code.  In short, you're up for a lot more material to learn --while dealing with C-- in terms of things like memory management and semantics than the other languages.\nIn regards to syntax: You'll find that if you're writing code in any language other than Lisp, brainfuck, or some other non-intuitive language (not claiming that C is, but in comparison, certainly), the syntax isn't too much of a variable. There are some differences, but nothing that should be considered too abstract. In C, you have to worry about things like pointers and whatnot which is a pain, but I think the difference is more-so about memory management than syntax.  You mostly have to worry about the differences in usages of semicolons and whatnot.\nYou'll find that Python is like writing English sentences, or at least writing pseudocode with constraints, which makes it significantly easier than C.  Additionally, I wouldn't consider jQuery a language on its own.  It's an extension of a language though, just as STL might be considered a particular type of extension to C++.\nGood luck.","Q_Score":4,"Tags":"javascript,jquery,python,c,syntax","A_Id":3615482,"CreationDate":"2010-09-01T04:54:00.000","Title":"How similar are Python, jQuery, C syntax wise?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I try to move email from mailbox's gmail to another one, Just curious that UID of each email will change when move to new mailbox ?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":5836,"Q_Id":3615561,"Users Score":4,"Answer":"Yes of course the UID is changed when you do move operation.\nthe new UID for that mail will be the next UID from the destination folder.\n(i.e if the last mail UID of the destination folder is : 9332 , \nthen the UID of the move  email   will be 9333) \nNote: UID is changed but the Message-Id will not be changed during any operation on that mail)","Q_Score":0,"Tags":"python,imap,imaplib","A_Id":3636059,"CreationDate":"2010-09-01T06:37:00.000","Title":"About IMAP UID with imaplib","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},{"Question":"I'm planning to use Python to develop a web application. Anybody has any idea about any accelerator for python? (something like eAccelerator or apc for php) if not, is there any way to cache the pre-compiled python bytecode ? \nAny idea about the performance comparison between python and php (assuming db\/network latencies are same)\nThanks in advance.","AnswerCount":4,"Available Count":3,"Score":0.2449186624,"is_accepted":false,"ViewCount":1571,"Q_Id":3619063,"Users Score":5,"Answer":"As long as you do trivial amounts of work in your \"main script\" (the one you directly invoke with python and which gets a __name__ of __main__) you need not worry about \"caching the pre-compiled python bytecode\": when you import foo, foo.py gets saved to disk (same directory) as foo.pyc, as long as that directory is writable by you, so the already-cheap compilation to bytecode happens once and \"forever after\" Python will load foo.pyc directly in every new process that does import foo -- within a single process, every import foo except the first one is just a fast lookup into a dictionary in memory (the sys.module dictionary).  A core performance idea in Python: makes sure every bit of substantial code happens within def statements in modules -- don't have any at module top level, in the main script, or esp. within exec and eval statements\/expressions!-).\nI have no benchmarks for PHP vs Python, but I've noticed that Python keeps getting optimized pretty noticeably with every new release, so make sure you compare a recent release (idealy 2.7, at least 2.6) if you want to see \"the fastes Python\".  If you don't find it fast enough yet, cython (a Python dialect designed to compile directly into C, and thence into machine code, with some limitations) is today the simplest way to selectively optimize those modules which profiling shows you need it.","Q_Score":4,"Tags":"php,python,accelerator","A_Id":3619178,"CreationDate":"2010-09-01T14:22:00.000","Title":"Python accelerator","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I'm planning to use Python to develop a web application. Anybody has any idea about any accelerator for python? (something like eAccelerator or apc for php) if not, is there any way to cache the pre-compiled python bytecode ? \nAny idea about the performance comparison between python and php (assuming db\/network latencies are same)\nThanks in advance.","AnswerCount":4,"Available Count":3,"Score":1.2,"is_accepted":true,"ViewCount":1571,"Q_Id":3619063,"Users Score":3,"Answer":"Others have mentioned Python byte code files, but that is largely irrelevant. This is because hosting mechanisms for Python, with the exception of CGI, keep the Python web Application in memory between requests. This is different to PHP which effectively throws away the application between requests. As such, Python doesn't need an accelerator as the way Python web hosting mechanisms work avoids the problems that PHP has.","Q_Score":4,"Tags":"php,python,accelerator","A_Id":3622927,"CreationDate":"2010-09-01T14:22:00.000","Title":"Python accelerator","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I'm planning to use Python to develop a web application. Anybody has any idea about any accelerator for python? (something like eAccelerator or apc for php) if not, is there any way to cache the pre-compiled python bytecode ? \nAny idea about the performance comparison between python and php (assuming db\/network latencies are same)\nThanks in advance.","AnswerCount":4,"Available Count":3,"Score":1.0,"is_accepted":false,"ViewCount":1571,"Q_Id":3619063,"Users Score":8,"Answer":"There's a trick to this.\nIt's called mod_wsgi.\nThe essence of it works like this.\n\nFor \"static\" content (.css, .js, images, etc.) put them in a directory so they're served by Apache, without your Python program knowing they were sent.\nFor \"dynamic\" content (the main HTML page itself) you use mod_wsgi to fork a \"back-end\" process that runs outside of Apache.  \n\nThis is faster than PHP because now several things are going on at once.  Apache has dispatched the request to a backend process and then moved on to handle the next request while the backend is still running the first one.\nAlso, when you've sent your HTML page, the follow-on requests are handled by Apache without your Python program knowing or caring what's going on.  This leads to huge speedups.  Nothing to do with the speed of Python.  Everything to do with the overall architecture.","Q_Score":4,"Tags":"php,python,accelerator","A_Id":3619244,"CreationDate":"2010-09-01T14:22:00.000","Title":"Python accelerator","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I am from Java world and I wonder what is so great about dynamic typing in Python besides missing errors while compiling the code?\nDo you like Python's typing? Do you have an example where it helped in a big project? Isn't it a bit error prone?","AnswerCount":7,"Available Count":6,"Score":0.0,"is_accepted":false,"ViewCount":2330,"Q_Id":3621297,"Users Score":0,"Answer":"It's a load off your mind. You can think the color red as \"Red\" (a constant) as \"255, 0, 0\" (a tuple) or \"#FF0000\" (a string): three different formats, that would require three different types, or complex lookup and conversion methods in Java.\nIt makes code simpler.","Q_Score":11,"Tags":"java,python,static-typing,dynamic-typing","A_Id":3621365,"CreationDate":"2010-09-01T19:07:00.000","Title":"How to deal with Python ~ static typing?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am from Java world and I wonder what is so great about dynamic typing in Python besides missing errors while compiling the code?\nDo you like Python's typing? Do you have an example where it helped in a big project? Isn't it a bit error prone?","AnswerCount":7,"Available Count":6,"Score":0.0,"is_accepted":false,"ViewCount":2330,"Q_Id":3621297,"Users Score":0,"Answer":"For example, you can write functions\n  to which you can pass an integer as\n  well as a string or a list or a\n  dictionary or whatever else, and it\n  will be able to transparently handle\n  all of them in appropriate ways (or\n  throw an exception if it cannot handle\n  the type). You can do things like that\n  in other languages, too, but usually\n  you have to resort to (ab)use things\n  like pointers, references or\n  typecasts, which opens holes for\n  programming errors, and it's just\n  plain ugly.","Q_Score":11,"Tags":"java,python,static-typing,dynamic-typing","A_Id":3621395,"CreationDate":"2010-09-01T19:07:00.000","Title":"How to deal with Python ~ static typing?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am from Java world and I wonder what is so great about dynamic typing in Python besides missing errors while compiling the code?\nDo you like Python's typing? Do you have an example where it helped in a big project? Isn't it a bit error prone?","AnswerCount":7,"Available Count":6,"Score":0.1418931938,"is_accepted":false,"ViewCount":2330,"Q_Id":3621297,"Users Score":5,"Answer":"Do you like it in Python? \n\nIt's part of Python.  Liking it in Python is silly.  \n\nDo you have an example where it helped in a big project? \n\nYes.  Every single day I rejoice that I can make changes and -- because of Duck typing -- they are reasonably localized, pass all the unit tests, pass all the integration tests, and nothing is disrupted elsewhere.\nIf this was Java, the changes would require endless refactoring to pull interfaces out of classes so that I could introduce variations that were still permitted under Java's static type checking.\n\nDoesn't it a bit error prone?\n\nNot any more than static typing is.  A simple unit test confirms that the objects conform to the expected features.  \nIt's easy to write a class in Java that (a) passes compile-time checks and (b) crashes horribly at run time.  Casts are a good way to do this.  Failing to meet the classes intent is a common thing -- a class may compile but still not work.","Q_Score":11,"Tags":"java,python,static-typing,dynamic-typing","A_Id":3621720,"CreationDate":"2010-09-01T19:07:00.000","Title":"How to deal with Python ~ static typing?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am from Java world and I wonder what is so great about dynamic typing in Python besides missing errors while compiling the code?\nDo you like Python's typing? Do you have an example where it helped in a big project? Isn't it a bit error prone?","AnswerCount":7,"Available Count":6,"Score":0.057080742,"is_accepted":false,"ViewCount":2330,"Q_Id":3621297,"Users Score":2,"Answer":"A lot of patterns (e.g. from GoF) are unnecessary or can be implemented with less efforts in dynamic-typed languages with functional flavor. In fact, a lot of patterns are \"built-in\" into python so if you write short and 'pythonic' code you will get all the benefits for free. You don't need Iterator, Observer, Strategy, Factory Method, Abstract Factory, and a bunch of other patterns that are common in Java or C++. \nThis means less code to write and (much more important) less code to read, understand and support. I think this is the main benefit of languages like python. And in my opinion this greatly outweighs the absence of static typing. Type-related errors are not often in python code and they are easy to catch with simple functional tests (and such tests are easier to write in python than in java for sure).","Q_Score":11,"Tags":"java,python,static-typing,dynamic-typing","A_Id":3621952,"CreationDate":"2010-09-01T19:07:00.000","Title":"How to deal with Python ~ static typing?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am from Java world and I wonder what is so great about dynamic typing in Python besides missing errors while compiling the code?\nDo you like Python's typing? Do you have an example where it helped in a big project? Isn't it a bit error prone?","AnswerCount":7,"Available Count":6,"Score":1.0,"is_accepted":false,"ViewCount":2330,"Q_Id":3621297,"Users Score":13,"Answer":"I suspect that the vast majority of non-trivial Java programs have dynamic typing in them.  \nEvery time in Java that you do a cast from Object to an explicit type you are doing dynamic type checking - this includes every use of a collection class before generics were introduced in 1.5.  Actually Java generics can still defer some type checking until runtime.\nEvery time you use Java reflection you are doing dynamic type checking.  This includes mapping from a class or method name in an text file to a real class or method - e.g. every time you use a Spring XML configuration file.\nDoes this make Java programs fragile and error prone?  Do Java programmers spend a significant part of their time having to track down and fix problems with incorrect dynamic typing?  Probably not - and neither do Python programmers.\nSome of the advantages of dynamic typing:\n\nGreatly reduced reliance on inheritance.  I have seen Java programs with massive inheritance trees.  Python programs often use little or no inheritance, preferring to use duck typing.   \nIt is easy to write truly generic code.  For example the min() and max() functions can take a sequence of any comparable type - integers, strings, floats, classes that have the appropriate comparison methods, lists, tuples etc.\nLess code.  A huge proportion of Java code contributes nothing to solving the problem at hand - it is purely there to keep the type system happy.  If a Python program is a fifth the size of the equivalent Java program then there is one fifth the code to write, maintain, read and understand.  To put it another way, Python has a much higher signal to noise ratio.\nFaster development cycle.  This goes hand in hand with less code - you spend less time thinking about types and classes and more time thinking about solving the problem you are working on.  \nLittle need for AOP.  I think there are aspect oriented libraries for Python but I don't know of anyone that uses them, since for 99% of what you need AOP for you can do with decorators and dynamic object modification.   The wide use of AspectJ in the Java world suggests to me that there are deficiencies in the core Java language that have to be compensated for with an external tool.","Q_Score":11,"Tags":"java,python,static-typing,dynamic-typing","A_Id":3621904,"CreationDate":"2010-09-01T19:07:00.000","Title":"How to deal with Python ~ static typing?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am from Java world and I wonder what is so great about dynamic typing in Python besides missing errors while compiling the code?\nDo you like Python's typing? Do you have an example where it helped in a big project? Isn't it a bit error prone?","AnswerCount":7,"Available Count":6,"Score":0.0,"is_accepted":false,"ViewCount":2330,"Q_Id":3621297,"Users Score":0,"Answer":"As you're from the Java world, the obvious answer would be that it's great not to be forced to write all that stuff you are forced to write, just to keep Java's type system happy.\nOf course, there are other statically type checked languages that don't force you to write all that stuff that Java forces you to write.\nEven C# does type inference for local method variables!\nAnd there are other statically type checked languages that provide more compile time error checking than Java provides.\n(The less obvious answers for - what is so great about dynamic typing in Python? - probably require more understanding of Python to understand.)","Q_Score":11,"Tags":"java,python,static-typing,dynamic-typing","A_Id":3621429,"CreationDate":"2010-09-01T19:07:00.000","Title":"How to deal with Python ~ static typing?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want a mercurial hook that will run JSLint\/PyChecker\/etc on all files that are modified. However, I do not have control over all hg clients, and want this to run on push to the master repository (which I have control), so a pretxnchangegroup hook on the master seems best.\nHow can I get a list of all changesets that are in the changegroup that is going to be committed?\nI have seem other solutions that use a precommit hook, but these will not work for me because the clients may already have a commit that fails JSLint. In this case, they should be able to fix the errors in a new commit, and be able to push (both the bad and new commits) to the server successfully. The server just needs to check the most recent changeset on each branch, of every file that was modified in the changegroup.","AnswerCount":3,"Available Count":1,"Score":0.2605204458,"is_accepted":false,"ViewCount":2726,"Q_Id":3621463,"Users Score":4,"Answer":"You're right that you want a pretxnchangegroup hook, but you don't want to check all the new revisions -- because people will fix the errors you reject in subsequent changesets but if you're checking all changesets their work will never be accepted!\nInstead either just check all files in all the heads, or use the hg status --rev x:y syntax to get a list of the changed files between the revision you already have and the tip revision you're receiving, and check only those files only in the tip revision.\nIf you really want the list of all revisions you'd use a revset ( hg help revsets ) new in version 1.6, but you really only want to check the results, not all the revisions that get you there.","Q_Score":3,"Tags":"python,mercurial,hook,mercurial-hook","A_Id":3621563,"CreationDate":"2010-09-01T19:28:00.000","Title":"Get list of changesets in a changegroup (mercurial python 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},{"Question":"i found out that my server is getting slower and slower.\non command top i get response that i have a lot svcrack.py and svwar.py processes active.\ncan you tell me what are those?\nthank you in advance!","AnswerCount":3,"Available Count":1,"Score":0.1325487884,"is_accepted":false,"ViewCount":4163,"Q_Id":3624521,"Users Score":2,"Answer":"as everyone else said, that's part of SIPVicious, of which I'm the original author. Your server got compromised (somehow) and is being used to scan and compromise PBX servers open on the internet.\nI would like more details about your case. Would be great if you could get in contact - sandro@enablesecurity.com\n\nsandro","Q_Score":1,"Tags":"python,apache","A_Id":3624825,"CreationDate":"2010-09-02T07:10:00.000","Title":"svcrack.py and svwar.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},{"Question":"While PyDev turns out to be a great IDE for python, especially if you are a former Java developer accustomed to all the eclipse ubercool navigation, it still lacks some features that Wing has, like GUI for running python unit-tests.\nI know Wing has some \"personalities\" of other editors: vi, emacs, Visual Studio, ...\nUnfortunately, Eclipse is not one of them.\nBefore I start configuring all the keys myself, creating a keymap.eclipse file, etc. (seems like it's gonna take ages), I wanted to know if no one already configured it and can share it with the rest of the world.\nThanks!","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":139,"Q_Id":3628847,"Users Score":1,"Answer":"I've added an experimental one in version 4.1.3","Q_Score":1,"Tags":"python,eclipse,wing-ide","A_Id":9213010,"CreationDate":"2010-09-02T15:54:00.000","Title":"Is there an Eclipse personality settings for Wing IDE?","Data Science and Machine Learning":0,"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},{"Question":"While PyDev turns out to be a great IDE for python, especially if you are a former Java developer accustomed to all the eclipse ubercool navigation, it still lacks some features that Wing has, like GUI for running python unit-tests.\nI know Wing has some \"personalities\" of other editors: vi, emacs, Visual Studio, ...\nUnfortunately, Eclipse is not one of them.\nBefore I start configuring all the keys myself, creating a keymap.eclipse file, etc. (seems like it's gonna take ages), I wanted to know if no one already configured it and can share it with the rest of the world.\nThanks!","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":139,"Q_Id":3628847,"Users Score":0,"Answer":"Unfortunately, there's no Eclipse personality.","Q_Score":1,"Tags":"python,eclipse,wing-ide","A_Id":3629793,"CreationDate":"2010-09-02T15:54:00.000","Title":"Is there an Eclipse personality settings for Wing IDE?","Data Science and Machine Learning":0,"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},{"Question":"I need to pull from hundreds of pop3 email accounts, and i want to build a robust server to do this.\nWould twisted be a good choice for this type of project?\nRight now a simple prototype would be to pull from a single pop3 account, then it would pull from many but it would be a serialized process.\nI want to create a server that has multiple threads so it can do things at the same time.","AnswerCount":4,"Available Count":2,"Score":-0.049958375,"is_accepted":false,"ViewCount":2134,"Q_Id":3629088,"Users Score":-1,"Answer":"A word of caution with twisted, while twisted is very robust I've found that spinning up a hundred threads using the code examples available in documentation is a recipe for race conditions and deadlocks. My suggestion is try twisted but have the stdlib multithreading module waiting in the wings if twisted becomes unmanageable. I have had good success with a producer consumer model using the aforementioned library.","Q_Score":6,"Tags":"python,multithreading,twisted","A_Id":3629349,"CreationDate":"2010-09-02T16:22:00.000","Title":"Would twisted be a good choice for building a multi-threaded 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":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I need to pull from hundreds of pop3 email accounts, and i want to build a robust server to do this.\nWould twisted be a good choice for this type of project?\nRight now a simple prototype would be to pull from a single pop3 account, then it would pull from many but it would be a serialized process.\nI want to create a server that has multiple threads so it can do things at the same time.","AnswerCount":4,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":2134,"Q_Id":3629088,"Users Score":0,"Answer":"It is a good choice for a server but from your description you are acutally looking for a multithreaded POP client.\nTwisted is made for reacting to events like incoming requests, you need to send requests, so in this case I fear twisted to be of limited value.","Q_Score":6,"Tags":"python,multithreading,twisted","A_Id":3629187,"CreationDate":"2010-09-02T16:22:00.000","Title":"Would twisted be a good choice for building a multi-threaded 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":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am attempting to use the tweepy api to make a twitter function and I have two issues.\nI have little experience with the terminal and Python in general.\n1)  It installed properly with Python 2.6, however I can't use it or install it with Python 3.1.  When I attempt to install the module in 3.1 it gives me an error that there is no module setuptools.  Originally I thought that perhaps I was unable to use tweepy module with 3.1, however in the readme it says \"Python 3 branch (3.1)\", which I assume means it is compatible.  When I searched for the setuptools module, which I figured I could load into the new version, there was only modules for up to Python 2.7.  How would I install the Tweepy api properly on Python 3.1?\n2)  My default Python when run from terminal is 2.6.1 and I would like to make it 3.1 so I don't have to type python3.1.","AnswerCount":2,"Available Count":1,"Score":-0.0996679946,"is_accepted":false,"ViewCount":1565,"Q_Id":3631828,"Users Score":-1,"Answer":"Update: The comments below have some solid points against this technique. \n2) What OS are you running? Generally, there is a symlink somewhere in your system, which points from 'python' to 'pythonx.x', where x.x is the version number preferred by your operating system. On Linux, there is a symlink \/usr\/bin\/python, which points to (on Ubuntu 10.04) \/usr\/bin\/python2.6 on a standard installation.\nJust manually change the current link to point to the python3.1 binary, and you are fine.","Q_Score":0,"Tags":"python,tweepy","A_Id":3631888,"CreationDate":"2010-09-02T22:39:00.000","Title":"Python defaults and using tweepy 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":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Imagine a web application that allows a logged in user to run a shell command on the web server at the press of a button. This is relatively simple in most languages via some standard library os tools.\nBut if that command is long running you don't want your UI to hang. Again this is relatively easy to deal with using some sort of background process or putting the command to be executed onto a message queue (and maybe saving the output and status somewhere for later consumption). Just return quickly saving we'll run that and get back to you.\nWhat I'd like to do is show the output of said web ui triggered shell command as it happens. So vertically scrolling text like when running in a terminal.\nI have a vague idea of how I might approach this, streaming the output to a websocket perhaps and simply printing the output to screen.\nWhat I'd like to ask is:\nAre their any plugins, libraries or applications that already do this. Something I can either use or read the source of. Ideally an open source python\/django or ruby\/rails tool, but other stacks would be interesting too.","AnswerCount":7,"Available Count":1,"Score":0.0285636566,"is_accepted":false,"ViewCount":4016,"Q_Id":3637503,"Users Score":1,"Answer":"I'm not sure if it's what you want, but there are some web based ssh clients out there. If you care about security and really just want dynamic feedback, you could look into comet or just have a frame with its own http session that doesn't end until it's done printing.","Q_Score":8,"Tags":"python,ruby-on-rails,ruby,django,shell","A_Id":3637544,"CreationDate":"2010-09-03T15:59:00.000","Title":"What is the best way of running shell commands from a web based 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":1},{"Question":"I'm a newbie to web technology, and still on a learning curve.\nHeard that, fastcgi would keep the compiled(interpreted) php code in memory, so why would one has to use op-code caching (apc or eaccelerators) for PHP? \nBut I never heard of any such accelerators for Python. I'd expect as python and php are both interpreted language, it makes me think that, there has to be a room for python accelerators ? pls correct me if I'm wrong. \nMany thanks","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":583,"Q_Id":3646205,"Users Score":0,"Answer":"Python is compiled to bytecode when executed (the .pyc files), and the bytecode is kept around, not discarded. The compiled python is used instead of the source if it is present. Therefore, there is no need for additional opcode caching in python as it is already built in.","Q_Score":4,"Tags":"php,python,fastcgi","A_Id":3646236,"CreationDate":"2010-09-05T13:28:00.000","Title":"Why would one use accelerators with fastcgi for 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},{"Question":"If so, What is the advantage ? (sure it will avoid restarting webserver). But isn't it a perfomance bottleneck? For production, is it possible to make web2py run directly from bytecode skipping interpreting stage (Caching) (except for the first request) ?","AnswerCount":2,"Available Count":2,"Score":0.1973753202,"is_accepted":false,"ViewCount":814,"Q_Id":3649607,"Users Score":2,"Answer":"I don't know web2py particularly, but it runs via WSGI like most other Python frameworks. This means that code is only interpreted when the process starts, and is otherwise kept in memory. Processes are dynamically started and killed by the web server itself, but usually last for multiple requests.\nIn any case, the Python interpreter usually creates a byte-code file, .pyc, when code is first read. This works in a webserver environment just as it does anywhere else.\nFinally, however, it is generally considered that code parsing is not particularly a bottleneck - the conversion to bytecode is pretty quick. In a web application, your bottleneck is almost certainly elsewhere (probably in the connection to the database).","Q_Score":4,"Tags":"python,performance,caching,bytecode,web2py","A_Id":3649957,"CreationDate":"2010-09-06T06:59:00.000","Title":"Is code interpreted at every call in Web2Py?","Data Science and Machine Learning":0,"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},{"Question":"If so, What is the advantage ? (sure it will avoid restarting webserver). But isn't it a perfomance bottleneck? For production, is it possible to make web2py run directly from bytecode skipping interpreting stage (Caching) (except for the first request) ?","AnswerCount":2,"Available Count":2,"Score":1.0,"is_accepted":false,"ViewCount":814,"Q_Id":3649607,"Users Score":6,"Answer":"In web2py, by default, all code in models, views and controllers (not web2py code, not code in modules imported by your models, views, controllers) is interpreted at every request. This allows to use a third party web server (for example apache) and still be able to see changes in your code reflected immediately without restart. PHP works in the same way. The performance penalty is negligible because the time to parse your code is less than the time to execute your code.\nAnyway, in the admin interface there is a \"compile\" button that will bytecode compile your code and collapse the view hierarchy (extended and included views) into a single file per action and remove the performance penalty. It also allows you to distribute your code bytecode compiled without giving away the source. The license allows it.","Q_Score":4,"Tags":"python,performance,caching,bytecode,web2py","A_Id":3653081,"CreationDate":"2010-09-06T06:59:00.000","Title":"Is code interpreted at every call in Web2Py?","Data Science and Machine Learning":0,"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},{"Question":"I have a function defined by a combination of basic math functions (abs, cosh, sinh, exp, ...).\nI was wondering if it makes a difference (in speed) to use, for example,\nnumpy.abs() instead of abs()?","AnswerCount":3,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":39385,"Q_Id":3650194,"Users Score":25,"Answer":"You should use numpy function to deal with numpy's types and use regular python function to deal with regular python types.\nWorst performance usually occurs when mixing python builtins with numpy, because of types conversion. Those type conversion have been optimized lately, but it's still often better to not use them. Of course, your mileage may vary, so use profiling tools to figure out.\nAlso consider the use of programs like cython or making a C module if you want to optimize further your program. Or consider not to use python when performances matters.\nbut, when your data has been put into a numpy array, then numpy can be really fast at computing bunch of data.","Q_Score":67,"Tags":"python,performance,numpy","A_Id":3650761,"CreationDate":"2010-09-06T09:04:00.000","Title":"Are NumPy's math functions faster than Python's?","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},{"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},{"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},{"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},{"Question":"I have a python code base and want to know whether pyxml is really used in the code any where. The python version i have is 2.6. pyxml's last binary distribution ended with 2.4 python version. Any clues or ideas to judge the code whether it is free of pyxml 0.8.4 on python 2.6 ?\nThanks in Advance.","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":364,"Q_Id":3657165,"Users Score":1,"Answer":"grep your codebase for from xml import or import xml.","Q_Score":2,"Tags":"python","A_Id":3657249,"CreationDate":"2010-09-07T08:51:00.000","Title":"Best way to know that my Python Code base is using PyXML or not?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"If you had to judge someones level of Python understand in just 3 questions, what would you ask?","AnswerCount":2,"Available Count":2,"Score":0.1973753202,"is_accepted":false,"ViewCount":1711,"Q_Id":3660503,"Users Score":2,"Answer":"This is pretty much the same as for any language.\n\nWhat projects have you done with Python?\nWhat is your favorite Python reference?\nHave you worked with other people on code written in Python?\n\nThat's how I would judge. If I wanted to test, it would depend on whether I were looking for someone to write in 2.x or 3.x. Since I'm familiar with the 2.x stuff...\n\nHow would you create a list containing the result of [insert operation] on another list?\nHow would you do the above if you cared about memory usage?\nWhat tool do you use to debug your Python code?\n\nCW'd because the question should be.","Q_Score":0,"Tags":"python","A_Id":3660592,"CreationDate":"2010-09-07T16:17:00.000","Title":"Top 3 questions to test someones Python level, what would they be?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"If you had to judge someones level of Python understand in just 3 questions, what would you ask?","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":1711,"Q_Id":3660503,"Users Score":1,"Answer":"Explain generators.\nWrite unit tests for .\nWho is Alex Martelli?","Q_Score":0,"Tags":"python","A_Id":3660564,"CreationDate":"2010-09-07T16:17:00.000","Title":"Top 3 questions to test someones Python level, what would they be?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have substantial PHP experience, although I realize that PHP probably isn't the best language for a large-scale web crawler because a process can't run indefinitely. What languages do people suggest?","AnswerCount":7,"Available Count":4,"Score":0.0285636566,"is_accepted":false,"ViewCount":6849,"Q_Id":3664016,"Users Score":1,"Answer":"You could consider using a combination of python and PyGtkMozEmbed or PyWebKitGtk plus javascript to create your spider.\nThe spidering could be done in javascript after the page and all other scripts have loaded.\nYou'd have one of the few web spiders that supports javascript, and might pick up some hidden stuff the others don't see :)","Q_Score":3,"Tags":"php,c++,python,web-crawler","A_Id":3664065,"CreationDate":"2010-09-08T01:27:00.000","Title":"What languages are good for writing a web crawler?","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},{"Question":"I have substantial PHP experience, although I realize that PHP probably isn't the best language for a large-scale web crawler because a process can't run indefinitely. What languages do people suggest?","AnswerCount":7,"Available Count":4,"Score":-0.0855049882,"is_accepted":false,"ViewCount":6849,"Q_Id":3664016,"Users Score":-3,"Answer":"C# and C++ are probably the best two languages for this, it's just a matter of which you know better and which is faster (C# is probably easier).\nI wouldn't recommend Python, Javascript, or PHP. They will usually be slower in text processing compared to a C-family language. If you're looking to crawl any significant chunk of the web, you'll need all the speed you can get.\nI've used C# and the HtmlAgilityPack to do so before, it works relatively well and is pretty easy to pick up. The ability to use a lot of the same commands to work with HTML as you would XML makes it nice (I had experience working with XML in C#).\nYou might want to test the speed of available C# HTML parsing libraries vs C++ parsing libraries. I know in my app, I was running through 60-70 fairly messy pages a second and pulling a good bit of data out of each (but that was a site with a pretty constant layout).\nEdit: I notice you mentioned accessing a database. Both C++ and C# have libraries to work with most common database systems, from SQLite (which would be great for a quick crawler on a few sites) to midrange engines like MySQL and MSSQL up to the bigger DB engines (I've never used Oracle or DB2 from either language, but it's possible).","Q_Score":3,"Tags":"php,c++,python,web-crawler","A_Id":3664086,"CreationDate":"2010-09-08T01:27:00.000","Title":"What languages are good for writing a web crawler?","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},{"Question":"I have substantial PHP experience, although I realize that PHP probably isn't the best language for a large-scale web crawler because a process can't run indefinitely. What languages do people suggest?","AnswerCount":7,"Available Count":4,"Score":1.0,"is_accepted":false,"ViewCount":6849,"Q_Id":3664016,"Users Score":6,"Answer":"Any language you can easily use with a good network library and support for parsing the formats you want to crawl. Those are really the only qualifications.","Q_Score":3,"Tags":"php,c++,python,web-crawler","A_Id":3664054,"CreationDate":"2010-09-08T01:27:00.000","Title":"What languages are good for writing a web crawler?","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},{"Question":"I have substantial PHP experience, although I realize that PHP probably isn't the best language for a large-scale web crawler because a process can't run indefinitely. What languages do people suggest?","AnswerCount":7,"Available Count":4,"Score":1.2,"is_accepted":true,"ViewCount":6849,"Q_Id":3664016,"Users Score":0,"Answer":"C++ - if you know what you're doing. You will not need a web server and a web application, because a web crawler is just a client, after all.","Q_Score":3,"Tags":"php,c++,python,web-crawler","A_Id":3664049,"CreationDate":"2010-09-08T01:27:00.000","Title":"What languages are good for writing a web crawler?","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},{"Question":"I m trying to use smtp class from Python 2.6.4 to send smtp email from a WinXP VMware machine.\nAfter the send method is called, I always got this error:\nsocket.error: [Errno 10061] No connection could be made because the target machine actively refused it.\nFew stuff I noticed:\n\nThe same code works in the physical WinXP machine with user in\/not in the domain, connected to the same smtp server.\nIf I use the smtp server which is setup in the same VM machine, then it works.\n\nAny help is appreciate!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":828,"Q_Id":3664438,"Users Score":2,"Answer":"The phrase \"...because the target machine actively refused it\" usually means there's a firewall that drops any unauthorized connections. Is there a firewall service on the SMTP server that's blocking the WinXP VM's IP address?\nOr, more likely: Is the SMTP server not configured to accept relays from the WinXP VM's IP address?","Q_Score":1,"Tags":"python,email,smtp,vmware","A_Id":3668622,"CreationDate":"2010-09-08T03:23:00.000","Title":"Python smtp connection is always failed in a VMware Windows machine","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},{"Question":"Matz, who invented Ruby, said that he designed the language to be more object-oriented than Python. How is Ruby more object-oriented than Python?","AnswerCount":4,"Available Count":2,"Score":1.0,"is_accepted":false,"ViewCount":5970,"Q_Id":3665656,"Users Score":17,"Answer":"One example that's commonly given is len, which in Python is a built-in function. You may implement a special __len__ method in your objects which will be called by len, but len is still a function. In Ruby, objects just have the .length property\/method so it appears more object oriented when you say obj.length rather than len(obj) although deep under the hood pretty much the same thing happens.\nThat said, over the years Python have moved towards more object-orientation. Currently all objects (and implicitly user-defined objects) inherit from the object class. Meta-classes have also been added, and many of the built-in and core library classes have been organized into hierarchies with the help of ABCs (Abstract Base Classes).\nIn my heavy usage of Python I have never found it lacking in the OO department. It can do everything I want it to do with objects. True, Ruby feels somewhat more purely OO, but at least in my experience this hasn't been a really practical concern.","Q_Score":23,"Tags":"python,ruby,oop","A_Id":3665937,"CreationDate":"2010-09-08T07:55:00.000","Title":"How is Ruby more object-oriented than 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},{"Question":"Matz, who invented Ruby, said that he designed the language to be more object-oriented than Python. How is Ruby more object-oriented than Python?","AnswerCount":4,"Available Count":2,"Score":-0.0996679946,"is_accepted":false,"ViewCount":5970,"Q_Id":3665656,"Users Score":-2,"Answer":"It's simple, nearly everything in Ruby (including numbers) is an object; there are no scalar values.","Q_Score":23,"Tags":"python,ruby,oop","A_Id":3666873,"CreationDate":"2010-09-08T07:55:00.000","Title":"How is Ruby more object-oriented than 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},{"Question":"I am developing an email client in Python.\nIs it possible to check if an email contains an attachement just from the e-mail header without downloading the whole E-Mail?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":2147,"Q_Id":3676344,"Users Score":5,"Answer":"\"attachment\" is quite a broad term. Is an image for HTML message an attachment? \nIn general, you can try analyzing content-type header. If it's multipart\/mixed, most likely the message contains an attachment.","Q_Score":4,"Tags":"python,email,imap,imaplib","A_Id":3676393,"CreationDate":"2010-09-09T12:05:00.000","Title":"Is it possible to check if an email contains an attachement just from the e-mail header?","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},{"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},{"Question":"I have a compiled Python library and API docs that I would like to use from Ruby.\nIs it possible to load a Python library, instantiate a class defined in it and call methods on that object from Ruby?","AnswerCount":6,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":27863,"Q_Id":3679501,"Users Score":3,"Answer":"Even you can make this work, you might want to consider if this is the best architectural choice. You could run into all sorts of versioning hell trying to maintain such a beast.\nIf you really can't find an equivalent Ruby library (or it's a big investment in Python you want to leverage,) consider using a queue (like RabbitMQ) to implement a message passing design. Then you can keep your Python bits Python and your Ruby bits Ruby and not try to maintain a Frankenstein build environment.","Q_Score":30,"Tags":"python,ruby","A_Id":3711490,"CreationDate":"2010-09-09T18:33:00.000","Title":"Calling Python from 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":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I was wondering is learning Python and Django a hard\/time consuming process for someone who's already rather familiar with OO programming (C++\/Java) and some web dev (Java EE)?\nI'm starting to look for a technology to implement a part of my master's thesis and since it will be a web app I'm considering Java EE (since I'm already familiar with it), Python\/Django (since my professor suggested it and I'd really like to learn Python), Ruby on Rails (also my profs suggestion but somehow I don't feel like learning it) and PHP (the last suggestion but I despise PHP). Oh he also said he heard something about Scala, but from what I know Scala\/Lift isn't all that mainstream yet and it might be problematic to work with it?\nMy greatest concern is time since for the next 4-5months I'll be attending my normal courses, go to work and work on my thesis (then I'll have 4-5months for only work+my thesis) and I'm not sure will I find the time to learn a new language.\nThe whole thing will be a web app for the teachers\/students to both check and make their schedules at the uni (there will be some constraint programming etc etc and we want to implement an algorithm which would, based on data from previous years and some user input, create a schedule for the upcoming year).\nPersonally I love java but my teacher said it's a performance hog and I'd like to know is python's performance better\/worse?","AnswerCount":3,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":1938,"Q_Id":3684105,"Users Score":5,"Answer":"I'd ask your professor for some data to support \"performance hog\".  Sounds like shallow thinking and FUD to me.  Benchmarks can be found to support either position, so I don't pay much attention.\nThe real reason to learn a language is so it can affect the way you think about programming.  I think Python will be beneficial.  Shame on your professor for not bringing that up.  S\/he's worried about performance?  Ask when they last wrote code where performance mattered.\nI'm learning Python right now as a long-time Java guy.  I think learning anything takes some time.  I'm working my way through \"Core Python Programming\" by Wesley Chun.\nI'm enjoying it very much so far.  I like the language.  The ideas map pretty nicely onto what I already know about Java and OO, but there are differences (e.g., dynamic typing, functional programming, etc.) that are worth understanding.\nThe most important thing is writing code.  I'm working through the exercises carefully and getting it under my fingers and into my brain.  I'm using PyCharm from JetBrains as my IDE.  It's brilliant to have such a good tool at my fingertips.\nI started about a month ago.  I'm about 1\/3rd of the way through the exercises (reading is further ahead; about halfway).  My goal is to finish it before the end of the year and feel comfortable enough to pick up Django.  \nI hope you like it as much as I do.  Good luck.","Q_Score":2,"Tags":"java,python,django","A_Id":3684170,"CreationDate":"2010-09-10T11:08:00.000","Title":"How hard is it to learn Python\/Django for a Java EE dev?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I was wondering is learning Python and Django a hard\/time consuming process for someone who's already rather familiar with OO programming (C++\/Java) and some web dev (Java EE)?\nI'm starting to look for a technology to implement a part of my master's thesis and since it will be a web app I'm considering Java EE (since I'm already familiar with it), Python\/Django (since my professor suggested it and I'd really like to learn Python), Ruby on Rails (also my profs suggestion but somehow I don't feel like learning it) and PHP (the last suggestion but I despise PHP). Oh he also said he heard something about Scala, but from what I know Scala\/Lift isn't all that mainstream yet and it might be problematic to work with it?\nMy greatest concern is time since for the next 4-5months I'll be attending my normal courses, go to work and work on my thesis (then I'll have 4-5months for only work+my thesis) and I'm not sure will I find the time to learn a new language.\nThe whole thing will be a web app for the teachers\/students to both check and make their schedules at the uni (there will be some constraint programming etc etc and we want to implement an algorithm which would, based on data from previous years and some user input, create a schedule for the upcoming year).\nPersonally I love java but my teacher said it's a performance hog and I'd like to know is python's performance better\/worse?","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":1938,"Q_Id":3684105,"Users Score":0,"Answer":"If for your thesis and you have decided up front that you like it and want to use it, you have in my opinion the best situation conceivable.\nGo for it.  Learn all you can.  Do the best you can.\nThis will happen again and again in your professional life, and you might as well have tried it in a situation where you have an experienced mentor handy (but do as the mentor says!)","Q_Score":2,"Tags":"java,python,django","A_Id":3684145,"CreationDate":"2010-09-10T11:08:00.000","Title":"How hard is it to learn Python\/Django for a Java EE dev?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I am trying, so far unsuccessfully, at installing the rpy2 for python on my Mac OSX.  I have tried Macports and DarwinPorts but have had no luck with import rpy2 within the python shell environment.  I don't know much about programming in Mac and I am a wiz at installing modules on a Windoze based system, but for the life of me cannot do a simple port on my Mac at home.   What I am after, if someone would be so kind, are \"dumbed down\" instructions for a successful install of rpy2 for Mac OSX Snow Leopard.  Hopefully someone here has done this successfully and can outline the process they took?  At least that is what I am hoping.  Many thanks in advance!","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":7010,"Q_Id":3687939,"Users Score":2,"Answer":"easy_install and rpy2 work fine together (just did it) but you need to have easy_install in sync with your specific python version. This comes down to controlling your $PATH and $PYTHONPATH environment variables so that the first Python directory that appears is the version you want and also has the easy_install version you want. Do not try to solve this by taking out the factory installed version of Python.\nYou set your path variables in your home directory. If you are using the default bash shell, check .bash_profile for\n$ echo $PYTHONPATH\n\/Library\/Frameworks\/Python.framework\/Versions\/2.7\/lib\/python2.7\/site-packages\/\nwhich will tell you where and in what order installed packages are searched for\nand \n$ echo $PATH\n\/opt\/local\/bin:\/opt\/local\/sbin:\/Library\/Frameworks\/Python.framework\/Versions\/2.7\/bin:\/usr\/bin:\nRather than giving a recipe for how to set these if needed, I encourage you to consult the usual sources because a little knowledge is dangerous and rendering the shell inoperative by reasonable, but wrong, guesses is a real danger.","Q_Score":6,"Tags":"python,macos,osx-snow-leopard,rpy2","A_Id":3792577,"CreationDate":"2010-09-10T20:04:00.000","Title":"How to Install rpy2 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},{"Question":"I have a class named SSLXMLRPCServer. Should it be that or SslXmlRpcServer?","AnswerCount":8,"Available Count":7,"Score":1.0,"is_accepted":false,"ViewCount":2562,"Q_Id":3688759,"Users Score":6,"Answer":"It should be SSLXMLRPCServer, to match the standard library classes like SimpleXMLRPCServer, CGIXMLRPCRequestHandler, etc.  \nAdopting a naming convention that differs from equivalents in the standard library is only going to confuse people.","Q_Score":10,"Tags":"python,standards","A_Id":3688987,"CreationDate":"2010-09-10T22:15:00.000","Title":"If my python class name has an acronym, should I keep it upper case, or only the first letter?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a class named SSLXMLRPCServer. Should it be that or SslXmlRpcServer?","AnswerCount":8,"Available Count":7,"Score":1.0,"is_accepted":false,"ViewCount":2562,"Q_Id":3688759,"Users Score":10,"Answer":"This is a matter of personal preference, but I find the second format much easier to read.  The fact that your first format has a typo in it (PRC instead or RPC)  suggests that I am not the only one.","Q_Score":10,"Tags":"python,standards","A_Id":3688784,"CreationDate":"2010-09-10T22:15:00.000","Title":"If my python class name has an acronym, should I keep it upper case, or only the first letter?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a class named SSLXMLRPCServer. Should it be that or SslXmlRpcServer?","AnswerCount":8,"Available Count":7,"Score":0.024994793,"is_accepted":false,"ViewCount":2562,"Q_Id":3688759,"Users Score":1,"Answer":"As stated already, PEP-8 says to use upper-case for acronym. Now, python zen also says \"readability counts\" (and for me the zen has priority over the PEP :-).\nMy opinion in such unclear situation is to take into account the standard in the programming context, not just the language. For example, some xml-http-query class should be written XMLHttpQuery in a servlet context (w.r.t XMLHttpRequest).\nI don't know your context, but it seems XMLRPCServer exists and you want to attach ssl to it. So you could choose something like:\nSSL_XMLRPCServer\nIt would emphasized the XMLRPCServer -without changing it-. \nAlso, you'd stay close to PEP-8 and follow the zen :-)\nMy 2 cents\nNote: if XMLRPCServer is not strongly related to your class and is really a standard in the domain, then you need to choose another name, as to not be confusing.","Q_Score":10,"Tags":"python,standards","A_Id":25161275,"CreationDate":"2010-09-10T22:15:00.000","Title":"If my python class name has an acronym, should I keep it upper case, or only the first letter?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a class named SSLXMLRPCServer. Should it be that or SslXmlRpcServer?","AnswerCount":8,"Available Count":7,"Score":0.0,"is_accepted":false,"ViewCount":2562,"Q_Id":3688759,"Users Score":0,"Answer":"How about SSL_XML_RPC_Server for acronymity and readability?\nIt's what I often do when I want to avoid camel-case for some reason.","Q_Score":10,"Tags":"python,standards","A_Id":3689087,"CreationDate":"2010-09-10T22:15:00.000","Title":"If my python class name has an acronym, should I keep it upper case, or only the first letter?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a class named SSLXMLRPCServer. Should it be that or SslXmlRpcServer?","AnswerCount":8,"Available Count":7,"Score":0.024994793,"is_accepted":false,"ViewCount":2562,"Q_Id":3688759,"Users Score":1,"Answer":"I normally uppercase acronyms. Twisted and a few other libraries do this as well.","Q_Score":10,"Tags":"python,standards","A_Id":3688773,"CreationDate":"2010-09-10T22:15:00.000","Title":"If my python class name has an acronym, should I keep it upper case, or only the first letter?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a class named SSLXMLRPCServer. Should it be that or SslXmlRpcServer?","AnswerCount":8,"Available Count":7,"Score":0.0,"is_accepted":false,"ViewCount":2562,"Q_Id":3688759,"Users Score":0,"Answer":"I had this problemlots of time . I uppercase Acronym but I doesn't like it because when you chain them (as in your example) it doesn't feel right. However I think the best things to do is to make a choice and stick to hit, so at least don't you know when you need to reference something how it's written without having to check (which is one of the benefit of coding standard)","Q_Score":10,"Tags":"python,standards","A_Id":3688821,"CreationDate":"2010-09-10T22:15:00.000","Title":"If my python class name has an acronym, should I keep it upper case, or only the first letter?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a class named SSLXMLRPCServer. Should it be that or SslXmlRpcServer?","AnswerCount":8,"Available Count":7,"Score":0.0748596907,"is_accepted":false,"ViewCount":2562,"Q_Id":3688759,"Users Score":3,"Answer":"The problem with uppercase acronyms in CamelCase names is that the word following the acronym looks like a part of it, since it begins with a capital letter. Also, when you have several in a row as in your example, it is not clear where each begins. For this reason, I would probably use your second choice.","Q_Score":10,"Tags":"python,standards","A_Id":3688836,"CreationDate":"2010-09-10T22:15:00.000","Title":"If my python class name has an acronym, should I keep it upper case, or only the first letter?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":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},{"Question":"I have a program I'm writing in python, and I have the need to store some passwords. These passwords will be the passwords to ftp servers, so it's important that they're not just plainly visible to everybody. This also means that I can't store a non-reversible hash of the password like you would on a webserver, because I'm not checking if somebody inputs the right password, I'm just relaying the password to somebody else.\nSo what's the best way to store passwords? I'm using python, and the program will be linux-only.","AnswerCount":5,"Available Count":1,"Score":0.0798297691,"is_accepted":false,"ViewCount":6251,"Q_Id":3691587,"Users Score":2,"Answer":"Depending on the distribution you can probably store it in the keychain if one is available. \nOtherwise take a look at some of the encryption algorithms available (PGP\/GPG, DES, AES etc) and their Python ports\/modules but this is hard stuff which you have to get right.","Q_Score":7,"Tags":"python,passwords,storage","A_Id":3691597,"CreationDate":"2010-09-11T15:42:00.000","Title":"Storing passwords 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},{"Question":"I'm working on a python script that monitors a directory and uploads files that have been created or modified using scp. That's fine, except I want this to be done recursively, and I'm having a problem if a user creates a directory in the watch directory, and then modifies a file inside that new directory.\nI can detect the directory creation and file nested file creation\/modification just fine. But if I try to upload that file to the remote server, it won't work since the directory on the remote site won't exist. Is there a simple way to do this WITHOUT recursively copying the created directory? I want to avoid this because I don't want to delete the remote folder if it exists.\nAlso, please don't suggest rsync. It has to only use ssh and scp.","AnswerCount":3,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":5882,"Q_Id":3693666,"Users Score":0,"Answer":"It's not exactly scp, but sftp can take the -b parameter with a batch file. You can send a mkdir and a put.","Q_Score":2,"Tags":"python,scp","A_Id":3693682,"CreationDate":"2010-09-12T03:54:00.000","Title":"Using scp to transfer a single file into a remote folder that doesn't exist","Data Science and Machine Learning":0,"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},{"Question":"I'm working on a python script that monitors a directory and uploads files that have been created or modified using scp. That's fine, except I want this to be done recursively, and I'm having a problem if a user creates a directory in the watch directory, and then modifies a file inside that new directory.\nI can detect the directory creation and file nested file creation\/modification just fine. But if I try to upload that file to the remote server, it won't work since the directory on the remote site won't exist. Is there a simple way to do this WITHOUT recursively copying the created directory? I want to avoid this because I don't want to delete the remote folder if it exists.\nAlso, please don't suggest rsync. It has to only use ssh and scp.","AnswerCount":3,"Available Count":3,"Score":1.2,"is_accepted":true,"ViewCount":5882,"Q_Id":3693666,"Users Score":2,"Answer":"Since you have ssh, can't you just create the directory first?  For example, given a file with absolute path \/some\/path\/file.txt, issue a mkdir -p \/home\/path before uploading file.txt.\nUPDATE:  If you're looking to lower the number of transactions, a better method might be to make a tar file locally, transfer that, and untar it.","Q_Score":2,"Tags":"python,scp","A_Id":3693690,"CreationDate":"2010-09-12T03:54:00.000","Title":"Using scp to transfer a single file into a remote folder that doesn't exist","Data Science and Machine Learning":0,"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},{"Question":"I'm working on a python script that monitors a directory and uploads files that have been created or modified using scp. That's fine, except I want this to be done recursively, and I'm having a problem if a user creates a directory in the watch directory, and then modifies a file inside that new directory.\nI can detect the directory creation and file nested file creation\/modification just fine. But if I try to upload that file to the remote server, it won't work since the directory on the remote site won't exist. Is there a simple way to do this WITHOUT recursively copying the created directory? I want to avoid this because I don't want to delete the remote folder if it exists.\nAlso, please don't suggest rsync. It has to only use ssh and scp.","AnswerCount":3,"Available Count":3,"Score":0.0665680765,"is_accepted":false,"ViewCount":5882,"Q_Id":3693666,"Users Score":1,"Answer":"While I imagine your specific application will have its own quirks (as does mine), this may put you on the right path.  Below is a short snippet from a script I use to put files onto a remote EC2 instance using Fabric built on paramiko.  Also note I where I put the sudo commands as Fabric has its own \"sudo\" class.  This is one of those quirks I was referring to.  Hope this helps someone.\n\nfrom fabric.api import env, run, put, settings, cd\nfrom fabric.contrib.files import exists\n'''\nsudo apt-get install fabric\nInitially setup for interaction with an AWS EC2 instance\nAt the terminal prompt run:\nfab ec2 makeRemoteDirectory changePermissions putScript\n'''\nTARGETPATH = '\/your\/path\/here'\ndef ec2():\n    env.hosts = ['your EC2 Instance or remote address']\n    env.user = 'user_name'\n    env.key_filename = '\/path\/to\/your\/private_key.pem'\ndef makeRemoteDirectory():\n    if not exists('%s'%TARGETPATH):\n        run('sudo mkdir %s'%TARGETPATH)\ndef changePermissions():\n    run('sudo chown -R %(user)s:%(user)s %(path)s'%{'user': env.user, 'path': TARGETPATH})\ndef putScript():\n    fileName = '\/path\/to\/local\/file'\n    dirName = TARGETPATH\n    put(fileName, dirName)","Q_Score":2,"Tags":"python,scp","A_Id":4294064,"CreationDate":"2010-09-12T03:54:00.000","Title":"Using scp to transfer a single file into a remote folder that doesn't exist","Data Science and Machine Learning":0,"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},{"Question":"I have a webapp, created using CakePhp. I need to interface with a Python script.\nWhat is the best way to go about doing that? \n(I could use pipe etc., but I want to check what the best practices are)\nThanks.","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":1320,"Q_Id":3702724,"Users Score":1,"Answer":"First of all, check what kinds of syndication CakePHP offers. It may expose part of its API through xmlrpc, json, RSS, and so on.\nIf that's not an option, connect directly to the same database the CakePHP application uses. Or alternatively, implement some php code within your CakePHP framework that expors relevant data as JSON and interface with it.","Q_Score":0,"Tags":"php,python,cakephp","A_Id":3702748,"CreationDate":"2010-09-13T17:09:00.000","Title":"Php\/Cakephp interface with 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},{"Question":"I use TextMate to debug python script, as I like the feature of using 'Command-R' for running python from TextMate, and I learned that emacs provide similar feature. \nI need to know if the python is run from command line or from TextMate\/emacs. How can I do that? \nADDED\nI use TextMate for python coding\/debugging, and it's pretty useful. But, sometimes I need to run the test using command line. I normally turn on debugging\/logging mode with TextMate, and off with command line mode. This is the reason I asked the question. Also, I plan to use emacs for python debugging, so I wanted to ask the case for emacs.\nI got an answer in the case with emacs, and I happen to solve this issue with TextMate.\n\nSet variables in Preferences -> Advanced -> Shell Variables, and I found that TM_ORGANIZATION_NAME is already there to be used. So, I'll just use this variable.\nUse this variable, if os.environ['TM_ORGANIZATION_NAME']: return True\n\nI guess the shell variable from TextMate disappear when I'm done using it.","AnswerCount":4,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":521,"Q_Id":3702889,"Users Score":0,"Answer":"Use Command-R to run the script directly\nUse Shift-Command-R to run the script from terminal.","Q_Score":0,"Tags":"python,emacs,textmate,environment","A_Id":3703093,"CreationDate":"2010-09-13T17:32:00.000","Title":"How to know if I run python from Textmate\/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":0},{"Question":"I use TextMate to debug python script, as I like the feature of using 'Command-R' for running python from TextMate, and I learned that emacs provide similar feature. \nI need to know if the python is run from command line or from TextMate\/emacs. How can I do that? \nADDED\nI use TextMate for python coding\/debugging, and it's pretty useful. But, sometimes I need to run the test using command line. I normally turn on debugging\/logging mode with TextMate, and off with command line mode. This is the reason I asked the question. Also, I plan to use emacs for python debugging, so I wanted to ask the case for emacs.\nI got an answer in the case with emacs, and I happen to solve this issue with TextMate.\n\nSet variables in Preferences -> Advanced -> Shell Variables, and I found that TM_ORGANIZATION_NAME is already there to be used. So, I'll just use this variable.\nUse this variable, if os.environ['TM_ORGANIZATION_NAME']: return True\n\nI guess the shell variable from TextMate disappear when I'm done using it.","AnswerCount":4,"Available Count":2,"Score":0.049958375,"is_accepted":false,"ViewCount":521,"Q_Id":3702889,"Users Score":1,"Answer":"sys.argv will tell you how Python was invoked. I don't know about TextMate, but when I tell Emacs to eval buffer, its value is ['-c']. That means it's executing a specified command, according to the man page. If Python's run directly from the command line with no parameters, sys.argv will be []. If you run a python script, it will have the script name and whatever arguments you pass it. You might want to set up your python-mode in Emacs and whatever the equivalent in TextMate is to put something special like -t in the command line.\nThat's pretty hackish though. Maybe there's a better way.","Q_Score":0,"Tags":"python,emacs,textmate,environment","A_Id":3702945,"CreationDate":"2010-09-13T17:32:00.000","Title":"How to know if I run python from Textmate\/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":0},{"Question":"I've been writing python scripts that run locally. I would now like to offer a service online using one of these python scripts and through the webhosting I have I can run python in the cgi-bin.\nThe python script takes input from an html form filled in by the user, has the credentials and connects with a local database, calculates stuff using python libraries and sends out the results as HTML to be displayed.\nWhat I would like to know is what security precautions I should take. Here are my worries:\n\nWhat are the right file permissions for scripts called via web? 755?\nI am taking user input. How do I guarantee it is sanitized?\nI have user\/pass for the database in the script. How do I prevent the script from being downloaded and the code seen?\nCan I install the other libraries next to the file? Do I have to worry about security of\/in these as well? Do I set their permissions to 700? 744?\nAny other vulnerability I am unaware of?","AnswerCount":3,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":2862,"Q_Id":3703621,"Users Score":5,"Answer":"check out owasp.org - you're now writing a web application, and you need to worry about everything web apps need to worry about.  The list is too long and complicated to place here, but owasp is a good starting point.","Q_Score":2,"Tags":"python,security,cgi-bin","A_Id":3703723,"CreationDate":"2010-09-13T19:17:00.000","Title":"Security precautions for running python in cgi-bin","Data Science and Machine Learning":0,"Database and SQL":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},{"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},{"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},{"Question":"How is Python able to call C++ objects when the interpreter is C and has been built w\/ a C compiler?","AnswerCount":3,"Available Count":1,"Score":0.1325487884,"is_accepted":false,"ViewCount":1508,"Q_Id":3712125,"Users Score":2,"Answer":"C++ can interoperate with C by extern \"C\" declarations.","Q_Score":8,"Tags":"c++,python,boost-python","A_Id":3712249,"CreationDate":"2010-09-14T19:16:00.000","Title":"How does Boost.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":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I already search for it on Google but I didn't have luck.","AnswerCount":5,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":282,"Q_Id":3712885,"Users Score":0,"Answer":"dir is what you need :)","Q_Score":1,"Tags":"python,module,attributes,return","A_Id":3713156,"CreationDate":"2010-09-14T21:03:00.000","Title":"Does Python have a method that returns all the attributes in 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":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"As a hobby project, I had like to implement a Morse code encoder and decoder in C++ and Python (both). I was wondering the right data structure I should use for that. Not only is this question related to this specific project, but in general, when one has to make predefined text replacements, what is the best and the fastest way of doing it?\nI would avoid re-inventing any data structure if possible (and I think it is). Please note that this is purely a learning exercise and I have always wondered what would be the best way of doing this. I can store the code and the corresponding character in a dictionary perhaps, then iterate over the text and make replacements. Is this the best way of doing this or can I do better?","AnswerCount":7,"Available Count":1,"Score":0.057080742,"is_accepted":false,"ViewCount":265,"Q_Id":3718304,"Users Score":2,"Answer":"On the Python side the string class' translate function is the way to go.  On the C++ side I would go with a std::map to hold the character mapping. Then I would probably use std::for_each to do the look up and swap.","Q_Score":3,"Tags":"c++,python,text","A_Id":3718792,"CreationDate":"2010-09-15T13:54:00.000","Title":"Predefined text replacements in C++ 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":0},{"Question":"I would like to see what is the best way to determine the current script directory in Python.\nI discovered that, due to the many ways of calling Python code, it is hard to find a good solution.\nHere are some problems:\n\n__file__ is not defined if the script is executed with exec, execfile\n__module__ is defined only in modules\n\nUse cases:\n\n.\/myfile.py\npython myfile.py\n.\/somedir\/myfile.py\npython somedir\/myfile.py\nexecfile('myfile.py') (from another script, that can be located in another directory and that can have another current directory.\n\nI know that there is no perfect solution, but I'm looking for the best approach that solves most of the cases.\nThe most used approach is os.path.dirname(os.path.abspath(__file__)) but this really doesn't work if you execute the script from another one with exec().\nWarning\nAny solution that uses current directory will fail, this can be different based on the way the script is called or it can be changed inside the running script.","AnswerCount":16,"Available Count":1,"Score":0.0624187467,"is_accepted":false,"ViewCount":156322,"Q_Id":3718657,"Users Score":5,"Answer":"Just use os.path.dirname(os.path.abspath(__file__)) and examine very carefully whether there is a real need for the case where exec is used.  It could be a sign of troubled design if you are not able to use your script as a module.  \nKeep in mind Zen of Python #8, and if you believe there is a good argument for a use-case where it must work for exec, then please let us know some more details about the background of the problem.","Q_Score":358,"Tags":"python","A_Id":6236300,"CreationDate":"2010-09-15T14:34:00.000","Title":"How do you properly determine the current script 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},{"Question":"although there are many posts on the internet as well as some posts on stack overflow, I still want to ask about this nasty python \"import\" problem.\nOK. so, the open source code organization is usually like this:\nproject\/src\/model.py;\nproject\/test\/testmodel.py\nif I put the famous __init__.py in project directory and also in src\/ and test\/ subdirectories, \nand then put \"from project.src import model\" for the testmodel.py. \nit does not work! keep telling me that the Module named \"project.src\" is not found!\nhow can I solve the problem without changing the code structure?","AnswerCount":4,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":7796,"Q_Id":3721415,"Users Score":2,"Answer":"Make sure you have the parent directory of project\/ on your pythonpath, rather than the project directory. If you add the project path itself, imports like import project.src will look for project\/project\/src.","Q_Score":1,"Tags":"python","A_Id":3721515,"CreationDate":"2010-09-15T20:11:00.000","Title":"python import problem","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"although there are many posts on the internet as well as some posts on stack overflow, I still want to ask about this nasty python \"import\" problem.\nOK. so, the open source code organization is usually like this:\nproject\/src\/model.py;\nproject\/test\/testmodel.py\nif I put the famous __init__.py in project directory and also in src\/ and test\/ subdirectories, \nand then put \"from project.src import model\" for the testmodel.py. \nit does not work! keep telling me that the Module named \"project.src\" is not found!\nhow can I solve the problem without changing the code structure?","AnswerCount":4,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":7796,"Q_Id":3721415,"Users Score":0,"Answer":"The directory where project is located is probably not in your python path.","Q_Score":1,"Tags":"python","A_Id":3721437,"CreationDate":"2010-09-15T20:11:00.000","Title":"python import problem","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"Hi I'm currently learning Python since the syntax feels so succinct and the idioms match well with my mental model.\nHowever I'm also interested in learning about OS internals and reverse engineering software, which ultimately means knowing C in a rather thorough capacity.\nWhen originally picking a language I did lots of reading and comparisons, and it seems that a number thrown out a lot is that to write short idiomatic statements in Python would require the equivalent of a few hundred lines of C (I'd guess code for memory management, writing the code for dictionaries,lists etc) that we take for granted as built into the Python language.\n1) With an average C programmer, is that 100-200 lines of code per Python idiom anywhere near accurate?\nBecause C doesn't come built-in with Python-like constructs such as dictionaries\/lists(with all their nice methods etc):\n2) Do C programmers tend to build these constructs from scratch and then re-use them between projects to greatly reduce the actual amount of hand coding for their projects?\nI assume re-using libraries like boost:: stuff also again, reduces some of the boilerplate hand coding also...\n3) But does using popular libraries and re-using common code one has written before in C for basic constructs\/etc, how much does that revise the lines of code written in C compared to the code in Python of a enthusiast sized code base?\nI know specific numbers aren't possible, but is it possible with libraries, code reuse etc, to have a development time in C close to that of Python without being a Linus Torvalds style coding machine?\nThanks!","AnswerCount":6,"Available Count":5,"Score":0.0333209931,"is_accepted":false,"ViewCount":7636,"Q_Id":3722003,"Users Score":1,"Answer":"As I did serious c programming I read a book that claimed libraries are worth to write. (Especially in C which considered a low level language)\nLibraries are build for reuse.\nIf you use libraries you write one line like detectFace( faceDesriptor ) or renderPDF( document) is doesn't matter whether an idiom in another language is more concise or not.\nLines of code isn't a proper metric if it is about what would more efficient.","Q_Score":3,"Tags":"python,c,comparison","A_Id":3722153,"CreationDate":"2010-09-15T21:33:00.000","Title":"Python vs C : Line of Code Comparison vs Dev 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},{"Question":"Hi I'm currently learning Python since the syntax feels so succinct and the idioms match well with my mental model.\nHowever I'm also interested in learning about OS internals and reverse engineering software, which ultimately means knowing C in a rather thorough capacity.\nWhen originally picking a language I did lots of reading and comparisons, and it seems that a number thrown out a lot is that to write short idiomatic statements in Python would require the equivalent of a few hundred lines of C (I'd guess code for memory management, writing the code for dictionaries,lists etc) that we take for granted as built into the Python language.\n1) With an average C programmer, is that 100-200 lines of code per Python idiom anywhere near accurate?\nBecause C doesn't come built-in with Python-like constructs such as dictionaries\/lists(with all their nice methods etc):\n2) Do C programmers tend to build these constructs from scratch and then re-use them between projects to greatly reduce the actual amount of hand coding for their projects?\nI assume re-using libraries like boost:: stuff also again, reduces some of the boilerplate hand coding also...\n3) But does using popular libraries and re-using common code one has written before in C for basic constructs\/etc, how much does that revise the lines of code written in C compared to the code in Python of a enthusiast sized code base?\nI know specific numbers aren't possible, but is it possible with libraries, code reuse etc, to have a development time in C close to that of Python without being a Linus Torvalds style coding machine?\nThanks!","AnswerCount":6,"Available Count":5,"Score":0.0333209931,"is_accepted":false,"ViewCount":7636,"Q_Id":3722003,"Users Score":1,"Answer":"I think Python is more productive for small projects (up to a few thousand lines of code).\nOn the other hand, C is better suited for large projects (even though IMHO there are better languages for that, such as Ada): static type-checking allows to find many errors at compile time that are much more difficult to detect at run-time, especially in a large program.\nIn a larger C project, the lack of lists and other powerful data structures that are found in Python can be compensated by implementing or using custom libraries. I agree with user stacker that by using well-designed libraries your C code can be pretty concise.","Q_Score":3,"Tags":"python,c,comparison","A_Id":7054149,"CreationDate":"2010-09-15T21:33:00.000","Title":"Python vs C : Line of Code Comparison vs Dev 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},{"Question":"Hi I'm currently learning Python since the syntax feels so succinct and the idioms match well with my mental model.\nHowever I'm also interested in learning about OS internals and reverse engineering software, which ultimately means knowing C in a rather thorough capacity.\nWhen originally picking a language I did lots of reading and comparisons, and it seems that a number thrown out a lot is that to write short idiomatic statements in Python would require the equivalent of a few hundred lines of C (I'd guess code for memory management, writing the code for dictionaries,lists etc) that we take for granted as built into the Python language.\n1) With an average C programmer, is that 100-200 lines of code per Python idiom anywhere near accurate?\nBecause C doesn't come built-in with Python-like constructs such as dictionaries\/lists(with all their nice methods etc):\n2) Do C programmers tend to build these constructs from scratch and then re-use them between projects to greatly reduce the actual amount of hand coding for their projects?\nI assume re-using libraries like boost:: stuff also again, reduces some of the boilerplate hand coding also...\n3) But does using popular libraries and re-using common code one has written before in C for basic constructs\/etc, how much does that revise the lines of code written in C compared to the code in Python of a enthusiast sized code base?\nI know specific numbers aren't possible, but is it possible with libraries, code reuse etc, to have a development time in C close to that of Python without being a Linus Torvalds style coding machine?\nThanks!","AnswerCount":6,"Available Count":5,"Score":1.2,"is_accepted":true,"ViewCount":7636,"Q_Id":3722003,"Users Score":6,"Answer":"Boost is C++, not C (emphatically not C -- virtually all of it makes heavy use of templates and such that aren't part of C).\nYes, C programmers tend to build up personal libraries of code for all sorts of \"stuff\" -- data structures, algorithms, user interfaces, and so on. There are also a fair number of other libraries for everything from basic string manipulation to database connectivity, user interfaces, basic algorithms and data structures, etc.\nComparing productivity between the two can be difficult though -- even if something can be done in one line of code either way, there's a greater chance that the C programmer will end up doing extra work to find and learn to use that particular library. OTOH, if he has used it before, the two might be directly competitive of (in a few cases) C might be more productive.\nI'd guess Python ends up more productive more often, but trying to guess how much so is difficult (and lines of code usually won't be a good indication either).","Q_Score":3,"Tags":"python,c,comparison","A_Id":3722185,"CreationDate":"2010-09-15T21:33:00.000","Title":"Python vs C : Line of Code Comparison vs Dev 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},{"Question":"Hi I'm currently learning Python since the syntax feels so succinct and the idioms match well with my mental model.\nHowever I'm also interested in learning about OS internals and reverse engineering software, which ultimately means knowing C in a rather thorough capacity.\nWhen originally picking a language I did lots of reading and comparisons, and it seems that a number thrown out a lot is that to write short idiomatic statements in Python would require the equivalent of a few hundred lines of C (I'd guess code for memory management, writing the code for dictionaries,lists etc) that we take for granted as built into the Python language.\n1) With an average C programmer, is that 100-200 lines of code per Python idiom anywhere near accurate?\nBecause C doesn't come built-in with Python-like constructs such as dictionaries\/lists(with all their nice methods etc):\n2) Do C programmers tend to build these constructs from scratch and then re-use them between projects to greatly reduce the actual amount of hand coding for their projects?\nI assume re-using libraries like boost:: stuff also again, reduces some of the boilerplate hand coding also...\n3) But does using popular libraries and re-using common code one has written before in C for basic constructs\/etc, how much does that revise the lines of code written in C compared to the code in Python of a enthusiast sized code base?\nI know specific numbers aren't possible, but is it possible with libraries, code reuse etc, to have a development time in C close to that of Python without being a Linus Torvalds style coding machine?\nThanks!","AnswerCount":6,"Available Count":5,"Score":1.0,"is_accepted":false,"ViewCount":7636,"Q_Id":3722003,"Users Score":10,"Answer":"but is it possible with libraries, code reuse etc, to have a development time in C close to that of Python\n\nNo.\nYou've missed the most important point.  \nPython's interactive.  It's not edit-compile-link-execute-break-debug.  It's edit-debug.","Q_Score":3,"Tags":"python,c,comparison","A_Id":3722732,"CreationDate":"2010-09-15T21:33:00.000","Title":"Python vs C : Line of Code Comparison vs Dev 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},{"Question":"Hi I'm currently learning Python since the syntax feels so succinct and the idioms match well with my mental model.\nHowever I'm also interested in learning about OS internals and reverse engineering software, which ultimately means knowing C in a rather thorough capacity.\nWhen originally picking a language I did lots of reading and comparisons, and it seems that a number thrown out a lot is that to write short idiomatic statements in Python would require the equivalent of a few hundred lines of C (I'd guess code for memory management, writing the code for dictionaries,lists etc) that we take for granted as built into the Python language.\n1) With an average C programmer, is that 100-200 lines of code per Python idiom anywhere near accurate?\nBecause C doesn't come built-in with Python-like constructs such as dictionaries\/lists(with all their nice methods etc):\n2) Do C programmers tend to build these constructs from scratch and then re-use them between projects to greatly reduce the actual amount of hand coding for their projects?\nI assume re-using libraries like boost:: stuff also again, reduces some of the boilerplate hand coding also...\n3) But does using popular libraries and re-using common code one has written before in C for basic constructs\/etc, how much does that revise the lines of code written in C compared to the code in Python of a enthusiast sized code base?\nI know specific numbers aren't possible, but is it possible with libraries, code reuse etc, to have a development time in C close to that of Python without being a Linus Torvalds style coding machine?\nThanks!","AnswerCount":6,"Available Count":5,"Score":0.0,"is_accepted":false,"ViewCount":7636,"Q_Id":3722003,"Users Score":0,"Answer":"Depends greatly on the task and the size of the project. For many small interesting tasks, I would not be surprised by 100:1 smaller Python code simply because the standard libraries are extremely good. If you find, buy, or build C\/C++ libraries that do what you want, I imagine the ratio would be much more like 3:1 on big projects. \nHowever, finding, buying, and building C\/C++ libraries does take time and effort, so I believe in the vast majority of cases, Python is going to be much faster to develop in.","Q_Score":3,"Tags":"python,c,comparison","A_Id":3790500,"CreationDate":"2010-09-15T21:33:00.000","Title":"Python vs C : Line of Code Comparison vs Dev 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},{"Question":"I am writing a python\/pygtk application that is adding some custom scripts (bash) in a certain folder in $HOME (eg. ~\/.custom_scripts). \nI want to make that folder available in $PATH. So every time the python app is adding the script, that script could be instantly available when the user is opening a terminal (eg. gnome-terminal). \nWhere do you suggest to \"inject\" that $PATH dependecy ? .bashrc, \/etc\/profile.d, etc. ?\nWhat advantages \/ disadvantages I might encounter ?\nFor example if i add a script to export the new path in \/etc\/profile.d, the path is not being updated until I re-login.\nThanks","AnswerCount":7,"Available Count":5,"Score":0.0285636566,"is_accepted":false,"ViewCount":3792,"Q_Id":3729965,"Users Score":1,"Answer":"You shouldn't. It's the user choice whether he wants that in the PATH, in what cases and how to achieve that. What you can do is inform the user about the directory where your scripts reside and suggest putting it to the PATH.\nOr maybe you're asking from the user's perspective?","Q_Score":3,"Tags":"python,scripting,path,bash","A_Id":3730090,"CreationDate":"2010-09-16T19:17:00.000","Title":"How to update $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},{"Question":"I am writing a python\/pygtk application that is adding some custom scripts (bash) in a certain folder in $HOME (eg. ~\/.custom_scripts). \nI want to make that folder available in $PATH. So every time the python app is adding the script, that script could be instantly available when the user is opening a terminal (eg. gnome-terminal). \nWhere do you suggest to \"inject\" that $PATH dependecy ? .bashrc, \/etc\/profile.d, etc. ?\nWhat advantages \/ disadvantages I might encounter ?\nFor example if i add a script to export the new path in \/etc\/profile.d, the path is not being updated until I re-login.\nThanks","AnswerCount":7,"Available Count":5,"Score":0.057080742,"is_accepted":false,"ViewCount":3792,"Q_Id":3729965,"Users Score":2,"Answer":".profile would be a reasonable place if it's a per-user install; \/etc\/profile.d for system-wide installs.  (You'll need root to do that, of course.)  \nYour installer won't be able to change the path of the current shell (unless it's being run via source, which would be...odd.)","Q_Score":3,"Tags":"python,scripting,path,bash","A_Id":3730011,"CreationDate":"2010-09-16T19:17:00.000","Title":"How to update $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},{"Question":"I am writing a python\/pygtk application that is adding some custom scripts (bash) in a certain folder in $HOME (eg. ~\/.custom_scripts). \nI want to make that folder available in $PATH. So every time the python app is adding the script, that script could be instantly available when the user is opening a terminal (eg. gnome-terminal). \nWhere do you suggest to \"inject\" that $PATH dependecy ? .bashrc, \/etc\/profile.d, etc. ?\nWhat advantages \/ disadvantages I might encounter ?\nFor example if i add a script to export the new path in \/etc\/profile.d, the path is not being updated until I re-login.\nThanks","AnswerCount":7,"Available Count":5,"Score":0.057080742,"is_accepted":false,"ViewCount":3792,"Q_Id":3729965,"Users Score":2,"Answer":"For scripts that go in the $HOME directory you'd typically use $HOME\/bin folder instead which is (usually) on the path.","Q_Score":3,"Tags":"python,scripting,path,bash","A_Id":3730014,"CreationDate":"2010-09-16T19:17:00.000","Title":"How to update $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},{"Question":"I am writing a python\/pygtk application that is adding some custom scripts (bash) in a certain folder in $HOME (eg. ~\/.custom_scripts). \nI want to make that folder available in $PATH. So every time the python app is adding the script, that script could be instantly available when the user is opening a terminal (eg. gnome-terminal). \nWhere do you suggest to \"inject\" that $PATH dependecy ? .bashrc, \/etc\/profile.d, etc. ?\nWhat advantages \/ disadvantages I might encounter ?\nFor example if i add a script to export the new path in \/etc\/profile.d, the path is not being updated until I re-login.\nThanks","AnswerCount":7,"Available Count":5,"Score":1.2,"is_accepted":true,"ViewCount":3792,"Q_Id":3729965,"Users Score":1,"Answer":"~\/.bashrc is read every time gnome-terminal is opened, (assuming the user has SHELL set to \/bin\/bash).\nBe sure to check os.environ['PATH'] to see if the directory has already been added, so that the script doesn't add it more than once.","Q_Score":3,"Tags":"python,scripting,path,bash","A_Id":3730027,"CreationDate":"2010-09-16T19:17:00.000","Title":"How to update $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},{"Question":"I am writing a python\/pygtk application that is adding some custom scripts (bash) in a certain folder in $HOME (eg. ~\/.custom_scripts). \nI want to make that folder available in $PATH. So every time the python app is adding the script, that script could be instantly available when the user is opening a terminal (eg. gnome-terminal). \nWhere do you suggest to \"inject\" that $PATH dependecy ? .bashrc, \/etc\/profile.d, etc. ?\nWhat advantages \/ disadvantages I might encounter ?\nFor example if i add a script to export the new path in \/etc\/profile.d, the path is not being updated until I re-login.\nThanks","AnswerCount":7,"Available Count":5,"Score":0.0285636566,"is_accepted":false,"ViewCount":3792,"Q_Id":3729965,"Users Score":1,"Answer":"\/etc\/profile.d would add it to every user's path\n~\/.bashrc would just be your own\nyou can always do \"$ source ~\/.bashrc\" to re-read the config files.","Q_Score":3,"Tags":"python,scripting,path,bash","A_Id":3730001,"CreationDate":"2010-09-16T19:17:00.000","Title":"How to update $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},{"Question":"Is there some ready-made addon that alerts admins about memcached instance being inaccessible from a Django application? I don't mean here monitoring memcached daemon itself, but something that checks if my Django app benefits from caching.\nMy basic idea is to check if cache.get that follow cache.set actually returns something, and if not - then send email to admins, but only one per hour, to not flood the inbox. \nBut maybe there is something more advanced out there ?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":481,"Q_Id":3735183,"Users Score":5,"Answer":"You should monitor your infrastructure. You can use a huge variety of tools for this, look on server fault for more discussions on monitoring.\nYou should probably monitor your cache hit rate and trend it in your monitoring system; if it falls below a figure (say 90%) then you can alert that the cache has stopped working or something.\nMemcached itself will have some way of monitoring hit rate, but that will be overall rather than for a specific part of your application. You probably want to monitor the hit rate for a specific cache instance in your code so you can be sure it's continuing to be effective.","Q_Score":2,"Tags":"python,django,memcached,python-memcached","A_Id":3735232,"CreationDate":"2010-09-17T12:11:00.000","Title":"Django - alert when memcached is down","Data Science and Machine Learning":0,"Database and SQL":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},{"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},{"Question":"I am building a system that has dependencies such as Apache, Postgresql, and mod_wsgi. As part of my deployment process, I would like to write a sanity-checking script that tries to determine whether the server environment conforms to various assumptions, the most basic of which is whether the dependencies are installed.\nChecks I have considered:\n\nCheck the service is responding, e.g. make an HTTP request, connect to a database, etc.\nCheck somehow that a service is running, e.g. maybe grepping ps ax?\n(This seems unreliable)\nCheck that the package is installed, e.g. through querying dpkg.\n\nThese obviously go in order of decreasing specificity, the hope being that if one test fails, I might find out why by running a more specific test.\nBut where do I stop? How many levels of specificity should I check? Are there any best practices for doing this sort of thing?\nThanks!","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":533,"Q_Id":3746090,"Users Score":1,"Answer":"I would run the program and do proper try..except at place of first use of feature in informative message to user for what is missing (not installed db, installed but not running etc)","Q_Score":4,"Tags":"python,deployment,packages","A_Id":3746128,"CreationDate":"2010-09-19T14:29:00.000","Title":"Best practices for programmatically sanity checking environment 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},{"Question":"I am amazed by how Expect (TCL) can automate a lot of things I normally could not do.\nI thought I could dig deeper into Expect by reading a book, but before I do that I want to ask if there are other solutions\/languages that could do what Expect does?\nEg. I have read that people compare Expect with Awk and also Perl.\nCould Awk and Perl do the same thing?\nHow about other languages like Python and Ruby?\nIs Expect the de-facto automation tool or are there other solutions\/languages that are more superior?","AnswerCount":4,"Available Count":2,"Score":0.1973753202,"is_accepted":false,"ViewCount":1532,"Q_Id":3746221,"Users Score":4,"Answer":"ajsie asks, \"Which other automation tools are you talking about?\"  \nI'll answer a different question:  \"which other contexts do I have in mind\"?  The answer:  any interactive environment OTHER than a stdio one.  Expect is NOT for automation of GUI points-and-clicks, for example.  Expect is also not available for Win* non-console applications, even if they look as though they are character-oriented (such exist).\nAn exciting counter-realization:  Expect is for automation of wacky equipment that permits control by a term-like connection.  If your diesel engine (or, more typically, telecomm iron) says it can be monitored by hooking up a telnet-like process (even through an old-style serial line, say), you're in a domain where Expect has a chance to work its magic.","Q_Score":8,"Tags":"python,perl,awk,tcl,expect","A_Id":3747275,"CreationDate":"2010-09-19T15:11:00.000","Title":"Other solutions\/languages that are superior to the TCL-based Expect?","Data Science and Machine Learning":0,"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},{"Question":"I am amazed by how Expect (TCL) can automate a lot of things I normally could not do.\nI thought I could dig deeper into Expect by reading a book, but before I do that I want to ask if there are other solutions\/languages that could do what Expect does?\nEg. I have read that people compare Expect with Awk and also Perl.\nCould Awk and Perl do the same thing?\nHow about other languages like Python and Ruby?\nIs Expect the de-facto automation tool or are there other solutions\/languages that are more superior?","AnswerCount":4,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":1532,"Q_Id":3746221,"Users Score":9,"Answer":"There's more to it.\nBluntly, the original Expect--the Tcl Expect--is the best one.  It better supports \"interact\" and various pty eccentricities than any of its successors.  It has no superior, for what it does.\nHOWEVER, at the same time, most Expect users exploit such a small fraction of Expect's capabilities that this technical superiority is a matter of indifference to them.  In nearly all cases, I advise someone coming from Perl to use Expect.pm, someone familiar with Python to rely on Pexpect, and so on.\nNaive comparisons of Perl with \"... Awk and also Perl\" are ill-founded.\nIn the abstract, all the common scripting languages--Lua, awk, sh, Tcl, Ruby, Perl, Python, ...--are about the same.  Expect slightly but very effectively extends this common core in the direction of pty-awareness (there's a little more to the story that we can neglect for the moment).  Roughly speaking, if your automation involves entering an invisible password, you want Expect.  Awk and Perl do NOT build in this capability.\nThere are other automation tools for other contexts.","Q_Score":8,"Tags":"python,perl,awk,tcl,expect","A_Id":3747203,"CreationDate":"2010-09-19T15:11:00.000","Title":"Other solutions\/languages that are superior to the TCL-based Expect?","Data Science and Machine Learning":0,"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},{"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},{"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},{"Question":"I have a python script which generates some reports based on a DB.\nI am testing the script using java Db Units which call the python script.\nMy question is how can I verify the code coverage for the python script while I am running the DB Units?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":172,"Q_Id":3749729,"Users Score":0,"Answer":"I don't know how you can check for inter-language unit test coverage. You will have to tweak the framework yourself to achieve something like this.\nThat said, IMHO this is a wrong approach to take for various reasons. \n\nInter-language disqualifies the tests from being described as \"unit\". These are functional tests. and thereby shouldn't care about code coverage (See @Ned's comment below). \nIf you must (unit) test the Python code then I suggest that you do it using Python. This will also solve your problem of checking for test coverage.\nIf you do want to function test then it would be good idea to keep Python code coverage checks away from Java. This would reduce the coupling between the Java and Python code. Tests are code after all and it is usually a good idea to reduce coupling between parts.","Q_Score":0,"Tags":"python,code-coverage","A_Id":3749902,"CreationDate":"2010-09-20T08:26:00.000","Title":"While running some java DB Unit tests which call a python script how can I test the code coverage for the 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},{"Question":"I'm writing an application and I'd like it to somehow schedule an email to be sent at a later date (likely an hour after it is run). The programming language will be Python or Java.\nAny open-source tools available for that purpose?\nEDIT: I forgot to mention it's to be run after a test run, so the application will already be down and I believe the Quartz solution wouldn't work. Would this be possible?\nIdeally, I'd like to hear that SMTP protocol has some hidden stuff that allows this, and would just require adding some flag to the message and email providers would interpret as to having to send them later.","AnswerCount":6,"Available Count":2,"Score":0.0333209931,"is_accepted":false,"ViewCount":4238,"Q_Id":3753982,"Users Score":1,"Answer":"I don't think standard SMTP protocol has such a feature, so if you want to be platform-independent, you will have to search for another solution.\nHow about writing your message to a queue (local database, for example) with a timestamp and then have some program watching it periodically and send pending emails out?\nIs the delay an exact timedelta or is it \"1-2 hours later\"? If it is the latter, than you can have an hourly job (cronjob starting every hour or a background job sleeping for an hour), which would then send out the emails.","Q_Score":1,"Tags":"java,python,email,scheduling","A_Id":3754181,"CreationDate":"2010-09-20T17:47:00.000","Title":"Scheduling a time in the future to send an email in Java 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":0,"Web Development":0},{"Question":"I'm writing an application and I'd like it to somehow schedule an email to be sent at a later date (likely an hour after it is run). The programming language will be Python or Java.\nAny open-source tools available for that purpose?\nEDIT: I forgot to mention it's to be run after a test run, so the application will already be down and I believe the Quartz solution wouldn't work. Would this be possible?\nIdeally, I'd like to hear that SMTP protocol has some hidden stuff that allows this, and would just require adding some flag to the message and email providers would interpret as to having to send them later.","AnswerCount":6,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":4238,"Q_Id":3753982,"Users Score":2,"Answer":"You can build the actual email to send, using JavaMail (with attachments and all), save it to disk, and then delegate a \"mail foo@bar.com < textfilefromjavamail\" to the Linux batch system.  \nThere is an \"at\" command which will most likely do exactly what you want.","Q_Score":1,"Tags":"java,python,email,scheduling","A_Id":3754446,"CreationDate":"2010-09-20T17:47:00.000","Title":"Scheduling a time in the future to send an email in Java 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":0,"Web Development":0},{"Question":"I'm curious how to copy the permission from directory to another.\nAny idea?\nThanks","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":1862,"Q_Id":3754848,"Users Score":1,"Answer":"Try cp -a from_dir to_dir. It will maintain the permissions from the first directory.","Q_Score":1,"Tags":"python,permissions","A_Id":3754917,"CreationDate":"2010-09-20T19:33:00.000","Title":"How to copy directory permissions","Data Science and Machine Learning":0,"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},{"Question":"Is there any production ready open source twitter clones written in Ruby or Python ?\nI am more interested in feature rich implementations, not just bare bones twitter like messages (e.g.: APIs, FBconnect, Notifications, etc)\nThanks !","AnswerCount":4,"Available Count":1,"Score":0.1488850336,"is_accepted":false,"ViewCount":2578,"Q_Id":3758440,"Users Score":3,"Answer":"I know of twissandra which is an open source clone. Of course I doubt it meets your need of feature rich implementations.","Q_Score":6,"Tags":"python,ruby,twitter","A_Id":3758455,"CreationDate":"2010-09-21T08:16:00.000","Title":"Open source Twitter clone (in Ruby\/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},{"Question":"I'm writing an application where quite a bit of the computational time will be devoted to performing basic linear algebra operations (add, multiply, multiply by vector, multiply by scalar, etc.) on sparse matrices and vectors. Up to this point, we've built a prototype using C++ and the Boost matrix library. \nI'm considering switching to Python, to ease of coding the application itself, since it seems the Boost library (the easy C++ linear algebra library) isn't particularly fast anyway. This is a research\/proof of concept application, so some reduction of run time speed is acceptable (as I assume C++ will almost always outperform Python) so long as coding time is also significantly decreased.\nBasically, I'm looking for general advice from people who have used these libraries before. But specifically:\n1) I've found scipy.sparse and and pySparse. Are these (or other libraries) recommended?\n2) What libraries beyond Boost are recommended for C++? I've seen a variety of libraries with C interfaces, but again I'm looking to do something with low complexity, if I can get relatively good performance.\n3) Ultimately, will Python be somewhat comparable to C++ in terms of run time speed for the linear algebra operations? I will need to do many, many linear algebra operations and if the slowdown is significant then I probably shouldn't even try to make this switch.\nThank you in advance for any help and previous experience you can relate.","AnswerCount":5,"Available Count":2,"Score":0.0798297691,"is_accepted":false,"ViewCount":3064,"Q_Id":3761994,"Users Score":2,"Answer":"I don't have directly applicable experience, but the scipy\/numpy operations are almost all implemented in C.  As long as most of what you need to do is expressed in terms of scipy\/numpy functions, then your code shouldn't be much slower than equivalent C\/C++.","Q_Score":4,"Tags":"c++,python,linear-algebra","A_Id":3762217,"CreationDate":"2010-09-21T15:45:00.000","Title":"Python vs. C++ for an application that does sparse linear algebra","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},{"Question":"I'm writing an application where quite a bit of the computational time will be devoted to performing basic linear algebra operations (add, multiply, multiply by vector, multiply by scalar, etc.) on sparse matrices and vectors. Up to this point, we've built a prototype using C++ and the Boost matrix library. \nI'm considering switching to Python, to ease of coding the application itself, since it seems the Boost library (the easy C++ linear algebra library) isn't particularly fast anyway. This is a research\/proof of concept application, so some reduction of run time speed is acceptable (as I assume C++ will almost always outperform Python) so long as coding time is also significantly decreased.\nBasically, I'm looking for general advice from people who have used these libraries before. But specifically:\n1) I've found scipy.sparse and and pySparse. Are these (or other libraries) recommended?\n2) What libraries beyond Boost are recommended for C++? I've seen a variety of libraries with C interfaces, but again I'm looking to do something with low complexity, if I can get relatively good performance.\n3) Ultimately, will Python be somewhat comparable to C++ in terms of run time speed for the linear algebra operations? I will need to do many, many linear algebra operations and if the slowdown is significant then I probably shouldn't even try to make this switch.\nThank you in advance for any help and previous experience you can relate.","AnswerCount":5,"Available Count":2,"Score":0.0399786803,"is_accepted":false,"ViewCount":3064,"Q_Id":3761994,"Users Score":1,"Answer":"Speed nowdays its no longer an issue for python  since ctypes and cython emerged. Whats brilliant about cython is that your write python code and it generates c code without requiring from you to know a single line of c and then compiles to a library or you could even create a stanalone. Ctypes also is similar though abit slower. From the tests I have conducted cython code is as fast as c code and that make sense since cython code is translated to c code. Ctypes is abit slower.\nSo in the end its a question of profiling , see what is slow in python and move it to cython, or you could wrap your existing c libraries for python with cython. Its quite easy to achieve c speeds this way. \nSo I will recommend not to waste the effort you invested creating these c libraries , wrap them with cython and do the rest with python. Or you could do all of it with cython if you wish as cython is python bar some limitations. And even allows you to mix c code as well. So you could do part of it in c and part of it python\/cython. Depending what makes you feel more comfortable.\nNumpy ans SciPy could be used as well for saving more time and providing ready to use solutions to your problems \/ needs.You should certainly check them out. Numpy has even has weaver a tool that let you inline c code inside your python code, just like you can inline assembly code inside your c code. But i think you would prefer to use cython . Remember because cython is both c and python at the same time it allows you to use directly c and python libraries.","Q_Score":4,"Tags":"c++,python,linear-algebra","A_Id":3762759,"CreationDate":"2010-09-21T15:45:00.000","Title":"Python vs. C++ for an application that does sparse linear algebra","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},{"Question":"I am interested in programming for Mobile Devices.\nNow I have a phone which runs Symbian S60 3rd, which is one of my motivations for programming for mobile devices.\nNow, my question is, which one is better to go for?\nPython or C++?\nI have a good background in C++ (ANSI), Java and C#.\nThanks.","AnswerCount":5,"Available Count":2,"Score":0.0399786803,"is_accepted":false,"ViewCount":1838,"Q_Id":3763766,"Users Score":1,"Answer":"Python is more easy to use, but you have to know that a mobile is normally a very strict environment, so is possible that C++ be a better alternative.","Q_Score":0,"Tags":"c++,python,symbian","A_Id":3763786,"CreationDate":"2010-09-21T19:31:00.000","Title":"Python or C++? Programming for mobile devices","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},{"Question":"I am interested in programming for Mobile Devices.\nNow I have a phone which runs Symbian S60 3rd, which is one of my motivations for programming for mobile devices.\nNow, my question is, which one is better to go for?\nPython or C++?\nI have a good background in C++ (ANSI), Java and C#.\nThanks.","AnswerCount":5,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":1838,"Q_Id":3763766,"Users Score":2,"Answer":"There's a large learning curve associated with Symbian C++, if you want to do a quick prototype probably do it in Python.\nIt depends on what you want your application to do. I believe the Symbian Python implementation was done in some Symbian developers spare time so it may not give you access to everything on the phone. Symbian C++ will give you access to almost everything.\nAlso, Java and MIDP may be useful to you too.","Q_Score":0,"Tags":"c++,python,symbian","A_Id":3763991,"CreationDate":"2010-09-21T19:31:00.000","Title":"Python or C++? Programming for mobile devices","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},{"Question":"I am trying to use python's imaplib to create an email and send it to a mailbox with specific name, e.g. INBOX. Anyone has some great suggestion :).","AnswerCount":4,"Available Count":1,"Score":-1.0,"is_accepted":false,"ViewCount":18674,"Q_Id":3769701,"Users Score":-6,"Answer":"No idea how they do it but doesn't Microsoft Outlook let you move an email from a local folder to a remote IMAP folder?","Q_Score":5,"Tags":"python,imaplib","A_Id":3787209,"CreationDate":"2010-09-22T13:28:00.000","Title":"How to create an email and send it to specific mailbox with imaplib","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},{"Question":"I'm sure you've seen the \"the connection was reset\" message displayed when trying to browse web pages.  (The text is from Firefox, other browsers differ.)\nI need to generate that message\/error\/condition on demand, to test workarounds.\nSo, how do I generate that condition programmatically?  (How to generate a TCP RST from PHP -- or one of the other web-app languages?)\nCaveats and Conditions:\n\nIt cannot be a general IP block.  The test client must still be able to see the test server when not triggering the condition.\nIdeally, it would be done at the web-application level (Python, PHP, Coldfusion, Javascript, etc.).   Access to routers is problematic.  Access to Apache config is a pain.\nIdeally, it would be triggered by fetching a specific web-page.\nBonus if it works on a standard, commercial web host.\n\nUpdate:\nSending RST is not enough to cause this condition.  See my partial answer, below.\nI've a solution that works on a local machine, Now need to get it working on a remote host.","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":3959,"Q_Id":3773566,"Users Score":1,"Answer":"I believe you need to close the low-level socket fairly abruptly. You won't be able to do it from Javascript. For the other languages you'll generally need to get a handle on the underlying socket object and close() it manually.\nI also doubt you can do this through Apache since it is Apache and not your application holding the socket. At best your efforts are likely to generate a HTTP 500 error which is not what you're after.","Q_Score":8,"Tags":"php,python,sockets,web-applications,tcp","A_Id":3773702,"CreationDate":"2010-09-22T20:56:00.000","Title":"How do I generate a connection reset programatically?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"For a project I'm currently working on, I'm looking to embed a scripting engine into my C++ code to allow for some extensibility down the line.  The application will require a fair amount of text processing and the use of regular expressions within these scripts.\nI know Lua is generally the industry darling when it comes to embedded scripting, but I also know it doesn't support regular expressions (at least out of the box).  This is causing me to lean toward python for my language to embed, as it seems to have the best support behind Lua and still offers powerful regex capabilities.\nIs this the right choice? Should I be looking at another language?  Is there a reason I should give Lua a second look?","AnswerCount":4,"Available Count":2,"Score":0.2449186624,"is_accepted":false,"ViewCount":9483,"Q_Id":3774108,"Users Score":5,"Answer":"Having incorporated Lua in one of my C projects myself, I'll suggest Lua, as this is easier.\nBut that depends on what your scripting language needs to be capable of. Lua rose to the de-facto scripting language of games. If you need advanced scripting capabilities, you might use Python, but if it's just for easy scripting support, take Lua. From what I've seen, Lua is easier to learn for newbees, that aren't used to scripting.\nI'd argue, that Lua is lighter, if you need to have external packages, you can add them, but the point is, the atomic part of Lua, is much smaller than that of Python.","Q_Score":16,"Tags":"c++,python,scripting,lua,embedded-language","A_Id":3774415,"CreationDate":"2010-09-22T22:30:00.000","Title":"Python vs Lua for embedded scripting\/text processing 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":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"For a project I'm currently working on, I'm looking to embed a scripting engine into my C++ code to allow for some extensibility down the line.  The application will require a fair amount of text processing and the use of regular expressions within these scripts.\nI know Lua is generally the industry darling when it comes to embedded scripting, but I also know it doesn't support regular expressions (at least out of the box).  This is causing me to lean toward python for my language to embed, as it seems to have the best support behind Lua and still offers powerful regex capabilities.\nIs this the right choice? Should I be looking at another language?  Is there a reason I should give Lua a second look?","AnswerCount":4,"Available Count":2,"Score":0.1973753202,"is_accepted":false,"ViewCount":9483,"Q_Id":3774108,"Users Score":4,"Answer":"dont forget the grand-daddy of them all - tcl\nthere is a c++ wrapper for tcl which makes it incredibly easy to embed\ni am using it in a current project\nin previous (c#) project I used lua over python. In older c# projects I had used python;\nI chose lua because the syntax is more normal for average scripter (used to vbscript or javascript). However I will change back to (iron)python for next c# project; lua is just too obscure\nFor c++ I will always use tcl from now on\nEDIT: My new favorite is jint (.net javascriptt interpreter) v easy to use, nice interface. And nobody can complain about the language given that js is the cool language at the moment","Q_Score":16,"Tags":"c++,python,scripting,lua,embedded-language","A_Id":3774148,"CreationDate":"2010-09-22T22:30:00.000","Title":"Python vs Lua for embedded scripting\/text processing 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":1,"System Administration and DevOps":0,"Web Development":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},{"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},{"Question":"I have no idea what could be the problem here:\nI have some modules from Biopython which I can import easily when using the interactive prompt or executing python scripts via the command-line.\nThe problem is, when I try and import the same biopython modules in a web-executable cgi script, I get a \"Import Error\"\n\n: No\n  module named Bio\n\nAny ideas here?","AnswerCount":3,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":9473,"Q_Id":3783887,"Users Score":7,"Answer":"Here are a couple of possibilities:\n\nApache (on Unix) generally runs as a different user, and with a different environment, to python from the command line. Try making a small script that just prints out sys.version and sys.prefix, and compare the result through apache and via the command line, to make sure that you're running from the same installation of python in both environments.\nIs Biopython installed under your home directory, or only readable just for your normal user? Again, because apache generally runs as a different user, perhaps you don't have access to that location, so can't import it.\nCan you try doing import site before trying to import Biopython? Perhaps something is preventing site packages from being imported when you run through apache.","Q_Score":9,"Tags":"python,cgi,bioinformatics,biopython","A_Id":3784056,"CreationDate":"2010-09-24T02:42:00.000","Title":"Why can't python find some modules when I'm running CGI scripts from the web?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I've written a class whose .__hash__() implementation takes a long time to execute. I've been thinking to cache its hash, and store it in a variable like ._hash so the .__hash__() method would simply return ._hash. (Which will be computed either at the end of the .__init__() or the first time .__hash__() is called.)\nMy reasoning was: \"This object is immutable -> Its hash will never change -> I can cache the hash.\"\nBut now that got me thinking: You can say the same thing about any hashable object. (With the exception of objects whose hash is their id.)\nSo is there ever a reason not to cache an object's hash, except for small objects whose hash computation is very fast?","AnswerCount":3,"Available Count":1,"Score":-0.0665680765,"is_accepted":false,"ViewCount":2299,"Q_Id":3787405,"Users Score":-1,"Answer":"The usual reason is that most objects in Python are mutable, so if the hash depends on the properties, it changes as soon as you change a property. If your class really is an immutable and (all the properties which go into the hash are immutable, too!), then you can cache the hash.","Q_Score":14,"Tags":"python,caching,hash","A_Id":3787439,"CreationDate":"2010-09-24T13:13:00.000","Title":"Is there any reason *not* to cache an object's hash?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I was wondering if there was a way that you could get init code to run upon importing a .NET assembly using clr.AddReference(), in the same way that importing a python file executes the init.py code that resides in the same directory.  Thanks in advance!","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":416,"Q_Id":3789716,"Users Score":1,"Answer":"It is not possible.\nThe only way is to change the clr.AddReference method. As IronPython is open source it should be easy.","Q_Score":0,"Tags":"ironpython","A_Id":3803617,"CreationDate":"2010-09-24T17:58:00.000","Title":"IronPython: how can I run init code when I import a module using clr.AddReference()?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Which one among the two languages is good for statistical analysis? What are the pros and cons, other than accessibility, for each?","AnswerCount":5,"Available Count":2,"Score":0.0798297691,"is_accepted":false,"ViewCount":1096,"Q_Id":3792465,"Users Score":2,"Answer":"SciPy, NumPy and Matplotlib.","Q_Score":8,"Tags":"python,matlab,statistics,analysis","A_Id":3792494,"CreationDate":"2010-09-25T04:12:00.000","Title":"Among MATLAB and Python, which one is good for statistical analysis?","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},{"Question":"Which one among the two languages is good for statistical analysis? What are the pros and cons, other than accessibility, for each?","AnswerCount":5,"Available Count":2,"Score":0.1194272985,"is_accepted":false,"ViewCount":1096,"Q_Id":3792465,"Users Score":3,"Answer":"I would pick Python because it can be a powerful as Matlab but is free. Also, you can distribute your applications for free and no licensing chains. \nMatlab is awesome and expensive (it had a great statistical package) and it will glow smoother than Python in the beginning, but not so in the long run. \nNow, if you really want the best solution then check out R, the statistical package which is de facto in the community. They even have a Python port for it. R is also free software.","Q_Score":8,"Tags":"python,matlab,statistics,analysis","A_Id":3792582,"CreationDate":"2010-09-25T04:12:00.000","Title":"Among MATLAB and Python, which one is good for statistical analysis?","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},{"Question":"Python 2.6\nMy script needs to monitor some 1G files on the ftp, when ever it's changed\/modified, the script will download it to another place. Those file name will remain unchanged, people will delete the original file on ftp first, then upload a newer version. My script will checking the file metadata like file size and date modified to see if any difference.\nThe question is when the script checking metadata, the new file may be still being uploading. How to handle this situation? Is there any file attribute indicates uploading status (like the file is locked)? Thanks.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":2665,"Q_Id":3795605,"Users Score":4,"Answer":"There is no such attribute. You may be unable to GET such file, but it depends on the server software. Also, file access flags may be set one way while the file is being uploaded and then changed when upload is complete; or incomplete file may have modified name (e.g. original_filename.ext.part) -- it all depends on the server-side software used for upload.\nIf you control the server, make your own metadata, e.g. create an empty flag file alongside the newly uploaded file when upload is finished.\nIn the general case, I'm afraid, the best you can do is monitor file size and consider the file completely uploaded if its size is not changing for a while. Make this interval sufficiently large (on the order of minutes).","Q_Score":1,"Tags":"python,ftp,metadata","A_Id":3795678,"CreationDate":"2010-09-25T21:20:00.000","Title":"Python to check if file status is being uploading","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"IronPython.net documentation says the MSIL in the assembly isn't CLS-compliant, but is there a workaround?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":305,"Q_Id":3795914,"Users Score":0,"Answer":"I'm typing this on my phone so please forgive any silly mistakes. To use the compiled assembly, make sure you compile with clr.CompileModules, NOT pyc.py. Then in your C# call the LoadAssembly method on your Python ScriptEngine object. The module can then be imported by calling the ImportModule method on your ScriptEngine. From there if you can take advantage of the dynamic keyword, do so. Otherwise you'll be stuck with some magic string heavy calls to GetVariable. Also note that you'll have to provide the standard library to your compiled Python Assembly in one form or another.","Q_Score":1,"Tags":"c#,ironpython,.net-assembly,cil,cls-compliant","A_Id":3835553,"CreationDate":"2010-09-25T23:07:00.000","Title":"Is there a way to use IronPython objects and functions (compiled into an assembly) from C# 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":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I was reading \"Growing Object-Oriented Software, Guided by Tests\" lately.\nAuthors of this book sugested to always start developing a feature with an end-to-end acceptance test (before starting TDD cycle) to not loose a track of progress and to make sure that you're still on the same page while unit-testing.\nOk, so I've start writing a veeeery simple application in python+django just to try this approach out. I want User to be able to ask a question via contact-form, the question should be then stored in a db, and a signal after completion should be send to notify mailer which will send follow-up message.\nQuestion is - how you'd approach this first end-to-end test in this case? Do you have contain all possibilities in this first test, or maybe I'm misunderstanding this whole technique. \nAny examples would be most welcome.","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":479,"Q_Id":3798629,"Users Score":1,"Answer":"You don't have to contain all possibilities in acceptance tests at all - you will still write unit tests. So I would say that a single tests \"user can fill in the form, save it and load it back\" is enough to start with. Then you can add more tests if you think that a particular aspect of your system is important enough that it needs an acceptance tests. Don't worry about handling all possibilities here, you will still write tons of unit tests where you will test everything!\nThe easiest way to start is to grow your acceptance test in parallel with the code: so start with testing that the user can input data, implement it until it stops failing, then add to the test the condition that the user has to load this data back etc. It will take a while to implement the initial infrastructure for the acceptance test, before you even start writing production code, but you can't escape from it anyway, and there are various benefits to have tests upfront.","Q_Score":7,"Tags":"python,django,unit-testing,tdd,bdd","A_Id":3799733,"CreationDate":"2010-09-26T16:09:00.000","Title":"\"Zero Iteration\" - end to end acceptance test in simple contact-form feature","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I was reading \"Growing Object-Oriented Software, Guided by Tests\" lately.\nAuthors of this book sugested to always start developing a feature with an end-to-end acceptance test (before starting TDD cycle) to not loose a track of progress and to make sure that you're still on the same page while unit-testing.\nOk, so I've start writing a veeeery simple application in python+django just to try this approach out. I want User to be able to ask a question via contact-form, the question should be then stored in a db, and a signal after completion should be send to notify mailer which will send follow-up message.\nQuestion is - how you'd approach this first end-to-end test in this case? Do you have contain all possibilities in this first test, or maybe I'm misunderstanding this whole technique. \nAny examples would be most welcome.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":479,"Q_Id":3798629,"Users Score":0,"Answer":"This use-case leads to several test-cases (every tests a dedicated possible path of execution). \nWhen writing tests focus on one possible outcome, after a while test-suite grows. The first tests then also give you safety net as regression tests to not break anything which you already implemented successfully.\nMy first tests would be:\n\nHappy path 1st part frontend-form + controller layer: User passes correct data, controller take the form and log to console\/stdout    \nHappy path 2nd part: Instead of logging to stdout, things get stored to database\nHappy path 3rd part: Follow-up mail gets sent and received by User\nValidation error handling (user fills form out incorrectly, e.g. misses mandatory fields, wrong email-pattern)\n...\n\nFill out the rest ;) Depends on the more detailed requirements...\nRemember to implement above as simple as possible. When all tests are in place, refactor ruthlessly to make \"internal quality\" nice.","Q_Score":7,"Tags":"python,django,unit-testing,tdd,bdd","A_Id":3799623,"CreationDate":"2010-09-26T16:09:00.000","Title":"\"Zero Iteration\" - end to end acceptance test in simple contact-form feature","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"There are two good open source python e-commerce solutions exist: Satchmo and LFS. But I can't find any theme for them. Does at least one open source theme for them exist? There are thousands themes for Magento, osCommerce, OpenCart, but zero themes for Satchmo.\nThanks.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":299,"Q_Id":3802544,"Users Score":0,"Answer":"well, if that is the case, I think the only reason I can think up of is that this Satchmo is not that popular so that nobody is willing to port or design a theme for it.\nI would suggest randomly grab a theme, port it here accordingly","Q_Score":3,"Tags":"python,e-commerce","A_Id":11260331,"CreationDate":"2010-09-27T09:33:00.000","Title":"Themes for python e-commerce solutions","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I changed my domain from abc.com to xyz.com. After that my facebook authentication is not working.\nIt is throwing a key error KeyError: 'access_token'I am using python as my language.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":186,"Q_Id":3806082,"Users Score":0,"Answer":"You probably need to update the domain in the facebook settings\/api key which allow you access.","Q_Score":0,"Tags":"python,facebook","A_Id":3806101,"CreationDate":"2010-09-27T17:08:00.000","Title":"My facebook authentication is not working?","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},{"Question":"Is there any python function that validates E-mail addresses, aware of IDN domains ?\nFor instance, user@example.com should be as correct as user@z\u00e4\u00e4z.de or user@\u7d0d\u8c46.ac.jp\nThanks.","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":548,"Q_Id":3806393,"Users Score":1,"Answer":"It is very difficult to validate an e-mail address because the syntax is so flexible. The best strategy is to send a test e-mail to the entered address.","Q_Score":0,"Tags":"python","A_Id":3806787,"CreationDate":"2010-09-27T17:43:00.000","Title":"Function to validate an E-mail (IDN aware)","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},{"Question":"Does python offer a way to easily get the current week of the month (1:4) ?","AnswerCount":17,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":60362,"Q_Id":3806473,"Users Score":16,"Answer":"If your first week starts on the first day of the month you can use integer division:\n\nimport datetime\nday_of_month = datetime.datetime.now().day\nweek_number = (day_of_month - 1) \/\/ 7 + 1","Q_Score":39,"Tags":"python,time,week-number","A_Id":3806516,"CreationDate":"2010-09-27T17:57:00.000","Title":"Week number of the month?","Data Science and Machine Learning":0,"Database and SQL":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},{"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},{"Question":"I'm considering learning a new language as an alternative to PHP. I'm considering Python and Ruby. Which one is a better language based on the following four criteria, and any other qualifiers you may have?\n\nWhich is more stable?\nWhich is more scaleable?\nWhich is more secure?\nWhich is easier to learn?\n\nEDIT:\nKeeping the original question intact, I'd like to add one more pair of questions.\n\nWhich is quicker to code with?\nWhich is quicker to learn? (Based on personal experience only please - to avoid holywars.)\n\nEDIT2:\nSorry for not clarifying - mostly web development, some desktop programming would be a nice bonus.","AnswerCount":8,"Available Count":6,"Score":0.049958375,"is_accepted":false,"ViewCount":3516,"Q_Id":3809981,"Users Score":2,"Answer":"I personally would prefer Ruby, as it goes wonderfully with the Rails framework and is a blast to learn and to work with.\nI have only used Python a few times. While I know it is powerful, I have never really fallen in love with it the way I have with Ruby (and specifically the Rails framework)","Q_Score":2,"Tags":"php,python,ruby,programming-languages","A_Id":3809997,"CreationDate":"2010-09-28T05:39:00.000","Title":"Ruby or Python instead of 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":0},{"Question":"I'm considering learning a new language as an alternative to PHP. I'm considering Python and Ruby. Which one is a better language based on the following four criteria, and any other qualifiers you may have?\n\nWhich is more stable?\nWhich is more scaleable?\nWhich is more secure?\nWhich is easier to learn?\n\nEDIT:\nKeeping the original question intact, I'd like to add one more pair of questions.\n\nWhich is quicker to code with?\nWhich is quicker to learn? (Based on personal experience only please - to avoid holywars.)\n\nEDIT2:\nSorry for not clarifying - mostly web development, some desktop programming would be a nice bonus.","AnswerCount":8,"Available Count":6,"Score":0.024994793,"is_accepted":false,"ViewCount":3516,"Q_Id":3809981,"Users Score":1,"Answer":"To get a quick feel for each and see which one \"tastes\" better I would suggest taking each one for a spin on a selection of problems on ProjectEeuler. PE is more about algorithms and math but some of thee simpler problems are a great way to get going with syntax and some core library features such as file IO etc.","Q_Score":2,"Tags":"php,python,ruby,programming-languages","A_Id":3810088,"CreationDate":"2010-09-28T05:39:00.000","Title":"Ruby or Python instead of 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":0},{"Question":"I'm considering learning a new language as an alternative to PHP. I'm considering Python and Ruby. Which one is a better language based on the following four criteria, and any other qualifiers you may have?\n\nWhich is more stable?\nWhich is more scaleable?\nWhich is more secure?\nWhich is easier to learn?\n\nEDIT:\nKeeping the original question intact, I'd like to add one more pair of questions.\n\nWhich is quicker to code with?\nWhich is quicker to learn? (Based on personal experience only please - to avoid holywars.)\n\nEDIT2:\nSorry for not clarifying - mostly web development, some desktop programming would be a nice bonus.","AnswerCount":8,"Available Count":6,"Score":0.0748596907,"is_accepted":false,"ViewCount":3516,"Q_Id":3809981,"Users Score":3,"Answer":"These two languages are so similar that any strong preference will be mostly subjective. They are both the correct answer.","Q_Score":2,"Tags":"php,python,ruby,programming-languages","A_Id":3810286,"CreationDate":"2010-09-28T05:39:00.000","Title":"Ruby or Python instead of 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":0},{"Question":"I'm considering learning a new language as an alternative to PHP. I'm considering Python and Ruby. Which one is a better language based on the following four criteria, and any other qualifiers you may have?\n\nWhich is more stable?\nWhich is more scaleable?\nWhich is more secure?\nWhich is easier to learn?\n\nEDIT:\nKeeping the original question intact, I'd like to add one more pair of questions.\n\nWhich is quicker to code with?\nWhich is quicker to learn? (Based on personal experience only please - to avoid holywars.)\n\nEDIT2:\nSorry for not clarifying - mostly web development, some desktop programming would be a nice bonus.","AnswerCount":8,"Available Count":6,"Score":0.024994793,"is_accepted":false,"ViewCount":3516,"Q_Id":3809981,"Users Score":1,"Answer":"i think you should prefer ruby, while python is assumed easier to learn! \npython is so friendly great language but you rarely find servers with python support most are expensive one's, ruby on rails is great framework many frameworks for other languages are drives from , great cake php is a sort of such a thing.\nruby on rails can be found on many servers. \nhow ever if you have specified applications with special clients you can go to python and it's funny frameworks.\nby the way, i had a lecture on ruby i had a article claim that ruby is a bit more efficient and more quick.","Q_Score":2,"Tags":"php,python,ruby,programming-languages","A_Id":3869927,"CreationDate":"2010-09-28T05:39:00.000","Title":"Ruby or Python instead of 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":0},{"Question":"I'm considering learning a new language as an alternative to PHP. I'm considering Python and Ruby. Which one is a better language based on the following four criteria, and any other qualifiers you may have?\n\nWhich is more stable?\nWhich is more scaleable?\nWhich is more secure?\nWhich is easier to learn?\n\nEDIT:\nKeeping the original question intact, I'd like to add one more pair of questions.\n\nWhich is quicker to code with?\nWhich is quicker to learn? (Based on personal experience only please - to avoid holywars.)\n\nEDIT2:\nSorry for not clarifying - mostly web development, some desktop programming would be a nice bonus.","AnswerCount":8,"Available Count":6,"Score":0.0,"is_accepted":false,"ViewCount":3516,"Q_Id":3809981,"Users Score":0,"Answer":"pyfunc pretty much said it, but I'd like to offer two more thoughts:\n1) Ruby will probably end up being a tiny bit more familiar as it a) can often optionally use a more C-like syntax, b) is not structured quite as foreignly as Python coming from PHP\n2) They can both scale well, but Python will probably give you the most bang for your buck (CPU wise - and if you use Ruby, you're probably pretty well off using Ruby Enterprise and mod_rails, aka phusion passenger).\nThat's all - even considering those points, the difference may well be negligible, as the power of the language is all about how you use it, regardless of its inherent pros and cons.","Q_Score":2,"Tags":"php,python,ruby,programming-languages","A_Id":3869982,"CreationDate":"2010-09-28T05:39:00.000","Title":"Ruby or Python instead of 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":0},{"Question":"I'm considering learning a new language as an alternative to PHP. I'm considering Python and Ruby. Which one is a better language based on the following four criteria, and any other qualifiers you may have?\n\nWhich is more stable?\nWhich is more scaleable?\nWhich is more secure?\nWhich is easier to learn?\n\nEDIT:\nKeeping the original question intact, I'd like to add one more pair of questions.\n\nWhich is quicker to code with?\nWhich is quicker to learn? (Based on personal experience only please - to avoid holywars.)\n\nEDIT2:\nSorry for not clarifying - mostly web development, some desktop programming would be a nice bonus.","AnswerCount":8,"Available Count":6,"Score":0.024994793,"is_accepted":false,"ViewCount":3516,"Q_Id":3809981,"Users Score":1,"Answer":"No significant difference on the first four criteria.\nNo significant difference on coding speed either - you're going to be slow in both at the start, then you'll get faster. Ruby may be slightly better at managing libraries (Ruby Gems) but Python probably has slightly broader library coverage. No big deal either way.\nComing from PHP, I'd guess that Python might be slightly quicker to learn. That might be a reason for choosing Ruby - you might learn a little more.\nThere are a lot of \"mights\" and \"slightlys\" there. That's because the two languages are much more similar to each other than either is to PHP. Neither is particularly hard to learn - I'd suggest spending a little time with both and then going deeper with the one you prefer.","Q_Score":2,"Tags":"php,python,ruby,programming-languages","A_Id":3811039,"CreationDate":"2010-09-28T05:39:00.000","Title":"Ruby or Python instead of 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":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},{"Question":"I have used Lua.NET on .NET platform and I  could call the .NET class\/object from Lua and I could call the Lua from .NET Lua API interface. I did the same with the IronPython. I knew the how the .NET binding works.\nNow I have a C++ project and I want to use the dynamic capabilities. I want to call C++ object which may not be possible from Lua so I may need to call some C API which makes call to C++. Meantime I want to call the Lua from C++.\nWe have configuration data which is best described in table like format in Lua or List & Dict like in Python. We need to enumerate these data structures defined in Lua\/Python in C++. \nWhen considering Lua to Python in C++ for two way calling, is Python have upper hand with Boost Python library? I don't have experience in Python\/C++ binding. I don't have equal experience of using Python in C++ and calling Python from C++.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":3491,"Q_Id":3818703,"Users Score":0,"Answer":"If you are planning to just use windows you could use C++\/CLI a managed variant of C++. With C++\/CLI you can easily mix managed and unmanaged code. You could call the managed classes from any .net language and the unmanaged (exported) functions from C.","Q_Score":2,"Tags":"c++,python,boost,lua,embedding","A_Id":3819333,"CreationDate":"2010-09-29T04:22:00.000","Title":"Lua or Python binding with 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":0,"Web Development":0},{"Question":"I am building Froyo, is it possible that during building, make\/python can output the file and the command it is calling right now.\nFor example, in one of the Android.mk, there is a line, says,\necho build success.\nOn the monitor it will show \"build success\", \nwhat I want is that in addition, it shows \n\"Android.mk line 20: echo build success\".\nIs it possible?","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":4399,"Q_Id":3826604,"Users Score":2,"Answer":"I've just experienced an odd effect of using $(info) when compiling a java+C++ Android application:\nI used $info) to output some informations about conditional compiling in the Android.mk of the main application and when trying to debug the native part of the program, using ndk-gdb, it failed because apparently the output of $(info) is read by the ndk-gdb script (using the get_build_var() and get_build_var_for_abi() functions).\nTHe result is that the ndk-gdb script is not executed properly.","Q_Score":3,"Tags":"python,android,debugging,build,trace","A_Id":9443567,"CreationDate":"2010-09-29T23:23:00.000","Title":"Android.mk debug 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":1},{"Question":"I would test via a python script whether a passwordless ssh login has been setup or not.\nIf i run the normal ssh command then it will wait to accept the password for some amount of time.\nIs there a way where the ssh command should return an error as soon as ssh asks for a password.\nIs it possible to achieve this?","AnswerCount":4,"Available Count":1,"Score":0.049958375,"is_accepted":false,"ViewCount":3677,"Q_Id":3830508,"Users Score":1,"Answer":"paramiko will raise an AuthenticationException if you don't pass a password to the SSHClient's .connect() method and a working key cannot be found.","Q_Score":5,"Tags":"python,ssh,ssh-keys","A_Id":3830595,"CreationDate":"2010-09-30T12:36:00.000","Title":"Check if passwordless access has been 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":0,"Web Development":0},{"Question":"I just need to write a simple python CGI script to parse the contents of a POST request containing JSON.  This is only test code so that I can test a client application until the actual server is ready (written by someone else).\nI can read the cgi.FieldStorage() and dump the keys() but the request body containing the JSON is nowhere to be found.\nI can also dump the os.environ() which provides lots of info except that I do not see a variable containing the request body.\nAny input appreciated.\nChris","AnswerCount":2,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":8362,"Q_Id":3836828,"Users Score":8,"Answer":"notice that if you call cgi.FieldStorage() before in your code, you can't get the body data from stdin, because it just be read once.","Q_Score":11,"Tags":"python,parsing,cgi,request","A_Id":39910366,"CreationDate":"2010-10-01T05:49:00.000","Title":"How to parse the \"request body\" using python CGI?","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},{"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},{"Question":"When an attribute is not found object.__getattr__ is called. Is there an equivalent way to intercept undefined methods?","AnswerCount":3,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":6173,"Q_Id":3855015,"Users Score":12,"Answer":"There is no difference. A method is also an attribute. (If you want the method to have an implicit \"self\" argument, though, you'll have to do some more work to \"bind\" the method).","Q_Score":16,"Tags":"python,object,methods,getattr","A_Id":3855032,"CreationDate":"2010-10-04T12:02:00.000","Title":"__getattr__ equivalent for methods","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"What is the fastest way to sort an array of whole integers bigger than 0 and less than 100000 in Python? But not using the built in functions like sort.\nIm looking at the possibility to combine 2 sport functions depending on input size.","AnswerCount":10,"Available Count":1,"Score":0.0798297691,"is_accepted":false,"ViewCount":57933,"Q_Id":3855537,"Users Score":4,"Answer":"Radix sort theoretically runs in linear time (sort time grows roughly in direct proportion to array size ), but in practice Quicksort is probably more suited, unless you're sorting absolutely massive arrays.\nIf you want to make quicksort a bit faster, you can use insertion sort] when the array size becomes small.\nIt would probably be helpful to understand the concepts of algorithmic complexity and Big-O notation too.","Q_Score":20,"Tags":"python,arrays,performance,sorting","A_Id":3859736,"CreationDate":"2010-10-04T13:12:00.000","Title":"Fastest way to sort in 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":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"We have an in house developed web-based admin console that uses a combination of C CGI and Perl scripts to administer our mail server stack. Of late we have been thinking of cleaning up the code (well, replacing most of it), making the implementation more secure, and improving the overall behavior.\nI don't have much programming knowledge, but I use Ruby on and off (mainly for writing erb templates), and hence was thinking of using ruby\/rails for developing such an app (off-duty for now, I also need to learn stuff !).\nBefore blindly picking up a language though, what would you folks suggest ? Please let me know if this is too vague a question, I'll try to supply more information, if needed.","AnswerCount":4,"Available Count":3,"Score":0.0996679946,"is_accepted":false,"ViewCount":155,"Q_Id":3861102,"Users Score":2,"Answer":"Have you considered writing your applications as Webmin modules?\nYou get a lot of stuff for free when you do so (users and groups, tons of security features, a pretty big variety of helper functions related to config files, and tons of existing code for most aspects of a UNIX\/Linux system). You also get a lot of stuff for nearly free, like action logging, packages and updates via wbm or apt or yum, an online help system, etc.\nThere are some cons, as well. It's an old codebase, so it has some clunky bits in the API among other places. A lot of the old modules can be a bit hard to grok if you're not an old-school Perl programmer. But, it's a well-maintained codebase, and it's been banged on by millions of users for over a dozen years. It's pretty robust. The UI isn't beautiful, but it is relatively theme-able, and if you're distributing a minimized version it becomes easier to customize the UI.\nI suspect you can be up and running a lot faster than starting from scratch or using most existing frameworks that aren't targeted specifically to building systems management interfaces the way Webmin is.\nAlso, it's BSD licensed, so you can do whatever you want with it, including building a custom commercial app with it (hundreds of companies have done so over the years).","Q_Score":0,"Tags":"python,ruby,migration,administration","A_Id":3868363,"CreationDate":"2010-10-05T05:43:00.000","Title":"Which language to use for writing an admin console \u00e0 la webmin?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"We have an in house developed web-based admin console that uses a combination of C CGI and Perl scripts to administer our mail server stack. Of late we have been thinking of cleaning up the code (well, replacing most of it), making the implementation more secure, and improving the overall behavior.\nI don't have much programming knowledge, but I use Ruby on and off (mainly for writing erb templates), and hence was thinking of using ruby\/rails for developing such an app (off-duty for now, I also need to learn stuff !).\nBefore blindly picking up a language though, what would you folks suggest ? Please let me know if this is too vague a question, I'll try to supply more information, if needed.","AnswerCount":4,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":155,"Q_Id":3861102,"Users Score":0,"Answer":"django has a nice admin interface","Q_Score":0,"Tags":"python,ruby,migration,administration","A_Id":3897721,"CreationDate":"2010-10-05T05:43:00.000","Title":"Which language to use for writing an admin console \u00e0 la webmin?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"We have an in house developed web-based admin console that uses a combination of C CGI and Perl scripts to administer our mail server stack. Of late we have been thinking of cleaning up the code (well, replacing most of it), making the implementation more secure, and improving the overall behavior.\nI don't have much programming knowledge, but I use Ruby on and off (mainly for writing erb templates), and hence was thinking of using ruby\/rails for developing such an app (off-duty for now, I also need to learn stuff !).\nBefore blindly picking up a language though, what would you folks suggest ? Please let me know if this is too vague a question, I'll try to supply more information, if needed.","AnswerCount":4,"Available Count":3,"Score":1.2,"is_accepted":true,"ViewCount":155,"Q_Id":3861102,"Users Score":0,"Answer":"If you already know a bit of ruby, then there's no reason not to use that.\nIf you're interested specifically in learning another language, then what you're trying to do could be done in pretty much any language\/framework, it's just a matter of which one you want to learn.","Q_Score":0,"Tags":"python,ruby,migration,administration","A_Id":3861123,"CreationDate":"2010-10-05T05:43:00.000","Title":"Which language to use for writing an admin console \u00e0 la webmin?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I am using PyDev\/Eclipse for several monthes and I get ever and ever the same bugs with imports:\nPyDev underline in red an import and say Unresolved import xxx ; Found at yyy. When I click on yyy eclispe find and open the implementation of the module.\n(PyDev just inform me that it can't find the module xxx and in the same message that it can  find it !)\nThe module xxx is in the PYTHONPATH of eclipse. When I \"explore\" the interpreter of the project, I can find it without any problems.\nWhen I try to execute (from eclipse), I don't get any error and it works fine.\nSometimes, the error message will stay for several days and will disappear. Sometimes, it won't. I've tried to refresh the projects but it has not impact on that.\nSomtimes, it works well on a project and I can use autocompletion and it don't work in another project (same interpreter) ...\nI just can't understand what is happenning ?\nSo far, I have ignored these bugs because everything was fully fonctionnal but sometimes, it is a bit disturbing to have red markers \"errors\" when you are working.\nDid you find a way to avoid these bugs in PyDev ? Is it \"normal\" ? Is there a way to force PyDev to \"refresh\" ?\nThank you.\nReferences :\n\npython 2.4.4 (built from sources)\nPyDev v 1.6.0 2010071813","AnswerCount":3,"Available Count":3,"Score":0.0665680765,"is_accepted":false,"ViewCount":6201,"Q_Id":3863369,"Users Score":1,"Answer":"You can try refreshing your PYTHONPATH in Preferences > Pydev > Interpreter - Python and selecting AutoConfig for your interpreter, then manually choosing the libraries for your PYTHONPATH.\nThis is pretty radical solution though. Making an insignificant change (like adding a space) and saving file should work in most cases. If not, you can also try temporary delete and then re-add the imports in file that is causing problems.","Q_Score":15,"Tags":"python,eclipse,pydev","A_Id":3863743,"CreationDate":"2010-10-05T11:55:00.000","Title":"PyDev bugs with imports","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I am using PyDev\/Eclipse for several monthes and I get ever and ever the same bugs with imports:\nPyDev underline in red an import and say Unresolved import xxx ; Found at yyy. When I click on yyy eclispe find and open the implementation of the module.\n(PyDev just inform me that it can't find the module xxx and in the same message that it can  find it !)\nThe module xxx is in the PYTHONPATH of eclipse. When I \"explore\" the interpreter of the project, I can find it without any problems.\nWhen I try to execute (from eclipse), I don't get any error and it works fine.\nSometimes, the error message will stay for several days and will disappear. Sometimes, it won't. I've tried to refresh the projects but it has not impact on that.\nSomtimes, it works well on a project and I can use autocompletion and it don't work in another project (same interpreter) ...\nI just can't understand what is happenning ?\nSo far, I have ignored these bugs because everything was fully fonctionnal but sometimes, it is a bit disturbing to have red markers \"errors\" when you are working.\nDid you find a way to avoid these bugs in PyDev ? Is it \"normal\" ? Is there a way to force PyDev to \"refresh\" ?\nThank you.\nReferences :\n\npython 2.4.4 (built from sources)\nPyDev v 1.6.0 2010071813","AnswerCount":3,"Available Count":3,"Score":1.2,"is_accepted":true,"ViewCount":6201,"Q_Id":3863369,"Users Score":16,"Answer":"This can happen if new modules are not cached by PyDev. For example, on my new laptop I first set up PyDev\/Eclipse and later installed the Django package. That's why Django imports were marked as unresolved. You can refresh it using Pydev > Interpreter - Python > Libraries > Apply. Select the interpreter you want to \"restore\" (they could have chosen a better word) and click OK. PyDev will then reparse all installed modules.\nI'm using the nightly version of PyDev, but any 1.6.x version should work correctly. If that doesn't help, remove the interpreter configure and create a new one.","Q_Score":15,"Tags":"python,eclipse,pydev","A_Id":3864323,"CreationDate":"2010-10-05T11:55:00.000","Title":"PyDev bugs with imports","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I am using PyDev\/Eclipse for several monthes and I get ever and ever the same bugs with imports:\nPyDev underline in red an import and say Unresolved import xxx ; Found at yyy. When I click on yyy eclispe find and open the implementation of the module.\n(PyDev just inform me that it can't find the module xxx and in the same message that it can  find it !)\nThe module xxx is in the PYTHONPATH of eclipse. When I \"explore\" the interpreter of the project, I can find it without any problems.\nWhen I try to execute (from eclipse), I don't get any error and it works fine.\nSometimes, the error message will stay for several days and will disappear. Sometimes, it won't. I've tried to refresh the projects but it has not impact on that.\nSomtimes, it works well on a project and I can use autocompletion and it don't work in another project (same interpreter) ...\nI just can't understand what is happenning ?\nSo far, I have ignored these bugs because everything was fully fonctionnal but sometimes, it is a bit disturbing to have red markers \"errors\" when you are working.\nDid you find a way to avoid these bugs in PyDev ? Is it \"normal\" ? Is there a way to force PyDev to \"refresh\" ?\nThank you.\nReferences :\n\npython 2.4.4 (built from sources)\nPyDev v 1.6.0 2010071813","AnswerCount":3,"Available Count":3,"Score":0.0665680765,"is_accepted":false,"ViewCount":6201,"Q_Id":3863369,"Users Score":1,"Answer":"Just in case anyone else runs into this thread but above answers don't solve the issue, make sure that your script does not have the same name as the library that you are trying to import.","Q_Score":15,"Tags":"python,eclipse,pydev","A_Id":38688200,"CreationDate":"2010-10-05T11:55:00.000","Title":"PyDev bugs with imports","Data Science and Machine Learning":0,"Database and SQL":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},{"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},{"Question":"What is the best way to approach writing a program in Python to translate English words and\/or phrases into other languages?","AnswerCount":6,"Available Count":1,"Score":0.0333209931,"is_accepted":false,"ViewCount":2381,"Q_Id":3867860,"Users Score":1,"Answer":"the simplest way to do this is to make a dictionary that matches one language's words to another language's words. However, this is extremely silly and would not take into account grammar at all and it would literally take a very long time to create a translator, especially if you plan to use it for multiple languages. If grammar is not important to you (for example, if you were creating your own language for a game or story that doesn't have grammar different from english) than you could get away with using dictionaries and simply having a function look for a requested match in the dictionary","Q_Score":1,"Tags":"python,localization,linguistics","A_Id":3868983,"CreationDate":"2010-10-05T21:24:00.000","Title":"Python - English translator","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"If I write a python script, anyone can simply point an editor to it and read it. But for programming written in C, one would have to use decompilers and hex tables and such. Why is that? I mean I simply can't open up the Safari web browser and look at its code.","AnswerCount":11,"Available Count":7,"Score":0.0,"is_accepted":false,"ViewCount":801,"Q_Id":3869435,"Users Score":0,"Answer":"Python scripts are analogous to a man looking at a to-do list written in English (or language he understands). The man has to do all the work, every time that list of things has to be done.\nIf the man, instead of doing the steps on his own each time, creates and programs a robot which can carry out those steps again and again (and probably faster than him), that robot is analogous to the C program.\nThe man in the python case is called the \"interpreter\" and in the C case is called the \"compiler\", and the C robot is called the compiled program\/executable.\nWhen you look at the python program source, you see the to-do list. In case of the robot, you see the gears, motors and batteries, etc, which look very different from the to-do list. If you could get hold of the C \"to-do\" list, it looks somewhat like the python code, just in a different language.","Q_Score":3,"Tags":"python,c,decompiling","A_Id":3869481,"CreationDate":"2010-10-06T04:07:00.000","Title":"Why do C programs require decompilers but python programs dont?","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},{"Question":"If I write a python script, anyone can simply point an editor to it and read it. But for programming written in C, one would have to use decompilers and hex tables and such. Why is that? I mean I simply can't open up the Safari web browser and look at its code.","AnswerCount":11,"Available Count":7,"Score":0.0906594778,"is_accepted":false,"ViewCount":801,"Q_Id":3869435,"Users Score":5,"Answer":"This is sorta a big topic. You should look into your local friendly Computer Science curriculum, you'll find a lot of great stuff on this subject there.\nThe short answer is the Python is an \"interpreted\" language, which means that it requires a machine language program (the python interpreter) to run the python program, adding a layer of indirection. C or C++ are different. They are compiled directly to machine code, which runs directly on your processor.\nThere is a lot of additional voodoo to be learned here, however. Technically Python is compiled to a bytecode, and modern interpreters do more and more \"Just in Time\" compilation, so the boundaries between compiled and interpreted code are getting fuzzier all the time.","Q_Score":3,"Tags":"python,c,decompiling","A_Id":3869458,"CreationDate":"2010-10-06T04:07:00.000","Title":"Why do C programs require decompilers but python programs dont?","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},{"Question":"If I write a python script, anyone can simply point an editor to it and read it. But for programming written in C, one would have to use decompilers and hex tables and such. Why is that? I mean I simply can't open up the Safari web browser and look at its code.","AnswerCount":11,"Available Count":7,"Score":0.0181798149,"is_accepted":false,"ViewCount":801,"Q_Id":3869435,"Users Score":1,"Answer":"because C code is complied to object (machine) code and python code is compiled into an intermediate byte code. I am not sure if you are even referring to the byte code of python - you must be referring to the source file itself which is directly executable (hiding the byte code from you!). C needs to be compiled and linked.","Q_Score":3,"Tags":"python,c,decompiling","A_Id":3869445,"CreationDate":"2010-10-06T04:07:00.000","Title":"Why do C programs require decompilers but python programs dont?","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},{"Question":"If I write a python script, anyone can simply point an editor to it and read it. But for programming written in C, one would have to use decompilers and hex tables and such. Why is that? I mean I simply can't open up the Safari web browser and look at its code.","AnswerCount":11,"Available Count":7,"Score":0.0,"is_accepted":false,"ViewCount":801,"Q_Id":3869435,"Users Score":0,"Answer":"Python scripts are parsed and converted to binary only when they're run - i.e., they're text files and you can read them with an editor.\nC code is compiled and linked to an executable binary file before they can be run. Normally, only this executable binary file is distributed - hence you need a decompiler. You can always view the source code, if you've access to it.","Q_Score":3,"Tags":"python,c,decompiling","A_Id":3869451,"CreationDate":"2010-10-06T04:07:00.000","Title":"Why do C programs require decompilers but python programs dont?","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},{"Question":"If I write a python script, anyone can simply point an editor to it and read it. But for programming written in C, one would have to use decompilers and hex tables and such. Why is that? I mean I simply can't open up the Safari web browser and look at its code.","AnswerCount":11,"Available Count":7,"Score":0.0,"is_accepted":false,"ViewCount":801,"Q_Id":3869435,"Users Score":0,"Answer":"G-WAN executes ANSI C scripts on the fly -making it just like Python scripts.\nThis can be server-side scripts (using G-WAN as a Web server) or any general-purpose C program and you can link any existing library.\nOh, and G-WAN C scripts are much faster than Python, PHP or Java...","Q_Score":3,"Tags":"python,c,decompiling","A_Id":3874099,"CreationDate":"2010-10-06T04:07:00.000","Title":"Why do C programs require decompilers but python programs dont?","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},{"Question":"If I write a python script, anyone can simply point an editor to it and read it. But for programming written in C, one would have to use decompilers and hex tables and such. Why is that? I mean I simply can't open up the Safari web browser and look at its code.","AnswerCount":11,"Available Count":7,"Score":1.0,"is_accepted":false,"ViewCount":801,"Q_Id":3869435,"Users Score":10,"Answer":"Python is a script language, runs in a virtual machine through an interpeter.\nC is a compiled language, the code compiled to binary code which the computer can run without all that extra stuff Python needs.","Q_Score":3,"Tags":"python,c,decompiling","A_Id":3869443,"CreationDate":"2010-10-06T04:07:00.000","Title":"Why do C programs require decompilers but python programs dont?","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},{"Question":"If I write a python script, anyone can simply point an editor to it and read it. But for programming written in C, one would have to use decompilers and hex tables and such. Why is that? I mean I simply can't open up the Safari web browser and look at its code.","AnswerCount":11,"Available Count":7,"Score":0.0363476168,"is_accepted":false,"ViewCount":801,"Q_Id":3869435,"Users Score":2,"Answer":"Yes, you can - it's called disassembling, and allows you to look at the code of Safari perfectly well. The thing is, C, among other languages, compiles to native code, i.e. code that your CPU can \"understand\" and execute. \nMore or less obviously, the level of abstraction present in the instruction set of your CPU is much smaller than that of a high level language like Python. The CPU instructions are not concerned with \"downloading that URI\", but more \"check if that bit is set in a hardware register\".\nSo, in conclusion, the level of complexity present in a native application is much higher when looking at the machine code, so many people simply can't make any sense of what is going on there, it's hard to get the big picture. With experience and time at your hands, it is possible though - people do it all the time, reversing applications and all.","Q_Score":3,"Tags":"python,c,decompiling","A_Id":3869460,"CreationDate":"2010-10-06T04:07:00.000","Title":"Why do C programs require decompilers but python programs dont?","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},{"Question":"What I'm trying to do:\nI want to give the user the ability to upload a picture that is any size. This image is then resized if it is over 1024 wide or over 768 high. It then resizes the image to be within those bounds, but keeping proportions. Then it adds a semi-transparent watermark to the lower right corner, and saves the file.\nBefore it adds the watermark, it will create a copy of the image and resize it down to a thumbnail size (also keeping proportions) and saves it in a separate folder.\nThe Problems with PIL:\nAs far as resizing goes, I was hoping it would have a way to do smart resizing (keep proportions). Also, I didn't seem to have much control over the quality level when saving it as a JPEG. I had to save it as a PNG to keep full quality which was pretty heavy.\nFor the thumbnail, it sounds that it might be pretty difficult, reading through the documentation of PIL, but I could be wrong.\nThe Question\nAre there any other, more advanced image libraries for Python that may be a bit more up to date, or include some features that I am looking for? Are there any public functions that do what I'm looking for that I could use? I don't mind writing this stuff myself, but wanted to check first. Thanks!","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":5217,"Q_Id":3869517,"Users Score":0,"Answer":"In a pinch, convert the Image to a numpy array, modify it as you please, and convert back.","Q_Score":4,"Tags":"python,image,python-imaging-library","A_Id":3869781,"CreationDate":"2010-10-06T04:34:00.000","Title":"Simple Image Manipulation 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},{"Question":"... or if not, can you provide me link or RFC number to full algorithm (from getting ASCII encoded Private key file\/string to generation of ASCII encoded public key file\/string).\nTo show you a bigger picture - I started using a pylibssh2 library. This library has a method - userauth_publickey_fromfile (it raises NotImplementedException, but when you force launching python binding - it works). The problem is that this method wants private key (good) and public key (hell knows why). Of course, I can pass both of those keys as argumets to my functions, but I think it is unnecessary, and I don't want to expect one more variable just for that. So I want to generate public key from private one by myself.\nMaybe I'm missing something in pylibssh2 or even in libssh2 itself (I can write bindings for that as well) ?\nThanks for any help!","AnswerCount":3,"Available Count":1,"Score":0.1325487884,"is_accepted":false,"ViewCount":1486,"Q_Id":3876114,"Users Score":2,"Answer":"Do you need the answer to be strictly python? You can do this with ssh-keygen -y -f privatekey","Q_Score":0,"Tags":"python,ssh-keys","A_Id":3876193,"CreationDate":"2010-10-06T19:20:00.000","Title":"Is there any way to generate public SSH key from private one 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},{"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},{"Question":"Is anybody familiar with Worldviz-Vizard's 3D engine for python? How does it compare to Panda3D? I have a feeling that it might be easier to learn but far more limited. They only support python 2.4 which also makes me not want to try it.","AnswerCount":3,"Available Count":2,"Score":0.1325487884,"is_accepted":false,"ViewCount":1459,"Q_Id":3877971,"Users Score":2,"Answer":"Been using Vizard for various VR and AR development for about 3 yrs now - it's NOT unity - i.e. a web enabled game engine (excellent though it is) - what Vizard provides is a highly optimized OpenGL engine, wrapped in user friendly python scripting environment BUT on top of this you get the ability to seamlessly distribute your simulations over a cluster or a network. Vizard keeps all things completely synched - invisible to the user. Connects to pretty much all known VR tracking equipment and display periphals and standard gaming equipment is also supported (Wiimote & Kinnect). Native support for frame sequential, side-by-side and anaglyph stereo, spatial sound engine and the ability to extend it with C and C++ plugins or GLSL shaders.\nDidn't actually mean to write that much and I don't want to come across as a Vizard evangelist, it is not perfect, BUT comparing it to Panda3D, Unity or other game engines I feel is an unfair comparison - not like-for-like :o)","Q_Score":1,"Tags":"python,pygame,3d-engine,panda3d","A_Id":6589557,"CreationDate":"2010-10-07T00:54:00.000","Title":"How does Worldviz Vizard compares to Panda3D and Pygame?","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},{"Question":"Is anybody familiar with Worldviz-Vizard's 3D engine for python? How does it compare to Panda3D? I have a feeling that it might be easier to learn but far more limited. They only support python 2.4 which also makes me not want to try it.","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":1459,"Q_Id":3877971,"Users Score":0,"Answer":"I only used Vizard, and that for one small project.\nIt was easy to use, well documented, and had a good set of examples.","Q_Score":1,"Tags":"python,pygame,3d-engine,panda3d","A_Id":4122231,"CreationDate":"2010-10-07T00:54:00.000","Title":"How does Worldviz Vizard compares to Panda3D and Pygame?","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},{"Question":"I understand that when you import a module, that file is compiled into a .pyc file to make it faster? Why is the main file also not compiled to a .pyc? Does this slow things down? Would it be better to keep the main file as small as possible then, or does it not matter?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":26157,"Q_Id":3878479,"Users Score":0,"Answer":"Compiling the main script would be annoying for scripts in e.g. \/usr\/bin. The .pyc file is generated in the same directory, thus polluting the public location.","Q_Score":33,"Tags":"python","A_Id":3878507,"CreationDate":"2010-10-07T03:33:00.000","Title":"Why are main runnable Python scripts not compiled to pyc files like 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},{"Question":"I want to create a gmail client with the ability to view emails as conversations (threads). In imaplib, there is a method: \nIMAP4.thread(threading_algorithm, charset, search_criterion[, ...])\nI think it could be the solution. Anybody has experience using it? Please give an example. Thanks.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1250,"Q_Id":3879265,"Users Score":0,"Answer":"As far as i know, Gmail uses an algorithm that is private, and it's not stated in RFCs.\n\nThey use a combination of headers (like in-reply-to and references) and considering subject (but in a different way that THREAD=references does).","Q_Score":4,"Tags":"python,client,imaplib,gmail-imap,email-threading","A_Id":34061867,"CreationDate":"2010-10-07T06:38:00.000","Title":"How to use thread search method in imaplib?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I was wondering whether objects serialized using CPython's cPickle are readable by using IronPython's cPickle; the objects in question do not require any modules outside of the built-ins that both Cpython and IronPython include.  Thank you!","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":871,"Q_Id":3882750,"Users Score":0,"Answer":"It will work because when you unpickle objects during load() it will use the current definitions of whatever classes you have defined now, not back when the objects were pickled. \nIronPython is simply Python with the standard library implemented in C# so that everything emits IL. Both the CPython and the IronPython pickle modules have the same functionality, except one is implemented in C and the other in C#.","Q_Score":5,"Tags":"python,ironpython,pickle","A_Id":3927390,"CreationDate":"2010-10-07T14:35:00.000","Title":"compatibility between CPython and IronPython cPickle","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I was wondering whether objects serialized using CPython's cPickle are readable by using IronPython's cPickle; the objects in question do not require any modules outside of the built-ins that both Cpython and IronPython include.  Thank you!","AnswerCount":2,"Available Count":2,"Score":0.1973753202,"is_accepted":false,"ViewCount":871,"Q_Id":3882750,"Users Score":2,"Answer":"If you use the default protocol (0) which is text based, then things should work. I'm not sure what will happen if you use a higher protocol. It's very easy to test this ...","Q_Score":5,"Tags":"python,ironpython,pickle","A_Id":3883735,"CreationDate":"2010-10-07T14:35:00.000","Title":"compatibility between CPython and IronPython cPickle","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"My project targets a low-cost and low-resource embedded device. I am dependent on a relatively large and sprawling Python code base, of which my use of its APIs is quite specific. \nI am keen to prune the code of this library back to its bare minimum, by executing my test suite within a coverage tools like Ned Batchelder's coverage or figleaf, then scripting removal of unused code within the various modules\/files. This will help not only with understanding the libraries' internals, but also make writing any patches easier. Ned actually refers to the use of coverage tools to \"reverse engineer\" complex code in one of his online talks.\nMy question to the SO community is whether people have experience of using coverage tools in this way that they wouldn't mind sharing? What are the pitfalls if any? Is the coverage tool a good choice? Or would I be better off investing my time with figleaf? \nThe end-game is to be able to automatically generate a new source tree for the library, based on the original tree, but only including the code actually used when I run nosetests. \nIf anyone has developed a tool that does a similar job for their Python applications and libraries, it would be terrific to get a baseline from which to start development. \nHopefully my description makes sense to readers...","AnswerCount":3,"Available Count":3,"Score":1.2,"is_accepted":true,"ViewCount":2137,"Q_Id":3883484,"Users Score":9,"Answer":"What you want isn't \"test coverage\", it is the transitive closure of \"can call\" from the root of the computation.  (In threaded applications, you have to include \"can fork\").\nYou want to designate some small set (perhaps only 1) of functions that make up the entry points of your application, and want to trace through all possible callees (conditional or unconditional) of that small set.  This is the set of functions you must have.\nPython makes this very hard in general (IIRC, I'm not a deep Python expert) because of dynamic dispatch and especially due to \"eval\".   Reasoning about what function can get called can be pretty tricky for a static analyzers applied to highly dynamic languages.\nOne might use test coverage as a way to seed the \"can call\" relation with specific \"did call\" facts; that could catch a lot of dynamic dispatches (dependent on your test suite coverage).  Then the result you want is the transitive closure of \"can or did\" call.  This can still be erroneous, but is likely to be less so.\nOnce you get a set of \"necessary\" functions, the next problem will be removing the unnecessary functions from the source files you have.  If the number of files you start with is large, the manual effort to remove the dead stuff may be pretty high. Worse, you're likely to revise your application, and then the answer as to what to keep changes.  So for every change (release), you need to reliably recompute this answer.\nMy company builds a tool that does this analysis for Java packages (with appropriate caveats regarding dynamic loads and reflection):  the input is a set of Java files and (as above) a designated set of root functions.  The tool computes the call graph, and also finds all dead member variables and produces two outputs: a) the list of purportedly dead methods and members, and b) a revised set of files with all the \"dead\" stuff removed.   If you believe a), then you use b).  If you think a) is wrong, then you add elements listed in a) to the set of roots and repeat the analysis until you think a) is right.  To do this, you need a static analysis tool that parse Java, compute the call graph, and then revise the code modules to remove the dead entries.  The basic idea applies to any language. \nYou'd need a similar tool for Python, I'd expect.\nMaybe you can stick to just dropping files that are completely unused, although that may still be a lot of work.","Q_Score":8,"Tags":"python,code-coverage,reverse-engineering,code-analysis","A_Id":3886403,"CreationDate":"2010-10-07T15:56:00.000","Title":"Using Python code coverage tool for understanding and pruning back source code of a large 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},{"Question":"My project targets a low-cost and low-resource embedded device. I am dependent on a relatively large and sprawling Python code base, of which my use of its APIs is quite specific. \nI am keen to prune the code of this library back to its bare minimum, by executing my test suite within a coverage tools like Ned Batchelder's coverage or figleaf, then scripting removal of unused code within the various modules\/files. This will help not only with understanding the libraries' internals, but also make writing any patches easier. Ned actually refers to the use of coverage tools to \"reverse engineer\" complex code in one of his online talks.\nMy question to the SO community is whether people have experience of using coverage tools in this way that they wouldn't mind sharing? What are the pitfalls if any? Is the coverage tool a good choice? Or would I be better off investing my time with figleaf? \nThe end-game is to be able to automatically generate a new source tree for the library, based on the original tree, but only including the code actually used when I run nosetests. \nIf anyone has developed a tool that does a similar job for their Python applications and libraries, it would be terrific to get a baseline from which to start development. \nHopefully my description makes sense to readers...","AnswerCount":3,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":2137,"Q_Id":3883484,"Users Score":0,"Answer":"I haven't used coverage for pruning out, but it seems like it should do well. I've used the combination of nosetests + coverage, and it worked better for me than figleaf. In particular, I found the html report from nosetests+coverage to be helpful -- this should be helpful to you in understanding where the unused portions of the library are.","Q_Score":8,"Tags":"python,code-coverage,reverse-engineering,code-analysis","A_Id":3883765,"CreationDate":"2010-10-07T15:56:00.000","Title":"Using Python code coverage tool for understanding and pruning back source code of a large 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},{"Question":"My project targets a low-cost and low-resource embedded device. I am dependent on a relatively large and sprawling Python code base, of which my use of its APIs is quite specific. \nI am keen to prune the code of this library back to its bare minimum, by executing my test suite within a coverage tools like Ned Batchelder's coverage or figleaf, then scripting removal of unused code within the various modules\/files. This will help not only with understanding the libraries' internals, but also make writing any patches easier. Ned actually refers to the use of coverage tools to \"reverse engineer\" complex code in one of his online talks.\nMy question to the SO community is whether people have experience of using coverage tools in this way that they wouldn't mind sharing? What are the pitfalls if any? Is the coverage tool a good choice? Or would I be better off investing my time with figleaf? \nThe end-game is to be able to automatically generate a new source tree for the library, based on the original tree, but only including the code actually used when I run nosetests. \nIf anyone has developed a tool that does a similar job for their Python applications and libraries, it would be terrific to get a baseline from which to start development. \nHopefully my description makes sense to readers...","AnswerCount":3,"Available Count":3,"Score":0.1325487884,"is_accepted":false,"ViewCount":2137,"Q_Id":3883484,"Users Score":2,"Answer":"As others have pointed out, coverage can tell you what code has been executed.  The trick for you is to be sure that your test suite truly exercises the code fully.  The failure case here is over-pruning because your tests skipped some code that will really be needed in production.\nBe sure to get the latest version of coverage.py (v3.4): it adds a new feature to indicate files that are never executed at all.\nBTW:: for a first cut prune, Python provides a neat trick: remove all the .pyc files in your source tree, then run your tests.  Files that still have no .pyc file were clearly not executed!","Q_Score":8,"Tags":"python,code-coverage,reverse-engineering,code-analysis","A_Id":3890093,"CreationDate":"2010-10-07T15:56:00.000","Title":"Using Python code coverage tool for understanding and pruning back source code of a large 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},{"Question":"Due to refactoring\/reworking on a controller I've had to embed a Python Interpreter inside a C application.  I can now call python functions and pass\/get Objects into Python fine.\nThe python code is a controller for a robot (currently simulated),  this now needs make use of some C code for comparisons I'm making.\nPreviously the Python code created objects, read sensors, ran control code and wrote the outputs to motors.  All of this except the control code now needs to be done in C.  The problem I have is that Objects which are created in an init function (in python) which, when I come to run the control code no longer exist.\nWhat is the best way to solve this?  My idea was to return the controllers from the init function and store references to them in the C, passing the reference to the controller each time it is called.\nThanks for any help.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":102,"Q_Id":3883724,"Users Score":1,"Answer":"This may not be the answer you want, but there are ways of working with C and Python other than embedding an interpreter inside a C application.\nNamely, why don't you do the opposite? Create C libraries for Python? You can control the general flow of your application in Python, which is much more comfortable, and call C code whenever you see fit.\nAgain, I'm not really addressing your actual question, so feel free to ignore me.","Q_Score":0,"Tags":"python,c,embedded-language","A_Id":3884055,"CreationDate":"2010-10-07T16:26:00.000","Title":"Maintaining a Python Object when embedding 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":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm wondering if there is a test framework that allows for tests to be declared as being dependent on other tests.  This would imply that they should not be run, or that their results should not be prominently displayed, if the tests that they depend on do not pass.\nThe point of such a setup would be to allow the root cause to be more readily determined in a situation where there are many test failures.\nAs a bonus, it would be great if there some way to use an object created with one test as a fixture for other tests.\nIs this feature set provided by any of the Python testing frameworks?  Or would such an approach be antithetical to unit testing's underlying philosophy?","AnswerCount":5,"Available Count":4,"Score":0.1973753202,"is_accepted":false,"ViewCount":1809,"Q_Id":3885489,"Users Score":5,"Answer":"Or would such an approach be\n  antithetical to unit testing's\n  underlying philosophy?\n\nYep...if it is a unit test, it should be able to run on its own. Anytime I have found someone wanting to create dependencies on tests was due to the code being structured in a poor manner. I am not saying this is the instance in your case but it can often be a sign of code smell.","Q_Score":6,"Tags":"python,unit-testing,testing","A_Id":3885518,"CreationDate":"2010-10-07T20:09:00.000","Title":"Test framework allowing tests to depend on other 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":0},{"Question":"I'm wondering if there is a test framework that allows for tests to be declared as being dependent on other tests.  This would imply that they should not be run, or that their results should not be prominently displayed, if the tests that they depend on do not pass.\nThe point of such a setup would be to allow the root cause to be more readily determined in a situation where there are many test failures.\nAs a bonus, it would be great if there some way to use an object created with one test as a fixture for other tests.\nIs this feature set provided by any of the Python testing frameworks?  Or would such an approach be antithetical to unit testing's underlying philosophy?","AnswerCount":5,"Available Count":4,"Score":0.0,"is_accepted":false,"ViewCount":1809,"Q_Id":3885489,"Users Score":0,"Answer":"It looks like what you need is not to prevent the execution of your dependent tests but to report the results of your unit test in a more structured way that allows you to identify when an error in a test cascades onto other failed tests.","Q_Score":6,"Tags":"python,unit-testing,testing","A_Id":3891628,"CreationDate":"2010-10-07T20:09:00.000","Title":"Test framework allowing tests to depend on other 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":0},{"Question":"I'm wondering if there is a test framework that allows for tests to be declared as being dependent on other tests.  This would imply that they should not be run, or that their results should not be prominently displayed, if the tests that they depend on do not pass.\nThe point of such a setup would be to allow the root cause to be more readily determined in a situation where there are many test failures.\nAs a bonus, it would be great if there some way to use an object created with one test as a fixture for other tests.\nIs this feature set provided by any of the Python testing frameworks?  Or would such an approach be antithetical to unit testing's underlying philosophy?","AnswerCount":5,"Available Count":4,"Score":0.0399786803,"is_accepted":false,"ViewCount":1809,"Q_Id":3885489,"Users Score":1,"Answer":"This seems to be a recurring question - e.g. #3396055\nIt most probably isn't a unit-test, because they should be fast (and independent). So running them all isn't a big drag. I can see where this might help in short-circuiting integration\/regression runs to save time. If this is a major need for you, I'd tag the setup tests with [Core] or some such attribute.\nI then proceed to write a build script which has two tasks  \n\nTaskn : run all tests in X,Y,Z dlls marked with tag [Core]\nTaskn+1 depends on Taskn: run all tests in X,Y,Z dlls excluding those marked with tag [Core]\n\n(Taskn+1 shouldn't run if Taskn didn't succeed.) It isn't a perfect solution - e.g. it would just bail out if any one [Core] test failed. But I guess you should be fixing the Core ones instead of proceeding with Non-Core tests.","Q_Score":6,"Tags":"python,unit-testing,testing","A_Id":3895868,"CreationDate":"2010-10-07T20:09:00.000","Title":"Test framework allowing tests to depend on other 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":0},{"Question":"I'm wondering if there is a test framework that allows for tests to be declared as being dependent on other tests.  This would imply that they should not be run, or that their results should not be prominently displayed, if the tests that they depend on do not pass.\nThe point of such a setup would be to allow the root cause to be more readily determined in a situation where there are many test failures.\nAs a bonus, it would be great if there some way to use an object created with one test as a fixture for other tests.\nIs this feature set provided by any of the Python testing frameworks?  Or would such an approach be antithetical to unit testing's underlying philosophy?","AnswerCount":5,"Available Count":4,"Score":0.0,"is_accepted":false,"ViewCount":1809,"Q_Id":3885489,"Users Score":0,"Answer":"The test runners py.test, Nosetests and unit2\/unittest2 all support the notion of \"exiting after the first failure\".  py.test more generally allows to specify \"--maxfail=NUM\" to stop running and reporting after NUM failures. This may already help your case especially since maintaining and updating dependencies for tests may not be that interesting a task.","Q_Score":6,"Tags":"python,unit-testing,testing","A_Id":3897462,"CreationDate":"2010-10-07T20:09:00.000","Title":"Test framework allowing tests to depend on other 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":0},{"Question":"Little question concerning app architecture:\nI have a python script, running as a daemon.\nInside i have many objects, all inheriting from one class (let's name it 'entity')\nI have also one main object, let it be 'topsys'\nEntities are identified by pair (id, type (= class, roughly)), and they are connected in many wicked ways. They are also created and deleted all the time, and they are need to access other entities. \nSo, i need a kind of storage, basically dictionary of dictionaries (one for each type), holding all entities.\nAnd the question is, what is better: attach this dictionary to 'topsys' as a object property or to class entity, as a property of the class? I would opt for the second (so entities does not need to know of existence of 'topsys'), but i am not feeling good about using properties directly in classes. Or maybe there is another way?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":3257,"Q_Id":3895359,"Users Score":0,"Answer":"There is no problem with using properties on classes. Classes are just objects, too. \nIn your case, with this little information available, I would go for a class property, too, because not creating dependencies ist great and will be one worry less sometimes later.","Q_Score":4,"Tags":"python,design-patterns,global-variables,class-design","A_Id":3895385,"CreationDate":"2010-10-09T01:48:00.000","Title":"python global object cache","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":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":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},{"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},{"Question":"I have a Python daemon running in production. It employs between 7 and 120 threads. Recently the smallest instance (7 threads) started to show hangs while all other instances never showed this kind of problem. Attaching strace to the python process shows that all threads are calling futex FUTEX_WAIT_PRIVATE, so they are probably trying to lock something.\nHow would you debug such a problem?\nNote that this is a production system running from flash memory, so disk writes are constrained, too.","AnswerCount":2,"Available Count":2,"Score":0.1973753202,"is_accepted":false,"ViewCount":7410,"Q_Id":3905883,"Users Score":2,"Answer":"Dear Helmut, I've the same problem with one thread hanging on FUTEXT_WAIT_PRIVATE.\nIt seems you have solved the issue. Can you share more information about the solution?\nUPD:\nThe reason for the lock was finally found (at least for my case): it was due to import lock in Python.\nConsider following situation:\nfile1.py:\n\nimport file2\n\nfile2.py:\n\ncreate thread \"thread2\"\nrun \"thread2\"\nwait until \"thread2\" finish with some function (let's say go Go())\ndef Go():\n\nimport some_module\n....\n\n\nHere the import in Go() would hang up since the import is locked in the main thread (by import file2) which will not be released until Go() finishes. The user will see in strace hang on FUTEX_WAIT_PRIVATE.\nTo work around this place the code executed during the import of file2 into Do() function and run it after importing file2:\n\nimport file2\nfile2.Do()","Q_Score":2,"Tags":"python,multithreading,debugging,deadlock,futex","A_Id":4533967,"CreationDate":"2010-10-11T11:48:00.000","Title":"Python hangs in futex calls","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I have a Python daemon running in production. It employs between 7 and 120 threads. Recently the smallest instance (7 threads) started to show hangs while all other instances never showed this kind of problem. Attaching strace to the python process shows that all threads are calling futex FUTEX_WAIT_PRIVATE, so they are probably trying to lock something.\nHow would you debug such a problem?\nNote that this is a production system running from flash memory, so disk writes are constrained, too.","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":7410,"Q_Id":3905883,"Users Score":4,"Answer":"The observation was slightly incorrect. One thread wasn't calling futex, but instead swapping while holding the gil. Since the machine in question is low hardware this swapping took very long and seemed to be a deadlock. The underlying problem is a memory leak. :-(","Q_Score":2,"Tags":"python,multithreading,debugging,deadlock,futex","A_Id":3913056,"CreationDate":"2010-10-11T11:48:00.000","Title":"Python hangs in futex calls","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I now primarily write in python, however I am looking for a language that is more thread friendly (not JAVA,C#,C or C++).\nPython's threads are good when they are IO bound but it's coming up short when I am doing something CPU intensive.\nAny ideas?\nThanks,\nJames","AnswerCount":8,"Available Count":2,"Score":0.024994793,"is_accepted":false,"ViewCount":457,"Q_Id":3911897,"Users Score":1,"Answer":"Take the hint.  CPU intensive programs can also be made into multiple processes.  Multiple processes and a pipeline to pass status around can often have outstanding performance.\nRather than fish around randomly for other languages, do this.\n\nDecompose the problem into a pipeline of steps that can be done concurrently.\nIn the shell, the top-level script is this: a.py | b.py | c.py | d.py...\nWrite each step as a very small Python loop that reads from sys.stdin and writes to sys.stdout.  Interesting, this is the default for raw_input() and print() making things simple.\nMeasure the performance.\n\nYou'll -- correctly -- spend all your time designing your algorithm.  You'll spend little time coding or learning a new language.  You'll trivially tie up every core on every CPU available to you.  You'll spend no time on thread synchronization or other foolishness.\nThis kind of thing works very, very well for \"CPU Intensive\" applications.","Q_Score":3,"Tags":"python,multithreading,multiprocessing,concurrency","A_Id":3913601,"CreationDate":"2010-10-12T05:26:00.000","Title":"\"Pythonic\" multithreaded (Concurrent) 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},{"Question":"I now primarily write in python, however I am looking for a language that is more thread friendly (not JAVA,C#,C or C++).\nPython's threads are good when they are IO bound but it's coming up short when I am doing something CPU intensive.\nAny ideas?\nThanks,\nJames","AnswerCount":8,"Available Count":2,"Score":0.024994793,"is_accepted":false,"ViewCount":457,"Q_Id":3911897,"Users Score":1,"Answer":"to overcome GIL, you can try interpreting python language with jython instead of cpython","Q_Score":3,"Tags":"python,multithreading,multiprocessing,concurrency","A_Id":3911913,"CreationDate":"2010-10-12T05:26:00.000","Title":"\"Pythonic\" multithreaded (Concurrent) 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},{"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},{"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},{"Question":"I'm developing a Python utility module to help with file downloads, archives, etc. I have a project set up in a virtual environment along with my unit tests. When I want to use this module on the same computer (essentially as \"Production\"), I move the files to the mymodule directory in the ~\/dev\/modules\/mymodule\nI keep all 3rd-party modules under ~\/dev\/modules\/contrib. This contrib path is on my PYTHONPATH, but mymodule is NOT because I've noticed that if mymodule is on my PYTHONPATH, my unit tests cannot distinguish between the \"Development\" version and the \"Production\" version. But now if I want to use this common utility module, I have to manually add it to the PYTHONPATH. \nThis works, but I'm sure there's a better, more automated way. \nWhat is the best way to have a Development and Production module on the same computer? For instance, is there a way to set PYTHONPATH dynamically?","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":209,"Q_Id":3914289,"Users Score":0,"Answer":"You could set the PYTHONPATH as a global environment variable pointing to your Production code, and then in any shell in which you want to use the Development code, change the PYTHONPATH to point to that code.\n(Is that too simplistic?  Have I missed something?)","Q_Score":2,"Tags":"python,module,packaging,pythonpath","A_Id":3914361,"CreationDate":"2010-10-12T11:47:00.000","Title":"Developing and using the same Python on the same 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":1,"System Administration and DevOps":0,"Web Development":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},{"Question":"Google won't let me search |= so I'm having trouble finding relevant documentation. Anybody know?","AnswerCount":10,"Available Count":2,"Score":1.0,"is_accepted":false,"ViewCount":124921,"Q_Id":3929278,"Users Score":53,"Answer":"When used with sets it performs union operation.","Q_Score":183,"Tags":"python","A_Id":43015990,"CreationDate":"2010-10-14T01:00:00.000","Title":"What does |= (ior) do 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},{"Question":"Google won't let me search |= so I'm having trouble finding relevant documentation. Anybody know?","AnswerCount":10,"Available Count":2,"Score":0.0399786803,"is_accepted":false,"ViewCount":124921,"Q_Id":3929278,"Users Score":2,"Answer":"In Python,|=(ior) works like union operation.\nlike if x=5 and x|=5 then both the value will first convert in binary value then the union operation will perform and we get the answer 5.","Q_Score":183,"Tags":"python","A_Id":51221579,"CreationDate":"2010-10-14T01:00:00.000","Title":"What does |= (ior) do 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},{"Question":"How do you execute nosetest from pycharm to run all unit tests?\nI know that pycharm supports python's unittest and py.test and that they will properly support nosetests in pycharm 1.1 but I was wondering if there was a work around.","AnswerCount":3,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":20545,"Q_Id":3930422,"Users Score":41,"Answer":"In the current version of Pycharm (2.6) there should be a context menu \"run Nosetests in ...\" on a test file. If this is missing, go to file->settings->Project Settings->python integrated tools and ensure the Default Test Runner is Nosetests. You do of course need to have Nosetests installed - pycharm will offer this if you do not.\nThis does have a limitation. If the file in question does not have a class derived from unittest.TestCase it will not automatically show this. If you are using nose.tools or simple assertions it will not automatically offer this. This is probably a bug.","Q_Score":30,"Tags":"python,unit-testing,nose,nosetests,pycharm","A_Id":13359250,"CreationDate":"2010-10-14T05:45:00.000","Title":"How do you run nosetest from 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},{"Question":"How do you execute nosetest from pycharm to run all unit tests?\nI know that pycharm supports python's unittest and py.test and that they will properly support nosetests in pycharm 1.1 but I was wondering if there was a work around.","AnswerCount":3,"Available Count":2,"Score":0.1325487884,"is_accepted":false,"ViewCount":20545,"Q_Id":3930422,"Users Score":2,"Answer":"If you can live without the graphical test runner, you can simply create a \"Python Script\" run configuration and run the tests as you run them from the command line.\nThe only way to get nose tests working with the graphical test runner, I'm afraid, is to hack on helpers\/pycharm\/utrunner.py from the PyCharm distribution.","Q_Score":30,"Tags":"python,unit-testing,nose,nosetests,pycharm","A_Id":3931985,"CreationDate":"2010-10-14T05:45:00.000","Title":"How do you run nosetest from 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},{"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},{"Question":"I'm unfamiliar with the new oauth system. I wanted to crawl the status updates of my friends, and their friends' (if permissions allow) with my specified account credentials using the python-twitter api. \nWith the new oauth authentication, does it means that I have to first register an application with twitter before I can use api?","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":206,"Q_Id":3940774,"Users Score":1,"Answer":"Yes, thats right. You need to register it and connect \"grant access\" it with your twitter id, if you want, for example, post something on your twitter wall. Also see \"connections\" in your twitter id.","Q_Score":1,"Tags":"python,oauth,twitter","A_Id":3940860,"CreationDate":"2010-10-15T08:53:00.000","Title":"noob question regarding twitter oauth","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},{"Question":"I'm unfamiliar with the new oauth system. I wanted to crawl the status updates of my friends, and their friends' (if permissions allow) with my specified account credentials using the python-twitter api. \nWith the new oauth authentication, does it means that I have to first register an application with twitter before I can use api?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":206,"Q_Id":3940774,"Users Score":0,"Answer":"For use api you must register your aplication or use GET methods to post into twi through  web interface.","Q_Score":1,"Tags":"python,oauth,twitter","A_Id":3940840,"CreationDate":"2010-10-15T08:53:00.000","Title":"noob question regarding twitter oauth","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},{"Question":"I was going through a few tests written in Java using JUnit and I could'nt help noticing the emphasis which is laid on checking the \"type\" of objects. This is something I have never seen in Python test-suites.\nJava being statically-typed and Python being dynamically-typed, should'nt the reverse be the case?","AnswerCount":3,"Available Count":1,"Score":0.3215127375,"is_accepted":false,"ViewCount":187,"Q_Id":3943808,"Users Score":5,"Answer":"Python unit tests do check types. All the time. In fact, that's the only thing they are doing.\nPython is duck-typed. Duck typing means that the type of an object is defined by its behavior. Unit tests test behavior. Ergo, they test types.","Q_Score":3,"Tags":"java,python,unit-testing","A_Id":3944260,"CreationDate":"2010-10-15T15:43:00.000","Title":"Python unittests almost never check types","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I am preparing to develop a web application that will (hopefully) be used by an audience with many different native languages.  \nWhat should I do to prepare my software project to have the user interface be almost entirely internationalized?  \nAre there any software stacks that make this easier?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":98,"Q_Id":3950851,"Users Score":0,"Answer":"One big change in your project: you need to build in time to localize your strings.  Depending on your schedules, you may have to rearrange work so that all the string-changing work is at the front so that you have time to get the translations done before launching.\nOr, alternately, you have to build in a buffer at the end to account for it.","Q_Score":1,"Tags":"python,django,internationalization,project-planning","A_Id":3970432,"CreationDate":"2010-10-16T21:21:00.000","Title":"Preparing a web site for international usage","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"So I have 16 GB worth of XML files to process (about 700 files total), and I already have a functional PHP script to do that (With XMLReader) but it's taking forever. I was wondering if parsing in Python would be faster (Python being the only other language I'm proficient in, I'm sure something in C would be faster).","AnswerCount":3,"Available Count":2,"Score":0.1325487884,"is_accepted":false,"ViewCount":1714,"Q_Id":3953563,"Users Score":2,"Answer":"I think that both of them can rely over wrappers for fast C libraries (mostly libxml2) so there's shouldn't be too much difference in parsing per se.\nYou could try if there are differences caused by overhead, then it depends what are you gonna do over that XML. Parsing it for what?","Q_Score":2,"Tags":"php,python,xml","A_Id":3953576,"CreationDate":"2010-10-17T14:07:00.000","Title":"Is XML parsing in PHP as fast as Python or other alternatives?","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},{"Question":"So I have 16 GB worth of XML files to process (about 700 files total), and I already have a functional PHP script to do that (With XMLReader) but it's taking forever. I was wondering if parsing in Python would be faster (Python being the only other language I'm proficient in, I'm sure something in C would be faster).","AnswerCount":3,"Available Count":2,"Score":0.1325487884,"is_accepted":false,"ViewCount":1714,"Q_Id":3953563,"Users Score":2,"Answer":"There's actually three differing performance problems here:\n\nThe time it takes to parse a file, which depends on the size of individual files.\nThe time it takes to handle the files and directories in the filesystem, if there's a lot of them.\nWriting the data into your databases.\n\nWhere you should look for performance improvements depends on which one of these is the biggest bottleneck.\nMy guess is that the last one is the biggest problem because writes is almost always the slowest: writes can't be cached, they requires writing to disk and if the data is sorted it can take a considerable time to find the right spot to write it.\nYou presume that the bottleneck is the first alternative, the XML parsing. If that is the case, changing language is not the first thing to do. Instead you should see if there's some sort of SAX parser for your language. SAX parsing is much faster and memory effective than DOM parsing.","Q_Score":2,"Tags":"php,python,xml","A_Id":3953874,"CreationDate":"2010-10-17T14:07:00.000","Title":"Is XML parsing in PHP as fast as Python or other alternatives?","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},{"Question":"I'm doing some research on how to compare sound files(wave). Basically, I want to compare stored soundfiles (wav) with sound from a microphone. So in the end I would like to pre-store some voice commands of my own and then when I'm running my app I would like to compare the pre-stored files with input from the microphone.\nMy thought was to put in some margin when comparing because saying something two times in a row in the exactly same way would be difficult I guess.\nSo after some googling I see that Python has this module named wave and the Wave_read object. That object has a function named readframes(n):\n\nReads and returns at most n frames of\naudio, as a string of bytes.\n\nWhat do these bytes contain? I'm thinking of looping thru the wave files one frame at the time comparing them frame by frame.","AnswerCount":4,"Available Count":4,"Score":1.0,"is_accepted":false,"ViewCount":39854,"Q_Id":3957025,"Users Score":6,"Answer":"The first thing you should do is a fourier transformation to transform the data into its frequencies. It is rather complex however. I wouldn't use voice recognition libraries here as it sounds like you don't record voices only. You would then try different time shifts (in case the sounds are not exactly aligned) and use the one that gives you the best similarity - where you have to define a similarity function. Oh and you should normalize both signals (same maximum loudness).","Q_Score":23,"Tags":"python,wav","A_Id":9184327,"CreationDate":"2010-10-18T06:38:00.000","Title":"What does a audio frame contain?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I'm doing some research on how to compare sound files(wave). Basically, I want to compare stored soundfiles (wav) with sound from a microphone. So in the end I would like to pre-store some voice commands of my own and then when I'm running my app I would like to compare the pre-stored files with input from the microphone.\nMy thought was to put in some margin when comparing because saying something two times in a row in the exactly same way would be difficult I guess.\nSo after some googling I see that Python has this module named wave and the Wave_read object. That object has a function named readframes(n):\n\nReads and returns at most n frames of\naudio, as a string of bytes.\n\nWhat do these bytes contain? I'm thinking of looping thru the wave files one frame at the time comparing them frame by frame.","AnswerCount":4,"Available Count":4,"Score":1.0,"is_accepted":false,"ViewCount":39854,"Q_Id":3957025,"Users Score":7,"Answer":"I believe the accepted description to be slightly incorrect.\nA frame appears to be somewhat like stride in graphics formats.  For interleaved stereo @ 16 bits\/sample, the frame size is 2*sizeof(short)=4 bytes.  For non-interleaved stereo @ 16 bits\/sample, the samples of the left channel are all one after another, so the frame size is just sizeof(short).","Q_Score":23,"Tags":"python,wav","A_Id":20810191,"CreationDate":"2010-10-18T06:38:00.000","Title":"What does a audio frame contain?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I'm doing some research on how to compare sound files(wave). Basically, I want to compare stored soundfiles (wav) with sound from a microphone. So in the end I would like to pre-store some voice commands of my own and then when I'm running my app I would like to compare the pre-stored files with input from the microphone.\nMy thought was to put in some margin when comparing because saying something two times in a row in the exactly same way would be difficult I guess.\nSo after some googling I see that Python has this module named wave and the Wave_read object. That object has a function named readframes(n):\n\nReads and returns at most n frames of\naudio, as a string of bytes.\n\nWhat do these bytes contain? I'm thinking of looping thru the wave files one frame at the time comparing them frame by frame.","AnswerCount":4,"Available Count":4,"Score":1.0,"is_accepted":false,"ViewCount":39854,"Q_Id":3957025,"Users Score":8,"Answer":"A simple byte-by-byte comparison has almost no chance of a successful match, even with some tolerance thrown in. Voice-pattern recognition is a very complex and subtle problem that is still the subject of much research.","Q_Score":23,"Tags":"python,wav","A_Id":3957097,"CreationDate":"2010-10-18T06:38:00.000","Title":"What does a audio frame contain?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I'm doing some research on how to compare sound files(wave). Basically, I want to compare stored soundfiles (wav) with sound from a microphone. So in the end I would like to pre-store some voice commands of my own and then when I'm running my app I would like to compare the pre-stored files with input from the microphone.\nMy thought was to put in some margin when comparing because saying something two times in a row in the exactly same way would be difficult I guess.\nSo after some googling I see that Python has this module named wave and the Wave_read object. That object has a function named readframes(n):\n\nReads and returns at most n frames of\naudio, as a string of bytes.\n\nWhat do these bytes contain? I'm thinking of looping thru the wave files one frame at the time comparing them frame by frame.","AnswerCount":4,"Available Count":4,"Score":1.2,"is_accepted":true,"ViewCount":39854,"Q_Id":3957025,"Users Score":47,"Answer":"An audio frame, or sample, contains amplitude (loudness) information at that particular point in time.  To produce sound, tens of thousands of frames are played in sequence to produce frequencies.\nIn the case of CD quality audio or uncompressed wave audio, there are around 44,100 frames\/samples per second.  Each of those frames contains 16-bits of resolution, allowing for fairly precise representations of the sound levels.  Also, because CD audio is stereo, there is actually twice as much information, 16-bits for the left channel, 16-bits for the right.\nWhen you use the sound module in python to get a frame, it will be returned as a series of  hexadecimal characters:\n\nOne character for an 8-bit mono signal.\nTwo characters for 8-bit stereo.\nTwo characters for 16-bit mono.\nFour characters for 16-bit stereo.\n\nIn order to convert and compare these values you'll have to first use the python wave module's functions to check the bit depth and number of channels.  Otherwise, you'll be comparing mismatched quality settings.","Q_Score":23,"Tags":"python,wav","A_Id":3957230,"CreationDate":"2010-10-18T06:38:00.000","Title":"What does a audio frame contain?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"How to get UID of mail in All Maill folder if I have UID of this mail in inbox using imaplib?\nAs you know the google store mails in the two instances in All Mail and in inbox I whant to move this to mail in trash folder using imaplib","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":2438,"Q_Id":3958019,"Users Score":1,"Answer":"You can do it using any of the 2 following ways.\n\nYou can use Message-Id field of the mail header.Message-Id field for both the mail \n    will be same.\nApply SEARCH  command on All Mail Folder.\n   i.e search on title --> it will give you uid for that mail.","Q_Score":2,"Tags":"python,gmail,imaplib","A_Id":3984960,"CreationDate":"2010-10-18T09:48:00.000","Title":"How to get UID of mail in All Maill folder if I have UID of this mail in inbox using imaplib? (GMail)","Data Science and Machine Learning":0,"Database and SQL":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},{"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},{"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},{"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},{"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},{"Question":"I have a python dictionary stored in a file which I need to access from a c++ program. What is the best way of doing this?\nThanks","AnswerCount":3,"Available Count":2,"Score":0.1325487884,"is_accepted":false,"ViewCount":2650,"Q_Id":3966227,"Users Score":2,"Answer":"There are umpteen Python\/C++ bindings (including the one in Boost) but I suggest KISS: not a Python\/C++ binding but the principle \"Keep It Simple, Stupid\".\nUse a Python program to access the dictionary. :-)\nYou can access the Python program(s) from C++ by running them, or you can do more fancy things such as communicating between Python and C++ via sockets or e.g. Windows \"mailslots\" or even some more full-fledged interprocess communication scheme.\nCheers & hth.","Q_Score":0,"Tags":"c++,python,dictionary","A_Id":3966356,"CreationDate":"2010-10-19T07:47:00.000","Title":"Read python dictionary using 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},{"Question":"I have a python dictionary stored in a file which I need to access from a c++ program. What is the best way of doing this?\nThanks","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":2650,"Q_Id":3966227,"Users Score":0,"Answer":"I assume your Python dict is using simple data types and no objects (so strings\/numbers\/lists\/nested dicts), since you want to use it in C++.\nI would suggest using json library (http:\/\/docs.python.org\/library\/json.html) to deserialize it and then use a C++ equivalent to serialize it to a C++ object.","Q_Score":0,"Tags":"c++,python,dictionary","A_Id":3967560,"CreationDate":"2010-10-19T07:47:00.000","Title":"Read python dictionary using 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},{"Question":"i saw a javascript implementation of sha-256.\ni waana ask if it is safe (pros\/cons wathever) to use sha-256 (using javascript implementation or maybe python standard modules) alogrithm as a password generator:\ni remember one password, put it in followed(etc) by the website address and use the generated text as the password for that website.\nrepeat process every time i need password\nsame for other websites","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1380,"Q_Id":3974211,"Users Score":0,"Answer":"SHA-256 generates very long strings. You're better off using random.choice() with a string a fixed number of times.","Q_Score":1,"Tags":"javascript,python,sha256","A_Id":3974224,"CreationDate":"2010-10-20T02:01:00.000","Title":"SHA-256 password generator","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"Say you want to schedule recurring tasks, such as:\n\nSend email every wednesday at 10am\nCreate summary on the first day of every month\n\nAnd you want to do this for a reasonable number of users in a web app - ie. 100k users each user can decide what they want scheduled when.\nAnd you want to ensure that the scheduled items run, even if they were missed originally - eg. for some reason the email didn't get sent on wednesday at 10am, it should get sent out at the next checking interval, say wednesday at 11am.\nHow would you design that?\nIf you use cron to trigger your scheduling app every x minutes, what's a good way to implement the part that decides what should run at each point in time?\nThe cron-like implementations I've seen compare the current time to the trigger time for all specified items, but I'd like to deal with missed items as well.\nI have a feeling there's a more clever design than the one I'm cooking up, so please enlighten me.","AnswerCount":3,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":3985,"Q_Id":3980782,"Users Score":7,"Answer":"There's 2 designs, basically.\nOne runs regularly and compares the current time to the scheduling spec (i.e. \"Does this run now?\"), and executes those that qualify.\nThe other technique takes the current scheduling spec and finds the NEXT time that the item should fire. Then, it compares the current time to all of those items who's \"next time\" is less than \"current time\", and fires those. Then, when an item is complete, it is rescheduled for the new \"next time\".\nThe first technique can not handle \"missed\" items, the second technique can only handle those items that were previously scheduled.\nSpecifically consider you you have a schedule that runs once every hour, at the top of the hour.\nSo, say, 1pm, 2pm, 3pm, 4pm.\nAt 1:30pm, the run task is down and not executing any processes. It does not start again until 3:20pm.\nUsing the first technique, the scheduler will have fired the 1pm task, but not fired the 2pm, and 3pm tasks, as it was not running when those times passed. The next job to run will be the 4pm job, at, well, 4pm.\nUsing the second technique, the scheduler will have fired the 1pm task, and scheduled the next task at 2pm. Since the system was down, the 2pm task did not run, nor did the 3pm task. But when the system restarted at 3:20, it saw that it \"missed\" the 2pm task, and fired it off at 3:20, and then scheduled it again for 4pm.\nEach technique has it's ups and downs. With the first technique, you miss jobs. With the second technique you can still miss jobs, but it can \"catch up\" (to a point), but it may also run a job \"at the wrong time\" (maybe it's supposed to run at the top of the hour for a reason).\nA benefit of the second technique is that if you reschedule at the END of the executing job, you don't have to worry about a cascading job problem.\nConsider that you have a job that runs every minute. With the first technique, the job gets fired each minute. However, typically, if the job is not FINISHED within it's minute, then you can potentially have 2 jobs running (one late in the process, the other starting up). This can be a problem if the job is not designed to run more than once simultaneously. And it can exacerbate (if there's a real problem, after 10 minutes you have 10 jobs all fighting each other).\nWith the second technique, if you schedule at the end of the job, then if a job happens to run just over a minute, then you'll \"skip\" a minute\" and start up the following minute rather than run on top of itself. So, you can have a job scheduled for every minute actually run at 1:01pm, 1:03pm, 1:05pm, etc.\nDepending on your job design, either of these can be \"good\" or \"bad\". There's no right answer here.\nFinally, implementing the first technique is really, quite trivial compared to implementing the second. The code to determine if a cron string (say) matches a given time is simple compared to deriving what time a cron string will be valid NEXT. I know, and I have a couple hundred lines of code to prove it. It's not pretty.","Q_Score":9,"Tags":"python,cron,scheduling","A_Id":3980935,"CreationDate":"2010-10-20T17:50:00.000","Title":"cron-like recurring task scheduler design","Data Science and Machine Learning":0,"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},{"Question":"I have Python extensions implemented on C++ classes. I don't have a C++ target to run valgrind with. I want to use valgrind for memory check. \nCan I use valgrind with Python?","AnswerCount":3,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":14762,"Q_Id":3982036,"Users Score":9,"Answer":"In Python 2.7 and 3.2 there is now a --with-valgrind compile-time flag that allows the Python interpreter to detect when it runs under valgrind and disables PyMalloc. This should allow you to more accurately monitor your memory allocations than otherwise, as PyMalloc just allocates memory in big chunks.","Q_Score":37,"Tags":"c++,python,valgrind","A_Id":7856043,"CreationDate":"2010-10-20T20:32:00.000","Title":"How can I use valgrind with Python C++ extensions?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":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},{"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},{"Question":"Is there a way to globally trap MemoryError exceptions so that a library can clear out caches instead of letting a MemoryError be seen by user code?\nI'm developing a memory caching library in Python that stores very large objects, to the point where it's common for users to want to use all available RAM to simplify their scripts and\/or speed them up.  I'd like to be able to have a hook where the python interpreter asks a callback function to release some RAM as a way of avoiding a MemoryError being invoked in user code.  \nOS: Solaris and\/or Linux\nPython: cPython 2.6.*\n\nEDIT: I'm looking for a mechanism that wouldn't be handled by an except block.  If there would be a memory error in any code for any reason, I'd like to have the Python interpreter first try to use a callback to release some RAM and never have the MemoryError exception ever generated.  I don't control the code that would generate the errors and I'd like my cache to be able to aggressively use as much RAM as it wants, automatically freeing up RAM as it's needed by the user code.","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":1774,"Q_Id":3991257,"Users Score":1,"Answer":"A MemoryError is an exception, you should be able to catch it in an except block.","Q_Score":4,"Tags":"python,memory-management,caching","A_Id":3991307,"CreationDate":"2010-10-21T19:41:00.000","Title":"MemoryError hook 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},{"Question":"Is there a way to globally trap MemoryError exceptions so that a library can clear out caches instead of letting a MemoryError be seen by user code?\nI'm developing a memory caching library in Python that stores very large objects, to the point where it's common for users to want to use all available RAM to simplify their scripts and\/or speed them up.  I'd like to be able to have a hook where the python interpreter asks a callback function to release some RAM as a way of avoiding a MemoryError being invoked in user code.  \nOS: Solaris and\/or Linux\nPython: cPython 2.6.*\n\nEDIT: I'm looking for a mechanism that wouldn't be handled by an except block.  If there would be a memory error in any code for any reason, I'd like to have the Python interpreter first try to use a callback to release some RAM and never have the MemoryError exception ever generated.  I don't control the code that would generate the errors and I'd like my cache to be able to aggressively use as much RAM as it wants, automatically freeing up RAM as it's needed by the user code.","AnswerCount":3,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":1774,"Q_Id":3991257,"Users Score":4,"Answer":"This is not a good way of handling memory management.  By the time you see MemoryError, you're already in a critical state where the kernel is probably close to killing processes to free up memory, and on many systems you'll never see it because it'll go to swap or just OOM-kill your process rather than fail allocations.\nThe only recoverable case you're likely to see MemoryError is after trying to make a very large allocation that doesn't fit in available address space, only common on 32-bit systems.\nIf you want to have a cache that frees memory as needed for other allocations, it needs to not interface with errors, but with the allocator itself.  This way, when you need to release memory for an allocation you'll know how much contiguous memory is needed, or else you'll be guessing blindly.  It also means you can track memory allocations as they happen, so you can keep memory usage at a specific level, rather than letting it grow unfettered and then trying to recover when it gets too high.\nI'd strongly suggest that for most applications this sort of caching behavior is overcomplicated, though--you're usually better off just using a set amount of memory for cache.","Q_Score":4,"Tags":"python,memory-management,caching","A_Id":3991666,"CreationDate":"2010-10-21T19:41:00.000","Title":"MemoryError hook 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},{"Question":"How can I make a Python script which checks if I have logged in the Facebook? If I haven't, it should log me in.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1207,"Q_Id":3998586,"Users Score":1,"Answer":"Being \"logged in\" to Facebook (or any system for that matter) is generally a contract between the server and the client - and not just a \"flipped bit\" on the server.\nAs an example, if you log into Facebook on you phone - you can't then pull up Facebook on your desktop machine and be logged in.\nIn short - no, I don't think so.","Q_Score":0,"Tags":"python,facebook","A_Id":3998919,"CreationDate":"2010-10-22T15:53:00.000","Title":"Python Facebook login","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"My current web host allows for up to 25 processes running at once. From what I can figure, Python scripts take up a spot in processes, but PHP doesn't? \nI get a 500 error if more than 25 processes are running at once (unlikely, but still a hassle), so I was wondering if it would be easier on the server if I were to port my site over to PHP?\nThanks!","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":591,"Q_Id":3999679,"Users Score":2,"Answer":"You are using HostGator. Switch hosts. Their shared server offerings should be used by very low traffic, brochure sites as they cram 100's of vhosts onto each server.\nIf you can't switch, ensure you're setup to use mod_php (not suPHP or cgi) or Python equivalent. Otherwise, new processes will be spawned on each request and you'll be serving up blank pages in no time.","Q_Score":2,"Tags":"php,python,resources","A_Id":3999983,"CreationDate":"2010-10-22T18:09:00.000","Title":"What's more resource intensive? PHP 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":0,"Web Development":0},{"Question":"Say I let users upload files to my server, and I let users download them.  I'd like to set the mime type to something other than just application\/octet-stream, so that if the browser can just open them, it does (say, for images, pdf files, plain text files, etc.)  Of course, since the files are uploaded by users, I can't trust the file extension, etc.\nIs there a good library for figuring out what mime type goes with an arbitrary blob?  Preferably usable from Python :-)\nThanks!","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":203,"Q_Id":4002015,"Users Score":1,"Answer":"Beware of text files: there's no way of knowing what encoding they're in, and there's no reliable way of guessing, especially since most ones created in Windows are in 8-bit MBCS encodings which are indistinguishable without language heuristics.  You need to know the encoding--not just the MIME type--to set the complete Content-Type for a file to be viewable in a browser.  If you want to allow uploading and displaying text, it's much safer to use an HTML text form than a raw file upload.\nAlso, note that a file can be multiple file types; for example, self-extracting ZIPs are both valid Windows executables and ZIP files, and can be treated as either.","Q_Score":0,"Tags":"python,web-applications,mime,mime-types","A_Id":4002237,"CreationDate":"2010-10-23T01:33:00.000","Title":"Can I reliably figure out the correct mime type to serve untrusted 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":1},{"Question":"In my organization, we have a couple of internally developed Python packages. For sake of example, let's call them Foo and Bar. Both are developed in separate Git repositories. Foo is a Pylons application that uses certain library functions from Bar. Neither is publicly distributed.\nWhen we deploy Foo, we typically export the latest revision from source control and run setup.py develop within our virtualenv. This works okay.\nThe problem is that we'll need some way of distributing Bar for every environment where we deploy Foo. We obviously can't put 'Bar' in setup.py's install_requires (as easy_install won't find be able to find it on any website). I can't find any way of automatically obtaining\/installing privately developed dependencies.\nIs there an easier to way to manage this? I feel like I'm missing the point of Python packaging and distribution.","AnswerCount":3,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":163,"Q_Id":4005009,"Users Score":2,"Answer":"You can create a package repository. The steps are basically:\n\nCreate an egg with setup.py bdist_egg\nCopy the created egg from dist to a directory served by Apache\nAdd the url to the directory exposed by Apache to the easy_install command with the -f switch\n\nNote that Apache is not necessarily required, but it automatically generates a directory listing that easy_install can deal with.\nIf you are using buildout, there are config options to do the same thing as -f and I am pretty sure there is something you can use in pip as well.","Q_Score":2,"Tags":"python,deployment,setuptools,distutils","A_Id":4005069,"CreationDate":"2010-10-23T16:40:00.000","Title":"Pylons app deployment with privately developed 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":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"In my organization, we have a couple of internally developed Python packages. For sake of example, let's call them Foo and Bar. Both are developed in separate Git repositories. Foo is a Pylons application that uses certain library functions from Bar. Neither is publicly distributed.\nWhen we deploy Foo, we typically export the latest revision from source control and run setup.py develop within our virtualenv. This works okay.\nThe problem is that we'll need some way of distributing Bar for every environment where we deploy Foo. We obviously can't put 'Bar' in setup.py's install_requires (as easy_install won't find be able to find it on any website). I can't find any way of automatically obtaining\/installing privately developed dependencies.\nIs there an easier to way to manage this? I feel like I'm missing the point of Python packaging and distribution.","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":163,"Q_Id":4005009,"Users Score":0,"Answer":"At my work we use setuptools to create packages specific to the OS.  We happen to use RedHat so we call bdist_rpm to create rpm package.  We find that works better than eggs because we can do dependency management in the packages for both python and non-python libs.\nWe create the rpms on our continuous integration machine and the move them to a YUM repo where they can be pushed out via a YUM update or upgrade.","Q_Score":2,"Tags":"python,deployment,setuptools,distutils","A_Id":4057725,"CreationDate":"2010-10-23T16:40:00.000","Title":"Pylons app deployment with privately developed 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":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"How can I make it so unit tests in Python (using unittest) are run in the order in which they are specified in the file?","AnswerCount":8,"Available Count":1,"Score":0.049958375,"is_accepted":false,"ViewCount":18462,"Q_Id":4005695,"Users Score":2,"Answer":"There are also test runners which do that by themselves \u2013 I think py.test does it.","Q_Score":35,"Tags":"python,unit-testing","A_Id":4005931,"CreationDate":"2010-10-23T19:32:00.000","Title":"changing order of unit tests 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},{"Question":"How can I tell the encoding of the source file from inside a running python process, if it is even possible?","AnswerCount":2,"Available Count":1,"Score":-0.0996679946,"is_accepted":false,"ViewCount":1318,"Q_Id":4005928,"Users Score":-1,"Answer":"If you examine __file__, it will give you the file name of the running code.  If it ends in \".pyc\" or \".pyo\", clip off the last character.  This is the source file of the running code.  Read that file, looking for the encoding header.\nNote that this is a simplification, and it can get much harder to find the real source file, but this will work in many cases.\nBTW: Why do you need to know the encoding of the source file? It should be irrelevant, I would have thought.","Q_Score":2,"Tags":"python,encoding","A_Id":4005965,"CreationDate":"2010-10-23T20:30:00.000","Title":"Get CURRENT_FILE_ENCODING for a python file or 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":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"It seems like just adding a package path to your PYTHONPATH gives you access to all of its modules and functions, similar to installing an egg. Is the difference just that the egg is zip compressed?","AnswerCount":4,"Available Count":1,"Score":0.049958375,"is_accepted":false,"ViewCount":1047,"Q_Id":4009781,"Users Score":1,"Answer":"yes, and zip egg files are decompressed on the fly when you reference them making them slower than when you install it.","Q_Score":1,"Tags":"python","A_Id":4009829,"CreationDate":"2010-10-24T18:44:00.000","Title":"How is a python egg different from a regular 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},{"Question":"I am solving a problem of transferring images from a camera in a loop from a client (a robot with camera) to a server (PC).\nI am trying to come up with ideas how to maximize the transfer speed so I can get the best possible FPS (that is because I want to create a live video stream out of the transferred images). Disregarding the physical limitations of WIFI stick on the robot, what would you suggest?\nSo far I have decided:\n\nto use YUV colorspace instead of RGB\nto use UDP protocol instead of TCP\/IP\n\nIs there anything else I could do to get the maximum fps possible?","AnswerCount":2,"Available Count":2,"Score":0.1973753202,"is_accepted":false,"ViewCount":375,"Q_Id":4013046,"Users Score":2,"Answer":"Compress the difference between successive images. Add some checksum. Provide some way for the receiver to request full image data for the case where things get out of synch.\nThere are probably a host of protocols doing that already.\nSo, search for live video stream protocols.\nCheers & hth.,","Q_Score":0,"Tags":"c#,c++,python,algorithm,performance","A_Id":4013104,"CreationDate":"2010-10-25T08:49:00.000","Title":"How to speed up transfer of images from client to server","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},{"Question":"I am solving a problem of transferring images from a camera in a loop from a client (a robot with camera) to a server (PC).\nI am trying to come up with ideas how to maximize the transfer speed so I can get the best possible FPS (that is because I want to create a live video stream out of the transferred images). Disregarding the physical limitations of WIFI stick on the robot, what would you suggest?\nSo far I have decided:\n\nto use YUV colorspace instead of RGB\nto use UDP protocol instead of TCP\/IP\n\nIs there anything else I could do to get the maximum fps possible?","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":375,"Q_Id":4013046,"Users Score":4,"Answer":"This might be quite a bit of work but if your client can handle the computations in real time you could use the same method that video encoders use. Send a key frame every say 5 frames and in between only send the information that changed not the whole frame. I don't know the details of how this is done, but try Googling p-frames or video compression.","Q_Score":0,"Tags":"c#,c++,python,algorithm,performance","A_Id":4013112,"CreationDate":"2010-10-25T08:49:00.000","Title":"How to speed up transfer of images from client to server","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},{"Question":"I wish to control my computer (and usb devices attached to the computer) at home with any computer that is connected to the internet. The computer at home must have a program installed that receives commands from any other computer that is connected to the internet. I thought it would be best if I do this with a web interface as it would not be necessary to install software on that computer. For obvious reasons it would require log in details.\nExtra details: The main part of the project is actually a device that I will develop that connects to the computer's usb port. Sorry if it was a bit vague in my original question. This device will perform simple functions such as turning lights on etc. At first I will just attempt to switch the lights remotely using the internet. Later on I will add commands that can control certain aspects of the computer such as the music player. I think doing a full remote desktop connection to control my device is therefore not quite necessary. Does anybody know of any open source projects that can perform these functions?\nSo basically the problem is sending encrypted commands from a web interface to my computer at home. What would be the best method to achieve this and what programming languages should I use? I know Java, Python and C quite well, but have very little experience with web applications, such as Javascript and PHP.\nI have looked at web chat examples as it is sort of similar concept to what I wish to achieve, except the text can be replaced with commands. Is this a viable solution or are there better alternatives?\nThank you","AnswerCount":6,"Available Count":3,"Score":0.0333209931,"is_accepted":false,"ViewCount":1907,"Q_Id":4014670,"Users Score":1,"Answer":"You can write a WEB APPLICATION. The encryption part is solved by simple HTTPS usage. On the server side (your home computer with USB devices attached to it) you should use Python (since you're quite experienced with it) and a Python Web Framework you want (I.E. Django).","Q_Score":3,"Tags":"java,php,javascript,python","A_Id":4014696,"CreationDate":"2010-10-25T12:48:00.000","Title":"Send commands between two computers over the internet","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},{"Question":"I wish to control my computer (and usb devices attached to the computer) at home with any computer that is connected to the internet. The computer at home must have a program installed that receives commands from any other computer that is connected to the internet. I thought it would be best if I do this with a web interface as it would not be necessary to install software on that computer. For obvious reasons it would require log in details.\nExtra details: The main part of the project is actually a device that I will develop that connects to the computer's usb port. Sorry if it was a bit vague in my original question. This device will perform simple functions such as turning lights on etc. At first I will just attempt to switch the lights remotely using the internet. Later on I will add commands that can control certain aspects of the computer such as the music player. I think doing a full remote desktop connection to control my device is therefore not quite necessary. Does anybody know of any open source projects that can perform these functions?\nSo basically the problem is sending encrypted commands from a web interface to my computer at home. What would be the best method to achieve this and what programming languages should I use? I know Java, Python and C quite well, but have very little experience with web applications, such as Javascript and PHP.\nI have looked at web chat examples as it is sort of similar concept to what I wish to achieve, except the text can be replaced with commands. Is this a viable solution or are there better alternatives?\nThank you","AnswerCount":6,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":1907,"Q_Id":4014670,"Users Score":0,"Answer":"Well, I think that java can work well, in fact you have to deal with system calls to manage usb devices and things like that (and as far as I know, PHP is not the best language to do this). Also shouldn't be so hard to create a basic server\/client program, just use good encryption mechanism to not show commands around web.","Q_Score":3,"Tags":"java,php,javascript,python","A_Id":4014765,"CreationDate":"2010-10-25T12:48:00.000","Title":"Send commands between two computers over the internet","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},{"Question":"I wish to control my computer (and usb devices attached to the computer) at home with any computer that is connected to the internet. The computer at home must have a program installed that receives commands from any other computer that is connected to the internet. I thought it would be best if I do this with a web interface as it would not be necessary to install software on that computer. For obvious reasons it would require log in details.\nExtra details: The main part of the project is actually a device that I will develop that connects to the computer's usb port. Sorry if it was a bit vague in my original question. This device will perform simple functions such as turning lights on etc. At first I will just attempt to switch the lights remotely using the internet. Later on I will add commands that can control certain aspects of the computer such as the music player. I think doing a full remote desktop connection to control my device is therefore not quite necessary. Does anybody know of any open source projects that can perform these functions?\nSo basically the problem is sending encrypted commands from a web interface to my computer at home. What would be the best method to achieve this and what programming languages should I use? I know Java, Python and C quite well, but have very little experience with web applications, such as Javascript and PHP.\nI have looked at web chat examples as it is sort of similar concept to what I wish to achieve, except the text can be replaced with commands. Is this a viable solution or are there better alternatives?\nThank you","AnswerCount":6,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":1907,"Q_Id":4014670,"Users Score":0,"Answer":"I you are looking for solution you could use from any computer anywhere in the worls without the need to install any software on client pc, try logmein.com (http:\/\/secure.logmein.com).\nIt is free, reliable, works in any modern browser, you don't have to remmeber IPs and hope they won't change, ...\nOr if this is a \"for fun project\" why not write a php script, open port 80 in your router so you can access you script from outside, possibly dynamically link some domain to your IP (http:\/\/www.dyndns.com\/). In the script you would just login and then for example type the orders in textfield in some form in your script. Lets just say you want to do some command prompt stuf, so you will basically remotely construst a *.bat file for example. Then the script stores this a fromtheinternets.bat to a folder on your desktop that is being constantly monitored for changes. And when such a change is found you just activate the bat file.\nInsecure? Yes (It could be made secureER)\nFun to write? Definitely\nPS: I am new here, hope it's not \"illegal\" to post link to actual services, instead of wiki lists. This is by no means and advertisement, I am just a happy user. :)","Q_Score":3,"Tags":"java,php,javascript,python","A_Id":4015151,"CreationDate":"2010-10-25T12:48:00.000","Title":"Send commands between two computers over the internet","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},{"Question":"After installing Python 2.7 on Windows XP, then manually setting the %PATH% to python.exe (why won't the python installer do this?), then installing setuptools 0.6c11 (why doesn't the python installer do this?), then manually setting the %PATH% to easy_install.exe (why doesn't the installer do this?), I finally tried to install a python package with easy_install, but easy_install failed when it couldn't install the pywin32 package, which is a dependency. How can I make easy_install work properly on Windows XP? The failure follows:\nC:\\>easy_install winpexpect\nSearching for winpexpect\nBest match: winpexpect 1.4\nProcessing winpexpect-1.4-py2.7.egg\nwinpexpect 1.4 is already the active version in easy-install.pth\n\nUsing c:\\python27\\lib\\site-packages\\winpexpect-1.4-py2.7.egg\nProcessing dependencies for winpexpect\nSearching for pywin32>=214\nReading http:\/\/pypi.python.org\/simple\/pywin32\/\nReading http:\/\/sf.net\/projects\/pywin32\nReading http:\/\/sourceforge.net\/project\/showfiles.php?group_id=78018\nNo local packages or download links found for pywin32>=214\nBest match: None\nTraceback (most recent call last):\n  File \"C:\\python27\\scripts\\easy_install-script.py\", line 8, in \n    load_entry_point('setuptools==0.6c11', 'console_scripts', 'easy_install')()\n  File \"C:\\python27\\lib\\site-packages\\setuptools\\command\\easy_install.py\", line 1712, in main\n    with_ei_usage(lambda:\n  File \"C:\\python27\\lib\\site-packages\\setuptools\\command\\easy_install.py\", line 1700, in with_ei_usage\n    return f()\n  File \"C:\\python27\\lib\\site-packages\\setuptools\\command\\easy_install.py\", line 1716, in \n    distclass=DistributionWithoutHelpCommands, **kw\n  File \"C:\\python27\\lib\\distutils\\core.py\", line 152, in setup\n    dist.run_commands()\n  File \"C:\\python27\\lib\\distutils\\dist.py\", line 953, in run_commands\n    self.run_command(cmd)\n  File \"C:\\python27\\lib\\distutils\\dist.py\", line 972, in run_command\n    cmd_obj.run()\n  File \"C:\\python27\\lib\\site-packages\\setuptools\\command\\easy_install.py\", line 211, in run\n    self.easy_install(spec, not self.no_deps)\n  File \"C:\\python27\\lib\\site-packages\\setuptools\\command\\easy_install.py\", line 446, in easy_install\n    return self.install_item(spec, dist.location, tmpdir, deps)\n  File \"C:\\python27\\lib\\site-packages\\setuptools\\command\\easy_install.py\", line 481, in install_item\n    self.process_distribution(spec, dists[0], deps, \"Using\")\n  File \"C:\\python27\\lib\\site-packages\\setuptools\\command\\easy_install.py\", line 519, in process_distribution\n    [requirement], self.local_index, self.easy_install\n  File \"C:\\python27\\lib\\site-packages\\pkg_resources.py\", line 563, in resolve\n    dist = best[req.key] = env.best_match(req, self, installer)\n  File \"C:\\python27\\lib\\site-packages\\pkg_resources.py\", line 799, in best_match\n    return self.obtain(req, installer) # try and download\/install\n  File \"C:\\python27\\lib\\site-packages\\pkg_resources.py\", line 811, in obtain\n    return installer(requirement)\n  File \"C:\\python27\\lib\\site-packages\\setuptools\\command\\easy_install.py\", line 434, in easy_install\n    self.local_index\n  File \"C:\\python27\\lib\\site-packages\\setuptools\\package_index.py\", line 475, in fetch_distribution\n    return dist.clone(location=self.download(dist.location, tmpdir))\nAttributeError: 'NoneType' object has no attribute 'clone'","AnswerCount":5,"Available Count":1,"Score":0.0399786803,"is_accepted":false,"ViewCount":152491,"Q_Id":4016151,"Users Score":1,"Answer":"For one thing, it says you already have that module installed. If you need to upgrade it, you should do something like this:\neasy_install -U packageName\nOf course, easy_install doesn't work very well if the package has some C headers that need to be compiled and you don't have the right version of Visual Studio installed. You might try using pip or distribute instead of easy_install and see if they work better.","Q_Score":63,"Tags":"python,windows,easy-install","A_Id":4016275,"CreationDate":"2010-10-25T15:31:00.000","Title":"How to use Python's \"easy_install\" on Windows ... it's not so easy","Data Science and Machine Learning":0,"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},{"Question":"We're having problems when trying to deploy a number of projects which use zc.buildout - specifically we're finding that they want to put their PYTHON_EGG_CACHE directories all over the show. We'd like to somehow set this directory to one at the same level as the built-out project, where eggs can be found.\nThere is some mention online that this can be done for Plone projects, but is it possible to do this without Plone? \nAre there some recipes that can set up an environment variable so we can set the PYTHON_EGG_CACHE executable files in .\/bin?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1434,"Q_Id":4025412,"Users Score":0,"Answer":"I'm not sure what you mean. Three options that you normally have:\n\nBuildout, by default, stores the eggs in a directory called eggs\/ inside your buildout directory.  \nYou can set the eggs-dir variable inside your buildout.cfg's [buildout] section to some directory. Just tell it where to place them.\nYou can also set that very same option in .buildout\/defaults.cfg inside your home directory.  That way you can set a default for all your projects.  Handy for storing all your eggs in one place: that can save a lot of download time, for instance.\n\nDoes one of those (especially the last one) accomplish what you want?\nAnd: don't muck around with eggs in the generated bin\/* files.  Let buldout pick the eggs, that's its purpose.","Q_Score":1,"Tags":"buildout,python-egg-cache","A_Id":4026496,"CreationDate":"2010-10-26T15:49:00.000","Title":"Specify a custom PYTHON_EGG_CACHE dir with zc.buildout?","Data Science and Machine Learning":0,"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},{"Question":"My needs :\n\nI need to develop an GUI application that is cross platform\nthe chosen solution must be the fastest to implement\nit should be easy to extend\n\nThe application is just a database front-end, mainly for CRUD operations, listing, filtering, exporting, charts and graphs etc.\nAfter reading about some solutions (Python Card, PyGUI, DABO, pygtkhelpers, kiwi, pyjamas, pure-mvc, PyQt\/PySide, Wax, Tk-based frameworks, AVC, Fox etc.), I found myself interrested in two particular solutions, one of them is Camelot.\nBefore jumping into it, I would like to have some opinions about Camelot users vs skeptics. \nThanks for sharing :)","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":593,"Q_Id":4026026,"Users Score":0,"Answer":"In my opinion the best option for this would be to make a CGI program to run through a browser so that you do not have to worry about platform issues. Granted it might take a little bit more work, it may be better suited for cross platform deployment. :)","Q_Score":3,"Tags":"python,user-interface,sqlalchemy,cross-platform,python-elixir","A_Id":9863280,"CreationDate":"2010-10-26T17:02:00.000","Title":"Feedback for Camelot","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},{"Question":"My needs :\n\nI need to develop an GUI application that is cross platform\nthe chosen solution must be the fastest to implement\nit should be easy to extend\n\nThe application is just a database front-end, mainly for CRUD operations, listing, filtering, exporting, charts and graphs etc.\nAfter reading about some solutions (Python Card, PyGUI, DABO, pygtkhelpers, kiwi, pyjamas, pure-mvc, PyQt\/PySide, Wax, Tk-based frameworks, AVC, Fox etc.), I found myself interrested in two particular solutions, one of them is Camelot.\nBefore jumping into it, I would like to have some opinions about Camelot users vs skeptics. \nThanks for sharing :)","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":593,"Q_Id":4026026,"Users Score":1,"Answer":"Disclaimer: I am a Camelot committer.\nIf the question has been raised on the Programmers Stack Exchange, please link to it.\nThis question is kind of old, but for any reference, i'll chime in.\nCamelot was and is developed for exactly the reasons you stated. It has matured a lot since this questions was asked and is about feature complete. Latest efforts have been made to use Declarative instead of Elixir. Stability and speed are strongpoints as well.","Q_Score":3,"Tags":"python,user-interface,sqlalchemy,cross-platform,python-elixir","A_Id":14327581,"CreationDate":"2010-10-26T17:02:00.000","Title":"Feedback for Camelot","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},{"Question":"I am developing a social networking website in the facebook\/foursquare-ish space. I have gotten such varied feedback on what platform I should develop in. Of course it will be heavily influenced by who I hire, but i was hoping for a little additional feedback from the larger community. Thanks.","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":156,"Q_Id":4033735,"Users Score":1,"Answer":"Write in assembler if you're comfortable with that.  :)\nSome questions you should ask yourself:\n\nAre there hosting restrictions? No point in coding ASP.net when you have a PHP-only host\/server.\nAre there technical restrictions? E.g. if you want to use SQL Server as a back-end, going with ASP.net may make your life easier.\nWhat other requirements do you have? Does it have to run on the JVM? Do you want to compile stuff all the time or do you want an interpreted language? etc. etc.\nWhat experience do you have? If you're already familiar with Python, why switch to Ruby?\n\nMy best tip is: use what's best for the job at hand according to the above questions. For me, I'd use Ruby on Rails for the project you described. Rails offers all the tools I need for a large project like that. \nPlease let us know when and what you've decided :)","Q_Score":1,"Tags":"php,.net,python,ruby-on-rails","A_Id":4034000,"CreationDate":"2010-10-27T13:26:00.000","Title":"What do i build my alpha platform on, PHP, Ruby, Python, .NET, etc?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I am developing a social networking website in the facebook\/foursquare-ish space. I have gotten such varied feedback on what platform I should develop in. Of course it will be heavily influenced by who I hire, but i was hoping for a little additional feedback from the larger community. Thanks.","AnswerCount":2,"Available Count":2,"Score":1.0,"is_accepted":false,"ViewCount":156,"Q_Id":4033735,"Users Score":7,"Answer":"It doesn't matter.\nStackOverflow was written in ASP .NET MVC and it's awesome.\nTwitter was written in Rails and it's super popular.\nFacebook was written in PHP and half a billion people use it.  \nIt's not the technology, it's the community.  That's the hard part.\nJust pick one and go.  Your best bet might actually be to find the technology that the most smart people are using while still working for the least amount of money.","Q_Score":1,"Tags":"php,.net,python,ruby-on-rails","A_Id":4033788,"CreationDate":"2010-10-27T13:26:00.000","Title":"What do i build my alpha platform on, PHP, Ruby, Python, .NET, etc?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I'm writing a class in python and I have an attribute that will take a relatively long time to compute, so I only want to do it once.  Also, it will not be needed by every instance of the class, so I don't want to do it by default in __init__.  \nI'm new to Python, but not to programming.  I can come up with a way to do this pretty easily, but I've found over and over again that the 'Pythonic' way of doing something is often much simpler than what I come up with using my experience in other languages.\nIs there a 'right' way to do this in Python?","AnswerCount":11,"Available Count":1,"Score":-0.0544914242,"is_accepted":false,"ViewCount":54820,"Q_Id":4037481,"Users Score":-3,"Answer":"The most simple way of doing this would probably be to just write a method (instead of using an attribute) that wraps around the attribute (getter method). On the first call, this methods calculates, saves and returns the value; later it just returns the saved value.","Q_Score":114,"Tags":"python,memoization","A_Id":4037504,"CreationDate":"2010-10-27T20:36:00.000","Title":"Caching class attributes 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},{"Question":"I have a typical producer, consumer pattern. If the producer sends an object over a channel, the producer is blocked until the consumer accepts the object. After the consumer accepts the object, the producer alters the object in some way. Does the consumer see the object get altered? Or was there an implicit copy when sending the data over the channel?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":135,"Q_Id":4046351,"Users Score":1,"Answer":"Stackless sends a reference to the python object over the channel, so any changes the producer makes to the object will be \"seen\" by the consumer.  No copying going on.","Q_Score":2,"Tags":"python,immutability,stackless,python-stackless","A_Id":9828193,"CreationDate":"2010-10-28T19:09:00.000","Title":"In stackless python, is data sent over a channel immutable?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"Hey,\nI am helping to set up a regression testing suite for our python web application. Many of our tests are scheduling style tests where the current date is important. For example: create a recurring event that runs every week for a month starting on Feb 1.\nIn order to test this, what I really want to do is override the current date so I can move back and forward in time to check the state of the app. For example, I may add an test-only page that lets me set the 'current' date which gets passed to the python back end and is used for date calculations.\nIn the past when I have done this, I engineered it into the application architecture from day 1. Unfortunately, I am coming in late to this project and there is no application support for this.\nSo here's my question, is there any way I can override the current date on a web service call? For example, can I intercept calls for the current date (monkey patching possibly?). I would rather not have to do a whole IOC thing as it would mean changing hundreds of methods.\n- dave","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":317,"Q_Id":4047049,"Users Score":0,"Answer":"Answering my own question:\nOur current plan is to test on virtual machines and change the date\/time on the VMs. This is a more complete solution as it gets the database and worker threads all at once. \nI'll post an update with some real world experience when we come to actual do it.","Q_Score":0,"Tags":"python,date,automated-tests,regression-testing","A_Id":4121205,"CreationDate":"2010-10-28T20:46:00.000","Title":"Date sensitive regression testing 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":1},{"Question":"I'm writing a Python client+server that uses gevent.socket for communication. Are there any good ways of testing the socket-level operation of the code (for example, verifying that SSL connections with an invalid certificate will be rejected)? Or is it simplest to just spawn a real server?\nEdit: I don't believe that \"naive\" mocking will be sufficient to test the SSL components because of the complex interactions involved. Am I wrong in that? Or is there a better way to test SSL'd stuff?","AnswerCount":3,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":14758,"Q_Id":4047897,"Users Score":9,"Answer":"Mocking and stubbing are great, but sometimes you need to take it up to the next level of integration.  Since spawning a server, even a fakeish one, can take some time, consider a separate test suite (call them integration tests) might be in order.\n\"Test it like you are going to use it\" is my guideline, and if you mock and stub so much that your test becomes trivial it's not that useful (though almost any test is better than none).  If you are concerned about handling bad SSL certs, by all means make some bad ones and write a test fixture you can feed them to.  If that means spawning a server, so be it. Maybe if that bugs you enough it will lead to a refactoring that will make it testable another way.","Q_Score":20,"Tags":"python,sockets,testing,gevent","A_Id":4048286,"CreationDate":"2010-10-28T23:16:00.000","Title":"Python: unit testing socket-based code?","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},{"Question":"I'm developing a Java program through Eclipse locally, and debugging on a remote machine. Whenever I make a change to my program, I copy the corresponding class file to the bin directory on the remote machine.  I run my program (a simulator) through a python script via the OS.system command.\nThe problem is that my program sometimes does not use the updated class files after they have been moved over. \nThe problem persists even if I log out and back into the remote machine. What's really strange is that, as a test, I deleted the bin directory entirely on the remote machine, and was still able to run my program.  \nCan anyone explain this?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":88,"Q_Id":4048821,"Users Score":1,"Answer":"I would bet dollars for donuts that under some conditions you are not restarting the JVM between tests.\nThe other obvious thought is that the class is not being copied to the target system as expected, or not to the correct location.  Or, of course, the program is not being run from where you expect (i.e. there is another copy of the class files, perhaps in a JAR, which is actually be run).\nExplicitly recheck all your assumptions.","Q_Score":0,"Tags":"java,python","A_Id":4048850,"CreationDate":"2010-10-29T03:42:00.000","Title":"Java: updated class files 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},{"Question":"I want to perform a comparison of multiple implementations of basically the same algorithm, written in Java, C++ and Python, the latter executed using Pypy, Jython and CPython on a Mac OS X 10.6.4 Macbook Pro with normal (non-SSD) HDD.\nIt's a \"decode a stream of data from a file\" type of algorithm, where the relevant measurement is total execution time, and I want to prevent bias through e.g. OS an HDD caches, other programs running simultaneously, too large\/small sample file etc. What do I need to pay attention to to create a fair comparison?","AnswerCount":4,"Available Count":3,"Score":0.049958375,"is_accepted":false,"ViewCount":183,"Q_Id":4052691,"Users Score":1,"Answer":"These are difficult to do well.\nIn many cases the operating system will cache files so the second time they are executed they suddenly perform much better.\nThe other problem is you're comparing interpreted languages against compiled. The interpreted languages require an interpreter loaded into memory somewhere or they can't run. To be scrupulously fair you really should consider if memory usage and load time for the interpreter should be part of the test. If you're looking for performance in an environment where you can assume the interpreter is always preloaded then you can ignore that. Many setups for web servers will be able to keep an interpreter preloaded. If you're doing ad hoc client applications on a desktop then the start up can be very slow while the interpreter is loaded.","Q_Score":0,"Tags":"java,c++,python,jython,performance","A_Id":4053156,"CreationDate":"2010-10-29T14:19:00.000","Title":"Performing unbiased program\/script performance comparison","Data Science and Machine Learning":0,"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},{"Question":"I want to perform a comparison of multiple implementations of basically the same algorithm, written in Java, C++ and Python, the latter executed using Pypy, Jython and CPython on a Mac OS X 10.6.4 Macbook Pro with normal (non-SSD) HDD.\nIt's a \"decode a stream of data from a file\" type of algorithm, where the relevant measurement is total execution time, and I want to prevent bias through e.g. OS an HDD caches, other programs running simultaneously, too large\/small sample file etc. What do I need to pay attention to to create a fair comparison?","AnswerCount":4,"Available Count":3,"Score":1.2,"is_accepted":true,"ViewCount":183,"Q_Id":4052691,"Users Score":0,"Answer":"I would recommend that you simply run each program many times (like 20 or so) and take the lowest measurement of each set. This will make it so it is highly likely that the program will use the HD cache and other things like that. If they all do that, then it isn't biased.","Q_Score":0,"Tags":"java,c++,python,jython,performance","A_Id":4053208,"CreationDate":"2010-10-29T14:19:00.000","Title":"Performing unbiased program\/script performance comparison","Data Science and Machine Learning":0,"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},{"Question":"I want to perform a comparison of multiple implementations of basically the same algorithm, written in Java, C++ and Python, the latter executed using Pypy, Jython and CPython on a Mac OS X 10.6.4 Macbook Pro with normal (non-SSD) HDD.\nIt's a \"decode a stream of data from a file\" type of algorithm, where the relevant measurement is total execution time, and I want to prevent bias through e.g. OS an HDD caches, other programs running simultaneously, too large\/small sample file etc. What do I need to pay attention to to create a fair comparison?","AnswerCount":4,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":183,"Q_Id":4052691,"Users Score":0,"Answer":"To get totally unbiased is impossible, you can do various stuff like running minimum processes etc but IMO best way is to run scripts in random order over a long period of time over different days and get average which will be as near to unbias as possible.\nBecause ultimately code will run in such environment in random order and you are interested in average behavior not some numbers.","Q_Score":0,"Tags":"java,c++,python,jython,performance","A_Id":4053230,"CreationDate":"2010-10-29T14:19:00.000","Title":"Performing unbiased program\/script performance comparison","Data Science and Machine Learning":0,"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},{"Question":"I'm trying to figure out how I can best save the map data for a 2d ORPG engine I am developing, the file would contain tile data (Is it blocked, what actual graphics would it use, and various other properties).\nI am currently using a binary format but I think this might be a bit too limited and hard to debug, what alternatives are there, I was thinking about perhaps JSON or XML but I don't know if there are any other better options.\nIt has to work with C++ and C# and preferably also with Python.","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":446,"Q_Id":4052990,"Users Score":1,"Answer":"XML is well supported across basically every language. It may become verbose for large maps, however, depending on how you encode the map data in XML.\nJSON might not be  a good choice, simply because I don't think it supports multiline strings, which would be helpful (although not really necessary)\nYAML is another alternative, though it's not as well-known.\nYou could just stick to binary - most maps would be a pain to edit by hand, no matter what format you pick (though I've heard of Starcraft maps being edited with hex editors...) Just use whatever seems easiest for you.\nAdditionally, check out the Tiled map editor (http:\/\/www.mapeditor.org\/), which lets you edit maps (with custom tile properties, I think) and save it in an XML based format, including optional GZip for compression.","Q_Score":0,"Tags":"c#,python,c++","A_Id":4056557,"CreationDate":"2010-10-29T14:53:00.000","Title":"Saving map data in a 2d ORPG","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to figure out how I can best save the map data for a 2d ORPG engine I am developing, the file would contain tile data (Is it blocked, what actual graphics would it use, and various other properties).\nI am currently using a binary format but I think this might be a bit too limited and hard to debug, what alternatives are there, I was thinking about perhaps JSON or XML but I don't know if there are any other better options.\nIt has to work with C++ and C# and preferably also with Python.","AnswerCount":3,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":446,"Q_Id":4052990,"Users Score":1,"Answer":"Personally, I would stick with a binary format.  Whatever method you choose, it's going to be a pain in the ass to edit by hand anyway, so you may as well stick to binary which gives you a size and speed advantage.\nYou're also going to want a map editor anyway so that you do not have to edit it by hand.","Q_Score":0,"Tags":"c#,python,c++","A_Id":4062198,"CreationDate":"2010-10-29T14:53:00.000","Title":"Saving map data in a 2d ORPG","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"just encountered a problem at dict \"type\" subclassing. I did override __iter__ method and expected it will affect other methods like iterkeys, keys etc. because I believed they call __iter__ method to get values but it seems they are implemented independently and I have to override all of them.\nIs this a bug or intention they don't make use of other methods and retrieves values separately ?\nI didn't find in the standard Python documentation description of calls dependency between methods of standard classes. It would be handy for sublassing work and for orientation what methods is required to override for proper behaviour. Is there some supplemental documentation about python base types\/classes internals ?","AnswerCount":4,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":142,"Q_Id":4053662,"Users Score":2,"Answer":"If not specified in the documentation, it is implementation specific. Implementations other that CPython might re-use the iter method to implement iterkeys and others. I would not consider this to be a bug, but simply a bit of freedom for the implementors. \nI suspect there is a performance factor in implementing the methods independently, especially as dictionaries are so widely used in Python.\nSo basically, you should implement them.","Q_Score":1,"Tags":"python,python-datamodel","A_Id":4053781,"CreationDate":"2010-10-29T16:02:00.000","Title":"Python std methods hierarchy calls documented?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"just encountered a problem at dict \"type\" subclassing. I did override __iter__ method and expected it will affect other methods like iterkeys, keys etc. because I believed they call __iter__ method to get values but it seems they are implemented independently and I have to override all of them.\nIs this a bug or intention they don't make use of other methods and retrieves values separately ?\nI didn't find in the standard Python documentation description of calls dependency between methods of standard classes. It would be handy for sublassing work and for orientation what methods is required to override for proper behaviour. Is there some supplemental documentation about python base types\/classes internals ?","AnswerCount":4,"Available Count":2,"Score":0.049958375,"is_accepted":false,"ViewCount":142,"Q_Id":4053662,"Users Score":1,"Answer":"You know the saying: \"You know what happens when you assume.\" :-)  \nThey don't officially document that stuff because they may decide to change it in the future. Any unofficial documentation you may find would simply document the current behavior of one Python implementation, and relying on it would result in your code being very, very fragile.\nWhen there is official documentation of special methods, it tends to describe behavior of the interpreter with respect to your own classes, such as using __len__() when __nonzero__() isn't implemented, or only needing __lt()__ for sorting.\nSince Python uses duck typing, you usually don't actually need to inherit from a built-in class to make your own class act like one.  So you might reconsider whether subclassing dict is really what you want to do. You might choose a different class, such as something from the collections module, or to encapsulate rather than inheriting.  (The UserString class uses encapsulation.) Or just start from scratch.","Q_Score":1,"Tags":"python,python-datamodel","A_Id":4053834,"CreationDate":"2010-10-29T16:02:00.000","Title":"Python std methods hierarchy calls documented?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I just downloaded the original Python interpreter from Python's site. I just want to learn this language but to start with, I want to write Windows-based standalone applications that are powered by any RDBMS. I want to bundle it like any typical Windows setup.\nI searched old posts on SO and found guys suggesting wxPython and py2exe. Apart from that few suggested IronPython since it is powered by .NET.\nI want to know whether IronPython is a pure variant of Python or a modified variant. Secondly, what is the actual use of Python? Is it for PHP like thing or like C# (you can either program Windows-based app. or Web.).","AnswerCount":4,"Available Count":3,"Score":1.2,"is_accepted":true,"ViewCount":1297,"Q_Id":4059201,"Users Score":6,"Answer":"IronPython isn't a variant of Python, it is Python. It's an implementation of the Python language based on the .NET framework. So, yes, it is pure Python.\nIronPython is caught up to CPython (the implementation you're probably used to) 2.6, so some of the features\/changes seen in Python 2.7 or 3.x will not be present in IronPython. Also, the standard library is a bit different (but what you lose is replaced by all that .NET has to offer).\nThe primary application of IronPython is to script .NET applications written in C# etc., but it can also be used as a standalone. IronPython can also be used to write web applications using the SilverLight framework.\nIf you need access to .NET features, use IronPython. If you're just trying to make a Windows executable, use py2exe.\nUpdate\nFor writing basic RDBMS apps, just use CPython (original Python), it's more extensible and faster. Then, you can use a number of tools to make it stand alone on a Windows PC. For now, though, just worry about learning Python (those skills will mostly carry over to IronPython if you choose to switch) and writing your application.","Q_Score":4,"Tags":"python,wxpython,ironpython","A_Id":4059227,"CreationDate":"2010-10-30T14:49:00.000","Title":"Is IronPython a 100% pure Python variant?","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},{"Question":"I just downloaded the original Python interpreter from Python's site. I just want to learn this language but to start with, I want to write Windows-based standalone applications that are powered by any RDBMS. I want to bundle it like any typical Windows setup.\nI searched old posts on SO and found guys suggesting wxPython and py2exe. Apart from that few suggested IronPython since it is powered by .NET.\nI want to know whether IronPython is a pure variant of Python or a modified variant. Secondly, what is the actual use of Python? Is it for PHP like thing or like C# (you can either program Windows-based app. or Web.).","AnswerCount":4,"Available Count":3,"Score":0.049958375,"is_accepted":false,"ViewCount":1297,"Q_Id":4059201,"Users Score":1,"Answer":"IronPython is an implementation of Python using C#. It's just like the implementation of Python using Java by Jython. You might want to note that IronPython and Jython will always lag behind a little bit in development. However, you do get the benefit of having some libraries that's not available in the standard Python libraries. In IronPython, you will be able to get access to some of the .NET stuff, like System.Drawings and such, though by using these non-standard libraries, it will be harder to port your code to other platforms. For example, you will have to install mono to run apps written in IronPython on Linux (On windows you will need the .NET Framework)","Q_Score":4,"Tags":"python,wxpython,ironpython","A_Id":4059540,"CreationDate":"2010-10-30T14:49:00.000","Title":"Is IronPython a 100% pure Python variant?","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},{"Question":"I just downloaded the original Python interpreter from Python's site. I just want to learn this language but to start with, I want to write Windows-based standalone applications that are powered by any RDBMS. I want to bundle it like any typical Windows setup.\nI searched old posts on SO and found guys suggesting wxPython and py2exe. Apart from that few suggested IronPython since it is powered by .NET.\nI want to know whether IronPython is a pure variant of Python or a modified variant. Secondly, what is the actual use of Python? Is it for PHP like thing or like C# (you can either program Windows-based app. or Web.).","AnswerCount":4,"Available Count":3,"Score":0.049958375,"is_accepted":false,"ViewCount":1297,"Q_Id":4059201,"Users Score":1,"Answer":"what does \"Pure Python\" mean?  If you're talking about implemented in Python in the same sense that a module may be pure python, then no, and no Python implementation is.  If you mean \"Compatible with cPython\" then yes, code written to cPython will work in IronPython, with a few caveats.  The one that's likely to matter most is that the libraries are different, for instance code depending on ctypes or Tkinter won't work.  Another difference is that IronPython lags behind cPython by a bit.  the very latest version of this writing is 2.6.1, with an Alpha version supporting a few of the 2.7 language features available too.\nWhat do you really need?  If you want to learn to program with python, and also want to produce code for windows, you can use IronPython for that, but you can also use cPython and py2exe;  both will work equally well for this with only differences in the libraries.","Q_Score":4,"Tags":"python,wxpython,ironpython","A_Id":4059291,"CreationDate":"2010-10-30T14:49:00.000","Title":"Is IronPython a 100% pure Python variant?","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},{"Question":"I am using sticky notes in ubuntu . And was wondering if it would be possible to read the text written in sticky notes using any scripting language .","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":536,"Q_Id":4059851,"Users Score":0,"Answer":"The tomboy notes are saved as xml files so you could write a xml parser.","Q_Score":0,"Tags":"python,ruby,perl","A_Id":4060827,"CreationDate":"2010-10-30T17:35:00.000","Title":"is it possible to read the text written in a sticky note using a script 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},{"Question":"I'm doing a few projects in python right now, and I'm trying to figure out how to work with my own versions of existing open source packages.\nFor instance, I'm using tipfy with zc.buildout, and I've added in the 'paypal' package. Unfortunately it doesn't have a feature I need, so I've forked it on github and added the feature. I will send the original package maintainers a pull request, but whether they accept my additions or not, I'd like to use my version of the package and keep the convenience of having zc.buildout manage my dependencies. How do I do this? \nDo I upload my own take on the library to PyPI and prefix it with my name? Wouldn't that unnecessarily pollute the index?\nOr should I make and maintain my own index and package repo? Where do I find the format for this? And is it against to terms of the OSS licenses to host my own repo with modified packages with the same names? (I'd rather not modify every file in the project with new namespaces)\nI'm sure this problem comes up quite a lot, and not just with python. I can see this happening with Maven and SBT, too... what do people usually do when they want to use their own versions of popular packages?","AnswerCount":6,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":1349,"Q_Id":4066571,"Users Score":2,"Answer":"To keep your headache in check, I would really recommend just bundling all such custom code with your package. Say you made a fork of some package. As long as its license allows it, I would just bundle the modified version of package with my code, as if it's just another directory. You can place it locally under package so it will be easily found. Once the developers of package fix what you need, just remove this directory and make it a dependency on an online package once again.\nAn added bonus of this approach is making distribution to users\/customers easier.","Q_Score":5,"Tags":"python,buildout,pypi,tipfy","A_Id":4066739,"CreationDate":"2010-11-01T04:06:00.000","Title":"Using custom packages on my python 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":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"When I use google IMAP and try to delete message the message removes from folder but not going to trash folder. Did i must to copy this message before delete it?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":896,"Q_Id":4067499,"Users Score":1,"Answer":"Simple answer: yes.\nThere is no concept of Deleted Items, Trash, etc. in IMAP. If you want to have a message in one of those folders after deletion, you have to copy it.","Q_Score":1,"Tags":"python,gmail,imap,imaplib,gmail-imap","A_Id":4069524,"CreationDate":"2010-11-01T08:34:00.000","Title":"Deleting using google IMAP (python, imaplib)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Our client wants us to implement change history for website articles. What is the best way to do it?","AnswerCount":3,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":289,"Q_Id":4075309,"Users Score":0,"Answer":"I presume you're using a CMS. If not, use one. WordPress is a good start.\nIf you're developing from scratch, the usual method is to have two tables: one for page information (so title, menu position etc.) and then a page_content table, which has columns for page_id, content, and timestamp.\nAs you save a page, instead of updating a database table you instead write a new record to the page_content table with the page's ID and the time of the save. That way, when displaying pages on your front-end you just select the latest record for that particular page ID, but you also have a history of that page by querying for all records by page_id, sorted by timestamp.","Q_Score":0,"Tags":"php,.net,python,ruby","A_Id":4076484,"CreationDate":"2010-11-02T06:11:00.000","Title":"What is the best way to store change history of website articles?","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},{"Question":"Our client wants us to implement change history for website articles. What is the best way to do it?","AnswerCount":3,"Available Count":2,"Score":-0.0665680765,"is_accepted":false,"ViewCount":289,"Q_Id":4075309,"Users Score":-1,"Answer":"There is a wide variety of ways to do this as you alluded by tagging php, .net, python, and ruby.  You missed a few off the top of my head perl and jsp.  Each of these have their plusses and minuses and is really a question of what best suits your needs.\nPHP is probably the fastest reward for time spent.\nRuby, i'm assuming Ruby on Rails, is the automatic Buzz Word Bingo for the day.\n.Net, are you all microsoft every where and want easy integration with your exchange server and a nice outlook API?\npython? Do you like the scripted languages but you're too good for php and ruby.\nEach of these languages have their strong points and their draw backs and it's really a matter of what you know, how much you have to spend, and what is your timeframe.","Q_Score":0,"Tags":"php,.net,python,ruby","A_Id":4075372,"CreationDate":"2010-11-02T06:11:00.000","Title":"What is the best way to store change history of website articles?","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},{"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},{"Question":"I've done some experiments using Apache Bench to profile my code response times, and it doesn't quite generate the right kind of data for me. I hope the good people here have ideas.\nSpecifically, I need a tool that\n\nDoes HTTP requests over the network (it doesn't need to do anything very fancy)\nRecords response times as accurately as possible (at least to a few milliseconds)\nWrites the response time data to a file without further processing (or provides it to my code, if a library)\n\nI know about ab -e, which prints data to a file. The problem is that this prints only the quantile data, which is useful, but not what I need. The ab -g option would work, except that it doesn't print sub-second data, meaning I don't have the resolution I need.\nI wrote a few lines of Python to do it, but the httplib is horribly inefficient and so the results were useless. In general, I need better precision than pure Python is likely to provide. If anyone has suggestions for a library usable from Python, I'm all ears.\nI need something that is high performance, repeatable, and reliable.\nI know that half my responses are going to be along the lines of \"internet latency makes that kind of detailed measurements meaningless.\" In my particular use case, this is not true. I need high resolution timing details. Something that actually used my HPET hardware would be awesome.\nThrowing a bounty on here because of the low number of answers and views.","AnswerCount":6,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":6473,"Q_Id":4083523,"Users Score":1,"Answer":"I have done this in two ways.\nWith \"loadrunner\" which is a wonderful but pretty expensive product (from I think HP these days).\nWith combination perl\/php and the Curl package. I found the CURL api slightly easier to use from php. Its pretty easy to roll your own GET and PUT requests. I would also recommend manually running through some sample requests with Firefox and the LiveHttpHeaders add on to captute the exact format of the http requests you need.","Q_Score":8,"Tags":"python,profiling,benchmarking,latency,apachebench","A_Id":4083570,"CreationDate":"2010-11-03T01:25:00.000","Title":"Alternatives to ApacheBench for profiling my code speed","Data Science and Machine Learning":0,"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},{"Question":"I've done some experiments using Apache Bench to profile my code response times, and it doesn't quite generate the right kind of data for me. I hope the good people here have ideas.\nSpecifically, I need a tool that\n\nDoes HTTP requests over the network (it doesn't need to do anything very fancy)\nRecords response times as accurately as possible (at least to a few milliseconds)\nWrites the response time data to a file without further processing (or provides it to my code, if a library)\n\nI know about ab -e, which prints data to a file. The problem is that this prints only the quantile data, which is useful, but not what I need. The ab -g option would work, except that it doesn't print sub-second data, meaning I don't have the resolution I need.\nI wrote a few lines of Python to do it, but the httplib is horribly inefficient and so the results were useless. In general, I need better precision than pure Python is likely to provide. If anyone has suggestions for a library usable from Python, I'm all ears.\nI need something that is high performance, repeatable, and reliable.\nI know that half my responses are going to be along the lines of \"internet latency makes that kind of detailed measurements meaningless.\" In my particular use case, this is not true. I need high resolution timing details. Something that actually used my HPET hardware would be awesome.\nThrowing a bounty on here because of the low number of answers and views.","AnswerCount":6,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":6473,"Q_Id":4083523,"Users Score":0,"Answer":"I've used a script to drive 10 boxes on the same switch to generate load by \"replaying\" requests to 1 server.  I had my web app logging response time (server only) to the granularity I needed, but I didn't care about the response time to the client.  I'm not sure you care to include the trip to and from the client in your calculations, but if you did it shouldn't be to difficult to code up. I then processed my log with a script which extracted the times per url and did scatter plot graphs, and trend graphs based on load. \nThis satisfied my requirements which were:\n\nReal world distribution of calls to different urls.\nTrending performance based on load.\nNot influencing the web app by running other intensive ops on the same box.\n\nI did controller as a shell script that foreach server started a process in the background to loop over all the urls in a file calling curl on each one.  I wrote the log processor in Perl since I was doing more Perl at that time.","Q_Score":8,"Tags":"python,profiling,benchmarking,latency,apachebench","A_Id":4162131,"CreationDate":"2010-11-03T01:25:00.000","Title":"Alternatives to ApacheBench for profiling my code speed","Data Science and Machine Learning":0,"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},{"Question":"I'm using PyDev ( with Aptana ) to write and debug a Python Pylons app, and I'd like to step through the tests in the debugger. \nIs it possible to launch nosetests through PyDev and stop at breakpoints?","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":4516,"Q_Id":4087582,"Users Score":0,"Answer":"Try import pydevd; pydevd.settrace() where would like a breakpoint.","Q_Score":8,"Tags":"python,debugging,pylons,pydev,nose","A_Id":4087763,"CreationDate":"2010-11-03T13:38:00.000","Title":"Interactive debugging with nosetests in 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},{"Question":"I wrote a nice little script to do some lightweight work. I set it to run all night, and when I eagerly checked it this morning, I found that I had left a module name prefix out of one of its variables. Is there any way to check for this kind of chicanery statically? The trouble is that this thing sleeps a lot, so running it isn't the best way to find out.","AnswerCount":2,"Available Count":1,"Score":0.4621171573,"is_accepted":false,"ViewCount":108,"Q_Id":4096751,"Users Score":5,"Answer":"There are three most popular tools: pylint, pyflakes and pycheker.\nPyflakes will show you unused imports, variables, variable usage before assignment, syntax errors and things like that. Pychecker, AFAIK is similar to pyflakes.\nPylint, on the other hand, is a much more comprehensive tool: apart from the listed above, it also checks for PEP8 compatibility, variable names, docstrings, proper indentation, checks for maximum line and module length, number of local variables and class methods and so on. It gives a more or less complete report with a universal score of your code. However, because of the outstanding amount of errors it shows, without proper configuration it is quite tedious to use.","Q_Score":4,"Tags":"python","A_Id":4096865,"CreationDate":"2010-11-04T12:44:00.000","Title":"Python syntax and other things checking?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am about to start collecting large amounts of numeric data in real-time (for those interested, the bid\/ask\/last or 'tape' for various stocks and futures).  The data will later be retrieved for analysis and simulation.  That's not hard at all, but I would like to do it efficiently and that brings up a lot of questions.  I don't need the best solution (and there are probably many 'bests' depending on the metric, anyway).  I would just like a solution that a computer scientist would approve of.  (Or not laugh at?)\n(1) Optimize for disk space, I\/O speed, or memory?\nFor simulation, the overall speed is important.  We want the I\/O (really, I) speed of the data just faster than the computational engine, so we are not I\/O limited.  \n(2) Store text, or something else (binary numeric)?\n(3) Given a set of choices from (1)-(2), are there any standout language\/library combinations to do the job-- Java, Python, C++, or something else?\nI would classify this code as \"write and forget\", so more points for efficiency over clarity\/compactness of code.  I would very, very much like to stick with Python for the simulation code (because the sims do change a lot and need to be clear).  So bonus points for good Pythonic solutions.\nEdit: this is for a Linux system (Ubuntu)\nThanks","AnswerCount":6,"Available Count":4,"Score":0.0333209931,"is_accepted":false,"ViewCount":2032,"Q_Id":4098509,"Users Score":1,"Answer":"Using D-Bus format to send the information may be to your advantage. The format is standard, binary, and D-Bus is implemented in multiple languages, and can be used to send both over the network and inter-process on the same machine.","Q_Score":2,"Tags":"java,c++,python,storage,simulation","A_Id":4098941,"CreationDate":"2010-11-04T15:51:00.000","Title":"Collecting, storing, and retrieving large amounts of numeric data","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},{"Question":"I am about to start collecting large amounts of numeric data in real-time (for those interested, the bid\/ask\/last or 'tape' for various stocks and futures).  The data will later be retrieved for analysis and simulation.  That's not hard at all, but I would like to do it efficiently and that brings up a lot of questions.  I don't need the best solution (and there are probably many 'bests' depending on the metric, anyway).  I would just like a solution that a computer scientist would approve of.  (Or not laugh at?)\n(1) Optimize for disk space, I\/O speed, or memory?\nFor simulation, the overall speed is important.  We want the I\/O (really, I) speed of the data just faster than the computational engine, so we are not I\/O limited.  \n(2) Store text, or something else (binary numeric)?\n(3) Given a set of choices from (1)-(2), are there any standout language\/library combinations to do the job-- Java, Python, C++, or something else?\nI would classify this code as \"write and forget\", so more points for efficiency over clarity\/compactness of code.  I would very, very much like to stick with Python for the simulation code (because the sims do change a lot and need to be clear).  So bonus points for good Pythonic solutions.\nEdit: this is for a Linux system (Ubuntu)\nThanks","AnswerCount":6,"Available Count":4,"Score":0.0,"is_accepted":false,"ViewCount":2032,"Q_Id":4098509,"Users Score":0,"Answer":"If you are just storing, then use system tools. Don't write your own. If you need to do some real-time processing of the data before it is stored, then that's something completely different.","Q_Score":2,"Tags":"java,c++,python,storage,simulation","A_Id":4098550,"CreationDate":"2010-11-04T15:51:00.000","Title":"Collecting, storing, and retrieving large amounts of numeric data","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},{"Question":"I am about to start collecting large amounts of numeric data in real-time (for those interested, the bid\/ask\/last or 'tape' for various stocks and futures).  The data will later be retrieved for analysis and simulation.  That's not hard at all, but I would like to do it efficiently and that brings up a lot of questions.  I don't need the best solution (and there are probably many 'bests' depending on the metric, anyway).  I would just like a solution that a computer scientist would approve of.  (Or not laugh at?)\n(1) Optimize for disk space, I\/O speed, or memory?\nFor simulation, the overall speed is important.  We want the I\/O (really, I) speed of the data just faster than the computational engine, so we are not I\/O limited.  \n(2) Store text, or something else (binary numeric)?\n(3) Given a set of choices from (1)-(2), are there any standout language\/library combinations to do the job-- Java, Python, C++, or something else?\nI would classify this code as \"write and forget\", so more points for efficiency over clarity\/compactness of code.  I would very, very much like to stick with Python for the simulation code (because the sims do change a lot and need to be clear).  So bonus points for good Pythonic solutions.\nEdit: this is for a Linux system (Ubuntu)\nThanks","AnswerCount":6,"Available Count":4,"Score":0.0333209931,"is_accepted":false,"ViewCount":2032,"Q_Id":4098509,"Users Score":1,"Answer":"Actually, this is quite similar to what I'm doing, which is monitoring changes players make to the world in a game. I'm currently using an sqlite database with python.\nAt the start of the program, I load the disk database into memory, for fast writing procedures. Each change is put in to two lists. These lists are for both the memory database and the disk database. Every x or so updates, the memory database is updated, and a counter is pushed up one. This is repeated, and when the counter equals 5, it's reset and the list with changes for the disk is flushed to the disk database and the list is cleared.I have found this works well if I also set the writing more to WOL(Write Ahead Logging). This method can stand about 100-300 updates a second if I update memory every 100 updates and the disk counter is set to update every 5 memory updates. You should probobly choose binary, sense, unless you have faults in your data sources, would be most logical","Q_Score":2,"Tags":"java,c++,python,storage,simulation","A_Id":4098613,"CreationDate":"2010-11-04T15:51:00.000","Title":"Collecting, storing, and retrieving large amounts of numeric data","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},{"Question":"I am about to start collecting large amounts of numeric data in real-time (for those interested, the bid\/ask\/last or 'tape' for various stocks and futures).  The data will later be retrieved for analysis and simulation.  That's not hard at all, but I would like to do it efficiently and that brings up a lot of questions.  I don't need the best solution (and there are probably many 'bests' depending on the metric, anyway).  I would just like a solution that a computer scientist would approve of.  (Or not laugh at?)\n(1) Optimize for disk space, I\/O speed, or memory?\nFor simulation, the overall speed is important.  We want the I\/O (really, I) speed of the data just faster than the computational engine, so we are not I\/O limited.  \n(2) Store text, or something else (binary numeric)?\n(3) Given a set of choices from (1)-(2), are there any standout language\/library combinations to do the job-- Java, Python, C++, or something else?\nI would classify this code as \"write and forget\", so more points for efficiency over clarity\/compactness of code.  I would very, very much like to stick with Python for the simulation code (because the sims do change a lot and need to be clear).  So bonus points for good Pythonic solutions.\nEdit: this is for a Linux system (Ubuntu)\nThanks","AnswerCount":6,"Available Count":4,"Score":0.0996679946,"is_accepted":false,"ViewCount":2032,"Q_Id":4098509,"Users Score":3,"Answer":"Optimizing for disk space and IO speed is the same thing - these days, CPUs are so fast compared to IO that it's often overall faster to compress data before storing it (you may actually want to do that). I don't really see memory playing a big role (though you should probably use a reasonably-sized buffer to ensure you're doing sequential writes).\nBinary is more compact (and thus faster). Given the amount of data, I doubt whether being human-readable has any value. The only advantage of a text format would be that it's easier to figure out and correct if it gets corrupted or you lose the parsing code.","Q_Score":2,"Tags":"java,c++,python,storage,simulation","A_Id":4098582,"CreationDate":"2010-11-04T15:51:00.000","Title":"Collecting, storing, and retrieving large amounts of numeric data","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},{"Question":"We have an application based on Excel 2003 and Python 2.4 on Windows XP 32bit. The application consists of a large collection of Python functions which can be called from a number of excel worksheets.\nWe've notcied an anomolous behavior which is that sometimes in the middle of one of these calls the python interpreter will start hunting around for modules which almost certainly are already loaded and in memory. \nWe know this because we were able to hook-up Sysinternal's Process Monitor to the process and observe that from time to time the process (when called) starts hunting around a bunch of directories and eggs for certain .py files. \nThe obvious thing to try is to see if the python search-path had become modified, however we found this not to be the case. It's exactly what we'd expect. The odd thing is that:\n\nThe occasions on which this searching behavior was triggered appears to be random, i.e. it did not happen every time or with any noticable pattern.\nThe behavior did not affect the result of the function. It returned the same value irrespective of whether this file searching behavior was triggered.\nThe folders that were being scanned were non-existant (e.g. J:\/python-eggs ) on a machine where J-drive contained no-such folder. Naturally procmon reports that this generated a file-not found error.\n\nIt's all very mysterious so I dont expect anybody to be able to provide a definitive answer as to what might be going wrong. I would appreciate any suggestions about how this problem might be debugged.\nThanks!\nAnswers to comments\n\nAll the things that are being searched for are actual, known python files which exist in the main project .egg file. The odd thing is that at the time they are being searched-for those particuar modules have already been imported. They must be in memory in order for the process to work.\nYes, this affects performance because sometimes this searching behavior tries to hit network drives. Also by searching eggs which couldnt possibly contain certain modules it the process gets interrupted by the corporate mandated virus-scanner. That slows down what would normally be a harmless and instant interruption.\nThis is stock python 2.4.4. No modifications.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":111,"Q_Id":4099817,"Users Score":1,"Answer":"\"Python functions which can be called from a number of excel worksheets\"  \n\nAnd you're not blaming Excel for randomly running Python modules?  Why not?  How have you proven that Excel is behaving properly?","Q_Score":3,"Tags":"python,windows,excel","A_Id":4103210,"CreationDate":"2010-11-04T18:14:00.000","Title":"Odd python search-path behavior, what's going wrong here?","Data Science and Machine Learning":0,"Database and SQL":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},{"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},{"Question":"I am going to build vim and see that it supports the pythoninterp feature by\n--enable-pythoninterp. What is it? Since I am a big Python fan, I'd like to know more about it.\nAnd also, what's the --with-python-config-dir=PATH for?","AnswerCount":1,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":3212,"Q_Id":4104202,"Users Score":8,"Answer":"vim supports scripting in various languages, Python being one of them. See :h python for more details.","Q_Score":4,"Tags":"python,vim","A_Id":4104215,"CreationDate":"2010-11-05T07:44:00.000","Title":"What is the vim feature: --enable-pythoninterp","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"What is the most compact way to write 1,000,000 ints (0, 1, 2...) to file using Python without zipping etc? My answer is: 1,000,000 * 3 bytes using struct module, but it seems like interviewer expected another answer...\nEdit. Numbers from 1 to 1,000,000 in random order (so transform like 5, 6, 7 -> 5-7 can be applied in rare case). You can use any writing method you know, but the resulting file should have minimum size.","AnswerCount":7,"Available Count":4,"Score":0.057080742,"is_accepted":false,"ViewCount":1746,"Q_Id":4104898,"Users Score":2,"Answer":"Assuming you do have to remember their order and that the numbers are in the range of 1 to 1,000,000, it would only take 20 bits or 2\u00bd bytes to write each one since 1,000,000 is 0xF4240 in hexadecimal. You'd have to pack them together to not waste any space with this approach, but by doing so it would only take 2.5 * 1,000,000 bytes.","Q_Score":4,"Tags":"python","A_Id":4105223,"CreationDate":"2010-11-05T09:59:00.000","Title":"Python: Write 1,000,000 ints to 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},{"Question":"What is the most compact way to write 1,000,000 ints (0, 1, 2...) to file using Python without zipping etc? My answer is: 1,000,000 * 3 bytes using struct module, but it seems like interviewer expected another answer...\nEdit. Numbers from 1 to 1,000,000 in random order (so transform like 5, 6, 7 -> 5-7 can be applied in rare case). You can use any writing method you know, but the resulting file should have minimum size.","AnswerCount":7,"Available Count":4,"Score":0.0,"is_accepted":false,"ViewCount":1746,"Q_Id":4104898,"Users Score":0,"Answer":"I would only write the start and end of the given range, in this case 1 and 1,000,000, because nowhere has the interviewer mentioned order is important.","Q_Score":4,"Tags":"python","A_Id":4105172,"CreationDate":"2010-11-05T09:59:00.000","Title":"Python: Write 1,000,000 ints to 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},{"Question":"What is the most compact way to write 1,000,000 ints (0, 1, 2...) to file using Python without zipping etc? My answer is: 1,000,000 * 3 bytes using struct module, but it seems like interviewer expected another answer...\nEdit. Numbers from 1 to 1,000,000 in random order (so transform like 5, 6, 7 -> 5-7 can be applied in rare case). You can use any writing method you know, but the resulting file should have minimum size.","AnswerCount":7,"Available Count":4,"Score":1.2,"is_accepted":true,"ViewCount":1746,"Q_Id":4104898,"Users Score":2,"Answer":"Well, your solution takes three bytes (= 24 bits) per integer. Theoretically, 20 bits are enough (since 2^19 < 1.000.000 < 2^20).\nEDIT: Oops, just noticed Neil\u2019s comment stating the same. I\u2019m making this answer CW since it really belongs to him.","Q_Score":4,"Tags":"python","A_Id":4105217,"CreationDate":"2010-11-05T09:59:00.000","Title":"Python: Write 1,000,000 ints to 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},{"Question":"What is the most compact way to write 1,000,000 ints (0, 1, 2...) to file using Python without zipping etc? My answer is: 1,000,000 * 3 bytes using struct module, but it seems like interviewer expected another answer...\nEdit. Numbers from 1 to 1,000,000 in random order (so transform like 5, 6, 7 -> 5-7 can be applied in rare case). You can use any writing method you know, but the resulting file should have minimum size.","AnswerCount":7,"Available Count":4,"Score":0.0,"is_accepted":false,"ViewCount":1746,"Q_Id":4104898,"Users Score":0,"Answer":"What is the most compact way to write 1,000,000 ints (0, 1, 2...) to file using Python without zipping etc\nIf you interpret the 1,000,000 ints as \"I didn't specify that they have to be different\", you can just use a for loop to write 0 one million times.","Q_Score":4,"Tags":"python","A_Id":4105238,"CreationDate":"2010-11-05T09:59:00.000","Title":"Python: Write 1,000,000 ints to 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},{"Question":"I am loading an IronPython script from a database and executing it.  This works fine for simple scripts, but imports are a problem.  How can I intercept these import calls and then load the appropriate scripts from the database?\nEDIT:  My main application is written in C# and I'd like to intercept the calls on the C# side without editing the Python scripts.\nEDIT: From the research I've done, it looks like creating your own PlatformAdaptationLayer is the way you're supposed to to implement this, but it doesn't work in this case.  I've created my own PAL and in my testing, my FileExsists method gets called for every import in the script.  But for some reason it never calls any overload of the OpenInputFileStream method.  Digging through the IronPython source, once FileExists returns true, it tries to locate the file itself on the path.  So this looks like a dead end.","AnswerCount":4,"Available Count":1,"Score":0.049958375,"is_accepted":false,"ViewCount":2738,"Q_Id":4105804,"Users Score":1,"Answer":"You can re-direct all I\/O to the database using the PlatformAdaptationLayer.  To do this you'll need to implement a ScriptHost which provides the PAL.  Then when you create the ScriptRuntime you set the HostType to your host type and it'll be used for the runtime.  On the PAL you then override OpenInputFileStream and return a stream object which has the content from the database (you could just use a MemoryStream here after reading from the DB).  \nIf you want to still provide access to file I\/O you can always fall back to FileStream's for \"files\" you can't find.","Q_Score":9,"Tags":"import,ironpython","A_Id":4111764,"CreationDate":"2010-11-05T12:25:00.000","Title":"Custom IronPython import resolution","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},{"Question":"Can someone recommend a library for calculating SHA1WithRSAEncryption in Python?\nContext: I'm trying to do some message authentication. I've looked at PyXMLDSig, but it seemed to expect the certificates as separate files. As a first step to better understanding the problem space, I wanted to calculate the digest values \"by hand\".\nI've looked around and seen Java implementations, but not Python ones. (Jython isn't really an option for my environment.) \nThanks in advance.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":378,"Q_Id":4107888,"Users Score":0,"Answer":"Take a look at M2Crypto, it's probably the best and most complete crypto library for Python.","Q_Score":0,"Tags":"python,xml,sha1","A_Id":4233195,"CreationDate":"2010-11-05T16:27:00.000","Title":"sha1WithRSAEncryption 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},{"Question":"I got a VS10 project. I want to build some C++ code so I can use it in python. I followed the boost tutorial and got it working. However VS keeps to link boost-python-vc100-mt-gd-1_44.lib but it's just a wrapper which calls boost-python-vc100-mt-gd-1_44.dll. That's why I need to copy the .dll with my .dll(.pyd) file. So I want to link boost:python statically to that .dll(.pyd) file. But I just can't find any configuration option in VS or in the compiler and linker manual. The weirdest thing is I've got one older project using boost::filesystem with the very same config but that project links against libboost-filesystem-*.lib which is static lib so it's ok. I've been googling for couple of hours without any success and it drivers me crazy.\nThanks for any help or suggestion.","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":4303,"Q_Id":4120169,"Users Score":0,"Answer":"What libraries are linked depends on the settings of your project. There are two possibilities: You can build against\n\nstatically\ndynamically\n\nlinked versions of the c-runtime libs. Depending on which option is selected, the boost sends a proper #pragma to the linker. These options need to be set consistently in all projects which constitute your program. So go to \"properties -> c++ -> code generation\" (or similar, I am just guessing, don't have VS up and running right now) and be sure that the right option is set (consistently). Of course, you must have compiled boost libraries in required format before...","Q_Score":1,"Tags":"c++,visual-studio-2010,static,linker,boost-python","A_Id":4121910,"CreationDate":"2010-11-07T22:58:00.000","Title":"MSVC - boost::python static linking to .dll (.pyd)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I got a VS10 project. I want to build some C++ code so I can use it in python. I followed the boost tutorial and got it working. However VS keeps to link boost-python-vc100-mt-gd-1_44.lib but it's just a wrapper which calls boost-python-vc100-mt-gd-1_44.dll. That's why I need to copy the .dll with my .dll(.pyd) file. So I want to link boost:python statically to that .dll(.pyd) file. But I just can't find any configuration option in VS or in the compiler and linker manual. The weirdest thing is I've got one older project using boost::filesystem with the very same config but that project links against libboost-filesystem-*.lib which is static lib so it's ok. I've been googling for couple of hours without any success and it drivers me crazy.\nThanks for any help or suggestion.","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":4303,"Q_Id":4120169,"Users Score":1,"Answer":"You probably don't want to do that. Statically linked Boost python has a number of problems and quirks when there are more then one boost python based library imported. \"But I only have one\" you say. Can you guarantee that your users won't have another? That you might want to use  another in the future? Stick with the DLL. Distributing another DLL is really not that big a deal. Just put it side-by-side in the same directory.","Q_Score":1,"Tags":"c++,visual-studio-2010,static,linker,boost-python","A_Id":4146530,"CreationDate":"2010-11-07T22:58:00.000","Title":"MSVC - boost::python static linking to .dll (.pyd)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Let's say I have a bunch of small targets in different programming languages (C++, Java, Python, etc), with inter programming language dependencies (Java project depends on a C++, Python depends on C++). How can one build\/compile them?\nI tried scons and more recently gyp. I don't remember what issues I had with scons. Gyp has a very ugly language definition plus I had to hack ant scripts in order to build my java targets.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":664,"Q_Id":4128555,"Users Score":0,"Answer":"I once checked out CMake (for C++), I liked it very much. It's easy to use yet powerful and quite similar to Make syntax. It also has Java support.","Q_Score":2,"Tags":"java,c++,python,build,scons","A_Id":4129038,"CreationDate":"2010-11-08T22:07:00.000","Title":"How to build\/compile C++, Java and 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},{"Question":"What would be this encoding's name?\n\nsmb:\/\/nas\/music\/_lib\/v\/voivod\/voivod-rrr%C3%B6%C3%B6%C3%B6aaarrr\/01%20-%20voivod%20-%20rrr%C3%B6%C3%B6%C3%B6aaarrr%20-%20korg%C3%BCll_the_exterminator.mp3\n\nI would like to convert such string to unicode using Python.  How would I do that?","AnswerCount":3,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":791,"Q_Id":4129658,"Users Score":3,"Answer":"That's URL-encoded UTF-8. URL-decode it, then decode it as UTF-8.","Q_Score":0,"Tags":"python,unicode","A_Id":4129665,"CreationDate":"2010-11-09T01:19:00.000","Title":"unknown encoding to unicode","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"What would be this encoding's name?\n\nsmb:\/\/nas\/music\/_lib\/v\/voivod\/voivod-rrr%C3%B6%C3%B6%C3%B6aaarrr\/01%20-%20voivod%20-%20rrr%C3%B6%C3%B6%C3%B6aaarrr%20-%20korg%C3%BCll_the_exterminator.mp3\n\nI would like to convert such string to unicode using Python.  How would I do that?","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":791,"Q_Id":4129658,"Users Score":0,"Answer":"Try urllib.unquote().","Q_Score":0,"Tags":"python,unicode","A_Id":4129716,"CreationDate":"2010-11-09T01:19:00.000","Title":"unknown encoding to unicode","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"What should I do for fast, full-text searching on App Engine with as little work as possible (and as little Java \u2014 I\u2019m doing Python.)?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1246,"Q_Id":4130813,"Users Score":0,"Answer":"GAE has announced plans to offer full-text searching natively in the Datastore soon.","Q_Score":7,"Tags":"python,google-app-engine,search,full-text-search,full-text-indexing","A_Id":5072790,"CreationDate":"2010-11-09T05:36:00.000","Title":"How should I do full-text searching on 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},{"Question":"There was the Unladen Swallow project that aims to get a faster python, but it seems to be stopped :\nIs there a way to get a faster python, I mean faster than C-Python, without the use of psyco ?","AnswerCount":4,"Available Count":2,"Score":0.1488850336,"is_accepted":false,"ViewCount":312,"Q_Id":4132493,"Users Score":3,"Answer":"Sure. Use one of the variants that uses a JITer, such as IronPython, Jython, or PyPy.","Q_Score":2,"Tags":"python,performance","A_Id":4132499,"CreationDate":"2010-11-09T10:09:00.000","Title":"When a faster 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},{"Question":"There was the Unladen Swallow project that aims to get a faster python, but it seems to be stopped :\nIs there a way to get a faster python, I mean faster than C-Python, without the use of psyco ?","AnswerCount":4,"Available Count":2,"Score":0.049958375,"is_accepted":false,"ViewCount":312,"Q_Id":4132493,"Users Score":1,"Answer":"I saw pypy to be very fast on some tests : have a look","Q_Score":2,"Tags":"python,performance","A_Id":4132523,"CreationDate":"2010-11-09T10:09:00.000","Title":"When a faster 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},{"Question":"I needed to make a change to a 3rd party library, so I edited the files in the egg (which is not zipped). The egg lives in site-packages in a virtualenv. Everything works fine on my dev machine, but when I copied the egg to another machine, the module can longer be found to import.\nI'm sure I went about this the wrong way, but I'm hoping there's a way to fix it.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":89,"Q_Id":4137917,"Users Score":1,"Answer":"A quick fix to your problem should be by adding the full path of the egg to a .pth file which should exist in the sys-path (in your case site-packages).","Q_Score":0,"Tags":"python","A_Id":4138407,"CreationDate":"2010-11-09T19:57:00.000","Title":"Copied python egg no longer works","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm going through the Python tutorial, and I got to the section on modules.  \nI created a fibo.py file in Users\/Me\/code\/Python   (s\nNow I'm back in the interpreter and I can't seem to import the module, because I don't understand how to import a relative (or absolute) path.\nI'm also thoroughly confused by how and if to modify PYTHONPATH and\/or sys.path. \nAll the other 'import module' questions on here seem to be","AnswerCount":4,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":6865,"Q_Id":4139167,"Users Score":0,"Answer":"Before importing any user defined module,specify the path to the directory containg that module\nsys.path.append(\"path to your directory\")","Q_Score":0,"Tags":"python,module","A_Id":30371608,"CreationDate":"2010-11-09T22:06:00.000","Title":"Importing a module 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},{"Question":"I am writing now writing some evented code (In python using gevent) and I use the nginx as a web server and I feel both are great. I was told that there is a trade off with events but was unable to see it. Can someone please shed some light?\nJames","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":1703,"Q_Id":4140656,"Users Score":1,"Answer":"Biggest issue is that without threads, a block for one client will cause a block for all client. For example, if one client requests a resource (file on disk, paged-out memory, etc) that requires the OS to block the requesting process, then all clients will have to wait. A multithreaded server can block just the one client and continue to serve others.\nThat said, if the above scenario is unlikely (that is, all clients will request the same resources), then event-driven is the way to go.","Q_Score":9,"Tags":"python,asynchronous,libevent,gevent","A_Id":4140840,"CreationDate":"2010-11-10T02:13:00.000","Title":"Why shouldn't I use async (evented) IO","Data Science and Machine Learning":0,"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},{"Question":"I am writing now writing some evented code (In python using gevent) and I use the nginx as a web server and I feel both are great. I was told that there is a trade off with events but was unable to see it. Can someone please shed some light?\nJames","AnswerCount":2,"Available Count":2,"Score":1.0,"is_accepted":false,"ViewCount":1703,"Q_Id":4140656,"Users Score":9,"Answer":"The only difficulty of evented programming is that you mustn't block, ever. This can be hard to achieve if you use some libraries that were designed with threads in mind. If you don't control these libraries, a fork() + message ipc is the way to go.","Q_Score":9,"Tags":"python,asynchronous,libevent,gevent","A_Id":4291204,"CreationDate":"2010-11-10T02:13:00.000","Title":"Why shouldn't I use async (evented) IO","Data Science and Machine Learning":0,"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},{"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},{"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},{"Question":"I have projects in C++, Java and Python. Projects in C++ export SWIG interfaces so they can be used by Java and Python projects.\nMy question is: what building mechanism can I use to manage dependencies and build these projects?\nI have used SCons and GYP. They are fairly easy to use and allow plugins (code-generators, compilers, packers). I'd like to know whether there are alternatives, in particular with native support for C++, Java and Python.\nI develop in Linux platform, but I'd like to be able to build in mac and win platforms as well.","AnswerCount":5,"Available Count":4,"Score":0.1586485043,"is_accepted":false,"ViewCount":2318,"Q_Id":4141511,"Users Score":4,"Answer":"I tried to do a Java \/ C++ \/ C++ To Java swig \/ (+ Protocol buffers) project in CMAKE and it was horrible! In such a case the problem with Cmake is, that the scripting language is extremely limited. I switched to Scons and everything got much easier.","Q_Score":6,"Tags":"java,c++,python,scons,gyp","A_Id":7201456,"CreationDate":"2010-11-10T05:32:00.000","Title":"What are the SCons alternatives?","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},{"Question":"I have projects in C++, Java and Python. Projects in C++ export SWIG interfaces so they can be used by Java and Python projects.\nMy question is: what building mechanism can I use to manage dependencies and build these projects?\nI have used SCons and GYP. They are fairly easy to use and allow plugins (code-generators, compilers, packers). I'd like to know whether there are alternatives, in particular with native support for C++, Java and Python.\nI develop in Linux platform, but I'd like to be able to build in mac and win platforms as well.","AnswerCount":5,"Available Count":4,"Score":0.0399786803,"is_accepted":false,"ViewCount":2318,"Q_Id":4141511,"Users Score":1,"Answer":"For Java and C++ projects you can take a look into Maven + Maven-nar-plugin but for Python i really don't know the best. May be other tools like CMake would fit better.","Q_Score":6,"Tags":"java,c++,python,scons,gyp","A_Id":4142509,"CreationDate":"2010-11-10T05:32:00.000","Title":"What are the SCons alternatives?","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},{"Question":"I have projects in C++, Java and Python. Projects in C++ export SWIG interfaces so they can be used by Java and Python projects.\nMy question is: what building mechanism can I use to manage dependencies and build these projects?\nI have used SCons and GYP. They are fairly easy to use and allow plugins (code-generators, compilers, packers). I'd like to know whether there are alternatives, in particular with native support for C++, Java and Python.\nI develop in Linux platform, but I'd like to be able to build in mac and win platforms as well.","AnswerCount":5,"Available Count":4,"Score":1.0,"is_accepted":false,"ViewCount":2318,"Q_Id":4141511,"Users Score":9,"Answer":"CMake\nI use and prefer it for my projects.\nThere's also Rake (comes with Ruby, but can be used for anything), which I regard rather highly.","Q_Score":6,"Tags":"java,c++,python,scons,gyp","A_Id":4141589,"CreationDate":"2010-11-10T05:32:00.000","Title":"What are the SCons alternatives?","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},{"Question":"I have projects in C++, Java and Python. Projects in C++ export SWIG interfaces so they can be used by Java and Python projects.\nMy question is: what building mechanism can I use to manage dependencies and build these projects?\nI have used SCons and GYP. They are fairly easy to use and allow plugins (code-generators, compilers, packers). I'd like to know whether there are alternatives, in particular with native support for C++, Java and Python.\nI develop in Linux platform, but I'd like to be able to build in mac and win platforms as well.","AnswerCount":5,"Available Count":4,"Score":0.0399786803,"is_accepted":false,"ViewCount":2318,"Q_Id":4141511,"Users Score":1,"Answer":"In Java world ant is \"lingua franca\" for build systems.\nAnt supports a C++ task via ant-contrib - so you can compile your C++ code.\nWith Ant's exec task you can still run swig on C++ code in order to get the wrappers.\nThen standard tasks as javac\/jar can be used for java application build.","Q_Score":6,"Tags":"java,c++,python,scons,gyp","A_Id":4143403,"CreationDate":"2010-11-10T05:32:00.000","Title":"What are the SCons alternatives?","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},{"Question":"Does anyone know of a \"language level\" facility for pickling in C++?  I don't want something like Boost serialization, or Google Protocol Buffers.  Instead, something that could automatically serialize all the members of a class (with an option to exclude some members, either because they're not serializable, or else because I just don't care to save them for later). This could be accomplished with an extra action at parse time, that would generate code to handle the automatic serialization.  Has anyone heard of anything like that?","AnswerCount":5,"Available Count":4,"Score":0.1194272985,"is_accepted":false,"ViewCount":3405,"Q_Id":4149086,"Users Score":3,"Answer":"something that could automatically\n  serialize all the members of a class\n\nThis is not possible in C++. Python, C#, Java et al. use run-time introspection to achieve this. You can't do that in C++, RTTI is not powerful enough.\nIn essence, there is nothing in the C++ language that would enable someone to discover the member variables of an object at run-time. Without that, you can't automatically serialize them.","Q_Score":11,"Tags":"c++,python,serialization,boost,pickle","A_Id":4149474,"CreationDate":"2010-11-10T21:07:00.000","Title":"Python-style pickling for 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":0,"Web Development":0},{"Question":"Does anyone know of a \"language level\" facility for pickling in C++?  I don't want something like Boost serialization, or Google Protocol Buffers.  Instead, something that could automatically serialize all the members of a class (with an option to exclude some members, either because they're not serializable, or else because I just don't care to save them for later). This could be accomplished with an extra action at parse time, that would generate code to handle the automatic serialization.  Has anyone heard of anything like that?","AnswerCount":5,"Available Count":4,"Score":0.0,"is_accepted":false,"ViewCount":3405,"Q_Id":4149086,"Users Score":0,"Answer":"One quick way to do this that I got working once when I needed to save a struct to a file was to cast my struct to a char array and write it out to a file. Then when I wanted to load my struct back in, I would read the entire file (in binary mode), and cast the whole thing to my struct's type. Easy enough and exploits the fact that structs are stored as a contiguous block in memory. I wouldn't expect this to work with convoluted data structures or pointers, though, but food for thought.","Q_Score":11,"Tags":"c++,python,serialization,boost,pickle","A_Id":4149445,"CreationDate":"2010-11-10T21:07:00.000","Title":"Python-style pickling for 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":0,"Web Development":0},{"Question":"Does anyone know of a \"language level\" facility for pickling in C++?  I don't want something like Boost serialization, or Google Protocol Buffers.  Instead, something that could automatically serialize all the members of a class (with an option to exclude some members, either because they're not serializable, or else because I just don't care to save them for later). This could be accomplished with an extra action at parse time, that would generate code to handle the automatic serialization.  Has anyone heard of anything like that?","AnswerCount":5,"Available Count":4,"Score":1.2,"is_accepted":true,"ViewCount":3405,"Q_Id":4149086,"Users Score":7,"Answer":"I don't believe there's any way to do this in a language with no run-time introspection capabilities.","Q_Score":11,"Tags":"c++,python,serialization,boost,pickle","A_Id":4149141,"CreationDate":"2010-11-10T21:07:00.000","Title":"Python-style pickling for 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":0,"Web Development":0},{"Question":"Does anyone know of a \"language level\" facility for pickling in C++?  I don't want something like Boost serialization, or Google Protocol Buffers.  Instead, something that could automatically serialize all the members of a class (with an option to exclude some members, either because they're not serializable, or else because I just don't care to save them for later). This could be accomplished with an extra action at parse time, that would generate code to handle the automatic serialization.  Has anyone heard of anything like that?","AnswerCount":5,"Available Count":4,"Score":0.0399786803,"is_accepted":false,"ViewCount":3405,"Q_Id":4149086,"Users Score":1,"Answer":"There's the standard C++ serialization with the << and >> operators, although you'll have to implement these for each of your classes (which it sounds like you don't want to do). Some practitioners say you should alway implement these operators, although of course, most of us rarely do.","Q_Score":11,"Tags":"c++,python,serialization,boost,pickle","A_Id":4149128,"CreationDate":"2010-11-10T21:07:00.000","Title":"Python-style pickling for 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":0,"Web Development":0},{"Question":"I'm a 5 years Python programmer, but shortly I'll be also working with PHP. Could you recommend me some readings to getting in touch with this language having in mind my Python skills?","AnswerCount":4,"Available Count":2,"Score":0.049958375,"is_accepted":false,"ViewCount":3823,"Q_Id":4149861,"Users Score":1,"Answer":"If you are familiar with MVC start learning from Zend Framework I think it will be easier for you to understand php, right php developing this way with a right leg start. \nObject oriented business logics are same in any language. \nI really want to get into python so we can exchange knowledge ;)","Q_Score":10,"Tags":"php,python","A_Id":4149942,"CreationDate":"2010-11-10T22:46:00.000","Title":"PHP for Python programmers?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm a 5 years Python programmer, but shortly I'll be also working with PHP. Could you recommend me some readings to getting in touch with this language having in mind my Python skills?","AnswerCount":4,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":3823,"Q_Id":4149861,"Users Score":0,"Answer":"the best resource IMHO is still php.net  there are a ton of decent books out there, but I still prefer to rely on php.net for the latest and greatest.","Q_Score":10,"Tags":"php,python","A_Id":4149875,"CreationDate":"2010-11-10T22:46:00.000","Title":"PHP for Python programmers?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Using Python, how might one read a file's path from a remote server?\nThis is a bit more clear to me on my local PC.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":36179,"Q_Id":4163456,"Users Score":0,"Answer":"use the os.path module to manipulate path string (you need to import os)\n\nthe current directory is os.path.abspath(os.curdir)\njoin 2 parts of a path with os.path.join(dirname, filename): this will take care of inserting the right path separator ('\\' or '\/', depending on the operating system) for building the path","Q_Score":10,"Tags":"python","A_Id":4164507,"CreationDate":"2010-11-12T09:58:00.000","Title":"Python - how to read path file\/folder from server","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},{"Question":"I have my own unit testing suite based on the unittest library. I would like to track the history of each test case being run. I would also like to identify after each run tests which flipped from PASS to FAIL or vice versa.\nI have very little knowledge about databases, but it seems that I could utilize sqlite3 for this task.\nAre there any existing solutions which integrate unittest and a database?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":280,"Q_Id":4170442,"Users Score":0,"Answer":"Technically, yes. The only thing that you need is some kind of scripting language or shell script that can talk to sqlite.\nYou should think of a database like a file in a file system where you don't have to care about the file format. You just say, here are tables of data, with columns. And each row of that is one record. Much like in a Excel table.\nSo if you are familiar with shell scripts or calling command line tools, you can install sqlite and use the sqlitecommand to interact with the database.\nAlthough I think the first thing you should do is to learn basic SQL. There are a lot of SQL tutorials out there.","Q_Score":1,"Tags":"python,unit-testing,sqlite","A_Id":4170458,"CreationDate":"2010-11-13T01:33:00.000","Title":"Using sqlite3 to track unit test results","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},{"Question":"About the only reason I can think of to distribute a python package as an egg is so that you can not include the .py files with your package (and only include .pyc files, which is a dubious way to protect your code anyway).  Aside from that, I can't really think of any reason to upload a package as an egg rather than an sdist.  In fact, pip doesn't even support eggs.\nIs there any real reason to use an egg rather than an sdist?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":251,"Q_Id":4170477,"Users Score":3,"Answer":"One reason: eggs can include compiled C extension modules so that the end user does not need to have the necessary build tools and possible additional headers and libraries to build the extension module from scratch.  The drawback to that is that the packager may need to supply multiple eggs to match each targeted platform and Python configuration. If there are many supported configurations, that can prove to be a daunting task but it can be effective for more homogenous environments.","Q_Score":1,"Tags":"python,packaging,egg,sdist","A_Id":4170898,"CreationDate":"2010-11-13T01:42:00.000","Title":"Why would one use an egg over an sdist?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm looking at writing a mashup app that will take submission titles from a subreddit and attempt to plot them on a map based on where they are likely to be relevant. I'd also like to add on things like Twitter later on.\nWhat I'm having difficulty planning is how to detect the most likely to be relevant country from the title. My first guess is to have a list of countries, along with their matching permutations (e.g. \"English\" matches \"England\", etc.) and check for occurrences of those items in the text. However this is probably going to be quite slow and will require me listing the possessive* name for each country.\nI'm planning on doing this in Python (so as to learn to use it) so I'm wondering is there a) a library that does this (and that I can learn from it) or b) a more obvious way to do this?\nTo give an idea of the types of input I'm working with here are some samples and what I'm trying to get out of them:\n\n\"Well they can't arrest all of us - Giving the middle finger to the British legal system (pic)\"\n\nKeyword: British (Great Britain)\n\n\"Poll: Wikileaks Assange leading Time 'Person of the Year' - Assange, an Australian who has become a thorn in the side of the Pentagon with his releases of secret US military documents about the wars in Iraq and Afghanistan, had received 21,736 votes as of Friday.\"\n\nKeywords: Afghanistan, Iraq, [Australian] (Afghanistan, Iraq, [Australia]) - Australia would be difficult to catch out as mainly irrelevant but this is acceptable for my purposes\n\n\"Cyber attack on Nobel peace prize website launched. Stay classy, China.\"\n\nKeyword: China (China)\n\n\"A Jewish surgeon refuses to operate on a patient and walks out of the operating room after discovering a nazi tattoo on the patient's arm.\"\n\nKeywords: none - acceptable for my purposes\n\n\n* This is probably the wrong word to use","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2432,"Q_Id":4170503,"Users Score":0,"Answer":"Use a FullText search index in MySQL. Then use AJAX calls to query against your database.","Q_Score":3,"Tags":"python,categorization","A_Id":4170680,"CreationDate":"2010-11-13T01:50:00.000","Title":"Extracting a country name from a text 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},{"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},{"Question":"I'm using emacs for python, and I'd like to have a nice useable shell in emacs to run an interpreter alongside my editing. \nIs there any better emacs shell package out there? The default shell is awful.","AnswerCount":4,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":2955,"Q_Id":4174633,"Users Score":4,"Answer":"That depends on what shell you are using, in GNU Emacs 23 there are at least 3 built in:\n\nshell - ugly, not working tab\neshell - not ugly but tab not working\nterm - not ugly and seems like ipython works with all goodies in it\n\nSo you might want to try the term mode.","Q_Score":2,"Tags":"python,emacs","A_Id":4174664,"CreationDate":"2010-11-13T20:51:00.000","Title":"Is there any way to get a better terminal 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":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have some Python scripts that I run on my desktop now for cutting up files. I want to put them on the web and write a simple front-end in PHP where a user uploads a file and it is passed as an argument to a python script on the web server and it is written out in chunks and the user can re-download the chunks.\nI know a decent amount of PHP, but I do not see:\n\nHow to mix PHP and Python programmatically\nIs it possible to have a webpage in python that can just call the python script? Can one have a GUI page that is like zzz.com\/text.py as example","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":4155,"Q_Id":4175419,"Users Score":10,"Answer":"For http requests, you need to set your web server to hand over certain request to PHP and others to Python. From within PHP's scripts, if you need to call some Python executable scripts, use one of PHP's shell functions. e.g. exec()\nYes it is possible. The djangobook is a nice tutorial that covers this in one of the earlier chapters. It shows you how to run python as a cgi or with apache.\n\nOn a personal note, if you have time to dig deeper into Python, I'd strongly encourage you to do the whole thing in it, rather than mix things with PHP. My experience tells me that there are probably more cases where a PHP app needs some Python support rather than the reverse. \nIf the supporting language can do everything that the main language does, what's the point of using the main language?","Q_Score":4,"Tags":"php,python,apache","A_Id":4175473,"CreationDate":"2010-11-14T00:04:00.000","Title":"Mixing Python and 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":1},{"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},{"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},{"Question":"I have a system currently written in Python that can be separated into backend and frontend layers. Python is too slow, so I want to rewrite the backend in a fast compiled language while keeping the frontend in Python, in a way that lets the backend functionality be called from Python. What are the best choices to do so?\nI've considered cython but it's very limited and cumbersome to write, and not that much faster. From what I remember of Boost Python for C++, it's very annoying to maintain the bridge between languages. Are there better choices? \nMy main factors are:\n\nspeed of execution\nspeed of compilation\nlanguage is declarative","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":247,"Q_Id":4188273,"Users Score":1,"Answer":"I would disagree about Boost::Python. It can get cumbersome when wrapping an existing c++-centric library and trying not to change the interface. But that is not what you are looking to do. \nYou are looking to push the heavy lifting of an existing python solution in to a faster language.  That means that you can control the interface. \nIf you are in control of the interface, you can keep it python-friendly, and bp-friendly (IE: avoid problematic things like pointers and immutable types as l-values) \nIn that case, Boost::Python can be as simple as telling it which functions you want to call from python.","Q_Score":5,"Tags":"java,c++,python,boost-python","A_Id":4227430,"CreationDate":"2010-11-15T19:58:00.000","Title":"Language choices for writing very fast abstractions interfacing 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},{"Question":"I have a system currently written in Python that can be separated into backend and frontend layers. Python is too slow, so I want to rewrite the backend in a fast compiled language while keeping the frontend in Python, in a way that lets the backend functionality be called from Python. What are the best choices to do so?\nI've considered cython but it's very limited and cumbersome to write, and not that much faster. From what I remember of Boost Python for C++, it's very annoying to maintain the bridge between languages. Are there better choices? \nMy main factors are:\n\nspeed of execution\nspeed of compilation\nlanguage is declarative","AnswerCount":3,"Available Count":2,"Score":0.1325487884,"is_accepted":false,"ViewCount":247,"Q_Id":4188273,"Users Score":2,"Answer":"If you used Jython you could call into Java back-end routines easily (trivially).  Java's about twice as slow as c and 10x faster than python last time I checked.","Q_Score":5,"Tags":"java,c++,python,boost-python","A_Id":4188359,"CreationDate":"2010-11-15T19:58:00.000","Title":"Language choices for writing very fast abstractions interfacing 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},{"Question":"I would like to be able to access all the components of say a Flash image gallery on someone else's site. I want to be able to find the images, image coordinates, action script code, audio files, video, etc. I do not want to manipulate these elements, I just want to view them and their related information. \nIs this possible via scripting languages like Ruby, Python or Javascript?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":110,"Q_Id":4198069,"Users Score":0,"Answer":"No, not really. Not like you can examine the DOM of a webpage. You can download and decompile the swf, but you may or may not be able to get all the info you want out.","Q_Score":0,"Tags":"javascript,python,flash","A_Id":4198087,"CreationDate":"2010-11-16T19:20:00.000","Title":"Is it possible to access the internal elements of an embedded Flash object via a scripting 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":1},{"Question":"I would like to be able to access all the components of say a Flash image gallery on someone else's site. I want to be able to find the images, image coordinates, action script code, audio files, video, etc. I do not want to manipulate these elements, I just want to view them and their related information. \nIs this possible via scripting languages like Ruby, Python or Javascript?","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":110,"Q_Id":4198069,"Users Score":0,"Answer":"You can if (and only if) your application domain is the same.","Q_Score":0,"Tags":"javascript,python,flash","A_Id":4198271,"CreationDate":"2010-11-16T19:20:00.000","Title":"Is it possible to access the internal elements of an embedded Flash object via a scripting 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":1},{"Question":"I am completely new to Python-- never used it before today.  I am interested in devloping Python applications for the web.  I would like to check to see if my web server supports WSGI or running python apps in some way.\nLet's say I have a .py file that prints \"Hello world!\".  How can I test to see if my server supports processing this file?\nFYI, this is a Mac OS X server 10.5.  So I know Python is installed (It's installed on Mac OS X by default), but I don't know if it's set up to process .py files server-side and return the results.\nBTW, I'm coming from a PHP background, so this is a bit foreign to me.  I've looked at the python docs re: wgsi, cgi, etc. but since I haven't done anything concrete yet, it's not quite making sense.","AnswerCount":2,"Available Count":1,"Score":0.2913126125,"is_accepted":false,"ViewCount":2547,"Q_Id":4199442,"Users Score":3,"Answer":"If you are new to Python and Python web application development, then ignore all the hosting issues to begin with and don't start from scratch. Simply go get a full featured Python web framework such as Django or web2py and learn how to write Python web applications using their in built development web server. You will only cause yourself much pain by trying to solve distinct problem of production web hosting first.","Q_Score":0,"Tags":"python,wsgi","A_Id":4200386,"CreationDate":"2010-11-16T21:57:00.000","Title":"Beginner Python question about making a web 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":0,"Web Development":0},{"Question":"Domain driven design has become my architecture of choice.  I've been able to find a abundance of books & tutorials for applying DDD principles within the ASP.net framework.  It mostly seems inspired from what Java developers have been doing for a good while now.\nFor my personal projects, I'm starting to lean more towards Python even though I'm finding it difficult to abandon static typing.  I was hoping to find lots of help with applying DDD using a dynamic language.  There doesn't seem to be anything out there about Python & DDD.  Why is that?  Obviously DDD can apply quite well to Python.  Do people not take on as large of projects in Python?  Or is applying DDD simply easier in Python given the dynamic typing therefore reducing the amount of required learning?\nPerhaps my questionning is due to my lack of experience with Python.  Any advice you might have for me will be appreciated.","AnswerCount":6,"Available Count":4,"Score":0.0333209931,"is_accepted":false,"ViewCount":14335,"Q_Id":4201846,"Users Score":1,"Answer":"If Domain Driven Design is an effectively defined design pattern, why does it matter what language you're using?  Advice for design philosophies and the like should be largely language agnostic. They're higher level than the language, so to speak.","Q_Score":45,"Tags":"python,domain-driven-design","A_Id":4205497,"CreationDate":"2010-11-17T05:47:00.000","Title":"Why does domain driven design seem only popular with static languages like C# & 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":1},{"Question":"Domain driven design has become my architecture of choice.  I've been able to find a abundance of books & tutorials for applying DDD principles within the ASP.net framework.  It mostly seems inspired from what Java developers have been doing for a good while now.\nFor my personal projects, I'm starting to lean more towards Python even though I'm finding it difficult to abandon static typing.  I was hoping to find lots of help with applying DDD using a dynamic language.  There doesn't seem to be anything out there about Python & DDD.  Why is that?  Obviously DDD can apply quite well to Python.  Do people not take on as large of projects in Python?  Or is applying DDD simply easier in Python given the dynamic typing therefore reducing the amount of required learning?\nPerhaps my questionning is due to my lack of experience with Python.  Any advice you might have for me will be appreciated.","AnswerCount":6,"Available Count":4,"Score":0.0665680765,"is_accepted":false,"ViewCount":14335,"Q_Id":4201846,"Users Score":2,"Answer":"Most books on design\/coding techniques such as TDD and design patterns are written in Java or C#, since that is currently the lowest common denominator language and have the widest user base, or at least the largest base of people who can read and understand the language.  This is done largely for marketing reasons so that they appeals to the largest demographic.\nThat does not mean the the techniques are not applicable to or used in other languages.  From what I know of DDD most of the principles are language independent and AFAICR the original DDD book had almost no code samples in it (but it is a couple of years since I read it, so I may be mistaken).","Q_Score":45,"Tags":"python,domain-driven-design","A_Id":4224643,"CreationDate":"2010-11-17T05:47:00.000","Title":"Why does domain driven design seem only popular with static languages like C# & 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":1},{"Question":"Domain driven design has become my architecture of choice.  I've been able to find a abundance of books & tutorials for applying DDD principles within the ASP.net framework.  It mostly seems inspired from what Java developers have been doing for a good while now.\nFor my personal projects, I'm starting to lean more towards Python even though I'm finding it difficult to abandon static typing.  I was hoping to find lots of help with applying DDD using a dynamic language.  There doesn't seem to be anything out there about Python & DDD.  Why is that?  Obviously DDD can apply quite well to Python.  Do people not take on as large of projects in Python?  Or is applying DDD simply easier in Python given the dynamic typing therefore reducing the amount of required learning?\nPerhaps my questionning is due to my lack of experience with Python.  Any advice you might have for me will be appreciated.","AnswerCount":6,"Available Count":4,"Score":0.1651404129,"is_accepted":false,"ViewCount":14335,"Q_Id":4201846,"Users Score":5,"Answer":"Python seems to be not too popular in enterprises till now compared to Java (but I believe the wind is in that direction. An example is Django, which was created by a newspaper company). Most programmers working with python are likely either into scientific computing or into web applications. Both of these fields relates to (computer) sciences, not domain-specific businesses, whereas DDD is most applicable within domain-specific businesses. \nSo I would argue that it is mostly a matter of legacy. C# and Java were targeted towards enterprise applications from the start.","Q_Score":45,"Tags":"python,domain-driven-design","A_Id":12297993,"CreationDate":"2010-11-17T05:47:00.000","Title":"Why does domain driven design seem only popular with static languages like C# & 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":1},{"Question":"Domain driven design has become my architecture of choice.  I've been able to find a abundance of books & tutorials for applying DDD principles within the ASP.net framework.  It mostly seems inspired from what Java developers have been doing for a good while now.\nFor my personal projects, I'm starting to lean more towards Python even though I'm finding it difficult to abandon static typing.  I was hoping to find lots of help with applying DDD using a dynamic language.  There doesn't seem to be anything out there about Python & DDD.  Why is that?  Obviously DDD can apply quite well to Python.  Do people not take on as large of projects in Python?  Or is applying DDD simply easier in Python given the dynamic typing therefore reducing the amount of required learning?\nPerhaps my questionning is due to my lack of experience with Python.  Any advice you might have for me will be appreciated.","AnswerCount":6,"Available Count":4,"Score":1.2,"is_accepted":true,"ViewCount":14335,"Q_Id":4201846,"Users Score":20,"Answer":"I think it is definitely popular elsewhere, especially functional languages.  However, certain patterns associated with the Big Blue Book are not as applicable in dynamic languages and frameworks like Rails tend to lead people away from ideas of bounded context\nHowever, the true thrust of DDD being ubiquitous language is certainly prevalent in dynamic languages. Rubyists especially takes a great deal of joy in constructing domain specific languages - think of how cucumber features end up looking, that's as DDD as it gets!\nKeep in mind, DDD is not a new idea at all, it was just repackaged in a way that got good uptake from C# and Java guys.  Those same ideas are around elsewhere under different banners.","Q_Score":45,"Tags":"python,domain-driven-design","A_Id":4208311,"CreationDate":"2010-11-17T05:47:00.000","Title":"Why does domain driven design seem only popular with static languages like C# & 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":1},{"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},{"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},{"Question":"I want to learn python, but I feel I should learn C or C++ to get a solid base to build on. I already know some C\/C++ as well as other programming languages, which does help. So, should I master C\/C++ first?","AnswerCount":4,"Available Count":3,"Score":0.1973753202,"is_accepted":false,"ViewCount":12034,"Q_Id":4202455,"Users Score":4,"Answer":"I would say it depends on what you want to achieve (cheesy answer...)\nThe truth is, learning language is a long process. If you plan on learning a language as a step toward learning another language, you're probably wasting your time.\nIt takes a good year to be proficient with C++, and that is with basic knowledge of algorithms and object concepts. And I only mean proficient, meaning you can get things done, but certainly not expert or anything.\nSo the real question is, do you want to spend a year learning C++ before beginning to learn Python ?\nIf the ultimate goal is to program in Python... it doesn't seem worth it.","Q_Score":3,"Tags":"c++,python,c","A_Id":4202951,"CreationDate":"2010-11-17T07:54:00.000","Title":"Is it worth learning C\/C++ before learning 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},{"Question":"I want to learn python, but I feel I should learn C or C++ to get a solid base to build on. I already know some C\/C++ as well as other programming languages, which does help. So, should I master C\/C++ first?","AnswerCount":4,"Available Count":3,"Score":0.049958375,"is_accepted":false,"ViewCount":12034,"Q_Id":4202455,"Users Score":1,"Answer":"In my opinion you should defiantly learn Python before attempting to learn C or C++ as you will get a better understanding of the core concepts, C++ is mush lower level than Python so you will need to make more commands to do something that you can do in one line in python.","Q_Score":3,"Tags":"c++,python,c","A_Id":4202502,"CreationDate":"2010-11-17T07:54:00.000","Title":"Is it worth learning C\/C++ before learning 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},{"Question":"I want to learn python, but I feel I should learn C or C++ to get a solid base to build on. I already know some C\/C++ as well as other programming languages, which does help. So, should I master C\/C++ first?","AnswerCount":4,"Available Count":3,"Score":0.0996679946,"is_accepted":false,"ViewCount":12034,"Q_Id":4202455,"Users Score":2,"Answer":"Real mastery of a language takes time and lots of practice .. its analogous to learning a natural language like French . you have to do a lot of practice in it. but then different languages teach you different programming methodologies.\npython and c++ are all object oriented languages so you will be learning the same programming methodology \nThe order in which you learn languages doesn't really matter but starting from a lower abstraction to higher one makes understanding some things easier..","Q_Score":3,"Tags":"c++,python,c","A_Id":4202571,"CreationDate":"2010-11-17T07:54:00.000","Title":"Is it worth learning C\/C++ before learning 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},{"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},{"Question":"I'm trying to get the CPU serial or motherboard serial using C or Python for licensing purposes. Is it possible?\nI'm using Linux.","AnswerCount":5,"Available Count":2,"Score":1.0,"is_accepted":false,"ViewCount":7942,"Q_Id":4216009,"Users Score":7,"Answer":"Under Linux, you could use \"lshw -quiet -xml\" and parse its output. You'll find plenty of system information here: cpuid, motherboard id and much more.","Q_Score":5,"Tags":"python,c,licensing,cpu,motherboard","A_Id":4216127,"CreationDate":"2010-11-18T14:49:00.000","Title":"Getting CPU or motherboard serial number?","Data Science and Machine Learning":0,"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},{"Question":"I'm trying to get the CPU serial or motherboard serial using C or Python for licensing purposes. Is it possible?\nI'm using Linux.","AnswerCount":5,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":7942,"Q_Id":4216009,"Users Score":0,"Answer":"CPUs no longer obtain a serial number and it's been like that for a while now. For the CPUID - it's unique per CPU model therefore it doesn't help with licensing.","Q_Score":5,"Tags":"python,c,licensing,cpu,motherboard","A_Id":4223022,"CreationDate":"2010-11-18T14:49:00.000","Title":"Getting CPU or motherboard serial number?","Data Science and Machine Learning":0,"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},{"Question":"i am working on a project that requires me to create multiple threads to download a large remote file. I have done this already but i cannot understand while it takes a longer amount of time to download a the file with multiple threads compared to using just a single thread. I used my xampp localhost to carry out the time elapsed test. I would like to know if its a normal behaviour or is it because i have not tried downloading from a real server. \nThanks\nKennedy","AnswerCount":3,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":1871,"Q_Id":4219134,"Users Score":4,"Answer":"9 women can't combine to make a baby in one month.  If you have 10 threads, they each have only 10% the bandwidth of a single thread, and there is the additional overhead for context switching, etc.","Q_Score":0,"Tags":"python,multithreading,download,urllib2","A_Id":4219434,"CreationDate":"2010-11-18T20:15:00.000","Title":"Python\/Urllib2\/Threading: Single download thread faster than multiple download threads. Why?","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},{"Question":"i am working on a project that requires me to create multiple threads to download a large remote file. I have done this already but i cannot understand while it takes a longer amount of time to download a the file with multiple threads compared to using just a single thread. I used my xampp localhost to carry out the time elapsed test. I would like to know if its a normal behaviour or is it because i have not tried downloading from a real server. \nThanks\nKennedy","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":1871,"Q_Id":4219134,"Users Score":1,"Answer":"Twisted uses non-blocking I\/O, that means if data is not available on socket right now, doesn't block the entire thread, so you can handle many socket connections waiting for I\/O in one thread simultaneous. But if doing something different than I\/O (parsing large amounts of data) you still block the thread.\nWhen you're using stdlib's socket module it does blocking I\/O, that means when you're call socket.read and data is not available at the moment \u2014 it will block entire thread, so you need one thread per connection to handle concurrent download.\nThese are two approaches to concurrency:\n\nFork new thread for new connection (threading + socket from stdlib).\nMultiplex I\/O and handle may connections in one thread (Twisted).","Q_Score":0,"Tags":"python,multithreading,download,urllib2","A_Id":4222497,"CreationDate":"2010-11-18T20:15:00.000","Title":"Python\/Urllib2\/Threading: Single download thread faster than multiple download threads. Why?","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},{"Question":"Can someone recommend a project skeleton for python tornado? I suppose it's easy enough to roll my own but I'm curious what else is out there since (obviously) others have been down this road before.","AnswerCount":6,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":3298,"Q_Id":4220244,"Users Score":0,"Answer":"Tornado comes with a good number of examples and the source is well documented with a few code snipits as well.","Q_Score":13,"Tags":"python,tornado","A_Id":4220282,"CreationDate":"2010-11-18T22:24:00.000","Title":"Defacto Project Template for Python Tornado","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"Just wondering, as I think about learning either PHP or Django (I have previous Python knowledge), what advantages do Python and Django have over PHP, what disadvantages etc.\nI don't want to know which one is better, surely neither is better, both have their good sides as well as bad sides and I will probably learn both at some point. I don't want to start a flame war or anything, but please tell me some advantages and disadvantages for both to help me choose which one to learn first.\nThanks in advance!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1897,"Q_Id":4229394,"Users Score":4,"Answer":"PHP is a popular language for web development with tons of libraries and examples online.\nPython is a modern, well-design programming language where everything is an object. It works well in many environments, including web programming, although it wasn't originally designed for that environment.\n\nIf you want a general purpose scripting language that can also be used for web development then learning Python would be a good idea. If you only plan to do web development and your main concern is to get a job, experience in PHP will make you attractive to a large number of potential employers who are already using this technology.","Q_Score":0,"Tags":"php,python,django","A_Id":4229417,"CreationDate":"2010-11-19T21:10:00.000","Title":"Python (with Django) and 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":1},{"Question":"I'm using simplejson to get data from the New York Time API. It works when I run the file through the terminal with the command \"python test.py\" but not when I run through TextMate using command + R. I'm running the exact same file. Why is this?\nI am running Snow Leopard 10.6.4, TextMate 1.5.10, and Python 2.6.4.\nEdit: Sorry for forgetting to include this: by \"doesn't work,\" I mean it says \"No module named simplejson\". I also noticed that this happens for PyMongo as well (\"No module named pymongo\").","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":300,"Q_Id":4235821,"Users Score":1,"Answer":"What doesn't work? You should provide more information like error messages and what-not. However, I assume that the version of python is different, and simplejson isn't on your PYTHONPATH when launched from textmate.","Q_Score":0,"Tags":"python,textmate,simplejson","A_Id":4235847,"CreationDate":"2010-11-21T00:39:00.000","Title":"Why does simplejson work in Terminal and not TextMate?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":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},{"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},{"Question":"I am looking for a python snippet to read an internet radio stream(.asx, .pls etc) and save it to a file.\nThe final project is cron'ed script that will record an hour or two of internet radio and then transfer it to my phone for playback during my commute. (3g is kind of spotty along my commute)\nany snippits or pointers are welcome.","AnswerCount":6,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":16163,"Q_Id":4247248,"Users Score":3,"Answer":"I am aware this is a year old, but this is still a viable question, which I have recently been fiddling with.\nMost internet radio stations will give you an option of type of download, I choose the MP3 version, then read the info from a raw socket and write it to a file. The trick is figuring out how fast your download is compared to playing the song so you can create a balance on the read\/write size. This would be in your buffer def.\nNow that you have the file, it is fine to simply leave it on your drive (record), but most players will delete from file the already played chunk and clear the file out off the drive and ram when streaming is stopped.\nI have used some code snippets from a file archive without compression app to handle a lot of the file file handling, playing, buffering magic. It's very similar in how the process flows. If you write up some sudo-code (which I highly recommend) you can see the similarities.","Q_Score":12,"Tags":"python,stream,audio-streaming,radio","A_Id":13279976,"CreationDate":"2010-11-22T15:47:00.000","Title":"Record streaming and saving internet radio 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},{"Question":"For a research project, I am collecting tweets using Python-Twitter. However, when running our program nonstop on a single computer for a week we manage to collect about only 20 MB of data per week. I am only running this program on one machine so that we do not collect the same tweets twice.\nOur program runs a loop that calls getPublicTimeline() every 60 seconds. I tried to improve this by calling getUserTimeline() on some of the users that appeared in the public timeline. However, this consistently got me banned from collecting tweets at all for about half an hour each time. Even without the ban, it seemed that there was very little speed-up by adding this code.\nI know about Twitter's \"whitelisting\" that allows a user to submit more requests per hour. I applied for this about three weeks ago, and have not hear back since, so I am looking for alternatives that will allow our program to collect tweets more efficiently without going over the standard rate limit. Does anyone know of a faster way to collect public tweets from Twitter? We'd like to get about 100 MB per week.\nThanks.","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":5951,"Q_Id":4249684,"Users Score":1,"Answer":"I did a similar project analyzing data from tweets. If you're just going at this from a pure data collection\/analysis angle, you can just scrape any of the better sites that collect these tweets for various reasons. Many sites allow you to search by hashtag, so throw in a popular enough hashtag and you've got thousands of results. I just scraped a few of these sites for popular hashtags, collected these into a large list, queried that list against the site, and scraped all of the usable information from the results. Some sites also allow you to export the data directly, making this task even easier. You'll get a lot of garbage results that you'll probably need to filter (spam, foreign language, etc), but this was the quickest way that worked for our project. Twitter will probably not grant you whitelisted status, so I definitely wouldn't count on that.","Q_Score":5,"Tags":"python,twitter,python-twitter","A_Id":4250479,"CreationDate":"2010-11-22T20:02:00.000","Title":"How to Collect Tweets More Quickly Using Twitter API 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},{"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},{"Question":"Can you guys please tell if building my own birtviewer like reporting tool but using python is a crazy idea. The company I'm working now, we are using birtviewer to generate reports for the clients, but I'm already getting frustrated tweaking the code to suit our client needs and it's written on massive java code which I don't have any experience at all. And they don't want to mavenize birtviewer, so every new releases I have to manually update my local copy and mavenize it. And the fact that it is really owned by a private company worries me about the future of birtviewer. What do you guys think?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":280,"Q_Id":4258624,"Users Score":0,"Answer":"Sure. Write it. Make it open source and give us a git repo to have a little look... Honestly if the problem exists solve it.","Q_Score":1,"Tags":"python,reporting","A_Id":4258672,"CreationDate":"2010-11-23T16:56:00.000","Title":"python reporting tool, similar to birtviewer","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"Does anyone have any experience using r\/python with data stored in Solid State Drives. If you are doing mostly reads, in theory this should significantly improve the load times of large datasets. I want to find out if this is true and if it is worth investing in SSDs for improving the IO rates in data intensive applications.","AnswerCount":5,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":4485,"Q_Id":4262984,"Users Score":0,"Answer":"The read and write times for SSDs are significantly higher than standard 7200 RPM disks (it's still worth it with a 10k RPM disk, not sure how much of an improvement it is over a 15k). So, yes, you'd get much faster times on data access.\nThe performance improvement is undeniable. Then, it's a question of economics. 2TB 7200 RPM disks are $170 a piece, and 100GB SSDS cost $210. So if you have a lot of data, you may run into a problem.\nIf you read\/write a lot of data, get an SSD. If the application is CPU intensive, however, you'd benefit much more from getting a better processor.","Q_Score":12,"Tags":"python,r,data-analysis,solid-state-drive","A_Id":4263022,"CreationDate":"2010-11-24T02:31:00.000","Title":"Data analysis using R\/python and SSDs","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},{"Question":"Does anyone have any experience using r\/python with data stored in Solid State Drives. If you are doing mostly reads, in theory this should significantly improve the load times of large datasets. I want to find out if this is true and if it is worth investing in SSDs for improving the IO rates in data intensive applications.","AnswerCount":5,"Available Count":2,"Score":0.0798297691,"is_accepted":false,"ViewCount":4485,"Q_Id":4262984,"Users Score":2,"Answer":"I have to second John's suggestion to profile your application. My experience is that it isn't the actual data reads that are the slow part, it's the overhead of creating the programming objects to contain the data, casting from strings, memory allocation, etc. \nI would strongly suggest you profile your code first, and consider using alternative libraries (like numpy) to see what improvements you can get before you invest in hardware.","Q_Score":12,"Tags":"python,r,data-analysis,solid-state-drive","A_Id":4264161,"CreationDate":"2010-11-24T02:31:00.000","Title":"Data analysis using R\/python and SSDs","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},{"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},{"Question":"I need to expose a file-like object from a C library that i'm wrapping with a Cython module. I want to reuse python's generic io code for stuff like buffering, readline(), etc.\nThe new IO module seems to be just what i need, but actually using it from Cython seems to be non-trivial, I've tried several aproaches:\n\nMy code in a cdef class that inherits from IO.RawIOBase - This fails because cdef classes can inherit only from other cython cdef classes, while IO is \"raw\" C.\nMy code in a cdef class, another (non-cdef) class that inherits both my cdef class and RawIOBase - Fails with \"TypeError: multiple bases have instance lay-out conflict\"\nMy code in a (non-cdef) class that inherits from RawIOBase - This works, but i loose the ability to store my c-level (that i need to talk to the underlying library) stuff inside the class, so i need a make a cdef wrapper around it and store that as a member... this looks like a mess.\nMy code in cdef class that doesn't inherit (Raw)IOBase rather reimplements it's functionality, Python code gets my object wrapped in BufferedReader\/BufferedWriter - This one seems to work and less messy than the previous option.\n\nMy questions(s): \n1) Am I missing something and reinventing the wheel here?\n2) What is the exact stuff from IOBase that I need to implement to keep BufferedReader\/Writer happy with my object in current and future versions of python? Is this documented anywhere?\n3) How will that work in python 2.6 where IO is pure python? I guess that performance will suffer but it will work, right?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":1145,"Q_Id":4278444,"Users Score":1,"Answer":"Would it be too inefficient to call os.fdopen() on the file descriptor number returned by the underlying library, and then to dispatch normal Python method calls to the resulting file object in order to do your input and output? With most I\/O, I would be surprised if you could see a difference with whether you called a C routine directly or let the Python method dispatch logic call it for you \u2014 but, of course, you might be in an unusual situation and I could be wrong!","Q_Score":20,"Tags":"python,file-io,cython","A_Id":8262264,"CreationDate":"2010-11-25T15:08:00.000","Title":"Exposing a file-like object from Cython","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},{"Question":"Importing M2Crypto version 0.20.2 on python 2.6.5 fails when M2Crypto was compiled against a recent openssl versions (0.9.8x or higher) on MAC OS X 10.4.11:\nEven though the compilation works against these openssl version, M2Crypto fails to import, because a missing symbol: _PEM_read_bio_EC_PUBKEY \nPython 2.6.5 (r265:79359, Mar 24 2010, 01:32:55) \n[GCC 4.0.1 (Apple Inc. build 5493)] on darwin\nType \"help\", \"copyright\", \"credits\" or \"license\" for more information.\n\n\n\nimport M2Crypto\n      Traceback (most recent call last):\n        File \"\", line 1, in \n        File \"M2Crypto\/init.py\", line 22, in \n          import _m2crypto\n      ImportError: dlopen(M2Crypto\/_m2crypto.so, 2): Symbol not found: _PEM_read_bio_EC_PUBKEY\n        Referenced from: M2Crypto\/__m2crypto.so\n        Expected in: dynamic lookup\n\n\n\nIf I compile M2Crypto against openssl version 0.9.7l or 0.9.7m it works just fine.\nAny suggestion?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":257,"Q_Id":4280885,"Users Score":0,"Answer":"I don't have 10.4.11, but I do have 10.5.8 with Python 2.6.5 and OpenSSL 0.9.8n and everything works without a problem. Please try with latest M2Crypto. If that does not work, try getting and compiling OpenSSL yourself and configuring M2Crypto to use that. Maybe something is wrong with your current OpenSSL.","Q_Score":0,"Tags":"python,openssl,m2crypto","A_Id":5480356,"CreationDate":"2010-11-25T21:13:00.000","Title":"Symbol not found: _PEM_read_bio_EC_PUBKEY Importing M2Crypto-0.20.2 when compiled against openssl 0.9.8x or 1.0.0x","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"Is it possible to configure PyCharm in the following way:\n\nRequest auto-completion on any letter key press\nComplete on space press, instead of enter\nRequest completion for modules not in path\n\nI mean, configure it in VS-way.\nAlso, VS-like hotkeys will be amazing option","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1813,"Q_Id":4281190,"Users Score":0,"Answer":"Not a pro on this but I think you have to use the module name preceding the method you want to call. For example to call a function named doStuff in the settings module call settings.doStuff(). \nTo call the methods directly you need to use \"from settings import *\". But I think this method is frowned upon.","Q_Score":0,"Tags":"python,pycharm","A_Id":4281235,"CreationDate":"2010-11-25T22:13:00.000","Title":"PyCharm imports and code 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":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I need to have a python client that can discover queues on a restarted RabbitMQ server exchange, and then start up a clients to resume consuming messages from each queue. How can I discover queues from some RabbitMQ compatible python api\/library?","AnswerCount":8,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":70261,"Q_Id":4287941,"Users Score":27,"Answer":"As far as I know, there isn't any way of doing this. That's nothing to do with Python, but because AMQP doesn't define any method of queue discovery.\nIn any case, in AMQP it's clients (consumers) that declare queues: publishers publish messages to an exchange with a routing key, and consumers determine which queues those routing keys go to. So it does not make sense to talk about queues in the absence of consumers.","Q_Score":42,"Tags":"python,rabbitmq,amqp","A_Id":4288304,"CreationDate":"2010-11-26T19:06:00.000","Title":"How can I list or discover queues on a RabbitMQ exchange 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},{"Question":"I need to have a python client that can discover queues on a restarted RabbitMQ server exchange, and then start up a clients to resume consuming messages from each queue. How can I discover queues from some RabbitMQ compatible python api\/library?","AnswerCount":8,"Available Count":2,"Score":0.049958375,"is_accepted":false,"ViewCount":70261,"Q_Id":4287941,"Users Score":2,"Answer":"Management features are due in a future version of AMQP. So for now you will have to wait till for a new version that will come with that functionality.","Q_Score":42,"Tags":"python,rabbitmq,amqp","A_Id":4289172,"CreationDate":"2010-11-26T19:06:00.000","Title":"How can I list or discover queues on a RabbitMQ exchange 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},{"Question":"My code was working correctly till yesterday and I was able to fetch tweets, from GetSearch(), but now it is returning empty list, though I check my credentials are correct\nIs something changed recently??  \nThank you","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":297,"Q_Id":4291319,"Users Score":0,"Answer":"They might have a limit of requests in a certain amount of time or they had a failure on the system. You can ask for new credentials to see if the problem was the first one and try getting the tweets with them.","Q_Score":0,"Tags":"python-twitter","A_Id":4291535,"CreationDate":"2010-11-27T11:08:00.000","Title":"python-twitter GetSearch giving empty list","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},{"Question":"I have been working as a web dev with C#, VB and PHP (now learning python)..\nI have been considering learning C (as a right of passage) because i hate feeling stupid =P\nApart from making me a better programmer in general..\nIs there any particualr use to C for a Web Dev in 2010?\nThanks,\nDaniel","AnswerCount":6,"Available Count":5,"Score":0.0665680765,"is_accepted":false,"ViewCount":241,"Q_Id":4291401,"Users Score":2,"Answer":"You always need to know enough c to port headers to your language of choice when there are no ports for a library you want to use yet. Many libraries are written in c since then they can be used from almost all platforms\/languages.","Q_Score":1,"Tags":"c#,python,c","A_Id":4291519,"CreationDate":"2010-11-27T11:30:00.000","Title":"Is there any merit to a web developer learning 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":0,"Web Development":0},{"Question":"I have been working as a web dev with C#, VB and PHP (now learning python)..\nI have been considering learning C (as a right of passage) because i hate feeling stupid =P\nApart from making me a better programmer in general..\nIs there any particualr use to C for a Web Dev in 2010?\nThanks,\nDaniel","AnswerCount":6,"Available Count":5,"Score":0.0,"is_accepted":false,"ViewCount":241,"Q_Id":4291401,"Users Score":0,"Answer":"no :)\nC is not targeted for web development","Q_Score":1,"Tags":"c#,python,c","A_Id":4291408,"CreationDate":"2010-11-27T11:30:00.000","Title":"Is there any merit to a web developer learning 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":0,"Web Development":0},{"Question":"I have been working as a web dev with C#, VB and PHP (now learning python)..\nI have been considering learning C (as a right of passage) because i hate feeling stupid =P\nApart from making me a better programmer in general..\nIs there any particualr use to C for a Web Dev in 2010?\nThanks,\nDaniel","AnswerCount":6,"Available Count":5,"Score":0.0665680765,"is_accepted":false,"ViewCount":241,"Q_Id":4291401,"Users Score":2,"Answer":"Learning C won't necessarily make you a better programmer; there's a superstition that because C is moderately difficult to learn (true) and doesn't have an extensive toolkit (also true), you gain a deeper insight into programming in general (not necessarily true).  C's just another language, no better or worse than any other.  You'd get as much benefit learning Fortran.  If you're really interested in how things work at the machine\/OS level, you'd be better served learning an assembler; just remember that assemblers are specific to their platforms, and some of the concepts that apply to x86 don't apply to other platforms such as MIPS or PPC.\nLearning C won't help you much in your day-to-day work in web development. \nHaving said that, it's always a good idea to pick up new languages if you can, especially languages that are as different as possible from what you're currently using, just because it helps you to learn the difference between a general programming concept vs. a particular language's implementation of that concept.  I've seen plenty of people proficient in a language like C# flail helplessly when forced to work in C because all of their shiny tools are missing.","Q_Score":1,"Tags":"c#,python,c","A_Id":4293283,"CreationDate":"2010-11-27T11:30:00.000","Title":"Is there any merit to a web developer learning 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":0,"Web Development":0},{"Question":"I have been working as a web dev with C#, VB and PHP (now learning python)..\nI have been considering learning C (as a right of passage) because i hate feeling stupid =P\nApart from making me a better programmer in general..\nIs there any particualr use to C for a Web Dev in 2010?\nThanks,\nDaniel","AnswerCount":6,"Available Count":5,"Score":0.0333209931,"is_accepted":false,"ViewCount":241,"Q_Id":4291401,"Users Score":1,"Answer":"Given that you have experience of object orientated programming in C#, I would recommend learning C++ as opposed to C. It will indeed make you a more rounded programmer. While you could program web sites using C or C++, it's not commonly done for small scale web sites. Facebook created HipHop for PHP for instance to improve performance:\n\nHipHop programmatically transforms your PHP source code into highly optimized C++ and then uses g++ to compile it.\n\nGood luck with your learning, never stop :-)","Q_Score":1,"Tags":"c#,python,c","A_Id":4292028,"CreationDate":"2010-11-27T11:30:00.000","Title":"Is there any merit to a web developer learning 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":0,"Web Development":0},{"Question":"I have been working as a web dev with C#, VB and PHP (now learning python)..\nI have been considering learning C (as a right of passage) because i hate feeling stupid =P\nApart from making me a better programmer in general..\nIs there any particualr use to C for a Web Dev in 2010?\nThanks,\nDaniel","AnswerCount":6,"Available Count":5,"Score":0.1325487884,"is_accepted":false,"ViewCount":241,"Q_Id":4291401,"Users Score":4,"Answer":"Learning C (or, for the added fun, C++) as a device of increasing your understanding of programming is a good idea IMHO. But it doesn't have anything to offer you as regards web development.","Q_Score":1,"Tags":"c#,python,c","A_Id":4291457,"CreationDate":"2010-11-27T11:30:00.000","Title":"Is there any merit to a web developer learning 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":0,"Web Development":0},{"Question":"I currently have Python 2.6.2 installed on my mac. I am writing a script which MUST run on Python 2.5.2. So I want to write a python script, and test is specifically against 2.5.2 and NOT 2.6.2.\nI was looking at virtualenv, but it doesn't seem to solve my problem. I ran python virtualenv.py TEST which made a TEST dir, but it had python 2.6 in it. Is there a way to make virtualenv use a different version of python than what's installed default on my machine? Is another way to use the #! as the first line of the python script? How would I do that?","AnswerCount":5,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":4321,"Q_Id":4301681,"Users Score":1,"Answer":"You could just install a Python 2.5.2.\nI have 3 different versions Python installed on my Lucid and they use different links under \/bin\/ so it's easy to call the specific version  \npython -> python3 ->python3.1\npython2 -> python2.7\npython2.5","Q_Score":2,"Tags":"python,tox","A_Id":4301739,"CreationDate":"2010-11-29T07:27:00.000","Title":"Testing a python script in a specific 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},{"Question":"I currently have Python 2.6.2 installed on my mac. I am writing a script which MUST run on Python 2.5.2. So I want to write a python script, and test is specifically against 2.5.2 and NOT 2.6.2.\nI was looking at virtualenv, but it doesn't seem to solve my problem. I ran python virtualenv.py TEST which made a TEST dir, but it had python 2.6 in it. Is there a way to make virtualenv use a different version of python than what's installed default on my machine? Is another way to use the #! as the first line of the python script? How would I do that?","AnswerCount":5,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":4321,"Q_Id":4301681,"Users Score":0,"Answer":"try #!\/path\/to\/your\/python\/version\nBut make sure you execute the script from the terminal, and make it executable before hand: chmod 755 myscript.py","Q_Score":2,"Tags":"python,tox","A_Id":4301698,"CreationDate":"2010-11-29T07:27:00.000","Title":"Testing a python script in a specific 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},{"Question":"I have a Python application (command line tool running on a machine M1) that has input I1 and output O2. Also, I have a PHP application (website running on a machine M2) that feeds the Python application with input I1 and expects to read the output O1. My question is what's the best approach to solve this problem? (the environment is GNU\/Linux)\nI was thinking at a solution with ssh; the PHP script executes a command via ssh: \"ssh M2:.\/my_script.py arguments output_file\" and transfers the output file \"scp M2:output_file .\" from M2 to M1. But, I don't think this solution is elegant. I was thinking of web services (the Python application should expose a web service), but I'm not sure what's the complexity of this solution or if it works.\nThanks,","AnswerCount":4,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":354,"Q_Id":4305070,"Users Score":0,"Answer":"I think you should implement a web service . I don't know how to do it with python but i suppose it would be fairly easy.","Q_Score":1,"Tags":"php,python","A_Id":4305158,"CreationDate":"2010-11-29T15:16:00.000","Title":"PHP and Python interfacing","Data Science and Machine Learning":0,"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},{"Question":"We use Hudson-CI for out Continuous Integration server for Python projects, all of which use Buildout to manage dependencies. Almost all our projects use lxml which, because of Buildout, must be built\/installed during each test-run and because it takes so long it reduces the number of builds we can run per day.\nIs there any way to speed-up the build of lxml when using Buildout? Maybe some environment variables can be set to help the build use both cores on the server? Or something to reduce the amount of optimization done?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":962,"Q_Id":4313782,"Users Score":1,"Answer":"My solution is to create an egg myself and keep that egg version-controlled with my buildout. I recreate the egg each time I need to upgrade lxml.  You can almost always create a binary egg of any Python project by throwing an import setuptools into the top of its setup.py and then saying python setup.py bdist_egg. And as long as the machines you install the egg on are roughly similar binary-wise (such as all being the same Linux distro), you should not have a terrible lot of trouble. Read up on building lxml with \"static deps\", as the call them, if you want your egg to not depend on libxml being installed on the box.","Q_Score":1,"Tags":"python,compilation,lxml","A_Id":4327797,"CreationDate":"2010-11-30T12:33:00.000","Title":"How can I speed-up the build\/install of lxml?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I want to send messages through the serial port using PySerial. One of the parameters for the serial constructor is 'bytesize'. I have been trying serial.SEVENBITS and serial.EIGHTBITS and haven't noticed a difference. The documentation is a bit vague and I am new to both Python and serial communication.\nDoes this just set the maximum value a byte can hold or is it something to do with signed bytes? Can anyone clear up why I'd use 7 bits over 8?\nI have been searching but haven't found an answer.\nThank you","AnswerCount":2,"Available Count":1,"Score":0.2913126125,"is_accepted":false,"ViewCount":4981,"Q_Id":4328223,"Users Score":3,"Answer":"Historically, it was common to only send ASCII text over a serial connection, which fit into seven bits, and an eighth bit would be used as a parity marker which could indicate if the data was being transmitted correctly. \nSince the parity check doesn't catch errors on an even number of bits, and can't correct the data at all, it's not that valuable, and modern practice is to use 8-bit data and do error detection and correction at a higher layer of protocol.\nShort answer is you probably want 8-bit, but it depends on what the other end of the serial connection is expecting.\nUpdate: \nFrom your other question it sounds like you're programming both ends of the connection, and checksumming your messages, so it's definitely most straightforward to use 8-bit.","Q_Score":1,"Tags":"python,size,byte,pyserial","A_Id":4328281,"CreationDate":"2010-12-01T19:25:00.000","Title":"'bytesize' in PySerial 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":0},{"Question":"So I have a big project with many modules in it, and I want to run some profiling on it. I have a profile module that basically just provides a decorator that I can add to a function to profile it when it's called.\nThe problem is, I'll have to import that module into the dozens of modules that I have. This is fine I guess, but I can't push the code with the profiling modules imported or the decorator on the functions to version control. This means every time I import\/export, I have to add\/remove all my profiling code.\nIs there any kind of system to manage this adding\/removing of profiling code without manually importing\/deleting the modules in every module of my project? We use mercurial, but I can't really mess with mercurial settings or make a branch.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":516,"Q_Id":4328681,"Users Score":0,"Answer":"Why not just create a branch with all the profiling changes, and then merge the branch when you want to test ... and revert everything afterwards.\ngit makes this somewhat easier with it's \"git stash\", but using branches shouldn't be significantly harder.","Q_Score":0,"Tags":"python,module,profiling","A_Id":4328745,"CreationDate":"2010-12-01T20:18:00.000","Title":"python module import 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":1,"System Administration and DevOps":0,"Web Development":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},{"Question":"I have an affinity for python, but I work in a .NET environment, so I was looking into Iron Python, and wondering what it would be used for.  \nCould you write an app in it? or is it for adding a scripting language to your app?\nHow do you guys use it?","AnswerCount":12,"Available Count":8,"Score":0.0665680765,"is_accepted":false,"ViewCount":19054,"Q_Id":4336228,"Users Score":4,"Answer":"I think the Iron family of languages is primarily for adding more flavours to the platform, allowing you to get into .NET using a language that you are familiar with. It lowers the bar a lot for getting new people with different backgrounds into .NET\nEven though the syntax is Python, the implementation is still built on top of the CLR and the end product will not differ a lot if you decide to go for an IronPython project instead of say C#.\nI've had some experience with IronPython and find it nice to work with (it helps of course that I really like the language). IronPython is now considered a first class citizen by Microsoft, and that is also the impression you get when using it. One downside to using it though is that it isn't as widely adopted as the two main languages, causing some issues when it comes to collaboration and maintaining a code base over time.\nI found it particularly useful when doing a .NET port of a search algorithm that was first implemented in Python.\nRegarding adding scripting abilities to your app, that is probably not the original intention with IronPython, but it has been done. The Umbraco CMS has (or at least had) the ability to create widgets using Python as a dynamic scripting language within their platform. A pretty neat feature to have.\nYou should go ahead and try it out.. It's always good to have more tools in the belt :)","Q_Score":29,"Tags":".net,python,ironpython,dynamic-language-runtime","A_Id":4336338,"CreationDate":"2010-12-02T14:47:00.000","Title":"Iron Python : what are good uses for Iron 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},{"Question":"I have an affinity for python, but I work in a .NET environment, so I was looking into Iron Python, and wondering what it would be used for.  \nCould you write an app in it? or is it for adding a scripting language to your app?\nHow do you guys use it?","AnswerCount":12,"Available Count":8,"Score":0.0166651236,"is_accepted":false,"ViewCount":19054,"Q_Id":4336228,"Users Score":1,"Answer":"You can write an app in it, you can use it as a scripting language in your app.\nIt's used for accessing existing Python libraries and, if needed, writing parts of your code in Python if a .NET languages doesn't seem well enough suited for that job.","Q_Score":29,"Tags":".net,python,ironpython,dynamic-language-runtime","A_Id":4336257,"CreationDate":"2010-12-02T14:47:00.000","Title":"Iron Python : what are good uses for Iron 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},{"Question":"I have an affinity for python, but I work in a .NET environment, so I was looking into Iron Python, and wondering what it would be used for.  \nCould you write an app in it? or is it for adding a scripting language to your app?\nHow do you guys use it?","AnswerCount":12,"Available Count":8,"Score":0.0665680765,"is_accepted":false,"ViewCount":19054,"Q_Id":4336228,"Users Score":4,"Answer":"We use it as an embedded language inside of our software.\nI had an article on my blog, but recently switched to a new system. You can find an archived version (with broken image links) here:\nOur field engineers now use the embedded language to test things on the fly,\nour quality assurance people use it to create small scripts to test all features of the hardware, etc....\nHope this helps.","Q_Score":29,"Tags":".net,python,ironpython,dynamic-language-runtime","A_Id":4336253,"CreationDate":"2010-12-02T14:47:00.000","Title":"Iron Python : what are good uses for Iron 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},{"Question":"I have an affinity for python, but I work in a .NET environment, so I was looking into Iron Python, and wondering what it would be used for.  \nCould you write an app in it? or is it for adding a scripting language to your app?\nHow do you guys use it?","AnswerCount":12,"Available Count":8,"Score":0.0333209931,"is_accepted":false,"ViewCount":19054,"Q_Id":4336228,"Users Score":2,"Answer":"My experience of IronPython is usage it as part of engine that can be changed after installation of base .Net application.\nWith help of Python we have described really large set of business rules, that can be changed from two system installation. Partially IronPython was used as plugin language.\nThe difference from script language - that after compilation IronPython executed as CLR code.","Q_Score":29,"Tags":".net,python,ironpython,dynamic-language-runtime","A_Id":4336268,"CreationDate":"2010-12-02T14:47:00.000","Title":"Iron Python : what are good uses for Iron 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},{"Question":"I have an affinity for python, but I work in a .NET environment, so I was looking into Iron Python, and wondering what it would be used for.  \nCould you write an app in it? or is it for adding a scripting language to your app?\nHow do you guys use it?","AnswerCount":12,"Available Count":8,"Score":1.2,"is_accepted":true,"ViewCount":19054,"Q_Id":4336228,"Users Score":31,"Answer":"Either or both :)\nI wouldn't claim to know a specific \"purpose\" for IronPython but it certainly can be used to write applications, and it can be used for scripting within a larger .NET application.\nAside from anything else, it's a handy way of gently easing Python developers into the world of .NET. (Why not learn C# at the same time? Come on in, the water's lovely...)","Q_Score":29,"Tags":".net,python,ironpython,dynamic-language-runtime","A_Id":4336244,"CreationDate":"2010-12-02T14:47:00.000","Title":"Iron Python : what are good uses for Iron 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},{"Question":"I have an affinity for python, but I work in a .NET environment, so I was looking into Iron Python, and wondering what it would be used for.  \nCould you write an app in it? or is it for adding a scripting language to your app?\nHow do you guys use it?","AnswerCount":12,"Available Count":8,"Score":0.0333209931,"is_accepted":false,"ViewCount":19054,"Q_Id":4336228,"Users Score":2,"Answer":"You use it to write Python code that runs on the .NET platform. It's good for anything that Python is good for.\nThe Python language is the Python language, no matter what. IronPython is an implementation of the runtime for that language - the support code that compiles your source, creates a virtual machine to execute the bytecode in the resulting .pyc file, communicates with the OS in order to put command line arguments into sys.argv, and all that other fun stuff. (Well, OK, the .NET platform itself does a lot of the work, too. :) )","Q_Score":29,"Tags":".net,python,ironpython,dynamic-language-runtime","A_Id":4336262,"CreationDate":"2010-12-02T14:47:00.000","Title":"Iron Python : what are good uses for Iron 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},{"Question":"I have an affinity for python, but I work in a .NET environment, so I was looking into Iron Python, and wondering what it would be used for.  \nCould you write an app in it? or is it for adding a scripting language to your app?\nHow do you guys use it?","AnswerCount":12,"Available Count":8,"Score":1.0,"is_accepted":false,"ViewCount":19054,"Q_Id":4336228,"Users Score":6,"Answer":"IronPython is just Yet Another Python Implementation. You can use it anywhere you would use any other Python implementation. (Modulo platform constraints, of course\u00a0\u2013 obviously you can't use IronPython on a Java-only device.)\nIronPython is just Yet Another .NET Compiler. You can use it anywhere you would use any other .NET language.\nIronPython is More Than Just Yet Another Python Implementation. It's a Python implementation that gives you full access to any .NET library.\nIronPython is More Than Just Yet Another .NET Compiler. It's a .NET compiler that gives you full access to any Python library.\nIronPython is an embeddable scripting engine for any .NET app, library and framework.","Q_Score":29,"Tags":".net,python,ironpython,dynamic-language-runtime","A_Id":4336304,"CreationDate":"2010-12-02T14:47:00.000","Title":"Iron Python : what are good uses for Iron 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},{"Question":"I have an affinity for python, but I work in a .NET environment, so I was looking into Iron Python, and wondering what it would be used for.  \nCould you write an app in it? or is it for adding a scripting language to your app?\nHow do you guys use it?","AnswerCount":12,"Available Count":8,"Score":0.0166651236,"is_accepted":false,"ViewCount":19054,"Q_Id":4336228,"Users Score":1,"Answer":"You can use it for cool things like having an embedded web server within your application which can be developed with one of the available Python web frameworks. It is much easier and smoother to develop for than hosting an ASP.NET web server within your application. CherryPy for example comes with a builtin web server as well that should work fine with IronPython with a few small modifications.","Q_Score":29,"Tags":".net,python,ironpython,dynamic-language-runtime","A_Id":4358367,"CreationDate":"2010-12-02T14:47:00.000","Title":"Iron Python : what are good uses for Iron 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},{"Question":"What are the differences between a systems programming language and Application programming language?","AnswerCount":5,"Available Count":5,"Score":1.0,"is_accepted":false,"ViewCount":13401,"Q_Id":4343014,"Users Score":9,"Answer":"As with a great many things in IT, the line is blurry. For example, C started its life as a systems programming language (and was used to implement Unix), but was and is used for applications development too. \nHaving said that, there are clearly some languages better suited to systems programming than others (eg. C\/C++ are better suited than COBOL\/FORTRAN for systems programming). Likewise there are languages that are better suited to applications development and not systems programming eg. VB.NET.\nThe language features that stand out from the examples above, are the low level features of the systems programming languages like C\/C++ (eg. pointers, bit manipulation operators, etc). There is of course the old joke that C is a \"Sea\" level language (sitting somewhere between the assembly level and the \"high\" level).  \nWarning: I'm coming at systems programming from the perspective of OS developer \/ OS tool developer.\nI think it is fair to say, notwithstanding the projects to develop OSes with Java (though I believe mostly are native compiled, rather than to byte code and JIT'ed \/ interpreted), that systems programming languages target native machine code of their target platforms. So languages that primarily target managed code \/ interpreted code are less likely to be used for systems programming. \nAnyway, that is surely enough to stir up some comments both in support and in opposition :)","Q_Score":13,"Tags":"c#,java,python,perl,programming-languages","A_Id":4343035,"CreationDate":"2010-12-03T06:23:00.000","Title":"Difference between Systems programming language and Application 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":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"What are the differences between a systems programming language and Application programming language?","AnswerCount":5,"Available Count":5,"Score":1.2,"is_accepted":true,"ViewCount":13401,"Q_Id":4343014,"Users Score":16,"Answer":"A few factors should in my opinon come into consideration\n\nIn a system programming language you must be able to reach low-level stuff, getting close to the real hardware world. In an application language instead there is a sort of \"virtual world\" (hopefully nicer and easier to interact with) that has been designed with the language and you only need to be able to cope with that.\nIn a system programming language there should be no concession in terms of performance. One must be able to write code that squeezes out all the juice from the hardware. This is not the biggest concern in an application programming language, where the time needed to actually write the program plays instead a greater role.\nBecause of 2 a system programming language is free to assume that the programmer makes no mistake and so there will be no \"runtime error\" guards. For example indexing out of an array is going to mean the end of the world unless the hardware gives those checks for free (but in that case you could probably choose less expensive or faster hardware instead). The idea is that if you assume that the code is correct there is no point in paying even a small price for checking the impossible. Also a system programming language shouldn't get into the way trying to forbid the programmer doing something s\/he wants to do intentionally... the assumption is that s\/he knows that is the right thing to do. In an application programming language instead it's considered good helping the programmer with checking code and also trying to force the code to use certain philosophical schemas. In application programming languages things like execution speed, typing time and code size can be sacrificed trying to help programmers avoiding shooting themselves.\nBecause of 3 a system programming language will be much harder to learn by experimentation. In a sense they're sort of powerful but dangerous tools that one should use carefully thinking to every single statement and for the same reason they're languages where debugging is much harder. In application programming languages instead the try-and-see approach may be reasonable (if the virtual world abstraction is not leaking too much) and letting errors in to remove them later is considered a viable option.","Q_Score":13,"Tags":"c#,java,python,perl,programming-languages","A_Id":4343639,"CreationDate":"2010-12-03T06:23:00.000","Title":"Difference between Systems programming language and Application 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":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"What are the differences between a systems programming language and Application programming language?","AnswerCount":5,"Available Count":5,"Score":0.1973753202,"is_accepted":false,"ViewCount":13401,"Q_Id":4343014,"Users Score":5,"Answer":"These are not exact concepts, but in essence, systems programming languages are suitable for writing operating systems (so they have low-level concepts such as pointers, integration with assembler, data types corresponding to memory and register organization), while the application programming languages are more suitable for writing applications, so they generally use higher-level concepts to represent the computation (such as OOP, closures, in-built complex datatypes and so on).","Q_Score":13,"Tags":"c#,java,python,perl,programming-languages","A_Id":4343077,"CreationDate":"2010-12-03T06:23:00.000","Title":"Difference between Systems programming language and Application 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":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"What are the differences between a systems programming language and Application programming language?","AnswerCount":5,"Available Count":5,"Score":0.0798297691,"is_accepted":false,"ViewCount":13401,"Q_Id":4343014,"Users Score":2,"Answer":"In general, a systems programming language is lower level than applications programming languages.  However, the language itself has nothing to do with it.. it's more the particulars of the implementation of the language.\nFor example, Pascal started life as a teaching language, and was pretty much strictly applications.. however, it was evolved into a systems language and was used to create early versions of MacOS and Windows.\nC# is not, typically a systems language because it cannot do low-level work, although even that line is blurred as managed operating systems come into being.","Q_Score":13,"Tags":"c#,java,python,perl,programming-languages","A_Id":4343085,"CreationDate":"2010-12-03T06:23:00.000","Title":"Difference between Systems programming language and Application 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":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"What are the differences between a systems programming language and Application programming language?","AnswerCount":5,"Available Count":5,"Score":0.0798297691,"is_accepted":false,"ViewCount":13401,"Q_Id":4343014,"Users Score":2,"Answer":"i don't think there is a final answer here anymore.\nperl and python come by default with almost every linux distro...both can inline C...both can do job control and other \"low level\" tasks...threading etc. \nany language with a good set of system call bindings and\/or FFI should be as fundamentally system-aware as C or C++. \nthe only languages i would discount as being systems languages are those that specifically address another platform (jvm, clr) and actively seek to prevent native interaction","Q_Score":13,"Tags":"c#,java,python,perl,programming-languages","A_Id":4350156,"CreationDate":"2010-12-03T06:23:00.000","Title":"Difference between Systems programming language and Application 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":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"python programmers,\nI'm am new to python ,I read that we have built in functions to achieve file compression in python . I just wanted to know if a file compression can be done without using these built in functions (maybe a longer code perhaps) .I wanted to understand the working of these built in functions(how they are coded) basically .\nforgive the fallacies(if any) of a beginner,\nthanks in advance","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":419,"Q_Id":4348660,"Users Score":1,"Answer":"If you would like to learn more about how file compression works, the code is available right in the python source code in the file gzip.py. You should also check out the zlib source code, on which the gzip module is based.\nYou can get zlib source code from zlib.net.","Q_Score":1,"Tags":"python,file,compression","A_Id":4348705,"CreationDate":"2010-12-03T18:30:00.000","Title":"file compression without using built in functions","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm currently in college, and we work in groups of three to create small python projects on a weekly basis.\nWe code with Eclipse and PyDev but we've got a problem when it comes to sharing our work. We end up sending an infinite stream of emails with compressed projects.\nWhat we need is a way to keep the source code updated and we need to be able to share it between us. (on both Windows and Linux) What do you recommend? \nthanks in advance.","AnswerCount":4,"Available Count":2,"Score":0.1488850336,"is_accepted":false,"ViewCount":582,"Q_Id":4350627,"Users Score":3,"Answer":"I'd suggest using a version control system.\nGit might be good for you - it doesn't require a central server and there is also support for Windows these days.","Q_Score":3,"Tags":"python,eclipse","A_Id":4350649,"CreationDate":"2010-12-03T22:53:00.000","Title":"Code sharing between small student group","Data Science and Machine Learning":0,"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},{"Question":"I'm currently in college, and we work in groups of three to create small python projects on a weekly basis.\nWe code with Eclipse and PyDev but we've got a problem when it comes to sharing our work. We end up sending an infinite stream of emails with compressed projects.\nWhat we need is a way to keep the source code updated and we need to be able to share it between us. (on both Windows and Linux) What do you recommend? \nthanks in advance.","AnswerCount":4,"Available Count":2,"Score":0.049958375,"is_accepted":false,"ViewCount":582,"Q_Id":4350627,"Users Score":1,"Answer":"What you need is a control version server (SVN for instance). You will be able to commit the changes and update the local version of your code  to the current server version.\nIt is for free:\nhttp:\/\/code.google.com\/\nYou should set up your repo and share your work! :-)\nI hope it helps.","Q_Score":3,"Tags":"python,eclipse","A_Id":4350652,"CreationDate":"2010-12-03T22:53:00.000","Title":"Code sharing between small student group","Data Science and Machine Learning":0,"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},{"Question":"I am working with Google App Engine python version. The app sends an \nemail to the user with a link to a page to upload an image as an \navatar. It would be nice to have the email so that I can associate the \navatar with that email. How can I get the email of the person who just clicked the link? Thank you.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1324,"Q_Id":4356776,"Users Score":9,"Answer":"Put a hash in the URL that uniquely identifies the address you sent it to.","Q_Score":2,"Tags":"python,google-app-engine,email","A_Id":4356783,"CreationDate":"2010-12-05T00:56:00.000","Title":"How do I get the email address of the person who clicked the link in the 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":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"A friend of mine that is a programmer told me that \"Python is written in Python\" or something like that. He meant that Python interpreter is written in Python (I think). I've read in some websites that Python interpret in real time ANY programming language (even C++ and ASM). Is this true?\nCould someone explain me HOW COULD IT BE?\nThe unique explanation that I came up with after thinking a bit is: python is at the same \"level\" of ASM, it makes sense to python interpret any language (that is in a higher level), am I right? Does this make sense?\nI would be grateful is someone explain me a little about it.\nThank you","AnswerCount":4,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":155,"Q_Id":4364507,"Users Score":0,"Answer":"Generally, when someone says language X is written in X, they mean that first a compiler or interpreter for X was written in assembly or other such language, compiled, and then a better compiler or interpreter was written in X.\nAdditionally, once a very basic compiler\/interpreter for X exists, it is sometimes easier to add new language features, classes, etc. to X by writing them in X than to extend the compiler\/interpreter itself.","Q_Score":1,"Tags":"python,compiler-construction,programming-languages,interpreter","A_Id":4364520,"CreationDate":"2010-12-06T08:32:00.000","Title":"Question about python construction","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"A friend of mine that is a programmer told me that \"Python is written in Python\" or something like that. He meant that Python interpreter is written in Python (I think). I've read in some websites that Python interpret in real time ANY programming language (even C++ and ASM). Is this true?\nCould someone explain me HOW COULD IT BE?\nThe unique explanation that I came up with after thinking a bit is: python is at the same \"level\" of ASM, it makes sense to python interpret any language (that is in a higher level), am I right? Does this make sense?\nI would be grateful is someone explain me a little about it.\nThank you","AnswerCount":4,"Available Count":2,"Score":0.2449186624,"is_accepted":false,"ViewCount":155,"Q_Id":4364507,"Users Score":5,"Answer":"It's not true. The standard implementation of Python - CPython - is written in C, although much of the standard library is written in Python. There are other implementations in Java (Jython) and .NET (IronPython).\nThere is a project called PyPy which, among other things, is rewriting the C parts of Python into Python. But the main development of Python is still based on C.","Q_Score":1,"Tags":"python,compiler-construction,programming-languages,interpreter","A_Id":4364861,"CreationDate":"2010-12-06T08:32:00.000","Title":"Question about python construction","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm looking for a good framework to use for a soap service. I'd prefer to use a pythonic framework, but after looking at soaplib\/rpclib (too unstable), SOAPy (doesn't work with 2.7) and ZSI (too...confusing), I'm not sure that's possible. \nI'm fine with it being in another language, though I'm hesitant to use php's soap libraries due to some previous issues I've had with php. \nYes, I would very much like to to be SOAP as this is destined to primarily provide data to a Silverlight client, and VS makes it dead simple to work with soap services. And no, it can't be an WCF service as all of the hosts are linux-based. \nMuch appreciated.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":1264,"Q_Id":4371139,"Users Score":1,"Answer":"I have used Spring WS, JAVA in my previous project. It worked well, without any glitches. We served more than a million API request a day.","Q_Score":3,"Tags":"python,silverlight,web-services,soap","A_Id":4371795,"CreationDate":"2010-12-06T21:29:00.000","Title":"What is a good framework for a soap service?","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},{"Question":"I am new to python and one thing I read is python is good for making fast prototype of your product because of its extensive library support. But it is not good(used) for large scale deployment?\nIs it true? your comments on this.\nI have not seen a place (domain) where it is heavily used although its a beautiful language with big fan following (like php for server scripting, JS for client side; c c++ for systems etc).","AnswerCount":2,"Available Count":2,"Score":0.1973753202,"is_accepted":false,"ViewCount":675,"Q_Id":4381239,"Users Score":2,"Answer":"The example I would give would be CCP Games who use Python for almost all code, iirc. They run eve online, a MMORPG with the record for the max amount of users online in one persistent universe (over 50 thousand yesterday afternoon for instance). So I would say that is a fairly large scale deployment, in my humble opinion.","Q_Score":1,"Tags":"python","A_Id":4381283,"CreationDate":"2010-12-07T20:28:00.000","Title":"Python good for prototyping and not for large scale deployment?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am new to python and one thing I read is python is good for making fast prototype of your product because of its extensive library support. But it is not good(used) for large scale deployment?\nIs it true? your comments on this.\nI have not seen a place (domain) where it is heavily used although its a beautiful language with big fan following (like php for server scripting, JS for client side; c c++ for systems etc).","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":675,"Q_Id":4381239,"Users Score":2,"Answer":"Google uses it, and I think this is a good example for large-scale deployment. It is not very fast, indeed, but it has awesome C\/C++ integration support for the bottlenecks.","Q_Score":1,"Tags":"python","A_Id":4381275,"CreationDate":"2010-12-07T20:28:00.000","Title":"Python good for prototyping and not for large scale deployment?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to start programming in python and I was wondering,\nwhich languages does Python resemble in syntax? I am familiar with .net.","AnswerCount":4,"Available Count":2,"Score":0.049958375,"is_accepted":false,"ViewCount":1860,"Q_Id":4381806,"Users Score":1,"Answer":"The only language I can think of that looks like Python today is Ruby, but Ruby was actually influenced by Python. It doesn't really look like anything you've ever used in .NET unless you used IronPython or IronRuby.\nDon't let that discourage you, Python is very simple to learn and most of the syntax (e.g. operators) won't confuse you.","Q_Score":3,"Tags":".net,python","A_Id":4381862,"CreationDate":"2010-12-07T21:32:00.000","Title":"Which of the languages does Python resemble in its class syntax?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to start programming in python and I was wondering,\nwhich languages does Python resemble in syntax? I am familiar with .net.","AnswerCount":4,"Available Count":2,"Score":0.1973753202,"is_accepted":false,"ViewCount":1860,"Q_Id":4381806,"Users Score":4,"Answer":"Python's abstract syntax is heavily inspired by C, as is its concrete micro-syntax. Its concrete macro-syntax, though is fairly different from C, since it uses indentation and dedentation to delimit blocks, similar to Haskell, F#, ISWIM and a couple of others.\nSemantically, Python is probably closer to something like Modula-2 with objects, but dynamically typed, of course.","Q_Score":3,"Tags":".net,python","A_Id":4383242,"CreationDate":"2010-12-07T21:32:00.000","Title":"Which of the languages does Python resemble in its class syntax?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Python packaging tools expect that our readme file should be named README or README.txt. But if we follow this convention, GitHub displays it as plain text in the project page which is not pretty. (unlike the beautiful HTML version when named as README.rst)\nIs there any technique to make both PyPI and GitHub happy about README.","AnswerCount":5,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":11100,"Q_Id":4384796,"Users Score":11,"Answer":"A crude way I can think of is to make a symlink to README called README.rst and check them both in.","Q_Score":37,"Tags":"python,github","A_Id":4384952,"CreationDate":"2010-12-08T06:33:00.000","Title":"README extension for 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},{"Question":"Pylint looks like a good tool for running analysis of Python code.\nHowever, our main objective is to catch any potential bugs and not coding conventions. Enabling all Pylint checks seems to generate a lot of noise. What is the set of Pylint features you use and is effective?","AnswerCount":5,"Available Count":2,"Score":1.0,"is_accepted":false,"ViewCount":32053,"Q_Id":4395499,"Users Score":13,"Answer":"To persistently disable warnings and conventions:\n\nCreate a ~\/.pylintrc file by running pylint --generate-rcfile > ~\/.pylintrc\nEdit ~\/.pylintrc\nUncomment disable= and change that line to disable=W,C","Q_Score":28,"Tags":"python,static-analysis,pylint","A_Id":19118976,"CreationDate":"2010-12-09T06:29:00.000","Title":"Pylint 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":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Pylint looks like a good tool for running analysis of Python code.\nHowever, our main objective is to catch any potential bugs and not coding conventions. Enabling all Pylint checks seems to generate a lot of noise. What is the set of Pylint features you use and is effective?","AnswerCount":5,"Available Count":2,"Score":1.0,"is_accepted":false,"ViewCount":32053,"Q_Id":4395499,"Users Score":7,"Answer":"-E will only flag what Pylint thinks is an error (i.e., no warnings, no conventions, etc.)","Q_Score":28,"Tags":"python,static-analysis,pylint","A_Id":4977086,"CreationDate":"2010-12-09T06:29:00.000","Title":"Pylint 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":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Which one of Ruby-PHP-Python is best suited for Cassandra\/Hadoop on 500M+ users?  I know language itself is not a big concern but I like to know base on proven success, infrastructure and available utilities around those frameworks! thanks so much.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":339,"Q_Id":4398341,"Users Score":0,"Answer":"Because Cassandra is written in Java, a client also in Java would likely have the best stability and maturity for your application.\nAs far as choosing between those 3 dynamic languages, I'd say whatever you're most comfortable with is best.  I don't know of any significant differences between client libraries in those languages.","Q_Score":0,"Tags":"php,python,ruby-on-rails,scalability,cassandra","A_Id":9921879,"CreationDate":"2010-12-09T12:46:00.000","Title":"Scability of Ruby-PHP-Python on Cassandra\/Hadoop on 500M+ users","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},{"Question":"I'm converting some python code to java, and have a situation where I need to call methods of an object but don't know which methods until runtime. In python I resolve this by using getattr on my object and passing it a string that is the name of my method. How would you do something similar in Java?","AnswerCount":6,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":4915,"Q_Id":4398432,"Users Score":0,"Answer":"The easiest way to handle this is to create a Map object in Java class & keep adding the name value pairs & retrieve it accordingly though it might not support different types that setAttr supports.","Q_Score":12,"Tags":"java,python,reflection","A_Id":54568702,"CreationDate":"2010-12-09T12:56:00.000","Title":"Java equivalent of python's getattr?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I'm converting some python code to java, and have a situation where I need to call methods of an object but don't know which methods until runtime. In python I resolve this by using getattr on my object and passing it a string that is the name of my method. How would you do something similar in Java?","AnswerCount":6,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":4915,"Q_Id":4398432,"Users Score":0,"Answer":"In Java you do this with the Reflection API (and it's usually pretty cumbersome).\nMethodUtils in Apache Commons BeanUtils project may make it a bit easier to work with, though it's a pretty hefty dependency for something simple like this.","Q_Score":12,"Tags":"java,python,reflection","A_Id":4398473,"CreationDate":"2010-12-09T12:56:00.000","Title":"Java equivalent of python's getattr?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"Under what circumstances would something like eventlet\/gevent be better than twisted? Twisted seems like the most used, but eventlet\/gevent must have some advantages...\nI'm not looking for an answer to a specific scenario, just generalities.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":2369,"Q_Id":4405667,"Users Score":10,"Answer":"It's an issue of aesthetic preference, I think.\nFirst of all, eventlet can actually use Twisted for networking, so in a sense, it's not an either-or question, it's a this-is-built-on-top-of-that question.\nPersonally, I don't see the need for libraries like gevent or eventlet, especially since the advent of the @inlineCallbacks decorator in Twisted, which already write code which sorta looks like it's blocking.\nBut, if you have a large library of code which already uses threads, and you want to port it to be event-driven, something like eventlet can save you some typing, since you don't need to insert 'yield's everywhere..  Some people, like the guys behind the EVE online game, think that code written in this style is just better for some things, such as AI code.","Q_Score":9,"Tags":"python,twisted,gevent,eventlet","A_Id":4411300,"CreationDate":"2010-12-10T04:29:00.000","Title":"Twisted, gevent eventlet - When would I use them","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"Would anyone happen to know what the maximum user ID is on Twitter? That is by now there are about 200mil users, so would the id's range from 1 - 200million? I am finding that in that range some of the id's are not used.\nI have a python script that is basically accessing the following url:\n\"\/1\/statuses\/user_timeline\/\" + str(user_id) + \".json?count=200\"\nThanks,","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":3366,"Q_Id":4406448,"Users Score":0,"Answer":"No one knows that.\nThere were discussions on that in relation of how many users twitter really has.\nThere were a lot of tests as well as probing of id ranges etc.\nThe results were that the ids were sequentially incrementing a long time, but then had regular gaps of about 10 between them, and sometimes also seemed to be complelety random.\nI don't know how accurately this information was collected, and the goal was something else, but I think you get the point.\nFrom a technical point of view I would expect nothing else in a network as big as twitter.\nI am pretty sure the IDs are sharded, which means they are assigned in special reagions or servers.\nSo that for example if your ID equals mudolo 17 I know I have to look on that very server.  Or in that very country. Or something.\nOr maby the server just have their own prefix or residue class for assigning ids when a new user signs up to avoid replication problems.\nIt is also in most cases uncommon, or \"not so cool\" to leak information as this.\nDon't ask me why, its just my esperience that comapnies want to show as least information to the outside as possible.\nThis includes not having an reproduceable transparanet id incremention system.\nIt is also vulnerable for some sort of harmful attacks, unwanted crawling, stuff like that.\nSo my point is.\nThere is no way of giving you a reliable answer. And it should not be necessary.\nYou should design your application do deal with eveyr possible situation.\nIf you want to know how big you should make your database field not to get any conflicts.\nI think integer should be fine for now. (even on 32 bit systems)\nBut always be prepared to upgrade.\nEspecially don't assume that it will stay numeric. Its just a unique string!","Q_Score":2,"Tags":"python,twitter,oauth","A_Id":4406528,"CreationDate":"2010-12-10T06:57:00.000","Title":"Max Twitter ID?","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},{"Question":"i'm writing a python application that uses a command line utility (propietary so it can't be modified) to do part of its work. The problem is that I have to pass the password as a command line argument to the tool which would easily be seen by any user doing 'ps ax'. How can I send the password to the command line tool safely from within python (or a shell script)?","AnswerCount":6,"Available Count":3,"Score":0.0665680765,"is_accepted":false,"ViewCount":4756,"Q_Id":4407843,"Users Score":2,"Answer":"If the password is only accepted on the command line, you're pretty much out of luck.  Are you absolutely sure there's no option to send the password in another way?  If you can send it over the process's stdin, you can talk to it via a pipe, and send the password securely in that way.","Q_Score":12,"Tags":"python,bash,shell","A_Id":4408136,"CreationDate":"2010-12-10T10:25:00.000","Title":"sending password to command line tools","Data Science and Machine Learning":0,"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},{"Question":"i'm writing a python application that uses a command line utility (propietary so it can't be modified) to do part of its work. The problem is that I have to pass the password as a command line argument to the tool which would easily be seen by any user doing 'ps ax'. How can I send the password to the command line tool safely from within python (or a shell script)?","AnswerCount":6,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":4756,"Q_Id":4407843,"Users Score":0,"Answer":"You may be able to gain more security by having an encrypted password argument and passing an encrypted password, and the program can de-crypt it. At least there would be no plain-text password floating around. I used this method when launching a process via another process and passing it arguments. It may not be feasible in your case though.","Q_Score":12,"Tags":"python,bash,shell","A_Id":13034720,"CreationDate":"2010-12-10T10:25:00.000","Title":"sending password to command line tools","Data Science and Machine Learning":0,"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},{"Question":"i'm writing a python application that uses a command line utility (propietary so it can't be modified) to do part of its work. The problem is that I have to pass the password as a command line argument to the tool which would easily be seen by any user doing 'ps ax'. How can I send the password to the command line tool safely from within python (or a shell script)?","AnswerCount":6,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":4756,"Q_Id":4407843,"Users Score":0,"Answer":"Write another python script that will accept password from command prompt using getpass.getpass() and store it in a variable. Then call the command from the script with that variable having password as parameter.","Q_Score":12,"Tags":"python,bash,shell","A_Id":13034839,"CreationDate":"2010-12-10T10:25:00.000","Title":"sending password to command line tools","Data Science and Machine Learning":0,"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},{"Question":"The question pretty much says it all.  The database is in MySQL using phpMyAdmin.  \nA little background: I'm writing the interface for a small non-profit organization.  They need to be able to see which customers to ship to this month, which customers have recurring orders, etc.  The current system is ancient, written in PHP 4, and I'm in charge of upgrading it.  I spoke with the creator of the current system, and he agreed that it would be better to just write a new interface.\nI'm new to Python, SQL and PHP, so this is a big learning opportunity for me.  I'm pretty excited.  I do have a lot of programming experience though (C, Java, Objective-C), and I don't anticipate any problems picking up Python.\nSo here I am!\nThanks in advance for all your help.","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":186,"Q_Id":4413840,"Users Score":0,"Answer":"What can I say? Just download the various software, dig in and ask questions here when you run into specific problems.","Q_Score":0,"Tags":"php,python,mysql,phpmyadmin","A_Id":4413898,"CreationDate":"2010-12-10T22:23:00.000","Title":"I have a MySQL database, I want to write an interface for it using Python. Help me get started, please!","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},{"Question":"What i'd like to have is a mechanism that all commands i enter on a Bash-Terminal are wrapped by a Python-script. The Python-script executes the entered command, but it adds some additional magic (for example setting \"dynamic\" environment variables). \nIs that possible somehow? \nI'm running Ubuntu and Debian Squeezy.\nAdditional explanation:\nI have a property-file which changes dynamically (some scripts do alter it at any time). I need the properties from that file as environment variables in all my shell scripts. Of course i could parse the property-file somehow from shell, but i prefer using an object-oriented style for that (especially for writing), as it can be done with Python (and ConfigObject). \nTherefore i want to wrap all my scripts with that Python script (without having to modify the scripts themselves) which handles these properties down to all Shell-scripts.\nThis is my current use case, but i can imagine that i'll find additional cases to which i can extend my wrapper later on.","AnswerCount":4,"Available Count":1,"Score":-0.0996679946,"is_accepted":false,"ViewCount":3793,"Q_Id":4418378,"Users Score":-2,"Answer":"There is no direct way you can do it .\nBut you can make a python script to emulate a bash terminal and you can use the beautiful \"Subprocess\" module in python to execute commnands the way you like","Q_Score":12,"Tags":"python,linux,bash","A_Id":4420885,"CreationDate":"2010-12-11T19:00:00.000","Title":"Wrap all commands entered within a Bash-Shell with 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":1,"System Administration and DevOps":1,"Web Development":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},{"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},{"Question":"I'm doing some feasibility research with regards to a (large) book cataloging project. Any help would w\/r\/t good sources of information would be appreciated but the things I would specifically like to know are:\n1.)does python have any modules for use with barcode readers (preferably USB)? What other programs are available for reading barcode information?\n2.)This may be better answered with a few sources of information, but what kinds of things should I look for in a barcode scanner, especially if I'm looking to scan, specifically, a lot of barcodes on books.\n3.)This may also be better answered with a few sources of information, what kind of information is stored standard in a book's barcode.\nI know this is relatively off-topic, but any help would be greatly appreciated.","AnswerCount":2,"Available Count":1,"Score":0.2913126125,"is_accepted":false,"ViewCount":4396,"Q_Id":4434959,"Users Score":3,"Answer":"Are you making a python web-app or a client application? Unless you're looking for specialized bar code scanning functionality it doesn't really matter since the input from the scanner appears like keyboard entry (sometimes prefixed with a special input character), so you just have to have a way of listening to the keyboard input and catching that special character.","Q_Score":11,"Tags":"python,barcode,barcode-scanner","A_Id":4435008,"CreationDate":"2010-12-14T00:55:00.000","Title":"USB Barcode scanner research","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"when I use pssh, trying to access a remote machine which is not inside the UNIX \nknown hosts file, pssh freeze after giving the password.\nAfter having added the host using a direct ssh command, pssh works.\nSo is there an option to give to the pssh command in order to avoid this problem ?\nThanks for your help,\nRegards","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":12459,"Q_Id":4437331,"Users Score":18,"Answer":"Try pssh -O StrictHostKeyChecking=no. This works for me.\nBy default ssh uses the value of \"ask\", which causes it to ask the user whether to continue connecting to unknown host. By setting the value to \"no\", you avoid the question, but are no longer protected against certain attacks. E.g. if you are connecting to hostA, and someone puts hostB there with the same IP address, then by default ssh will notice that hostB has changed, and will prompt you about it. With StrictHostKeyChecking=no, it will silently assume everything is OK.","Q_Score":5,"Tags":"python,ssh","A_Id":4441673,"CreationDate":"2010-12-14T08:47:00.000","Title":"pssh and known_hosts 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},{"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},{"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},{"Question":"I have around 80 lines of a function in a file. I need the same functionality in another file so I am currently importing the other file for the function.\nMy question is that in terms of running time on a machine which technique would be better :- importing the complete file and running the function or copying the function as it is and run it from same package.\nI know it won't matter in a large sense but I want to learn it in the sense that if we are making a large project is it better to import a complete file in Python or just add the function in the current namespace.....","AnswerCount":5,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":143,"Q_Id":4443509,"Users Score":0,"Answer":"If the two modules are unrelated except for that common function, you may wish to consider extracting that function (and maybe other things that are related to that function) into a third module.","Q_Score":0,"Tags":"python","A_Id":4443870,"CreationDate":"2010-12-14T19:50:00.000","Title":"Is importing a file good 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},{"Question":"I have around 80 lines of a function in a file. I need the same functionality in another file so I am currently importing the other file for the function.\nMy question is that in terms of running time on a machine which technique would be better :- importing the complete file and running the function or copying the function as it is and run it from same package.\nI know it won't matter in a large sense but I want to learn it in the sense that if we are making a large project is it better to import a complete file in Python or just add the function in the current namespace.....","AnswerCount":5,"Available Count":3,"Score":0.0399786803,"is_accepted":false,"ViewCount":143,"Q_Id":4443509,"Users Score":1,"Answer":"Importing is good cause it helps you manage stuff easily. What if you needed the same function again? Instead of making changes at multiple places, there is just one centralized location - your module. \nIn case the function is small and you won't need it anywhere else, put it in the file itself.\nIf it is complex and would require to be used again, separate it and put it inside a module. \nPerformance should not be your concern here. It should hardly matter. And even if it does, ask yourself - does it matter to you?","Q_Score":0,"Tags":"python","A_Id":4443553,"CreationDate":"2010-12-14T19:50:00.000","Title":"Is importing a file good 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},{"Question":"I have around 80 lines of a function in a file. I need the same functionality in another file so I am currently importing the other file for the function.\nMy question is that in terms of running time on a machine which technique would be better :- importing the complete file and running the function or copying the function as it is and run it from same package.\nI know it won't matter in a large sense but I want to learn it in the sense that if we are making a large project is it better to import a complete file in Python or just add the function in the current namespace.....","AnswerCount":5,"Available Count":3,"Score":1.2,"is_accepted":true,"ViewCount":143,"Q_Id":4443509,"Users Score":4,"Answer":"Importing is how you're supposed to do it. That's why it's possible. Performance is a complicated question, but in general it really doesn't matter. People who really, really need performance, and can't be satisfied by just fixing the basic algorithm, are not using Python in the first place. :) (At least not for the tiny part of the project where the performance really matters. ;) )","Q_Score":0,"Tags":"python","A_Id":4443551,"CreationDate":"2010-12-14T19:50:00.000","Title":"Is importing a file good 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},{"Question":"I am looking to implement a simple project that backs up files and encrypts them using AES.\nThe normal backing up part is done thanks to how Python handles everything ... however I need to encrypt the data also.\nSo my questions are:\n\nIs AES the best encryption algorithm for encrypting the files or I can do better?\nWhat is the best Python library for encrypting stuff? I searched and came across M2Crypto and PyCrypto. Any differences\/ which one should I favour?\nIs this going to be secure? I mean, I will be typing the key everytime I need to encrypt \/ decrypt and so I will be getting the key from raw_input. Is this OK?\n\nIf you have any suggestions, feel free to let me know.\nThanks.","AnswerCount":3,"Available Count":1,"Score":0.1325487884,"is_accepted":false,"ViewCount":2086,"Q_Id":4453724,"Users Score":2,"Answer":"Ideally, you would not be at a cipher level in order to secure your data. If nothing else, use an existing, proven secure, framework such as GPG to handle file encryption. This is driven home by your question regarding AES: you haven't even mentioned what cipher modes you were considering (CBC, XTR, CTR, CFB, EBC, etc).","Q_Score":3,"Tags":"python,encryption,aes","A_Id":4453804,"CreationDate":"2010-12-15T18:57:00.000","Title":"AES encryption of files 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},{"Question":"I have a python script which I would like to launch from inittab, shown below\ns1:respawn:\/home\/a_user\/app\/script.py \nI believe initab executes as root, so the a_user's envrinment is not available\nThe script needs to know \"a_user\" home directory for ini file settings and log file storage. I would like to avoid hard coding these paths in my script. Is it possible to execute this script as a_user and not a root? If this is possible would a_user HOME environment variable  be available?\nRegards","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":1378,"Q_Id":4455973,"Users Score":1,"Answer":"you could copy python binary to python-suid,\nchown it to user you want to run scripts as and chown u+s python-suid\nthen in script #!\/usr\/bin\/python-suid","Q_Score":1,"Tags":"python,root","A_Id":4456065,"CreationDate":"2010-12-15T23:21:00.000","Title":"Executing a python script from inittab not as root","Data Science and Machine Learning":0,"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},{"Question":"I have a python script which I would like to launch from inittab, shown below\ns1:respawn:\/home\/a_user\/app\/script.py \nI believe initab executes as root, so the a_user's envrinment is not available\nThe script needs to know \"a_user\" home directory for ini file settings and log file storage. I would like to avoid hard coding these paths in my script. Is it possible to execute this script as a_user and not a root? If this is possible would a_user HOME environment variable  be available?\nRegards","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":1378,"Q_Id":4455973,"Users Score":1,"Answer":"Use runuser (or the distro's equvalent) to run it as a different user. runuser does change $HOME, but other similar commands may not.","Q_Score":1,"Tags":"python,root","A_Id":4456006,"CreationDate":"2010-12-15T23:21:00.000","Title":"Executing a python script from inittab not as root","Data Science and Machine Learning":0,"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},{"Question":"I know it is possible to use Powershell from within IronPython, but is this possible using CPython beyond using Popen() and other similar calls? I'm trying to do some very basic NET framework programming (windows Forms, etc.) like you can do inside of IronPython using CPython. \nThanks!\nAny help appreciated.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":2213,"Q_Id":4455999,"Users Score":3,"Answer":"I am not sure why you got downvoted as this is a legitimate question. I think the best integration you are going to get trying to integrate PowerShell into CPython will be through spawning a new process and passing in the PowerShell script you want run. Unfortunately this will also mean parsing any output that is generated as well. There is not a COM or C library you can really link against to get much better. \nThere might be some sort of a general .NET interop library for CPython (I haven't checked), but that may be an option, using that layer you could (at least in theory) use the same techniques as embedding the PowerShell runtime into a regular .NET App.","Q_Score":11,"Tags":"python,powershell","A_Id":4456153,"CreationDate":"2010-12-15T23:25:00.000","Title":"Powershell integration with Python (not 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},{"Question":"I have this text in a file - Recu\u00e9rdame (notice it's a French word). When I read this file with a python script, I get this text as Recuérdame.\nI read it as a unicode string. Do I need to find what the encoding of the text is & decode this? or is my terminal playing tricks on me?","AnswerCount":4,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":3875,"Q_Id":4458090,"Users Score":0,"Answer":"Working with xlrd, I have in a line \n...xl_data.find(str(cell_value))...\nwhich gives the error:\"'ascii' codec can't encode character u'\\xdf' in position 3: ordinal not in range(128)\".\nAll suggestions in the forums have been useless for my german words.\nBut changing into:\n...xl_data.find(cell.value)...\ngives no error.\nSo, I suppose using strings as arguments in certain commands with xldr has specific encoding problems.","Q_Score":0,"Tags":"python,text,encoding,character-encoding,decoding","A_Id":14012214,"CreationDate":"2010-12-16T06:34:00.000","Title":"Python Text Encoding","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have an application written in IronPython which uses classes and methods from imported .NET assembly (compiled with debug support). When a method in assembly throws an exception, it gets caught in IronPython code as Exception (not System.Exception) and the traceback ends at last IronPython method.\nWhat I would like to do is to go deeper and append the original CLI traceback after last IronPython method to see where the exception occured inside the assembly.\nIs it possible to get original CLI exception from caught IronPython equvivalent or catch it without loosing IronPython's stack trace?\nThanx.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":323,"Q_Id":4461191,"Users Score":1,"Answer":"You can get the ExceptionOperations object from scriptEngine.GetService().   You can then call FormatException or GetStackFrames. You can also set the ExceptionDetail option to true to get more verbose stack traces from FormatException.","Q_Score":2,"Tags":"ironpython","A_Id":4467668,"CreationDate":"2010-12-16T13:27:00.000","Title":"Combine IronPython's and CLI stack trace","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm using emacs23 with tramp to modify python scripts on a remote host.\nI found that when I start the python shell within emacs it starts up \npython on the remote host. \nMy problem is that when I then try to call python-send-buffer via C-c C-c it comes up with the error\n\nTraceback (most recent call last):\n    File \"\", line 1, in ?\n  ImportError: No module named emacs\nTraceback (most recent call last):\n    File \"\", line 1, in ?\n  NameError: name 'emacs' is not defined\n\nNow, I must admit that I don't really know what's going on here. Is there a way for me to configure emacs so that I can evaluate the buffer on the remote host?\nMany thanks.\nEdit: I've followed eichin's advice and re-implemented python-send-region. See my answer below.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":2594,"Q_Id":4465615,"Users Score":2,"Answer":"Short answer: not without writing some missing elisp code.\nLong version: In python.el, run-python adds data-directory (which on my Ubuntu 10.10 box is \/usr\/share\/emacs\/23.1\/etc\/ ) to $PYTHONPATH, specifically so that it can find emacs.py (as supplied by the local emacs distribution.)  Then it does a (python-send-string \"import emacs\") and expects it to work...\nIt looks like the defadvice wrappers that tramp uses don't actually pass PYTHONPATH, so this doesn't work even if you have the matching emacs version on the remote system.\nIf you M-x customize-variable RET tramp-remote-process-environment RET\nthen hit one of the INS buttons and add PYTHONPATH=\/usr\/share\/emacs\/23.1\/etc then hit STATE and set it to \"current session\" (just to test it, or \"save for future sessions\" if it works for you) it almost works - the complaint goes away, in any case, because the remote python can now find the remote emacs.py.  If you now go back to the original question, doing python-send-buffer, you just run into a different error: No such file or directory: '\/tmp\/py24574XdA' because python-mode just stuffs the content into a temporary file and tells the python subprocess to load that.\nYou'd have to change python-send-region (the other functions call it) and particularly the way it uses make-temp-file to be tramp-aware - there's even a tramp-make-tramp-temp-file you could probably build upon.  (Be sure to post it if you do...)","Q_Score":5,"Tags":"python,emacs","A_Id":4577034,"CreationDate":"2010-12-16T21:39:00.000","Title":"evaluating buffer in emacs python-mode on remote host","Data Science and Machine Learning":0,"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},{"Question":"I need a method to generate 3D simplex noise in python rather quickly. What methods are there out there to solve this problem?","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":5673,"Q_Id":4467638,"Users Score":0,"Answer":"use a mod function with a suitable period. there are quite a few pages around the www explaining mod functions.\njust make sure it is also suitable for 3 dimensions, some mods that are suitable for 1 or 2 dimensions may not be suitable over 3.","Q_Score":10,"Tags":"python,noise","A_Id":4467703,"CreationDate":"2010-12-17T04:14:00.000","Title":"Generating 3D noise quickly 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},{"Question":"Which is better to use in a python automation script for following simple operations\nTo create a zip file and copy it or rename it to a new location.\nUsing python inbuilt functions or terminal commands through os.system modules is better?","AnswerCount":5,"Available Count":4,"Score":1.0,"is_accepted":false,"ViewCount":211,"Q_Id":4470302,"Users Score":11,"Answer":"The inbuilt Python modules\/ stdlib wherever you can, subprocess (os.system) where you must.\nReasons: Portability, maintenance, code readability just to name a few.","Q_Score":2,"Tags":"python","A_Id":4470327,"CreationDate":"2010-12-17T12:08:00.000","Title":"Which is better? Using inbuilt python functions or os.system commands?","Data Science and Machine Learning":0,"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},{"Question":"Which is better to use in a python automation script for following simple operations\nTo create a zip file and copy it or rename it to a new location.\nUsing python inbuilt functions or terminal commands through os.system modules is better?","AnswerCount":5,"Available Count":4,"Score":0.0798297691,"is_accepted":false,"ViewCount":211,"Q_Id":4470302,"Users Score":2,"Answer":"I would say python ones since it'll make the script portable. But sometimes, performance and availability are of concerns.","Q_Score":2,"Tags":"python","A_Id":4470324,"CreationDate":"2010-12-17T12:08:00.000","Title":"Which is better? Using inbuilt python functions or os.system commands?","Data Science and Machine Learning":0,"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},{"Question":"Which is better to use in a python automation script for following simple operations\nTo create a zip file and copy it or rename it to a new location.\nUsing python inbuilt functions or terminal commands through os.system modules is better?","AnswerCount":5,"Available Count":4,"Score":0.0798297691,"is_accepted":false,"ViewCount":211,"Q_Id":4470302,"Users Score":2,"Answer":"In general I'd say use the python libraries where possible - that way it'll be more portable, e.g. you won't need to worry about different commands or command options on various systems, and also if you need to change anything it's easier to do just python code.","Q_Score":2,"Tags":"python","A_Id":4470331,"CreationDate":"2010-12-17T12:08:00.000","Title":"Which is better? Using inbuilt python functions or os.system commands?","Data Science and Machine Learning":0,"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},{"Question":"Which is better to use in a python automation script for following simple operations\nTo create a zip file and copy it or rename it to a new location.\nUsing python inbuilt functions or terminal commands through os.system modules is better?","AnswerCount":5,"Available Count":4,"Score":0.0,"is_accepted":false,"ViewCount":211,"Q_Id":4470302,"Users Score":0,"Answer":"Using python internals command is nice, especially in terms of portability. \nBut at some point, you can be confused by lack of \"os.kill\" in Python older than 2.7 (Windows), you can be surprised by way how os.Popen is working, than you will discover win32pipe etc etc.\nPersonally I would suggest always a small research (do you need daemons etc) and then decide. If you don't need windows platform - using python's internals could be more efficient.","Q_Score":2,"Tags":"python","A_Id":4470576,"CreationDate":"2010-12-17T12:08:00.000","Title":"Which is better? Using inbuilt python functions or os.system commands?","Data Science and Machine Learning":0,"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},{"Question":"I am trying to get a decent python environment using emacs. As part of this process i want to integrate pydbgr with emacs.\nI have almost done it but with an issue. When i try to start a debugging session pydbgr does not found my modules when i try to import them.\nIf i change PYTHONPATH and then execute pydbgr from command line all works fine.\nSo my question is. IS there any way to change python environment so i can debug with pydbgr inside emacs?\nThanks in advance!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":101,"Q_Id":4471587,"Users Score":0,"Answer":"Use Emacs Lisp function setenv as in:\n(setenv \"PYTHONPATH\" \"c:\/....\")","Q_Score":2,"Tags":"python,debugging,emacs","A_Id":4471792,"CreationDate":"2010-12-17T14:47:00.000","Title":"Unable to find modules from pydbgr 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":0},{"Question":"If I were to write several classes in c++ then use swig to do the conversion so I could later use them in python, would they run faster or slower than if I completely rewrote them in python? Or is there no noticable speed difference?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":3456,"Q_Id":4476663,"Users Score":6,"Answer":"The quality and speed of wrappers generated by SWIG is very good, and they will probably perform just as good as handcrafted wrappers. \nFrom my experience, the wrappers themselves are very thin and add very little overhead to the native functions they wrap, making it a perfectly valid choice to use wrapped libraries in python or any other supported language, and is a good way to reuse code.\nhowever, to be if you are interested in performance in addition to code reuse, wrapping native code will probably only pay off if you have some computationally intensive native functions, like multiplying matrices, computing MD5 or CRC, folding proteins etc.\non the other hand, sometimes you can just rewrite everything in an easy language like python or C# and enjoy better code and better tools, with comparable performance.","Q_Score":9,"Tags":"c++,python,performance,swig","A_Id":4484174,"CreationDate":"2010-12-18T04:38:00.000","Title":"Speed of swig wrappers","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},{"Question":"I'm trying to create a configuration file for a C# app in IronPython.  Is there any way I can have that python file just return a value, or do I have to go through variables\/functions to access the results of the script?\ni.e., right now I've got Config.py that looks like\nx = \"test\"\nand C# code that goes\n\n                dynamic pyfile = Python.CreateRuntime().ExecuteFile(\"Config.py\");\n                Console.WriteLine(pyfile.x);\n\nIs there any way to remove the x?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":618,"Q_Id":4479679,"Users Score":3,"Answer":"You can create a ScriptSource with SourceCodeKind.AutoDetect and it will return the last expression in the file.","Q_Score":2,"Tags":"c#,dynamic,interop,ironpython","A_Id":4480156,"CreationDate":"2010-12-18T19:21:00.000","Title":"How to create an IronPython file that simply returns a single value to 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},{"Question":"I'm designing a distributed system where a master node starts a bunch of worker nodes on remote machines. Since I am using Python and want to take advantage of the fact each physical machine has several cores, I want to run multiple worker nodes per machine (GIL etc). Additionally, each worker node may vary quite a bit in the amount of CPU it requires each \"cycle\". I can however split the worker nodes into quite a few pieces and my initial strategy will be to spawn many more worker nodes than there are cores per machine. The reasoning being that if a few nodes require more CPU, they can occupy a core for a longer duration. (If each node was already CPU bound, it could not suddenly require more CPU.)\nThis leads me to a question: How can I accurately gauge the CPU time of a python process?\nI cannot measure the time naively, I need the time actually spent specifically for a given process. That is, for each process I want a number X, which, as accurately as possible, represents the amount of CPU resources spent exclusively on that process, regardless of unrelated processes. (I have been looking at Python's getrusage but it appears to give only 2 decimal points of precision on ubuntu, which is insufficient. EDIT: This also happens if I use getrusage() directly in C; at most 0.01 second precision. Close, but no cigar)\nMy specific use-case would be to measure the CPU time of each node cycle, from Start to End, where End happens about 0-30ms after Start.\nThe best answer would be a portable way to do this in Python. Methods that requires using C extension is fine.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":334,"Q_Id":4483182,"Users Score":1,"Answer":"The quick answer, at least for linux, is to use getrusage along with a kernel that has a higher resolution timer. \nThe reason my initial tests gave the terrible precision of 10ms was because apparently 64-bit ubuntu is configured to a 100hz timer by default.","Q_Score":4,"Tags":"python,timing","A_Id":4483416,"CreationDate":"2010-12-19T13:44:00.000","Title":"How can I accurately gauge the CPU time of a python process?","Data Science and Machine Learning":0,"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},{"Question":"I have a python script that I'd like to add to cron.\nThe script has +x permission on it.\nHow shall I add it to crontab? (say, I want it to run every minute).\nImportant: when I navigate (using the shell) to the script's folder, I cannot run it using \".\/script_name.py\"; it doesn't work. Yet, when I run it using \"Python script_name.py\", everything works.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":4736,"Q_Id":4486472,"Users Score":8,"Answer":"From cron you should be running the script as script_name.py and your script meets the following criteria:\n\nExecutable bit is set\nThe script's hash-bang is set correctly eg. #!\/usr\/bin\/env python\nit is accessible from the PATH\n\ne.g. place it in \/usr\/local\/bin\/ or \/opt\/local\/bin\/ (and they are accessible to your system PATH.)\n\n\nIf these conditions are met, you should be able to run it from anywhere on your local system as script_name.py","Q_Score":6,"Tags":"python,linux,cron,ubuntu-10.04","A_Id":4486483,"CreationDate":"2010-12-20T02:37:00.000","Title":"Running a Python Script using Cron?","Data Science and Machine Learning":0,"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},{"Question":"I'm writing a Python module in C and I intend to mmap largeish blocks of memory (perhaps 500 MB). Is there anything about working in the same process space as the Python interpreter that I should be careful of?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":140,"Q_Id":4499483,"Users Score":2,"Answer":"No, you're fine.\nOn 32-bit systems, you could run out of virtual memory, or with virtual memory fragmentation not have a single chunk big enough to map as many huge files as you want. But that pitfall isn't particular to CPython.","Q_Score":1,"Tags":"python,c,mmap,cpython,memory-mapping","A_Id":4499674,"CreationDate":"2010-12-21T12:59:00.000","Title":"mmapping in Python C modules - any pitfalls to be aware of?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I understand why interpretation overhead is expensive, but why are JITted Python implementations (Psyco and PyPy) still so much slower than other JITted languages like C# and Java?  \nEdit:  I also understand that everything is an object, dynamic typing is costly, etc.  However, for functions where types can be inferred, I'm not sure why this matters.","AnswerCount":7,"Available Count":3,"Score":1.0,"is_accepted":false,"ViewCount":878,"Q_Id":4500232,"Users Score":6,"Answer":"People have already pointed out the technical details, so I'll add another factor: money.\nIn the last few years, Javascript VMs (Google's V8, Mozilla's Tracemonkey & Jaegermonkey, Apple's Nitro) have delivered a huge speed increase for another dynamic language. That's been driven in large part by Google's desire to make web apps more powerful. Python just doesn't have a big company standing to gain by making it 50x faster.\nOh, and the integration with C extensions like numpy means that speed is rarely critical for Python code, anyway.","Q_Score":15,"Tags":"c#,java,python,performance,jit","A_Id":4500536,"CreationDate":"2010-12-21T14:20:00.000","Title":"Why are JITted Python implementations still 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},{"Question":"I understand why interpretation overhead is expensive, but why are JITted Python implementations (Psyco and PyPy) still so much slower than other JITted languages like C# and Java?  \nEdit:  I also understand that everything is an object, dynamic typing is costly, etc.  However, for functions where types can be inferred, I'm not sure why this matters.","AnswerCount":7,"Available Count":3,"Score":0.0285636566,"is_accepted":false,"ViewCount":878,"Q_Id":4500232,"Users Score":1,"Answer":"A really good question. I can't give you a complete answer, but I think one of the reasons is the \"everything is objects and an object could be anything\" concept. In Java, if you try \"1.getClass()\", it won't work unless you box it first, either explicitly or implicitly. In Python, it works out of the box. But objects are definitely more heavyweight than primitive types, which Python just doesn't seem to have.\nThe \"an object can be anything\" part is even more important. If you write \"someobject.somefield\" in Java, it knows at compile time what exactly is \"somefield\" and generates code that accesses it directly. Well, there are probably some tricks to give better binary compatibility, but that's nothing like Python, where it actually performs some sort of dictionary look-up at run time to figure out what exactly is \"somefield\" at that particular moment, as fields can be added and deleted dynamically.\nTo put it short, Python is more powerful, but that power has its cost.","Q_Score":15,"Tags":"c#,java,python,performance,jit","A_Id":4500345,"CreationDate":"2010-12-21T14:20:00.000","Title":"Why are JITted Python implementations still 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},{"Question":"I understand why interpretation overhead is expensive, but why are JITted Python implementations (Psyco and PyPy) still so much slower than other JITted languages like C# and Java?  \nEdit:  I also understand that everything is an object, dynamic typing is costly, etc.  However, for functions where types can be inferred, I'm not sure why this matters.","AnswerCount":7,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":878,"Q_Id":4500232,"Users Score":0,"Answer":"The whole issue is not so clear anymore in 2014. Google's V8 JS engine does some pretty heavy stuff to optimize the hell out of js.\nPyPy could be much faster if only enough money would be available. Python's execution speed mostly does not matter so nobody heavily invests in PyPy.\nIt's really not a technical issue anymore. Look at Java's InvokeDynamic instruction. Sure, those invocations cost more the first time they are called, but the JVM can do magic stuff once those invocations start to start up. That is: The JVM can do assumptions and can learn about the code while running it. If a method always returns an int, it's possible that this method always returns an int. In reality the JVM does much more.\nIn 2014 it's really not dynamic vs static in terms of performance. Sure C++ will always be the fastest tool around, but jitted dynamic languages are not \"magnitudes\" slower as they used to be a few years ago.\nWait a few more years, I bet static analysis is much stronger in 2016 or 2017. There are a few very interesting research projects running right now.\nIn Theory:\nYou can basically infer every type using static type analysis, you have to understand what the code is doing before it does it. That's not impossible.\nWhen static analysis becomes more powerful, you really do not need a static type system anymore. All static type systems, even haskell's, limit the number of correct programs. So in essence: If you have an analyzer which can proof the correctness of a program by analyzing it is much more powerful as a static type system which only can act within boundaries. And concerning code re-usage: Nothing can beat dynamic typing.\nThere are a few who would say that dynamic typing is bad for large applications but if static analysis becomes more powerful, you would actually have the same or maybe much more proven correctness as a static type system could ever offer. Of course statically typed languages could also be statically analyzed, but than the static type system would be useless.\nSo in essence: Here are a lot of if's, i know. But 10 years ago people would have laughed if you would have told them that js becomes the so fast, that you could easily write heavy 3d opengl applications in it.\nNever underestimate the future.","Q_Score":15,"Tags":"c#,java,python,performance,jit","A_Id":23262554,"CreationDate":"2010-12-21T14:20:00.000","Title":"Why are JITted Python implementations still 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},{"Question":"What is the fastest\/most efficient method to execute an executable from python?  It seems to me that os.system is faster than subprocess.popen.   I would like to be able to read the lines that come out of this other process, but far more important than anything else is speed.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":2379,"Q_Id":4502469,"Users Score":4,"Answer":"I would expect any speed difference between, say, os.system and os.execv and subprocess.Popen, to be swamped by the expense of starting a new process (and the context-switching needed to actually run it). Therefore I recommend using subprocess first and measuring the performance.\nOne possible performance consideration: os.system and subprocess.Popen(shell=True, ...) cause an extra shell process to be created. In most cases, that shell isn't necessary. It's wasteful to create it; you get twice as many processes as you need for no benefit.","Q_Score":3,"Tags":"python,linux,subprocess","A_Id":4502661,"CreationDate":"2010-12-21T18:11:00.000","Title":"fastest way to invoke a process 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},{"Question":"I'm looking to implement a shared configuration file that will be written (output) in python, but be read (input) in C.\nThe only prerequisite of this configuration file is that it can't be human readable.\nAnyone have any suggestions on what file format I should use for this project?\nEdit:  The file can't be human readable because we don't want the user to be able to modify the configuration, also, in some cases, we don't want the user to know about certain configurations.","AnswerCount":4,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":754,"Q_Id":4504470,"Users Score":0,"Answer":"Use a plain human readable format such as XML, and then obfuscate that to make it uneditable (i.e. encrypt the whole thing and store a hash somewhere and fail to load if its' been messed with).\nOtherwise you just have to bite the bullet and write a spec for the binary format that'll be exchanged between the two programs.","Q_Score":2,"Tags":"c++,python,c,configuration-files","A_Id":4504547,"CreationDate":"2010-12-21T22:16:00.000","Title":"Shared configuration file format between python and 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},{"Question":"I'm looking to implement a shared configuration file that will be written (output) in python, but be read (input) in C.\nThe only prerequisite of this configuration file is that it can't be human readable.\nAnyone have any suggestions on what file format I should use for this project?\nEdit:  The file can't be human readable because we don't want the user to be able to modify the configuration, also, in some cases, we don't want the user to know about certain configurations.","AnswerCount":4,"Available Count":3,"Score":0.049958375,"is_accepted":false,"ViewCount":754,"Q_Id":4504470,"Users Score":1,"Answer":"Probably easiest to use XML, then obfuscate it with a simple cypher or encryption with a fixed key.","Q_Score":2,"Tags":"c++,python,c,configuration-files","A_Id":4504538,"CreationDate":"2010-12-21T22:16:00.000","Title":"Shared configuration file format between python and 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},{"Question":"I'm looking to implement a shared configuration file that will be written (output) in python, but be read (input) in C.\nThe only prerequisite of this configuration file is that it can't be human readable.\nAnyone have any suggestions on what file format I should use for this project?\nEdit:  The file can't be human readable because we don't want the user to be able to modify the configuration, also, in some cases, we don't want the user to know about certain configurations.","AnswerCount":4,"Available Count":3,"Score":0.0996679946,"is_accepted":false,"ViewCount":754,"Q_Id":4504470,"Users Score":2,"Answer":"How secure do you need this config file to be?\nThere is no absolute security, you'll quickly run into DRM like issues (allow users to open a file but not allow them to open it ... I know it's insane).\nOften simple obfuscation is quite effective.  Dump the config to a JSON file (please don't use xml).  XOR the contents and change the extension.  That will stop all casual inspection of the file.  Obviously don't document that this is your obfuscation procedure.\nIf you're worried about user modification of config files (you don't care if the configs are readable you just want prevent loading custom configs) use a cryptographic signature.  Store the private key at your company and use it and the python app to generate a signed configuration.  Store the public key in the c++ application and use it to verify the config is properly signed before applying the settings.","Q_Score":2,"Tags":"c++,python,c,configuration-files","A_Id":4505256,"CreationDate":"2010-12-21T22:16:00.000","Title":"Shared configuration file format between python and 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},{"Question":"is there a way to get the date of friendship creation for both my friends and followers in twitter?\nespecially for python-twitter....","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":316,"Q_Id":4517265,"Users Score":3,"Answer":"Twitter doesn't preserve the date a friendship or follow is created, and it doesn't return it in  the API. Going forward you can query friends\/ids and followers\/id every day and record any new relationships with the current date in a database.","Q_Score":1,"Tags":"python,twitter,python-twitter","A_Id":4518740,"CreationDate":"2010-12-23T09:11:00.000","Title":"can i get date of friendship 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},{"Question":"I need a python library or module or whatever that can compare a .wav file to microphone input without too too much code. Sample code would be cool too. TY!","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1653,"Q_Id":4522964,"Users Score":0,"Answer":"If you're trying to compare something like, what words people are saying, this would have to be a fairly complex piece of code. You could directly compare them at a frequency\/wave level, but you'll very rarely if ever get a match.","Q_Score":0,"Tags":"python,audio,comparison,wav","A_Id":4523066,"CreationDate":"2010-12-23T22:36:00.000","Title":"python library to compare a .wav with mic input?","Data Science and Machine Learning":0,"Database and SQL":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},{"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},{"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},{"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},{"Question":"I am building a GAE site that uses AJAX\/JSON for almost all its tasks including building the UI elements, all interactions and client-server requests. What is a good way to test it for highloads so that I could have some statistics about how much resources 1000 average users per some period of time would take. I think I can create some Python functions for this purpose. What can you advise? Thanks.","AnswerCount":4,"Available Count":2,"Score":0.049958375,"is_accepted":false,"ViewCount":193,"Q_Id":4529913,"Users Score":1,"Answer":"You can get a free linux micro instance from EC2 and then run ab (apache benchmark) with lots of requests.  You can change number of requests, concurrent requests and you can even launch multiple EC2 instances from different data centers.","Q_Score":2,"Tags":"python,google-app-engine,load-testing","A_Id":4536343,"CreationDate":"2010-12-25T09:37:00.000","Title":"How to test my GAE site for 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":1},{"Question":"I am building a GAE site that uses AJAX\/JSON for almost all its tasks including building the UI elements, all interactions and client-server requests. What is a good way to test it for highloads so that I could have some statistics about how much resources 1000 average users per some period of time would take. I think I can create some Python functions for this purpose. What can you advise? Thanks.","AnswerCount":4,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":193,"Q_Id":4529913,"Users Score":0,"Answer":"If you have the budget for it, a professional load testing tool will save you a lot of time and produce more accurate results.  Some of those tools handle AJAX apps better than others. I will naturally recommend our product (Web Performance Load Tester) and one of our engineers will help you get it working with your site. You should, of course, evaluate other products to see what works best for your site. Load Impact and Browser Mob are online services that in many cases handle AJAX better than the more traditional tools (except ours!), but they also have downsides.","Q_Score":2,"Tags":"python,google-app-engine,load-testing","A_Id":4547737,"CreationDate":"2010-12-25T09:37:00.000","Title":"How to test my GAE site for 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":1},{"Question":"I've checked so many articles, but can't find one for server to server email receiving. I want to write a program or some code just acts as an email receiver, not SMTP server or something else.\nLet's suppose I have a domain named example.com, and a gmail user user@gmail.com sends me an email to admin@example.com, or a yahoo user user@yahoo.com sends me an email to test@example.com. Now, what do I do to receive this email? I prefer to write this code in Python or Perl.\nRegards,\nDavid","AnswerCount":4,"Available Count":1,"Score":0.049958375,"is_accepted":false,"ViewCount":2845,"Q_Id":4530323,"Users Score":1,"Answer":"\"reveive\" is not a word. I'm really not sure if you mean \"receive\" or \"retrieve\". \nIf you mean \"receive\" then you probably do want an SMTP server, despite your claim. An SMTP server running on a computer is responsible for listening for network requests from other SMTP servers that wish to deliver mail to that computer.\nThe SMTP server then, typically, deposits the mail in a directory where it can be read by the recipient. They can usually be configured (often in combination with tools such as Procmail) to do stuff to incoming email (such as pass it to a program for manipulation along the way, this allows you to avoid having to write a full blown SMTP server in order to capture some emails).\nIf, on the other hand,  you mean \"retrieve\", then you are probably looking to find a library that will let your program act as an IMAP or POP client. These protocols are used to allow remote access to a mailbox.","Q_Score":1,"Tags":"python,perl,email","A_Id":4530368,"CreationDate":"2010-12-25T12:58:00.000","Title":"How to receive an email on server? Better using Python or Perl","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},{"Question":"Coming from a Matlab background, I wanted to write small functions in python, and test them individually in the interpreter. However, every time I start the interpreter, I have to import all the modules. In contrast, with matlab all you do is give it the path to the directory and you can execute any matlab function through the interpreter without worrying what to import. \nIs there any way the python interpreter could do this?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":890,"Q_Id":4530763,"Users Score":0,"Answer":"I also consider myself a MATLAB user who is converting to Python.  \"ipython -pylab\" (from a unix shell or mac terminal shell) does a pretty good job of setting up the variables and functions I use for MATLAB-type computing.  \nAlso - although I found it a pain to install on my mac - I like Spyder for its resemblance to the MATLAB IDE.  In the Spyder environment - as in MATLAB - you can run scripts (.py files as compared to the .m files in MATLAB) in the interactive window, which can perform the imports.  Then you can type interactively into the window, using the functions you imported.  As compared to \"ipython -pylab\" and autoimport, this will allow you to only import the functions\/variables that you desire and keep your workspace uncluttered.  For now, this may not be of interest, but eventually it could come in handy.","Q_Score":4,"Tags":"python,matlab,module,import","A_Id":4531603,"CreationDate":"2010-12-25T16:21:00.000","Title":"Automatically import all modules in the current directory into python interactive 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":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to come up with a good coding problem to ask interview candidates to solve with Python.\nThey'll have an hour to work on the problem, with an IDE and access to documentation (we don't care what people have memorized). \nI'm not looking for a tough algorithmic problem - there are other sections of the interview where we do that kind of thing. The point of this section is to sit and watch them actually write code. So it should be something that makes them use just the data structures which are the everyday tools of the application developer - lists, hashtables (dictionaries in Python), etc, to solve a quasi-realistic task. They shouldn't be blocked completely if they can't think of something really clever.\nWe have a problem which we use for Java coding tests, which involves reading a file and doing a little processing on the contents. It works well with candidates who are familiar with Java (or even C++). But we're running into a number of candidates who just don't know Java or C++ or C# or anything like that, but do know Python or Ruby. Which shouldn't exclude them, but leaves us with a dilemma: On the one hand, we don't learn much from watching someone struggle with the basics of a totally unfamiliar language. On the other hand, the problem we use for Java turns out to be pretty trivial in Python (or Ruby, etc) - anyone halfway competent can do it in 15 minutes. So, I'm trying to come up with something better.\nSurprisingly, Google doesn't show me anyone doing something like this, unless I'm just too dumb to enter the obvious search term. The best idea I've come up with involves scheduling workers to time slots, but it's maybe a little too open-ended. Have you run into a good example? Or a bad one? Or do you just have an idea?","AnswerCount":5,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":46812,"Q_Id":4536195,"Users Score":0,"Answer":"I don't know about Python specifically, but I found that interview questions which involve recursion are a very effective filter. I have asked candidates to produce all the permutations of a string (and think about how to test it), and I have been asked to pseudo-code the Longest Common Subsequence.","Q_Score":19,"Tags":"python","A_Id":4536240,"CreationDate":"2010-12-27T01:33:00.000","Title":"Python coding test problem for interviews","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":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},{"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},{"Question":"I spend most of my time programming in Python, so forgive me if my approach to this problem is short-sited:\nI want to have certain methods of a class require login credentials. Simply, each method should check whether the class variable user is set, and if so, continue, but if not, spit out a \"you need to login\" message.\nIn Python, I would just write a decorator to do this. How can I accomplish the same thing in java with as little redundant code as possible?\nThanks!","AnswerCount":3,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":12568,"Q_Id":4551457,"Users Score":8,"Answer":"The simplest thing to do is to write a method like \"assertCredentials\" and call that method at the start of every method that needs credentials. If credentials are not set, the method should throw an exception, which will abort the parent method.\nJava has annotations that can be used to decorate methods, etc., but I don't think using annotations in this case would simplify things.","Q_Score":27,"Tags":"java,python","A_Id":4551485,"CreationDate":"2010-12-29T04:22:00.000","Title":"Python-like decorators 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":1},{"Question":"I've done a lot of web development in JSP\/JSF, and lately quite a lot in ASP.NET.\nI would like to learn one of the following: ruby\/python\/php, for quick and simple projects.\nI don't really care which one it is as long as it meets following demands:\n  - decent IDE (forget the notepad\/pspad etc.), something with code completition (like eclipse\/visual studio\/netbeans)\n  - it has to be able to run on windows (IDE and environment)\nThanks for suggestions\nCheers","AnswerCount":5,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1531,"Q_Id":4561909,"Users Score":0,"Answer":"PHP and use codecanyon.net to get things up and running quick. I got INRtracker.com running in under 2 months with what I just mentioned. \nIf you're going to use php, then get wamp and then after you install it, restart your computer. Then click on the Wampserver short cut on your desktop to start it up and then click on the icon in the bottom right of your desktop (you might have to click a little arrow) and then click start all services, then you can put php files in your wamp\/www folder (you should be able to get to that from your C drive). Then you test them by going to http:\/\/localhost\/filename.php in your browser. Have fun dude!","Q_Score":0,"Tags":"php,python,ruby","A_Id":11289391,"CreationDate":"2010-12-30T10:39:00.000","Title":"From asp.net to python\/ruby\/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":1},{"Question":"I have an application I wrote in PHP (on symfony) that imports large CSV files (up to 100,000 lines). It has a real memory usage problem. Once it gets through about 15,000 rows, it grinds to a halt.\nI know there are measures I could take within PHP but I'm kind of done with PHP, anyway.\nIf I wanted to write an app that imports CSV files, do you think there would be any significant difference between Ruby and Python? Is either one of them geared to more import-related tasks? I realize I'm asking a question based on very little information. Feel free to ask me to clarify things, or just speak really generally.\nIf it makes any difference, I really like Lisp and I would prefer the Lispier of the two languages, if possible.","AnswerCount":4,"Available Count":1,"Score":0.049958375,"is_accepted":false,"ViewCount":959,"Q_Id":4571119,"Users Score":1,"Answer":"I think the problem is that you are loading the csv in memory at once. If that is the case then I am sure that also python\/ruby is going to blow up on you. I am a big fan of python, but that is just a personal opinion.","Q_Score":2,"Tags":"php,python,ruby,import,lisp","A_Id":4571760,"CreationDate":"2010-12-31T16:23:00.000","Title":"Ruby or Python for heavy import 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},{"Question":"I have written a python script to draw the sierpinski gasket using Tkinter and when run from the python IDLE the program takes about half the time it takes to run when run from bash. I timed the script using them time module in python. Any ideas as to why this is happening will be appreciated. thanks","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":830,"Q_Id":4573094,"Users Score":0,"Answer":"Rafe is likely correct - you can test this out by limiting your imports and seeing if that makes a difference in startup time. I.e., if you are doing\nfrom Tkinter import *\nthen change that to import only the modules you actually need. Or write a quick null program that just sets up and tears down without using anything in the package - that should run pretty close to the same in both.","Q_Score":0,"Tags":"python","A_Id":4573124,"CreationDate":"2011-01-01T03:30:00.000","Title":"running python script in bash slower than running code in 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},{"Question":"I have written a python script to draw the sierpinski gasket using Tkinter and when run from the python IDLE the program takes about half the time it takes to run when run from bash. I timed the script using them time module in python. Any ideas as to why this is happening will be appreciated. thanks","AnswerCount":2,"Available Count":2,"Score":0.1973753202,"is_accepted":false,"ViewCount":830,"Q_Id":4573094,"Users Score":2,"Answer":"It's because of the way you're passing it. Based on your comment on the other answer, you're using python -c, and in IDLE you're using the Run command (or something similar). I'm not aware of any performance issues with python -c, but using Run in IDLE to run somescript.py is equivalent to python somescript.py.\nYou really should run scripts using python -c, it's more for small snippets.","Q_Score":0,"Tags":"python","A_Id":4573147,"CreationDate":"2011-01-01T03:30:00.000","Title":"running python script in bash slower than running code in 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},{"Question":"I want to create a somehow complex application:\nIt is a game level editor. You can put in tiles and other objects for a level. Then \"compress\" the level data into a file.\nWith another application, it will read the file's data and play the game.\nThe application is for Windows mainly. Other platforms are yet to be considered.\nSo I need help deciding:\nIf you were to do something like what I described, which programming language would you choose?\nI want to decide between Ruby or Python.\nI want you to help me choose depending on my following needs:\n\nEasy GUI platform for making the editor.\nCan show sprites, move, transform them etc.\nCan play audio.\nCan compress data, graphics and audio. The compressed file can only be read by another application I make.","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":955,"Q_Id":4577156,"Users Score":1,"Answer":"I've never used Ruby but I'm sure there is virtually no difference between the 2 when it comes to libraries.  I know what you want can be done with Python using wxPython or pygame (or the combination of two).  But I'm sure there are similar libs for Ruby.  So just look at both languages and use the one you like better.","Q_Score":0,"Tags":"python,ruby,user-interface","A_Id":4577169,"CreationDate":"2011-01-02T04:38:00.000","Title":"Making a somehow complex application: Ruby vs 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":0,"Web Development":1},{"Question":"I want to create a somehow complex application:\nIt is a game level editor. You can put in tiles and other objects for a level. Then \"compress\" the level data into a file.\nWith another application, it will read the file's data and play the game.\nThe application is for Windows mainly. Other platforms are yet to be considered.\nSo I need help deciding:\nIf you were to do something like what I described, which programming language would you choose?\nI want to decide between Ruby or Python.\nI want you to help me choose depending on my following needs:\n\nEasy GUI platform for making the editor.\nCan show sprites, move, transform them etc.\nCan play audio.\nCan compress data, graphics and audio. The compressed file can only be read by another application I make.","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":955,"Q_Id":4577156,"Users Score":4,"Answer":"Python + PyGame. Hands down. You will benefit from:\n\nGood docs for both the language and PyGame\nGUI, sprites, and audio all in one, again with PyGame\nBetter Windows support than Ruby (you can install both Python and PyGame from .exes)\n\nDesktop applications (esp. for Windows) aren't really Ruby's sweet spot. PyGame will serve your purposes perfectly, though.\nThat's not to say you couldn't do it with Ruby; you could write this in any language. But for ease of use, Python is the way to go.","Q_Score":0,"Tags":"python,ruby,user-interface","A_Id":4577168,"CreationDate":"2011-01-02T04:38:00.000","Title":"Making a somehow complex application: Ruby vs 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":0,"Web Development":1},{"Question":"I'd like to try my hand at some PC game development.  I keep hearing that python is slow compared to C++.  Is this something I should be worried about?  \nI am more familiar with python than C++.  If I'm looking to make some games, should I take the time to learn C++ or just stick with Python?","AnswerCount":5,"Available Count":4,"Score":0.1586485043,"is_accepted":false,"ViewCount":13393,"Q_Id":4578307,"Users Score":4,"Answer":"The kind of game matters immensely. High performance games like the big name PC or console games are almost exclusively the domain of C++.\nCasual games can be written in almost any language, including slower languages like Python.\nIf you're a garage type developer who gets his hands wet with some simple game development for this first time, Python would be more than enough. If you however have the ambition to work for a game developer studio, I would definitely recommend learning C++.","Q_Score":8,"Tags":"python,performance","A_Id":4578373,"CreationDate":"2011-01-02T12:15:00.000","Title":"How \"slow\" is python for game development?","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},{"Question":"I'd like to try my hand at some PC game development.  I keep hearing that python is slow compared to C++.  Is this something I should be worried about?  \nI am more familiar with python than C++.  If I'm looking to make some games, should I take the time to learn C++ or just stick with Python?","AnswerCount":5,"Available Count":4,"Score":1.0,"is_accepted":false,"ViewCount":13393,"Q_Id":4578307,"Users Score":6,"Answer":"Elebenty-seven.\nNo, really, it's fast enough for most things, and can drop to C when you really need speed. Profile twice, optimize once.","Q_Score":8,"Tags":"python,performance","A_Id":4578311,"CreationDate":"2011-01-02T12:15:00.000","Title":"How \"slow\" is python for game development?","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},{"Question":"I'd like to try my hand at some PC game development.  I keep hearing that python is slow compared to C++.  Is this something I should be worried about?  \nI am more familiar with python than C++.  If I'm looking to make some games, should I take the time to learn C++ or just stick with Python?","AnswerCount":5,"Available Count":4,"Score":-0.1194272985,"is_accepted":false,"ViewCount":13393,"Q_Id":4578307,"Users Score":-3,"Answer":"C++ is much more easier for object orientation.  When you're doing things, it's easier to keep track of everything, because most IDEs for C++ are more based on projects, were as IDLE is more based on single files.  \nThe bottom line is for game development, use what you're comfortable with using.  I mean, game development is about what you want to do, not what would be better, because better == what you want.","Q_Score":8,"Tags":"python,performance","A_Id":15419304,"CreationDate":"2011-01-02T12:15:00.000","Title":"How \"slow\" is python for game development?","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},{"Question":"I'd like to try my hand at some PC game development.  I keep hearing that python is slow compared to C++.  Is this something I should be worried about?  \nI am more familiar with python than C++.  If I'm looking to make some games, should I take the time to learn C++ or just stick with Python?","AnswerCount":5,"Available Count":4,"Score":0.0798297691,"is_accepted":false,"ViewCount":13393,"Q_Id":4578307,"Users Score":2,"Answer":"Many if not most top-end commercial games these days include some kind of scripting engine for game logic. Game logic decisions, for the most part, aren't particularly performance-sensitive in the way that e.g. the rendering engine is.\nBTW - I'm not claiming any insider knowledge of game development - this is fairly well known outside the industry. Some games publishers have even allowed users access to the scripting stuff and other tools for games modding - for years.\nIf you find a game engine that is wrapped to be used in Python, you'll be dealing with the same basic principles. Write the game logic in Python, and you'll probably be fine.\nPyGame is basically SDL wrapped for Python, supporting basic 2D games for the most part (though OpenGL can be used for 3D in SDL - not sure for PyGame).\nIt's a good starting point. You may hit a performance issue with managing your game objects and running your blit loop, since only very basic graphics stuff is handled by SDL, but you should find that it's just fine for most things.\nAs Ignacio implies - worry about performance problems when you know you have performance problems, not before. Some performance problems are predictable in advance, but if you're not writing the actual game engine in Python, you should be OK - don't fall into the premature optimisation trap, IOW.","Q_Score":8,"Tags":"python,performance","A_Id":4578381,"CreationDate":"2011-01-02T12:15:00.000","Title":"How \"slow\" is python for game development?","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},{"Question":"I need to scrape about 100 websites that are very similar in the content that they provide.\nMy first doubt. Should be possible to write a generic script to scrape all the 100 websites or in scraping techniques is only possible to write scripts for particular websites. (Dumb question.). I think I should ask what possibility is easier. Write 100 different scripts for each website is hard.\nSecond question. My primary language is PHP, but after searching here on Stackoverflow I found that one of the most advanced scrapers is \"Beautiful Soup\" in Python. Should be possible to make calls in PHP to \"Beautiful Soup\" in Python? Or should be better to do all the script in Python?\nGive me some clues on how should I go.\nSorry for my weak english.\nBest Regards,","AnswerCount":4,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":4219,"Q_Id":4585490,"Users Score":0,"Answer":"We do something sort of like this with RSS feeds using Python -- we use ElementTree since RSS is usually guaranteed to be well-formed.  Beautiful Soup is probably better suited for parsing HTML.\nInsofar as dealing with 100 different sites, try to write an abstraction that works on most of them and transforms the page into a common data-structure you can work with.  Then override parts of the abstraction to handle individual sites which differ from the norm.\nScrapers are usually I\/O bound -- look into coroutine libraries like eventlet or gevent to exploit some I\/O parallelism and speed up the whole process.","Q_Score":3,"Tags":"php,python,screen-scraping","A_Id":4586678,"CreationDate":"2011-01-03T14:59:00.000","Title":"Webscraping Techniques using PHP or 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},{"Question":"I need to scrape about 100 websites that are very similar in the content that they provide.\nMy first doubt. Should be possible to write a generic script to scrape all the 100 websites or in scraping techniques is only possible to write scripts for particular websites. (Dumb question.). I think I should ask what possibility is easier. Write 100 different scripts for each website is hard.\nSecond question. My primary language is PHP, but after searching here on Stackoverflow I found that one of the most advanced scrapers is \"Beautiful Soup\" in Python. Should be possible to make calls in PHP to \"Beautiful Soup\" in Python? Or should be better to do all the script in Python?\nGive me some clues on how should I go.\nSorry for my weak english.\nBest Regards,","AnswerCount":4,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":4219,"Q_Id":4585490,"Users Score":0,"Answer":"I've done this a few ways.\n1: with grep, sed, and awk. This is about the same as 2: regex. These methods are very direct, but fail whenever the HTML structure of the site changes.\n3: PHP's XML\/HTML parser DomDocument. This is far more reliable than regex, but I found it annoying to work with (I hate the mixture of PHP arrays and objects). If you want to use PHP, PHPQuery is probably a good solution, as Thai suggested.\n4: Python and BeautifulSoup. I can't say enough good things about BeautifulSoup, and this is the method I recommend. I found my code feels cleaner in Python, and BeautifulSoup was very easy and efficient to work with. Good documentation, too.\nYou will have to specialize your script for each site. It depends on what sort of information you wish to extract. If it was something standard like body title, of course you wouldn't have to change anything, but it's likely the info you want is more specific?","Q_Score":3,"Tags":"php,python,screen-scraping","A_Id":4585784,"CreationDate":"2011-01-03T14:59:00.000","Title":"Webscraping Techniques using PHP or 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},{"Question":"I am trying to send an email using python that has the standard To From, body, etc. However this is where my question comes in. My python script takes information in a string and manipulates it(adds,removes, formats, etc) I am trying to take this output and send it as an attachment on-the-fly. I know I can dump the output to a text file and then attach it to the email. However, due to the security of this CGI script I cannot write to the CGI directory. Is there a way to dynamically create a textfile object and send it as an attachment?\nUsing Python SMTP module.\nI cannot create a traditional static text file due to permissions. I would like to see if Python is able to create a text file upon execution that i can populate with data and then attach to the email smtp module.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":566,"Q_Id":4598204,"Users Score":0,"Answer":"Are you using smtplib and email.mime.multipart modules? the attach() method of the MIMEMultipart class accepts chunk of data to be attached, not a file.","Q_Score":1,"Tags":"python,email,text,cgi,attachment","A_Id":4598568,"CreationDate":"2011-01-04T20:40:00.000","Title":"python CGI email dynamic output as a text file attachment","Data Science and Machine Learning":0,"Database and SQL":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},{"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},{"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},{"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},{"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},{"Question":"I wrote a python script to monitor a log file on a CentOS server for a specific value and send an email when it finds it.  It runs as a cron every 5 minutes.\nMy question is what is the best way to put this script to sleep after it has sent the first email.  I don't want it to be sending emails every 5 mins, but it needs to wake up and check the log again after an hour or so.  This is assuming the problem can be fixed in under an hour.  The people who are receiving the email don't have shell access to disable the cron.\nI thought about sleep but I'm not sure if cron will try to run the script again if another process is active (sleeping).","AnswerCount":6,"Available Count":4,"Score":0.1325487884,"is_accepted":false,"ViewCount":1999,"Q_Id":4607343,"Users Score":4,"Answer":"cron will absolutely  run the script again.  You need to think this through a little more carefully than just \"sleep\" and \"email every 10 minutes.\"\nYou need to write out your use cases.\n\nSystem sends message and user does something.\nSystem sends message and user does nothing.  Why email the user again?  What does 2 emails do that 1 email didn't do?  Perhaps you should SMS or email someone else.  \n\nHow does the user register that something was done?  How will they cancel or stop this cycle of messages?\nWhat if something is found in the log, an email is sent and then (before the sleep finishes) the thing is found again in the log.  Is that a second email?  It is two incidents.  Or is that one email with two incidents?","Q_Score":1,"Tags":"python,cron","A_Id":4607368,"CreationDate":"2011-01-05T17:46:00.000","Title":"How to sleep a python script running as a cronjob?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I wrote a python script to monitor a log file on a CentOS server for a specific value and send an email when it finds it.  It runs as a cron every 5 minutes.\nMy question is what is the best way to put this script to sleep after it has sent the first email.  I don't want it to be sending emails every 5 mins, but it needs to wake up and check the log again after an hour or so.  This is assuming the problem can be fixed in under an hour.  The people who are receiving the email don't have shell access to disable the cron.\nI thought about sleep but I'm not sure if cron will try to run the script again if another process is active (sleeping).","AnswerCount":6,"Available Count":4,"Score":0.0333209931,"is_accepted":false,"ViewCount":1999,"Q_Id":4607343,"Users Score":1,"Answer":"When your scripts sends email, make it also create a txt file \"email_sent.txt\". Then make it check for existence of this txt file before sending email. If it exists, don't send email. If it does not exist, send email and create the text file.\nThe text files serves as an indicator that email has already been sent and it does not need to be sent again.","Q_Score":1,"Tags":"python,cron","A_Id":4608337,"CreationDate":"2011-01-05T17:46:00.000","Title":"How to sleep a python script running as a cronjob?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I wrote a python script to monitor a log file on a CentOS server for a specific value and send an email when it finds it.  It runs as a cron every 5 minutes.\nMy question is what is the best way to put this script to sleep after it has sent the first email.  I don't want it to be sending emails every 5 mins, but it needs to wake up and check the log again after an hour or so.  This is assuming the problem can be fixed in under an hour.  The people who are receiving the email don't have shell access to disable the cron.\nI thought about sleep but I'm not sure if cron will try to run the script again if another process is active (sleeping).","AnswerCount":6,"Available Count":4,"Score":1.2,"is_accepted":true,"ViewCount":1999,"Q_Id":4607343,"Users Score":3,"Answer":"@Lennart, @S. Lott: I think the question was somewhat the other way around - the script runs as a cron job every five minutes, but after sending an error-email it shouldn't send another for at least an hour (even if the error state persists).\nThe obvious answer, I think, is to save a self-log - for each problem detected, an id and a timestamp for the last time an email was sent. When a problem is detected, check the self-log; if the last email for this problem-id was less than an hour ago, don't send the email. Then your program can exit normally until called again by cron.","Q_Score":1,"Tags":"python,cron","A_Id":4607608,"CreationDate":"2011-01-05T17:46:00.000","Title":"How to sleep a python script running as a cronjob?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I wrote a python script to monitor a log file on a CentOS server for a specific value and send an email when it finds it.  It runs as a cron every 5 minutes.\nMy question is what is the best way to put this script to sleep after it has sent the first email.  I don't want it to be sending emails every 5 mins, but it needs to wake up and check the log again after an hour or so.  This is assuming the problem can be fixed in under an hour.  The people who are receiving the email don't have shell access to disable the cron.\nI thought about sleep but I'm not sure if cron will try to run the script again if another process is active (sleeping).","AnswerCount":6,"Available Count":4,"Score":0.0,"is_accepted":false,"ViewCount":1999,"Q_Id":4607343,"Users Score":0,"Answer":"You are running it every five minutes. Why would you sleep it? Just exit. If you want to make sure it doesn't send email every five minutes, then make the program only send an email if there is anything to send. \nIf you sleep it for an hour, and run it every five minutes, after an hour you'll have 12 copies running (and twelve emails sent) so that's clearly not the way to go forward. :-)","Q_Score":1,"Tags":"python,cron","A_Id":4607451,"CreationDate":"2011-01-05T17:46:00.000","Title":"How to sleep a python script running as a cronjob?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"How can I access the SMS inbox from an application (on Symbian s60)? Us it possible with j2me? How about C++ or Python?","AnswerCount":3,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":939,"Q_Id":4609956,"Users Score":2,"Answer":"Reading message from inbox in j2me is not possible\nif you want to read sms then you can send message using particular port and\nyour j2me application should listen on that port\notherwise you can go with symbian c++ where it is possible.","Q_Score":2,"Tags":"c++,python,java-me,symbian,inbox","A_Id":4612488,"CreationDate":"2011-01-05T22:43:00.000","Title":"access to sms inbox","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"How can I access the SMS inbox from an application (on Symbian s60)? Us it possible with j2me? How about C++ or Python?","AnswerCount":3,"Available Count":2,"Score":0.1325487884,"is_accepted":false,"ViewCount":939,"Q_Id":4609956,"Users Score":2,"Answer":"In j2me, you can't access the native message box related stuff like Inbox, Sent Message or etc. But it is possible in c++. I don't know about python.","Q_Score":2,"Tags":"c++,python,java-me,symbian,inbox","A_Id":4611971,"CreationDate":"2011-01-05T22:43:00.000","Title":"access to sms inbox","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I want to write a (preferably python) script to modify the content of one file in a gzipped tar file. The script must run on FreeBSD 6+.\nBasically, I need to:\n\nopen the tar file\nif the tar file has _MY_FILE_ in it:\n\nif _MY_FILE_ has a line matching \/RE\/ in it:\ninsert LINE after the matching line\n\nrewrite the content into the tar file, preserving all metadata except the file size\n\nI'll be repeating this for a lot of files.\nPython's tarfile module doesn't seem to be able to open tar files for read\/write access when they're compressed, which makes a certain amount of sense. However, I can't find a way to copy the tar file with modifications, either.\nIs there an easy way to do this?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":6217,"Q_Id":4610205,"Users Score":5,"Answer":"Don't think of a tar file as a database that you can read\/write -- it's not.  A tar file is a concatenation of files.  To modify a file in the middle, you need to rewrite the rest of the file.  (for files of a certain size, you might be able to exploit the block padding)\nWhat you want to do is process the tarball file by file, copying files (with modifications) into a new tarball.  The Python tarfile module should make this easy to do.  You should be able to retain the attributes by copying them from the old TarInfo object to the new one.","Q_Score":2,"Tags":"python,scripting,automation,tar","A_Id":4610327,"CreationDate":"2011-01-05T23:15:00.000","Title":"How can I modify a file in a gzipped tar 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},{"Question":"Can the equivalent of eval and exec exist in a compiled language? If so, how would they be compiled (roughly speaking)?","AnswerCount":2,"Available Count":2,"Score":0.4621171573,"is_accepted":false,"ViewCount":453,"Q_Id":4611369,"Users Score":5,"Answer":"Certainly, various Lisp environments have had this capability for decades. A Lisp compiler typically works on a per-function basis, and the compiler and runtime system work hand in hand.\nWhen asked to eval something, the Lisp runtime environment will pass the list (a data structure) to the compiler for compiling. The compiler may generate machine code (or maybe bytecode, depending on the system), and then the function will be callable at the machine level just like every other function in the program.","Q_Score":5,"Tags":"python,compilation,eval,exec","A_Id":4611385,"CreationDate":"2011-01-06T03:03:00.000","Title":"If Python's exec and eval were compiled?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Can the equivalent of eval and exec exist in a compiled language? If so, how would they be compiled (roughly speaking)?","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":453,"Q_Id":4611369,"Users Score":5,"Answer":"For starters, python is a compiled language, it just does the compilation at runtime.  That being said, all that you need to do to implement eval in any other compiled language is to be able to run the compiler (and dynamically load object code) - you can do this in Python (and a litany of other languages) easily because the compiler is an integral part of the runtime.  There's technically nothing that stops a program written in C from invoking the compiler and loading the result at runtime (using dlopen), it's just not a common occurrence because the C runtime doesn't require a compiler, so most users don't have one.","Q_Score":5,"Tags":"python,compilation,eval,exec","A_Id":4611394,"CreationDate":"2011-01-06T03:03:00.000","Title":"If Python's exec and eval were compiled?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Taking e.g. Python as a good example of a modern scripting language, it has the option of reading a program (as opposed to input data for the program) from stdin. The REPL is the obvious use case where stdin is a terminal, but it's also designed to handle the scenario where it's not a terminal.\nWhat use cases are there for reading the program itself from noninteractive stdin?\n(The reason I ask is that I'm working on a scripting language myself, and wondering whether this is an important feature to provide, and if so, what the specifics need to look like.)","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":104,"Q_Id":4613888,"Users Score":3,"Answer":"If you want to execute code generated by some tool it could be useful to be able to pipe the generated into your interpreter\/compiler..\nSimply support it ;) Checking if stdin is a tty or not is not hard anyway.","Q_Score":1,"Tags":"python,scripting,programming-languages","A_Id":4613922,"CreationDate":"2011-01-06T10:21:00.000","Title":"Script from stdin use case","Data Science and Machine Learning":0,"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},{"Question":"I built a small micro framework for our web service \/ web app and have it hosted it in a private repository on github. \nI've added the private github repo in the dependency_links and have verified that it exists in dependency_links.txt\nWhen I execute python setup.py install, I get unknown url type: git+ssh, so I looked deeper into the code and realized that distribute only has support for svn+ url types. I was under the (apparently wrong) impression that distribute used pip under the hood, but looks like it still uses easy_install.\nHas anyone found a solution to using distutils \/ distribute to install private github repos as dependencies?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":816,"Q_Id":4614552,"Users Score":3,"Answer":"If you know, that \"pip\" works, why don't you just use \"pip\"?  \"pip\" can not only install from a package index, but also from a local source directory.  Just use pip install . instead of python setup.py install.\nConcerning your impression, it is indeed wrong.  \"pip\" and \"distribute\" are altogether different projects with different aims.  \"pip\" is a frontend to the distutils\/setuptools API, trying to replace the rather weird \"easy_install\" frontend, whereas \"distribute\" is an alternative implementation of the backend \"setuptools\" API (which only includes an \"easy_install\" implementation for the sake of compatibility).  \"pip\" isn't tied to \"distribute\" and also works with the old \"setuptools\" implementation.\nI'd therefore recommend to always use \"pip\" for all package installations, and to never use \"easy_install\" or \"python setup.py install\".  \"pip\" just works, whereas the other two are somewhat strange.","Q_Score":2,"Tags":"python,github,distribution,distutils,easy-install","A_Id":4615208,"CreationDate":"2011-01-06T11:46:00.000","Title":"Has anyone gotten distribute to work correctly with github, specifically private repositories?","Data Science and Machine Learning":0,"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},{"Question":"I have just started using Ubuntu as my first Linux, have a couple of question.\n\nWhat is the difference between easy_install and apt-get? \nHow do I update my packages with packages installed in both these ways?\nThey are under pythonpath right?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1284,"Q_Id":4615299,"Users Score":8,"Answer":"You are confusing two completely separate things.\nAptitude, of which apt_get is one part, is the Ubuntu system-wide package manager. It has packages for absolutely everything - applications, libraries, system utils, whatever. They may not be the latest versions, as packages are usually only updated for each separate Ubuntu release (except for security and bug fixes).\neasy_install is a Python-only system for install Python libraries. It doesn't do anything else. The libraries are installed in the system Python's site-packages directory. There are some downsides to easy_install, one of which is that it's hard to upgrade and uninstall libraries. Use pip instead.","Q_Score":2,"Tags":"python,linux,ubuntu,packages","A_Id":4615378,"CreationDate":"2011-01-06T13:20:00.000","Title":"what is the difference between easy_install and 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":0},{"Question":"Simply, I'm developing a wireless ECG (electrocardiogram, or EKG from the German Elektrokardiogramm) and I need to choose the best language for a desktop application that allows the following:\n\nwireless transmission of data over WiFi\nreal-time graphing of ECG data signal\na good DSP library\n\nThanks.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":883,"Q_Id":4623047,"Users Score":1,"Answer":"From the viewpoint of a normal program (i.e., not a device driver) a Wi-Fi connection is just a network connection -- not noticeably different from (for example) a wired Ethernet connection.\nReal-time graphing and digital signal processing libraries are probably a little less common, but not much. \"Real time\" is one of those slippery phrases that it's hard to pin down exactly what it means (different people use it differently). At a guess, you just mean you want to update the graph as data arrives. In that case, the important question is what bandwidth you're dealing with -- i.e., how many updates of how much information, how fast?\nBottom line -- none of what you've told us gives much in the way of real criteria for picking a language to use. The obvious open question would be performance -- how much data you need to process, and how much processing you need to do on it. That might at least hint at one being better than another.","Q_Score":1,"Tags":"c#,java,c++,python,c","A_Id":4623129,"CreationDate":"2011-01-07T06:26:00.000","Title":"ECG\/EKG software language advice","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},{"Question":"Is it possible to send a MIME message as it is, without adding any headers? For example, if I have a correct MIME message with all headers and content saved to a text file, is it possible to use the contents of this file without modification and send it via SMTP?\nApparently both python's SMTP.sendmail and PHP smtp::mail require at least \"To:\" and \"From:\", and passing the complete message to these functions doesn't seem to work.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":161,"Q_Id":4634171,"Users Score":0,"Answer":"You could read up to the first blank line, use those as additional headers, then send the rest in the body.","Q_Score":1,"Tags":"php,python,email","A_Id":4634184,"CreationDate":"2011-01-08T13:52:00.000","Title":"Sending a MIME email prepared beforehand (in PHP or 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},{"Question":"I am writing an application for image processing. I am just wondering which programming language would be the best fit. Python or PHP. This process is system based not web based so I am just thinking if Python could be of more help.\nLet me know your thoughts!","AnswerCount":5,"Available Count":4,"Score":0.0399786803,"is_accepted":false,"ViewCount":2343,"Q_Id":4641187,"Users Score":1,"Answer":"Possibly neither; it depends on what you want to do.\nBoth PHP and Python are scripting languages, and are therefore not suited for high-performance numerical routines (which most image processing requires).  However, they both have a number of image-processing libraries available for them, the innards of which are probably written in C.  These will be fast.\nIf these libraries do what you want, then fine.  If you need to so something custom, then you're probably better off with C or C++ (or Pascal, or whatever) if speed of execution is of concern.","Q_Score":3,"Tags":"php,python,image,image-processing,image-manipulation","A_Id":4641208,"CreationDate":"2011-01-09T19:19:00.000","Title":"PHP or Python for Image Processing?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I am writing an application for image processing. I am just wondering which programming language would be the best fit. Python or PHP. This process is system based not web based so I am just thinking if Python could be of more help.\nLet me know your thoughts!","AnswerCount":5,"Available Count":4,"Score":0.0798297691,"is_accepted":false,"ViewCount":2343,"Q_Id":4641187,"Users Score":2,"Answer":"One cannot suggest much without knowing the kind of image processing you have in mind.\n\nIf you just want to do some generic rotate\/resize\/etc then I guess there isn't much difference.\nIf you want to do something more complex, then study the libraries and decide which fits best for your particular task.\nIf you want to do something really custom, then C or similar language might be a better fit for the task.","Q_Score":3,"Tags":"php,python,image,image-processing,image-manipulation","A_Id":4641228,"CreationDate":"2011-01-09T19:19:00.000","Title":"PHP or Python for Image Processing?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I am writing an application for image processing. I am just wondering which programming language would be the best fit. Python or PHP. This process is system based not web based so I am just thinking if Python could be of more help.\nLet me know your thoughts!","AnswerCount":5,"Available Count":4,"Score":0.0,"is_accepted":false,"ViewCount":2343,"Q_Id":4641187,"Users Score":0,"Answer":"It really depends on what you want to do with the images. You probably should just use a batch or similar script to run a command that does the processing your looking for.\nBetween the two languages, I would go with python. The command line interface for php is only a recent addition, while python was designed primarily as a scripting language, not for serving pages. For a console application, python is a better fit.","Q_Score":3,"Tags":"php,python,image,image-processing,image-manipulation","A_Id":4641242,"CreationDate":"2011-01-09T19:19:00.000","Title":"PHP or Python for Image Processing?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I am writing an application for image processing. I am just wondering which programming language would be the best fit. Python or PHP. This process is system based not web based so I am just thinking if Python could be of more help.\nLet me know your thoughts!","AnswerCount":5,"Available Count":4,"Score":0.0399786803,"is_accepted":false,"ViewCount":2343,"Q_Id":4641187,"Users Score":1,"Answer":"Python is more clean and readable.\nFor image processing there is the imageMagic library available for Python and PHP too.\nIf you want to do some other complex image processing, which cannot by done using a library and you still want to do it in Python or PHP, then Python is defenitely the answer as Python can be extended with C -- But, wait, you didn't mention programming in C, well, there is Cython! It would allow you to write Python modules which are afterwards compiled to C","Q_Score":3,"Tags":"php,python,image,image-processing,image-manipulation","A_Id":4641248,"CreationDate":"2011-01-09T19:19:00.000","Title":"PHP or Python for Image Processing?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"What is the easiest way to generate PDF documents with embedded fonts in Python without a commercial\/restricted library?\nI want to generate documents with tabular data and headers\/footers. I've tried reportlab, but while powerful, it seems rather difficult to use.","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":383,"Q_Id":4641877,"Users Score":0,"Answer":"Be careful if you want to be able to extract the tabular data later from the PDFs. They need to be created as Structured Content or there will be no tabular metadata in the PDF file.","Q_Score":3,"Tags":"python,pdf,pdf-generation","A_Id":4641984,"CreationDate":"2011-01-09T21:18:00.000","Title":"FLOSS\/Free solution to generate PDF documents 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},{"Question":"is it possible to convert a Python program to C\/C++?\nI need to implement a couple of algorithms, and I'm not sure if the performance gap is big enough to justify all the pain I'd go through when doing it in C\/C++ (which I'm not good at). I thought about writing one simple algorithm and benchmark it against such a converted solution. If that alone is significantly faster than the Python version, then I'll have no other choice than doing it in C\/C++.","AnswerCount":8,"Available Count":2,"Score":1.0,"is_accepted":false,"ViewCount":475467,"Q_Id":4650243,"Users Score":163,"Answer":"If the C variant needs x hours less, then I'd invest that time in letting the algorithms run longer\/again\n\n\"invest\" isn't the right word here.\n\nBuild a working implementation in Python.  You'll finish this long before you'd finish a C version.\nMeasure performance with the Python profiler.  Fix any problems you find.  Change data structures and algorithms as necessary to really do this properly.  You'll finish this long before you finish the first version in C. \nIf it's still too slow, manually translate the well-designed and carefully constructed Python into C.\nBecause of the way hindsight works, doing the second version from existing Python (with existing unit tests, and with existing profiling data) will still be faster than trying to do the C code from scratch.\n\nThis quote is important.\n\nThompson's Rule for First-Time Telescope Makers\n  It is faster to make a four-inch mirror and then a six-inch mirror than to make a six-inch mirror.\nBill McKeenan\n  Wang Institute","Q_Score":202,"Tags":"c++,python,c,code-generation","A_Id":4650953,"CreationDate":"2011-01-10T18:46:00.000","Title":"Convert Python program to C\/C++ 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},{"Question":"is it possible to convert a Python program to C\/C++?\nI need to implement a couple of algorithms, and I'm not sure if the performance gap is big enough to justify all the pain I'd go through when doing it in C\/C++ (which I'm not good at). I thought about writing one simple algorithm and benchmark it against such a converted solution. If that alone is significantly faster than the Python version, then I'll have no other choice than doing it in C\/C++.","AnswerCount":8,"Available Count":2,"Score":1.0,"is_accepted":false,"ViewCount":475467,"Q_Id":4650243,"Users Score":12,"Answer":"I know this is an older thread but I wanted to give what I think to be helpful information.\nI personally use PyPy which is really easy to install using pip. I interchangeably use Python\/PyPy interpreter, you don't need to change your code at all and I've found it to be roughly 40x faster than the standard python interpreter (Either Python 2x or 3x). I use pyCharm Community Edition to manage my code and I love it. \nI like writing code in python as I think it lets you focus more on the task than the language, which is a huge plus for me. And if you need it to be even faster, you can always compile to a binary for Windows, Linux, or Mac (not straight forward but possible with other tools). From my experience, I get about 3.5x speedup over PyPy when compiling, meaning 140x faster than python. PyPy is available for Python 3x and 2x code and again if you use an IDE like PyCharm you can interchange between say PyPy, Cython, and Python very easily (takes a little of initial learning and setup though). \nSome people may argue with me on this one, but I find PyPy to be faster than Cython. But they're both great choices though.\nEdit: I'd like to make another quick note about compiling: when you compile, the resulting binary is much bigger than your python script as it builds all dependencies into it, etc. But then you get a few distinct benefits: speed!, now the app will work on any machine (depending on which OS you compiled for, if not all. lol) without Python or libraries, it also obfuscates your code and is technically 'production' ready (to a degree). Some compilers also generate C code, which I haven't really looked at or seen if it's useful or just gibberish. Good luck.\nHope that helps.","Q_Score":202,"Tags":"c++,python,c,code-generation","A_Id":37192125,"CreationDate":"2011-01-10T18:46:00.000","Title":"Convert Python program to C\/C++ 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},{"Question":"I have a project where I use erlang to aggregate RSS, and I use python to process the RSS feeds.\nMethod 1:\nUse an erlang port, using erlport.org, to call python.\n   I'm not sure how to design the python code to be asyncrhonous using erlport.\nMethod 2:\nUse erlang to call on a RESTful interface with Tornado that does the processing (asynchro downloading of urls -- asynchro procssing)","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":196,"Q_Id":4653361,"Users Score":1,"Answer":"I haven't worked Erlang<->Python before but erlport.org seems promising. I would try that first before getting into greasiness with REST and what not. I.e. I didn't provide and answer but a recommendation :)","Q_Score":2,"Tags":"python,erlang","A_Id":4654839,"CreationDate":"2011-01-11T01:34:00.000","Title":"Which of two methods of using python within erlang 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":1,"Web Development":0},{"Question":"I am interested to make a chatbot. My script is currently working fine with imified.com bot. however imified is down almost everday. so i am looking for my own solution. \nduring my findings, I have found (through this site) openfire and I have configured it and it is working fine even with gmails users. \nbut i am still not getting what I need. \nI need to request a URL (with the chat scripts and some other user data something like imified provides) when each gmail or other external users send me a message. let me explain. \nmy openfire is hosted and working for mybot.com and my id is: autobot@mybot.com. \nnow a gmail user say client@gmail.com added me in his gtalk\/piding and we can communicate each other. he can send me message and I can reply. \nbut I need a robot instead of me. when client@gmail.com (and any other user) sends me a message, I need to request a URL so that i can dynamically generate response based on the message he\/she sent. \nin which way I should go for achieving this? Is there any way to customize openfire to do so? \nor should I make a php\/python (i need to learn python though) script that will listen to xmpp ports and generate responses? if so, any helpful scripts that may guide me? \nbunch of thanks for reading it and thanks in advance for providing any response.","AnswerCount":4,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":2089,"Q_Id":4657611,"Users Score":1,"Answer":"The OpenFire understand XMPP, what you need is XMPP library\/API (like XMPP4R if you are Rubyist). Using it your app will login to OpenFire (by sending gmail\/yahoo credentials) and others will see you as online. But when they will reply to you, you will be notified in your application. Where you can receive the message, process it, and send response (by writing a required program\/logic).\nWe have done it in our SMS Chat application with Gmail\/Yahoo messenger friends\/contacts.","Q_Score":0,"Tags":"java,php,python,xmpp","A_Id":8296818,"CreationDate":"2011-01-11T12:29:00.000","Title":"XMPP, openfire and bot issue","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},{"Question":"We have a website that lists links to blogs in realtime. The problem is that the pages are slow to load because they are reading data from the various source sites.\nI wrote a PHP script that creates an HTML version of each page. This runs once each hour. The problem is that the PHP script is timing out before it finishes all the pages. I know that I could increase the execute time allowed for PHP scripts, but this does not seem like the most efficient way to handle the issue.\nIs there another way to do this? I just don't know what to begin looking for - PERL? JAVA? Python? How do these scripts run on a server? What should I look for from my web host?","AnswerCount":3,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":1341,"Q_Id":4661377,"Users Score":0,"Answer":"A different solution might be to use a database, and not bite off so much work at once.  Make a table listing the sites you pull, and store when they were last pulled.  Then have the cron pull out 1 or 2 that haven't been pulled in a while.  Have it run often, then you'll always have fresh data, but the script will have an easier time working as its not trying to do so much at once.  This concept will scale well.","Q_Score":1,"Tags":"php,python,cron,web-hosting","A_Id":4661872,"CreationDate":"2011-01-11T18:45:00.000","Title":"Alternatives to PHP Cron Job for Long Running Jobs","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"We have a website that lists links to blogs in realtime. The problem is that the pages are slow to load because they are reading data from the various source sites.\nI wrote a PHP script that creates an HTML version of each page. This runs once each hour. The problem is that the PHP script is timing out before it finishes all the pages. I know that I could increase the execute time allowed for PHP scripts, but this does not seem like the most efficient way to handle the issue.\nIs there another way to do this? I just don't know what to begin looking for - PERL? JAVA? Python? How do these scripts run on a server? What should I look for from my web host?","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":1341,"Q_Id":4661377,"Users Score":1,"Answer":"Given the fact that your original problem is one of network latency (\"pages are slow to load\") I see no reason to believe that PHP is the bottleneck here. I doubt changing languages will affect your script run time.","Q_Score":1,"Tags":"php,python,cron,web-hosting","A_Id":4661510,"CreationDate":"2011-01-11T18:45:00.000","Title":"Alternatives to PHP Cron Job for Long Running Jobs","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I have a Rails server which will need to run a python script at the background. I know that I can run it like I run terminal commands in ruby, but how is the performance like? is it better to use a python framework and not Rails? Is there better ways (optimization wise) to run python scripts on a Rails server?","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":3452,"Q_Id":4664325,"Users Score":1,"Answer":"You will incur the cost of starting python each time you run it from ruby.  The cost would be the same in a python framework, unless you could use the python script as a library instead.","Q_Score":1,"Tags":"python,ruby-on-rails,ruby","A_Id":4664359,"CreationDate":"2011-01-12T00:42:00.000","Title":"How to run a python script on a Rails 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":0},{"Question":"I have a Rails server which will need to run a python script at the background. I know that I can run it like I run terminal commands in ruby, but how is the performance like? is it better to use a python framework and not Rails? Is there better ways (optimization wise) to run python scripts on a Rails server?","AnswerCount":3,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":3452,"Q_Id":4664325,"Users Score":5,"Answer":"If you mean that it needs to run periodically, just set it up as a cron job, no special performance characteristics to worry about there.\nIf you mean that it needs to run when pages are requested from your Ruby website, then simply running the script each time won't perform well as it needs to fire up the Python interpreter over and over again.\nIf the Python script is large but is only called from a relatively small number of page requests, you might be able to get away with this, sometimes it's not worth the time to optimise a slow operation that isn't called often.\nIf the bulk of your website is based around the functionality of the Python script, then yes, you are probably better off switching to a Python web framework and loading it as a module.\nIf the Python script isn't very big, then you are probably better off rewriting it in Ruby.\nWorst case scenario is that the script is big and used often, but doesn't make up enough of your website to justify switching to Python.  In that case, I'd consider wrapping the Python in a daemon that Ruby can talk to in the background.","Q_Score":1,"Tags":"python,ruby-on-rails,ruby","A_Id":4664387,"CreationDate":"2011-01-12T00:42:00.000","Title":"How to run a python script on a Rails 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":0},{"Question":"each unit test I'm running is writing python code out to a file, then importing it as a module.  The problem is that the code changes but further import statements don't modify the module.\nI think what I need is a way to ether force a reload on a module or clear the internal bytecode cache.  Any ideas?\nThanks!","AnswerCount":4,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":12520,"Q_Id":4664438,"Users Score":0,"Answer":"Ran into a similar situation.\nLater on found that the white space indentation technique used matters.\nEspecially on windows platforms, ensure that a uniform technique is adapted \nthroughout the module i.e., either use tab or spaces exclusively.","Q_Score":4,"Tags":"python,cpython","A_Id":42154981,"CreationDate":"2011-01-12T01:04:00.000","Title":"Is there anyway to clear python bytecode cache?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I used a python script to install boost (without bjam) but I cannot find it anymore. Does anybody know where it is located?\nThanks","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":100,"Q_Id":4666274,"Users Score":0,"Answer":"If on Windows, do a 'Find' (or download and use Agent Ransack).  If on linux, grep for it.  If it is on your local computer, one of these will find it.","Q_Score":0,"Tags":"c++,python,boost,build","A_Id":4671114,"CreationDate":"2011-01-12T07:26:00.000","Title":"python script for installing boost","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"i recently wrote a method to cycle through \/usr\/share\/dict\/words and return a list of palindromes using my ispalindrome(x) method\nhere's some of the code...what's wrong with it? it just stalls for 10 minutes and then returns a list of all the words in the file\n\ndef reverse(a):\n    return a[::-1]\n\ndef ispalindrome(a):\n    b = reverse(a)\n    if b.lower() == a.lower():\n        return True\n    else:\n        return False\n\nwl = open('\/usr\/share\/dict\/words', 'r')\nwordlist = wl.readlines()\nwl.close()\nfor x in wordlist:\n    if not ispalindrome(x):\n        wordlist.remove(x)\nprint wordlist","AnswerCount":5,"Available Count":1,"Score":0.0399786803,"is_accepted":false,"ViewCount":3147,"Q_Id":4666339,"Users Score":1,"Answer":"You're including the newline at the end of each word in \/usr\/share\/dict\/words.  That means you never find any palindromes.  You'll speed things up if you just log the palindromes as you find them, instead of deleting non-palindromes from the list, too.","Q_Score":2,"Tags":"python,arrays,file,list,palindrome","A_Id":4666394,"CreationDate":"2011-01-12T07:39:00.000","Title":"python and palindromes","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am happily using fabric for my Python projects for deployment. Now I am engaged in a larger PHP project and wondering if there is something like fabric for PHP?","AnswerCount":6,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":7479,"Q_Id":4666392,"Users Score":11,"Answer":"Hmm? Why does it matter? Fabric is just python scripting. So it's project language agnostic. You can use it put anything on a server you'd use scp for, as well as script anything via ssh you'd use bash or [insert other tool here] for. Fabric really isn't Python's capistrano. It's more akin to a combining of both cap and rake, though I still think that's pigeonholing fabric's ability.\nI do like the one stop recipe bits that cap and (from first look) weploy gives you for projects, as in fabric unless you're leveraging something like woven, you'll be rolling your own. But the customization ability of fabric is a plus to me, as I'm all over the place in my uses for it.","Q_Score":8,"Tags":"php,python,fabric","A_Id":4670514,"CreationDate":"2011-01-12T07:49:00.000","Title":"PHP alternative for Python's fabric","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I am happily using fabric for my Python projects for deployment. Now I am engaged in a larger PHP project and wondering if there is something like fabric for PHP?","AnswerCount":6,"Available Count":2,"Score":0.0333209931,"is_accepted":false,"ViewCount":7479,"Q_Id":4666392,"Users Score":1,"Answer":"If you're looking for a build tool (as opposed to deployment), you can use Phing (http:\/\/phing.info\/), a PHP equivalent of Java's Ant.\nDoesn't handle the tunnelling (running remote commands etc.) but does do a nice job of breaking up your deployment into tasks with chained dependancies, and being PHP can interact with your PHP libraries easilly. You might find that some simple cap or fabfiles for the actual deployment, and could then call a Phing script to handle the post-deployment configuration.","Q_Score":8,"Tags":"php,python,fabric","A_Id":4697683,"CreationDate":"2011-01-12T07:49:00.000","Title":"PHP alternative for Python's fabric","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"How do I setup a server so I can get emails and parse them in python?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":194,"Q_Id":4672697,"Users Score":0,"Answer":"There's a bunch of services on the web that will make it easier for you to send and receive e-mails using their API. This would relieve you from the pain of setting up, running and administrering your own e-mail service.","Q_Score":1,"Tags":"python","A_Id":12867404,"CreationDate":"2011-01-12T18:48:00.000","Title":"How to setup parsing emails?","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},{"Question":"I'm writing a CAD application that outputs PDF files using the Cairo graphics library. A lot of the unit testing does not require actually generating the PDF files, such as computing the expected bounding boxes of the objects. However, I want to make sure that the generated PDF files \"look\" correct after I change the code. Is there an automated way to do this? How can I automate as much as possible? Do I need to visually inspect each generated PDF? How can I solve this problem without pulling my hair out?","AnswerCount":5,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":5316,"Q_Id":4672945,"Users Score":0,"Answer":"I would try this using xpresser - (https:\/\/wiki.ubuntu.com\/Xpresser )  You can try to match images to similar images not exact copies - which is the problem in these cases. \nI don't know if xpresser is being ctively developed, or if it can be used with stand alone image files (I think so) -- anyway it takes its ideas from teh Sikuli project (which is Java with a Jython front end, while xpresser is Python).","Q_Score":19,"Tags":"python,unit-testing,pdf-generation,imagemagick,cairo","A_Id":4676387,"CreationDate":"2011-01-12T19:11:00.000","Title":"How to unit test a Python function that draws PDF graphics?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I'm writing a CAD application that outputs PDF files using the Cairo graphics library. A lot of the unit testing does not require actually generating the PDF files, such as computing the expected bounding boxes of the objects. However, I want to make sure that the generated PDF files \"look\" correct after I change the code. Is there an automated way to do this? How can I automate as much as possible? Do I need to visually inspect each generated PDF? How can I solve this problem without pulling my hair out?","AnswerCount":5,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":5316,"Q_Id":4672945,"Users Score":8,"Answer":"You could capture the PDF as a bitmap (or at least a losslessly-compressed) image, and then compare the image generated by each test with a reference image of what it's supposed to look like. Any differences would be flagged as an error for the test.","Q_Score":19,"Tags":"python,unit-testing,pdf-generation,imagemagick,cairo","A_Id":4673001,"CreationDate":"2011-01-12T19:11:00.000","Title":"How to unit test a Python function that draws PDF graphics?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I appreciate there are perhaps better ways of making a PHP application scale than the above, however I'm wondering more on principle. From what I've heard, Python is faster than PHP and I'm trying to decide which language to learn next, as a PHP developer.","AnswerCount":4,"Available Count":4,"Score":0.0,"is_accepted":false,"ViewCount":107,"Q_Id":4675504,"Users Score":0,"Answer":"I cant comment on the difference in scalability of a website but i have had very positive experiences using frameworks such as django for small time websites. I really love the separation of code and templating (i know you can do this somehow with php too).","Q_Score":1,"Tags":"php,python","A_Id":4677419,"CreationDate":"2011-01-13T00:14:00.000","Title":"Would porting parts of a PHP application to Python help it scale?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I appreciate there are perhaps better ways of making a PHP application scale than the above, however I'm wondering more on principle. From what I've heard, Python is faster than PHP and I'm trying to decide which language to learn next, as a PHP developer.","AnswerCount":4,"Available Count":4,"Score":1.2,"is_accepted":true,"ViewCount":107,"Q_Id":4675504,"Users Score":3,"Answer":"Python's a very good language to learn for a number of reasons, including its clear syntax, its excellent standard library, its multi-paradigm support, and the helpful community that surrounds it. \nHowever, scalability has more to do with your system's overall architecture than with the programming language you choose. Often, the database is the main bottleneck, and the performance of the programming language that's talking to the database will not have much impact on overall site performance.","Q_Score":1,"Tags":"php,python","A_Id":4675567,"CreationDate":"2011-01-13T00:14:00.000","Title":"Would porting parts of a PHP application to Python help it scale?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I appreciate there are perhaps better ways of making a PHP application scale than the above, however I'm wondering more on principle. From what I've heard, Python is faster than PHP and I'm trying to decide which language to learn next, as a PHP developer.","AnswerCount":4,"Available Count":4,"Score":0.0996679946,"is_accepted":false,"ViewCount":107,"Q_Id":4675504,"Users Score":2,"Answer":"I don't think rewriting in Python will help you that much, it is very hard to say anyway without knowing your exact scalability problem. When it comes to real scaling issues, every problem is unique and there is no one true solution.\nThat being said, Python is an interesting language, and if you've time on your hands and want to learn something, it sounds like a good idea to look at it closely. I would also look at JavaScript more closely though, be it using NodeJS (which is also pretty damn fast for some things) or just in a browser, it's a language that is not going away anytime soon. If you're a web developer, you can't know enough JS imo.","Q_Score":1,"Tags":"php,python","A_Id":4675551,"CreationDate":"2011-01-13T00:14:00.000","Title":"Would porting parts of a PHP application to Python help it scale?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I appreciate there are perhaps better ways of making a PHP application scale than the above, however I'm wondering more on principle. From what I've heard, Python is faster than PHP and I'm trying to decide which language to learn next, as a PHP developer.","AnswerCount":4,"Available Count":4,"Score":0.0,"is_accepted":false,"ViewCount":107,"Q_Id":4675504,"Users Score":0,"Answer":"For web applications I would personally learn Python after PHP, but if your a Windows fan consider ASP.NET.","Q_Score":1,"Tags":"php,python","A_Id":4675549,"CreationDate":"2011-01-13T00:14:00.000","Title":"Would porting parts of a PHP application to Python help it scale?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"How do I redirect stdout to an arbitrary file in Python?\nWhen a long-running Python script (e.g, web application) is started from within the ssh session and backgounded, and the ssh session is closed, the application will raise IOError and fail the moment it tries to write to stdout. I needed to find a way to make the application and modules output to a file rather than stdout to prevent failure due to IOError. Currently, I employ nohup to redirect output to a file, and that gets the job done, but I was wondering if there was a way to do it without using nohup, out of curiosity.\nI have already tried sys.stdout = open('somefile', 'w'), but this does not seem to prevent some external modules from still outputting to terminal (or maybe the sys.stdout = ... line did not fire at all). I know it should work from simpler scripts I've tested on, but I also didn't have time yet to test on a web application yet.","AnswerCount":13,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":655144,"Q_Id":4675728,"Users Score":0,"Answer":"I know this question is answered (using python abc.py > output.log 2>&1  ), but I still have to say:\nWhen writing your program, don't write to stdout. Always use logging to output whatever you want. That would give you a lot of freedom in the future when you want to redirect, filter, rotate the output files.","Q_Score":395,"Tags":"python,stdout","A_Id":68410134,"CreationDate":"2011-01-13T00:51:00.000","Title":"Redirect stdout to 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},{"Question":"So I know there are a lot of questions on getters and setters in general, but I couldn't find something exactly like my question.  I was wondering if people change the use of get\/set depending on different languages.  I started learning with C++ and was taught to use getters and setters.  This is what I understand:\nIn C++ (and Java?), a variable can either be public or private, but we cannot have a mix.  For example, I can't have a read-only variable that can still be changed inside the class.  It's either all public (can read and change it), or all private (can't read and can only change inside the class).  Because of this (and possibly other reasons), we use getters and setters.\nIn MATLAB, I can control the \"setaccess\" and \"getaccess\" properties of variables, so that I can make things read-only (can directly access the property, but can't overwrite it).  In this case, I don't feel like I need a getter because I can just do class.property.\nAlso, in Python it is considered \"Pythonic\" to not use getters\/setters and to only put things into properties if needed.  I don't really understand why its OK to have all public variables in Python, because that's opposite of what I learned when I started with C++.\nI'm just curious what other people's thoughts are on this.  Would you use getters and setters for all languages?  Would you only use it for C++\/Java and do direct access in MATLAB and Python (which is what I am currently doing)?  Is the second option considered bad?  For my purposes, I am only referring to simple getters and setters (just return\/set the value and do not do anything else).\nThanks!","AnswerCount":10,"Available Count":7,"Score":0.0,"is_accepted":false,"ViewCount":2133,"Q_Id":4683937,"Users Score":0,"Answer":"In Matlab, each additional function call incurs some overhead. So if you don't need a setter\/getter, because some language feature allows you to do exactly the same, then I really cannot see why you wouldn't want to use the language feature.","Q_Score":6,"Tags":"c++,python,matlab,setter,getter","A_Id":4683972,"CreationDate":"2011-01-13T18:47:00.000","Title":"The use of getters and setters for different 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":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"So I know there are a lot of questions on getters and setters in general, but I couldn't find something exactly like my question.  I was wondering if people change the use of get\/set depending on different languages.  I started learning with C++ and was taught to use getters and setters.  This is what I understand:\nIn C++ (and Java?), a variable can either be public or private, but we cannot have a mix.  For example, I can't have a read-only variable that can still be changed inside the class.  It's either all public (can read and change it), or all private (can't read and can only change inside the class).  Because of this (and possibly other reasons), we use getters and setters.\nIn MATLAB, I can control the \"setaccess\" and \"getaccess\" properties of variables, so that I can make things read-only (can directly access the property, but can't overwrite it).  In this case, I don't feel like I need a getter because I can just do class.property.\nAlso, in Python it is considered \"Pythonic\" to not use getters\/setters and to only put things into properties if needed.  I don't really understand why its OK to have all public variables in Python, because that's opposite of what I learned when I started with C++.\nI'm just curious what other people's thoughts are on this.  Would you use getters and setters for all languages?  Would you only use it for C++\/Java and do direct access in MATLAB and Python (which is what I am currently doing)?  Is the second option considered bad?  For my purposes, I am only referring to simple getters and setters (just return\/set the value and do not do anything else).\nThanks!","AnswerCount":10,"Available Count":7,"Score":0.0399786803,"is_accepted":false,"ViewCount":2133,"Q_Id":4683937,"Users Score":2,"Answer":"Depends on how abstracted you need. For example, I recently needed a getter and setter in C++ when abstracting a Text object. The Direct3D text object just held a string Text member variable. The Direct2D Text object however had to be recreated and recached and that kind of thing. If I had opted for public variables when designing the original abstraction, I would have had to redesign the interface and change all the dependent code. While I agree that getters and setters over certain kinds of class are pointless, there are some cases in which they are necessary.\nOf course, languages with properties don't need this kind of thing. But conceptually, they're the same. Defining a property over a variable is just a getter and setter with syntactic sugar, and while I support syntactic sugar, it doesn't change the encapsulation. I wouldn't change my encapsulation design on a language by language basis. Of course, the community opinion on whether or not encapsulation is a good thing is another matter- that's likely the difference that you're seeing. In C++ encapsulation is rated very highly, whereas the Python community cares for it less.","Q_Score":6,"Tags":"c++,python,matlab,setter,getter","A_Id":4684067,"CreationDate":"2011-01-13T18:47:00.000","Title":"The use of getters and setters for different 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":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"So I know there are a lot of questions on getters and setters in general, but I couldn't find something exactly like my question.  I was wondering if people change the use of get\/set depending on different languages.  I started learning with C++ and was taught to use getters and setters.  This is what I understand:\nIn C++ (and Java?), a variable can either be public or private, but we cannot have a mix.  For example, I can't have a read-only variable that can still be changed inside the class.  It's either all public (can read and change it), or all private (can't read and can only change inside the class).  Because of this (and possibly other reasons), we use getters and setters.\nIn MATLAB, I can control the \"setaccess\" and \"getaccess\" properties of variables, so that I can make things read-only (can directly access the property, but can't overwrite it).  In this case, I don't feel like I need a getter because I can just do class.property.\nAlso, in Python it is considered \"Pythonic\" to not use getters\/setters and to only put things into properties if needed.  I don't really understand why its OK to have all public variables in Python, because that's opposite of what I learned when I started with C++.\nI'm just curious what other people's thoughts are on this.  Would you use getters and setters for all languages?  Would you only use it for C++\/Java and do direct access in MATLAB and Python (which is what I am currently doing)?  Is the second option considered bad?  For my purposes, I am only referring to simple getters and setters (just return\/set the value and do not do anything else).\nThanks!","AnswerCount":10,"Available Count":7,"Score":0.0399786803,"is_accepted":false,"ViewCount":2133,"Q_Id":4683937,"Users Score":2,"Answer":"I don't generally use getters\/setters because the presence of them indicates that my class isn't doing enough to be alive.\nWhen I do consider needing them I always create them, no matter whether or not the language supports mixing access wrt variables.  Only time I'd consider not doing so is in languages like VB that support \"properties\" where a function can look just like a variable access.  The key reason here is that I don't want clients bound to the fact that the property is implemented by a variable.","Q_Score":6,"Tags":"c++,python,matlab,setter,getter","A_Id":4683991,"CreationDate":"2011-01-13T18:47:00.000","Title":"The use of getters and setters for different 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":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"So I know there are a lot of questions on getters and setters in general, but I couldn't find something exactly like my question.  I was wondering if people change the use of get\/set depending on different languages.  I started learning with C++ and was taught to use getters and setters.  This is what I understand:\nIn C++ (and Java?), a variable can either be public or private, but we cannot have a mix.  For example, I can't have a read-only variable that can still be changed inside the class.  It's either all public (can read and change it), or all private (can't read and can only change inside the class).  Because of this (and possibly other reasons), we use getters and setters.\nIn MATLAB, I can control the \"setaccess\" and \"getaccess\" properties of variables, so that I can make things read-only (can directly access the property, but can't overwrite it).  In this case, I don't feel like I need a getter because I can just do class.property.\nAlso, in Python it is considered \"Pythonic\" to not use getters\/setters and to only put things into properties if needed.  I don't really understand why its OK to have all public variables in Python, because that's opposite of what I learned when I started with C++.\nI'm just curious what other people's thoughts are on this.  Would you use getters and setters for all languages?  Would you only use it for C++\/Java and do direct access in MATLAB and Python (which is what I am currently doing)?  Is the second option considered bad?  For my purposes, I am only referring to simple getters and setters (just return\/set the value and do not do anything else).\nThanks!","AnswerCount":10,"Available Count":7,"Score":0.0599281035,"is_accepted":false,"ViewCount":2133,"Q_Id":4683937,"Users Score":3,"Answer":"It's OK to have all public variables in any language. Yes, I know it's the opposite of what you learned.\nOO theory says that there should be a public API that is stable, and private variables, where you can do whatever you want, and an implementation you can change to your hearts delight without changing the API.\nAnd this is correct. But what is not correct is the idea that the private API must be made inaccessible from other classes. This is simply a mistake in the OO theory. It is an idea that sounds reasonable on paper, but in practice has little to go for it, but causes plenty of problems.\nFor example, many years ago I needed to subclass a widget in Delphi to make it behave slightly differently. Not a lot you see, just a bit. But the code I needed to override called a method that was private, so I couldn't override it. Instead I needed to override both methods. And of course, that other method did things that was really internal, so I ended up basically not subclassing the widget, but duplicating it, just because I did one small change.\nOO theory claims this is how it should be, because horror of horror, maybe otherwise my sublclass might stop work with the next version of Delphi, if the superclass changes something internal! Well, so what? In that case I would just fix it.\nIt's my problem if I use parts of your internal data. You don't need to care. What you need to do is somehow flag that \"This bit is internal and might change, use on your own risk\". But when you as a developer of a library actively prevents me from using internal bits, you are only causing me problems.\nI've now developed almost exclusively with Python for soon to be ten years, and the openness of Python has never caused me problems, and it fact has saved my ass several times (as I can fix framework bugs by simply patching in fixed code at runtime). Delphis standard OO model with different levels of protection caused me problems several times during the two years I worked with it.\nThe OO Theory is in fact wrong. There is nothing useful in having private members. Everything should be public. And that goes for any language, in my experience.","Q_Score":6,"Tags":"c++,python,matlab,setter,getter","A_Id":4684469,"CreationDate":"2011-01-13T18:47:00.000","Title":"The use of getters and setters for different 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":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"So I know there are a lot of questions on getters and setters in general, but I couldn't find something exactly like my question.  I was wondering if people change the use of get\/set depending on different languages.  I started learning with C++ and was taught to use getters and setters.  This is what I understand:\nIn C++ (and Java?), a variable can either be public or private, but we cannot have a mix.  For example, I can't have a read-only variable that can still be changed inside the class.  It's either all public (can read and change it), or all private (can't read and can only change inside the class).  Because of this (and possibly other reasons), we use getters and setters.\nIn MATLAB, I can control the \"setaccess\" and \"getaccess\" properties of variables, so that I can make things read-only (can directly access the property, but can't overwrite it).  In this case, I don't feel like I need a getter because I can just do class.property.\nAlso, in Python it is considered \"Pythonic\" to not use getters\/setters and to only put things into properties if needed.  I don't really understand why its OK to have all public variables in Python, because that's opposite of what I learned when I started with C++.\nI'm just curious what other people's thoughts are on this.  Would you use getters and setters for all languages?  Would you only use it for C++\/Java and do direct access in MATLAB and Python (which is what I am currently doing)?  Is the second option considered bad?  For my purposes, I am only referring to simple getters and setters (just return\/set the value and do not do anything else).\nThanks!","AnswerCount":10,"Available Count":7,"Score":0.0,"is_accepted":false,"ViewCount":2133,"Q_Id":4683937,"Users Score":0,"Answer":"Python and C++ have different principles. C++ and Java are quite \u201cstatic\u201d and have lots of compile time checks, so you should exploit them when using C++ and Java: public vs. private, const-correctness, etc. Plus they don't have properties, so if you find that you should do some parameter validation, you cannot easily convert a public member variable into a getter\u2013setter pair without changing syntax and breaking existing code. Python, on the other hand, is a dynamic language that allows everybody to do everything: you can override every variable from every module, encapsulation cannot be enforced, there are no static type checks, etc. Python people tend to say \u201cwe\u2019re all adults,\u201d and that you should not rely on undocumented behavior and use unit tests instead of compile-time checks. I\u2019m not in the position to judge what is better, but generally you should stick to the established conventions of your language.","Q_Score":6,"Tags":"c++,python,matlab,setter,getter","A_Id":4684420,"CreationDate":"2011-01-13T18:47:00.000","Title":"The use of getters and setters for different 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":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"So I know there are a lot of questions on getters and setters in general, but I couldn't find something exactly like my question.  I was wondering if people change the use of get\/set depending on different languages.  I started learning with C++ and was taught to use getters and setters.  This is what I understand:\nIn C++ (and Java?), a variable can either be public or private, but we cannot have a mix.  For example, I can't have a read-only variable that can still be changed inside the class.  It's either all public (can read and change it), or all private (can't read and can only change inside the class).  Because of this (and possibly other reasons), we use getters and setters.\nIn MATLAB, I can control the \"setaccess\" and \"getaccess\" properties of variables, so that I can make things read-only (can directly access the property, but can't overwrite it).  In this case, I don't feel like I need a getter because I can just do class.property.\nAlso, in Python it is considered \"Pythonic\" to not use getters\/setters and to only put things into properties if needed.  I don't really understand why its OK to have all public variables in Python, because that's opposite of what I learned when I started with C++.\nI'm just curious what other people's thoughts are on this.  Would you use getters and setters for all languages?  Would you only use it for C++\/Java and do direct access in MATLAB and Python (which is what I am currently doing)?  Is the second option considered bad?  For my purposes, I am only referring to simple getters and setters (just return\/set the value and do not do anything else).\nThanks!","AnswerCount":10,"Available Count":7,"Score":0.0,"is_accepted":false,"ViewCount":2133,"Q_Id":4683937,"Users Score":0,"Answer":"Python, being a dynamic scripting language, is less about compile-time constraints, and more about flexibility.\nGetters and setters (\"property\" is just getter + setter) allow for better encapsulation (checking validity, only getter, not setter; implementation details does not matter - e.g. time has hours, minutes, seconds, but how are data actually stored? who cares?), and future extensibility (e.g. code of setter might change, consumers don't care).\nIn modern efficient languages like C++, there is inlining, so there is no performance cost for simple getters\/setters.\nPoint is, use public fields for structural and simple (small-scale) programming, use getters and setters for large-scale OOP projects.","Q_Score":6,"Tags":"c++,python,matlab,setter,getter","A_Id":4684036,"CreationDate":"2011-01-13T18:47:00.000","Title":"The use of getters and setters for different 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":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"So I know there are a lot of questions on getters and setters in general, but I couldn't find something exactly like my question.  I was wondering if people change the use of get\/set depending on different languages.  I started learning with C++ and was taught to use getters and setters.  This is what I understand:\nIn C++ (and Java?), a variable can either be public or private, but we cannot have a mix.  For example, I can't have a read-only variable that can still be changed inside the class.  It's either all public (can read and change it), or all private (can't read and can only change inside the class).  Because of this (and possibly other reasons), we use getters and setters.\nIn MATLAB, I can control the \"setaccess\" and \"getaccess\" properties of variables, so that I can make things read-only (can directly access the property, but can't overwrite it).  In this case, I don't feel like I need a getter because I can just do class.property.\nAlso, in Python it is considered \"Pythonic\" to not use getters\/setters and to only put things into properties if needed.  I don't really understand why its OK to have all public variables in Python, because that's opposite of what I learned when I started with C++.\nI'm just curious what other people's thoughts are on this.  Would you use getters and setters for all languages?  Would you only use it for C++\/Java and do direct access in MATLAB and Python (which is what I am currently doing)?  Is the second option considered bad?  For my purposes, I am only referring to simple getters and setters (just return\/set the value and do not do anything else).\nThanks!","AnswerCount":10,"Available Count":7,"Score":0.0,"is_accepted":false,"ViewCount":2133,"Q_Id":4683937,"Users Score":0,"Answer":"You're right - no need for \"simple\" getters and setters in modern Matlab OOP; the access modifiers that you mentioned are the \"Right Way\".\nIn the new MCOS Matlab classes, the syntax for accessing a class property is the same whether you define custom getter\/setters or not. Clients can always access property foo as \"obj.foo\". If you decide to add the special \"get.foo\" and \"set.foo\" methods, they are implicitly called by Matlab when a client accesses that property using the \"obj.foo\" syntax. So it's not really \"direct field access\" like public fields in Java or C++. It's like Scala's \"Uniform Access\" model. (I think.) The \".\" syntax and declarative access controls you mention keep things simple and lets you transparently add custom logic when you need it, without committing to writing boilerplate code up front. The ubiquity of user-defined getters and setters in Java is partially because the language lacks these features.\nIn old-style Matlab classes, the inverse is true: all fields are private, so you must write your own getter\/setters. The convention I've seen is to write a single method with the same name as the property that gets or sets depending on whether you call it as \"foo(obj)\" or \"foo(obj, NewValue)\".","Q_Score":6,"Tags":"c++,python,matlab,setter,getter","A_Id":4684480,"CreationDate":"2011-01-13T18:47:00.000","Title":"The use of getters and setters for different 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":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm writing a program which is sending files through SMTP, thanks to my (local) Postfix server, on port 25.\nIs it possible to use several threads (thus several sockets) to inject emails faster ?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":305,"Q_Id":4685634,"Users Score":0,"Answer":"Depends entirely on where the bottleneck is.  If it's on the SMTP server or the network, the answer is no.  If it's in your python code, probably yes.","Q_Score":0,"Tags":"python,sockets,smtp,smtplib","A_Id":4685735,"CreationDate":"2011-01-13T21:44:00.000","Title":"Several threads connecting to a Postfix 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":0},{"Question":"Suppose I hashed a password and obtained a hashcode for it. I need to find the degree of similarity between the password and its hashcode. Please suggest me some different mechanism for this","AnswerCount":4,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":131,"Q_Id":4689456,"Users Score":7,"Answer":"This is impossible.  That's the entire point of secure hash algorithms that are used, among other things, to hash passwords.","Q_Score":0,"Tags":"python,cryptography","A_Id":4689577,"CreationDate":"2011-01-14T09:04:00.000","Title":"Anybody know a valid mechanism to detect the degree of similarity between a string and its hashcode?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I normally code admin scripts in Python and I know of many that code them in Perl. I was about to invest some time on improving my skills on bash programming. But I wonder if people around think that this is a good idea ? \nI know bash is a good skill to have and market very often demand it but ... if I can get by with Python or Perl then ... is it really worth the effort ?\nAs answers I am looking for cases where actually bash is way better than Perl or Python to develop admin scripts.","AnswerCount":2,"Available Count":1,"Score":-0.0996679946,"is_accepted":false,"ViewCount":5752,"Q_Id":4701766,"Users Score":-1,"Answer":"I'd say if this is only your machine and you're not supposed to share those administration scripts with any other one, so you'd better to keep doing that in Python (which seems you feel more comfortable on that).\nBut if you have colleagues or your admin scripts are supposed to employee by other people, so let keep it in a way that is more popular and more understandable for others also: Bash!\nAlso I guess if you know Bash, you can simply use dozens of existing Bash scripts by customizing them or improving them to whatever which is more suitable for you!","Q_Score":8,"Tags":"python,perl,bash,admin","A_Id":13985089,"CreationDate":"2011-01-15T19:45:00.000","Title":"Python and\/or Perl VS 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},{"Question":"I've got a situation where I'm contemplating using subversion\/svn as the repository\/version control system for a project. I'm trying to figure out if it's possible, (and if so, how) to be able to have the subversion system, on a post commit hook\/process to to write the user\/file\/time (and maybe msg) to either an external file (csv) or to a mysql db. \nOnce I can figure out how to invoke the post commit hook to write the output to a file, I can then modify my issue tracker\/project app to then implement a basic workflow process based on the user role, as well as the success\/failure of the repository files.\nShort sample\/pointers would be helpful.\nMy test env, is running subversion\/svnserve on centos5. The scripting languages in use are Php\/Python.","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":1005,"Q_Id":4701902,"Users Score":0,"Answer":"I would say that's possible, but you are going to need a bit of work to retrieve the username, date and commit message.\nSubversion invokes the post-commit hook with the repo path and the number of revision which was just committed as arguments.\nIn order to retrieve the information you're looking for, you will need to use an executable by the name of svnlook, which is bundled with Subversion.\nSee repo\\hooks\\post-commit.tmpl for a rather clear explanation about how to use it\nAlso, take a look at svnlook help, it's not difficult to use.","Q_Score":1,"Tags":"php,python,svn,hook,svn-hooks","A_Id":4701984,"CreationDate":"2011-01-15T20:14:00.000","Title":"subversion post commit hooks","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},{"Question":"I've got a situation where I'm contemplating using subversion\/svn as the repository\/version control system for a project. I'm trying to figure out if it's possible, (and if so, how) to be able to have the subversion system, on a post commit hook\/process to to write the user\/file\/time (and maybe msg) to either an external file (csv) or to a mysql db. \nOnce I can figure out how to invoke the post commit hook to write the output to a file, I can then modify my issue tracker\/project app to then implement a basic workflow process based on the user role, as well as the success\/failure of the repository files.\nShort sample\/pointers would be helpful.\nMy test env, is running subversion\/svnserve on centos5. The scripting languages in use are Php\/Python.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":1005,"Q_Id":4701902,"Users Score":0,"Answer":"Indeed it is very possible, in your repository root there should be a folder named hooks, inside which should be a file named post-commit (if not, create one), add whatever bash code you put there and it will execute after every commit.\nNote, there are 2 variables that are passed into the script $1 is the repository, and $2 is the revision number (i think), you can use those two variables to execute some svn commands\/queries, and pull out the required data, and do with it whatever your heart desires.","Q_Score":1,"Tags":"php,python,svn,hook,svn-hooks","A_Id":4701973,"CreationDate":"2011-01-15T20:14:00.000","Title":"subversion post commit hooks","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},{"Question":"I have a python script that outputs the program name, version number and the author when called with command line arguments like --help or --version. Currently this information is hardcoded in the python script itself. But I use distutils for building\/packaging the application so all this information is already present in the setup.py. Is it possible to let distutils write metadata like version and author name\/email to the built python script so I only need to maintain this data in the setup.py file? Or is there another standard mechanism to handle stuff like that?","AnswerCount":3,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":201,"Q_Id":4705723,"Users Score":3,"Answer":"Do it the other way around.  Add the version number, the author name and other metadata you need in the script to the script itself.  Then import or execfile() the script in setup.py, and use the metadata defined in the script as arguments to the setup() function.","Q_Score":2,"Tags":"python,distutils","A_Id":4706043,"CreationDate":"2011-01-16T13:58:00.000","Title":"Replace symbols in python script on 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":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am thinking about to learn new language or framework. Now I deal with C# and WPF, WCF, Winforms. I have some free time so I would like get new skills.\nBut I have dilema, start with some C++ framework (such as Platinum, Reason, Evocosm, ACF)\nor try Python \/ python framework.\nI you are on my place which possibility you choose?\nI am 17 years student, I have basic skills in C++ (OOP, little with STL), with Python I haven\u2019t any experience.\nWhat would be your choice and why?","AnswerCount":6,"Available Count":4,"Score":1.2,"is_accepted":true,"ViewCount":438,"Q_Id":4708482,"Users Score":0,"Answer":"Personally I prefer Python, but profesionally, that is if you want a good job C++ is a better choice.","Q_Score":3,"Tags":"c++,python,frameworks","A_Id":4708502,"CreationDate":"2011-01-16T22:20:00.000","Title":"Start with some C++ framework or 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},{"Question":"I am thinking about to learn new language or framework. Now I deal with C# and WPF, WCF, Winforms. I have some free time so I would like get new skills.\nBut I have dilema, start with some C++ framework (such as Platinum, Reason, Evocosm, ACF)\nor try Python \/ python framework.\nI you are on my place which possibility you choose?\nI am 17 years student, I have basic skills in C++ (OOP, little with STL), with Python I haven\u2019t any experience.\nWhat would be your choice and why?","AnswerCount":6,"Available Count":4,"Score":0.0333209931,"is_accepted":false,"ViewCount":438,"Q_Id":4708482,"Users Score":1,"Answer":"I recommend you to keep learning C++. Before you started looking for framework learn some popular search algorithm and try implement them. After that try implement some structures, like queues, list, stack, binary trees and some operation on them. Meanwhile play with I\/O (for example, try write your stack to file and read it back to stack - in plain text and binary). \nIt was my university tour on programming class. C++ is good choice because it is hard and multiparadigmats language so in future u will find much in common with other languages and you will be familiar with memory management system.","Q_Score":3,"Tags":"c++,python,frameworks","A_Id":4708519,"CreationDate":"2011-01-16T22:20:00.000","Title":"Start with some C++ framework or 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},{"Question":"I am thinking about to learn new language or framework. Now I deal with C# and WPF, WCF, Winforms. I have some free time so I would like get new skills.\nBut I have dilema, start with some C++ framework (such as Platinum, Reason, Evocosm, ACF)\nor try Python \/ python framework.\nI you are on my place which possibility you choose?\nI am 17 years student, I have basic skills in C++ (OOP, little with STL), with Python I haven\u2019t any experience.\nWhat would be your choice and why?","AnswerCount":6,"Available Count":4,"Score":0.0,"is_accepted":false,"ViewCount":438,"Q_Id":4708482,"Users Score":0,"Answer":"Well. Learning Python basics will take a week, and you will save the time spent in a year since it is such a good language for small hacks and scripts. So I suggest you learn it first.\nLearning C++ well will take you five to ten years, so there is not the same immediate benefit :)","Q_Score":3,"Tags":"c++,python,frameworks","A_Id":4708899,"CreationDate":"2011-01-16T22:20:00.000","Title":"Start with some C++ framework or 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},{"Question":"I am thinking about to learn new language or framework. Now I deal with C# and WPF, WCF, Winforms. I have some free time so I would like get new skills.\nBut I have dilema, start with some C++ framework (such as Platinum, Reason, Evocosm, ACF)\nor try Python \/ python framework.\nI you are on my place which possibility you choose?\nI am 17 years student, I have basic skills in C++ (OOP, little with STL), with Python I haven\u2019t any experience.\nWhat would be your choice and why?","AnswerCount":6,"Available Count":4,"Score":0.0,"is_accepted":false,"ViewCount":438,"Q_Id":4708482,"Users Score":0,"Answer":"I'd pick C++ for the sole reason that it's nothing like the languages you already know, even though it shares some syntax.","Q_Score":3,"Tags":"c++,python,frameworks","A_Id":4708606,"CreationDate":"2011-01-16T22:20:00.000","Title":"Start with some C++ framework or 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},{"Question":"Is there a way to get python to read modules from a network? \nWe have many machines and it would be a too much effort to update each machine manually each time I change a module so I want python to get the modules from a location on the network.\nAny ideas?","AnswerCount":6,"Available Count":2,"Score":0.0333209931,"is_accepted":false,"ViewCount":10613,"Q_Id":4710588,"Users Score":1,"Answer":"How I ended up doing this:\nControl Panel\\All Control Panel Items\\System >> Advanced >> Environment Variables >> System Variables >> New >> Name = PYTHONPATH, value = \\server\\scriptFolder\nThanks everyone for all the help :)","Q_Score":4,"Tags":"python,networking,module,import,centralized","A_Id":4734071,"CreationDate":"2011-01-17T06:37:00.000","Title":"Importing module from network","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},{"Question":"Is there a way to get python to read modules from a network? \nWe have many machines and it would be a too much effort to update each machine manually each time I change a module so I want python to get the modules from a location on the network.\nAny ideas?","AnswerCount":6,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":10613,"Q_Id":4710588,"Users Score":4,"Answer":"Mount your network location into your file-system and add that path to your PYTHONPATH. That way, Python on your local machine will be able to see the modules which are present in the remote location.\nYou cannot directly import from modules remotely, like specifying a js file in html.","Q_Score":4,"Tags":"python,networking,module,import,centralized","A_Id":4710633,"CreationDate":"2011-01-17T06:37:00.000","Title":"Importing module from network","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},{"Question":"Are there any guidelines for writing test-friendly Python code?\nWhat I believe:\n\nOne method does one thing.\nDon't use side-effects.\n\nAny other suggestions?","AnswerCount":3,"Available Count":2,"Score":1.0,"is_accepted":false,"ViewCount":3938,"Q_Id":4710621,"Users Score":7,"Answer":"Write methods that don't rely on other models or resources - if they need to access them, they should be passed in to the method.","Q_Score":14,"Tags":"python,unit-testing","A_Id":4710652,"CreationDate":"2011-01-17T06:43:00.000","Title":"Any tips on writing testing-friendly 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},{"Question":"Are there any guidelines for writing test-friendly Python code?\nWhat I believe:\n\nOne method does one thing.\nDon't use side-effects.\n\nAny other suggestions?","AnswerCount":3,"Available Count":2,"Score":1.0,"is_accepted":false,"ViewCount":3938,"Q_Id":4710621,"Users Score":6,"Answer":"Alfred\u2018s answer is great, but I would add one thing for the questioner: \nIf you want to read a book, that is all about testing in Python using pytest, I suggest you to read \u201ePython Testing with pytest: Simple, Rapid, Effective, and Scalable\u201c by Brian Okken. It\u2019s perfect for what you want to do and it\u2019s brand new (published September 2017).","Q_Score":14,"Tags":"python,unit-testing","A_Id":50113761,"CreationDate":"2011-01-17T06:43:00.000","Title":"Any tips on writing testing-friendly 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},{"Question":"What is most similar PHP framework to Pylons?\nI mean mostly ideology of programming.","AnswerCount":3,"Available Count":1,"Score":0.1325487884,"is_accepted":false,"ViewCount":755,"Q_Id":4716689,"Users Score":2,"Answer":"Being primarily a Python developer, and having used Pylons, TurboGears, and Django, I would whole heartedly, 100% recommend Kohana 3.x.  To be completely honest I am not a huge fan of PHP, even though it is the language of choice at my current employer.  Given the choice I would use Python and Pylons.  But, using Kohana is just about the best framework I could hope for from PHP.  I hope I am not biases, considering I work with two developers on the Kohana development team. ;-)\nPHP and Python are very different.  As such, there is no real equivalent of Pylons in PHP.  But, I would also say there is no real equivalent of Kohana in Python","Q_Score":5,"Tags":"php,python,comparison,pylons,web-frameworks","A_Id":4721004,"CreationDate":"2011-01-17T18:49:00.000","Title":"PHP framework similar to Python Pylons","Data Science and Machine Learning":0,"Database and SQL":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},{"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},{"Question":"Python's installation comes with some handy tools, located under \n$YOUR_PYTHON\/Tools\/Scripts. Is there a platform-independent way to find out where on a system they are located? I want to use ftpmirror.py as part of a shell script.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1415,"Q_Id":4722072,"Users Score":5,"Answer":"I see you are talking about the source bundle of Python, which includes Tools\/Scripts, a set of helpful scripts for working with Python Source. It should be noted that they are not a part of Python Standard Library and installers are not obliged to bundle them with their distribution, for e.g in Ubuntu, I don't find it in \/usr\/lib\/python2.6 or some other path.\nIf you want to rely on any of the Tools\/Scripts, just carry them along with your script, that would be most portable.","Q_Score":3,"Tags":"python","A_Id":4722121,"CreationDate":"2011-01-18T08:48:00.000","Title":"Python: detecting install location of python tools","Data Science and Machine Learning":0,"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},{"Question":"Am just being curious but I would like to know whether python can be implemented in assembly and if not why has it not been done to help for speed issues. forgive my naivete in matters of programming languages.","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":1879,"Q_Id":4727351,"Users Score":15,"Answer":"The main implementation is written in C, and that's compiled to machine code (i.e. assembly made readable for the CPU). So writing it assembly is certainly possible, and if it's possible for a compiler, it's possible for humans - in theory. In practice, it is not even remotely practical. Not only asm is even more low-level than C (increasing development time significantly, perhaps even expotentially to the project size), it's also highly platform-specific, so each port takes a huge lot of work (and maintaince is multiplied by the number of supported platforms - quite a few in the case of CPython).\nApart from that, it's highly questionable if this would give a notable speed bonus. Writing it closer to the metal doesn't make stuff go faster magically (the contrary can be the case - you'd be hard-pressed to find a programmer who can consistently write better assembly than the four or five well-known C compilers). And much of Python's slowness comes from the many many abstractions and indirections the language consists of, not from a sloppy implementation of these.\nA more promising approach (which is indeed followed by several alternative implementations) is a clever Just In Time-Compiler (JIT), which preserves all the dynamicness but exploits the fact that most Python programs make little use of that dynamicness by recognizing the most common paths at runtime and optimizing for these. Such complex programs are again not written in asm.","Q_Score":4,"Tags":"python","A_Id":4727418,"CreationDate":"2011-01-18T17:57:00.000","Title":"python implemented in assembly","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Am just being curious but I would like to know whether python can be implemented in assembly and if not why has it not been done to help for speed issues. forgive my naivete in matters of programming languages.","AnswerCount":2,"Available Count":2,"Score":1.0,"is_accepted":false,"ViewCount":1879,"Q_Id":4727351,"Users Score":6,"Answer":"Native code isn't a magic make-it-go-faster operation. The language semantics really dictate quite a bit about how fast (or not) a language is. (For instance, erlang compiled to native code via Hipe is still fairly slow).","Q_Score":4,"Tags":"python","A_Id":4727381,"CreationDate":"2011-01-18T17:57:00.000","Title":"python implemented in assembly","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to schedule an email to be sent to a user upon a specific action.\nHowever, if the user takes another action I want to cancel that email and have it not send.\nHow would I do that in django or python?","AnswerCount":5,"Available Count":2,"Score":0.1194272985,"is_accepted":false,"ViewCount":5173,"Q_Id":4731419,"Users Score":3,"Answer":"I would set up a cron job which could handle everything you want to do...","Q_Score":2,"Tags":"python,django,email,schedule","A_Id":4731583,"CreationDate":"2011-01-19T03:16:00.000","Title":"How can I schedule an email to be sent at some point in the future 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},{"Question":"I want to schedule an email to be sent to a user upon a specific action.\nHowever, if the user takes another action I want to cancel that email and have it not send.\nHow would I do that in django or python?","AnswerCount":5,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":5173,"Q_Id":4731419,"Users Score":0,"Answer":"You said that you want to do it through Python or Django, but it seems as though something else will need to be involved. Considering you are on a shared host, there is a chance installing other packages could also be a problem.\nAnother possible solution could be something like this:\nUse a javascript framework which can setup timed events, start\/cancel them etc. I have done timed events using a framework called ExtJS. Although ExtJS is rather large im sure other frameworks such as jQuery or even raw javascript you could do a similar thing.\nSet up a task on a user action, that will execute in 5 minutes. The action could be an ajax call to a python script which sends the email... If a user does something where the task needs to be stopped, just cancel the event.\nIt kind of seems complicated and convoluted, but it really isn't. If this seems like a path you would like to try out, let me know and I'll edit with some code","Q_Score":2,"Tags":"python,django,email,schedule","A_Id":4741503,"CreationDate":"2011-01-19T03:16:00.000","Title":"How can I schedule an email to be sent at some point in the future 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},{"Question":"I'm trying to create a very simple script that uses python's xmpppy to send a message over facebook chat.\n\nimport xmpp\nFACEBOOK_ID = \"username@chat.facebook.com\"\nPASS = \"password\"\nSERVER = \"chat.facebook.com\"\njid=xmpp.protocol.JID(FACEBOOK_ID)\nC=xmpp.Client(jid.getDomain(),debug=[])\nif not C.connect((SERVER,5222)):\n    raise IOError('Can not connect to server.')\nif not C.auth(jid.getNode(),PASS):\n    raise IOError('Can not auth with server.')\nC.send(xmpp.protocol.Message(\"friend@chat.facebook.com\",\"Hello world\",))\n\nThis code works to send a message via gchat, however when I try with facebook I recieve this error:\nAn error occurred while looking up _xmpp-client._tcp.chat.facebook.com\nWhen I remove @chat.facebook.com from the FACEBOOK_ID I get this instead:\n\nFile \"gtalktest.py\", line 11, in \n    if not C.connect((SERVER,5222)):\n  File \"\/home\/john\/xmpppy-0.3.1\/xmpp\/client.py\", line 195, in connect\n    if not CommonClient.connect(self,server,proxy,secure,use_srv) or secureNone and not secure: return self.connected\n  File \"\/home\/john\/xmpppy-0.3.1\/xmpp\/client.py\", line 179, in connect\n    if not self.Process(1): return\n  File \"\/home\/john\/xmpppy-0.3.1\/xmpp\/dispatcher.py\", line 302, in dispatch\n    handler['func'](session,stanza)\n  File \"\/home\/john\/xmpppy-0.3.1\/xmpp\/dispatcher.py\", line 214, in streamErrorHandler\n    raise exc((name,text))\nxmpp.protocol.HostUnknown: (u'host-unknown', '')\n\nI also notice any time I import xmpp I get the following two messages when running:\n\n\/home\/john\/xmpppy-0.3.1\/xmpp\/auth.py:24: DeprecationWarning: the sha module is deprecated; use the hashlib module instead\n  import sha,base64,random,dispatcher\n\/home\/john\/xmpppy-0.3.1\/xmpp\/auth.py:26: DeprecationWarning: the md5 module is deprecated; use hashlib instead\n  import md5\n\nI'm fairly new to solving these kinds of problems, and advise, or links to resources that could help me move forward in solve these issues would be greatly appreciated. Thanks for reading!","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":2814,"Q_Id":4732230,"Users Score":2,"Answer":"I also started the same project, and was trapped into same problem. I found the solution too. You have to write the UserName of facebook (Hence You must opt one Username) and that too in small Caps. This is the most important part. Most probably you too like me would not be writing it in small Caps.","Q_Score":3,"Tags":"python,facebook,chat,xmpppy","A_Id":5268496,"CreationDate":"2011-01-19T06:03:00.000","Title":"xmpppy and Facebook Chat 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":1,"Web Development":0},{"Question":"I'm looking for a public private key solution that I can use with a javascript client and python backend. The aim is to send data encrypted from the client to the server... Are the any solutions? Thanks for hints.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":401,"Q_Id":4737721,"Users Score":0,"Answer":"Use SSL for your connections to the server. Probably the easiest way to do that is to use HTTP for communication and also to run a proxy (say, Apache) on the server that can do HTTPS and forwards requests to the actual server application.","Q_Score":1,"Tags":"javascript,python,encryption,pgp","A_Id":4738545,"CreationDate":"2011-01-19T16:17:00.000","Title":"public private key solution for javascript and 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},{"Question":"What is the meaning of <> in Python?\nI have tried searching for it on Google but I cannot seem to get inside the search term...\nI have not seen this in any other language also otherwise I would have tried to find it.","AnswerCount":5,"Available Count":1,"Score":0.0798297691,"is_accepted":false,"ViewCount":866,"Q_Id":4738285,"Users Score":2,"Answer":"It is the same as != (\"not equal\")","Q_Score":6,"Tags":"python","A_Id":4738310,"CreationDate":"2011-01-19T17:05:00.000","Title":"what does <> mean 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},{"Question":"Rather than triggering a flamewar on what DI framework is \"best\" (I don't think there's a definitive general solution), this question is meant to discuss good alternatives for projects of different kinds, no matter the programming language, based on professional experience.\nSome issues I'd like to lean about:\n\nWhat were the most important features you were looking for in a DI framework? Why was it what best fitted your project?\nWhat does the DI framework have that others do not? What makes it special?\nWhy would you not pick the same DI framework for other different projects?\nHow did the DI framework improve the testability and configuration flexibility of the application (especially on different environments: development, staging, production, etc.)?\nMany DI frameworks are said to be simple. But how easy is it to maintain the configuration of dependencies? (For example: Is it too verbose or difficult to read and modify?)\n\nI may eventually accept one answer, but there is no \"best answer\" on this topic. I would appreciate anyone's experience that is useful to share.\nI'm particularly interested in experience with DI frameworks in Python and PHP, where I think the choice isn't very straight-forward. The question is language-agnostic, though.","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":367,"Q_Id":4738980,"Users Score":2,"Answer":"I usually choose frameworks, whether DI or otherwise, using the following criteria:\n\nPick a framework that has the required functionality for the job at hand\nPrefer frameworks that are simple - The less \"extra\" stuff not required for 1., the better.\nPrefer frameworks \"built-in\" to the language\/framework you're already using.\nPrefer frameworks that I already know and have used\n\nUsually, by working through the above, it's pretty obvious.  For example, the last DI framework I choose was MEF, mainly because it was a C# project (point 3.), it's simple, and it did what I needed it to do.","Q_Score":2,"Tags":"php,python,frameworks,dependency-injection","A_Id":4739047,"CreationDate":"2011-01-19T18:10:00.000","Title":"Inversion of Control: Have you ever had to decide what Dependency Injection framework is best for a project? Which one did you pick and why?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've written C# and the mantra coming from on high seems to be \"never use reflection in production code\". I have used it for test code, but never anything that runs in the wild. All the arguments seem reasonable, and there's always a way to do it by adding another layer of abstraction or design pattern or whatever.\nNow I'm starting to write some serious Python code, I wonder if the same principle applies. It seems that python is designed with reflection in mind. Modules and classes store members in an easily accessible dictionary. Django's models' Meta classes, for example take strings to reference members. \nI could write C#\/Java in Python but I really don't want to. I still firmly believe in 'no reflection' for said languages. Is the Python way just fundamentally different?","AnswerCount":5,"Available Count":4,"Score":0.0798297691,"is_accepted":false,"ViewCount":3093,"Q_Id":4745071,"Users Score":2,"Answer":"Yes, in that aspect, Python developement is fundametally different.\nReflection in C#\/Java refers to the ability of the runtime to know things about the code it's running, and to take decisions based on that information.\nSince Python uses dynamic typing, any type discovery is delegated to the runtime and not the compile time, so basically that means, that any Python program must use reflection in order to work, only it's not called reflecting, it's called running the program :)\nIn addition, the Python philosophy embraces the dynamic nature of execution, so you should not hesitate to use it to your advantage.\nP.S. While one should avoid using reflection in tight loops, and one should be aware that reflection is one or two orders of magnitude slower, one should not be afraid to use it when it's the right tool for the job.","Q_Score":9,"Tags":"c#,java,python,reflection","A_Id":4745791,"CreationDate":"2011-01-20T08:53:00.000","Title":"Never use reflection in production code! What about 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},{"Question":"I've written C# and the mantra coming from on high seems to be \"never use reflection in production code\". I have used it for test code, but never anything that runs in the wild. All the arguments seem reasonable, and there's always a way to do it by adding another layer of abstraction or design pattern or whatever.\nNow I'm starting to write some serious Python code, I wonder if the same principle applies. It seems that python is designed with reflection in mind. Modules and classes store members in an easily accessible dictionary. Django's models' Meta classes, for example take strings to reference members. \nI could write C#\/Java in Python but I really don't want to. I still firmly believe in 'no reflection' for said languages. Is the Python way just fundamentally different?","AnswerCount":5,"Available Count":4,"Score":0.0,"is_accepted":false,"ViewCount":3093,"Q_Id":4745071,"Users Score":0,"Answer":"IMO the reason for me about avoiding using reflection in production code is the fact than reflection could make code really harder to maintain and debug.","Q_Score":9,"Tags":"c#,java,python,reflection","A_Id":4745191,"CreationDate":"2011-01-20T08:53:00.000","Title":"Never use reflection in production code! What about 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},{"Question":"I've written C# and the mantra coming from on high seems to be \"never use reflection in production code\". I have used it for test code, but never anything that runs in the wild. All the arguments seem reasonable, and there's always a way to do it by adding another layer of abstraction or design pattern or whatever.\nNow I'm starting to write some serious Python code, I wonder if the same principle applies. It seems that python is designed with reflection in mind. Modules and classes store members in an easily accessible dictionary. Django's models' Meta classes, for example take strings to reference members. \nI could write C#\/Java in Python but I really don't want to. I still firmly believe in 'no reflection' for said languages. Is the Python way just fundamentally different?","AnswerCount":5,"Available Count":4,"Score":1.0,"is_accepted":false,"ViewCount":3093,"Q_Id":4745071,"Users Score":6,"Answer":"I think that the \"no reflection in production code\" is not correct in c#.\nReflection often allows the programmer to do things otherwise impossible.\nI would say \"no reflection for non-public members in production code\" and \"use reflection with care!\" if not used correctly, you could lose performance. Used correctly could make you gain performance (just think about static reflection)\nDon't use reflection for massivly called code.\nPython instead is a dynamic language. All concepts are different. The normality (and the correct way to do it) is using the techinques you are talking about.","Q_Score":9,"Tags":"c#,java,python,reflection","A_Id":4745134,"CreationDate":"2011-01-20T08:53:00.000","Title":"Never use reflection in production code! What about 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},{"Question":"I've written C# and the mantra coming from on high seems to be \"never use reflection in production code\". I have used it for test code, but never anything that runs in the wild. All the arguments seem reasonable, and there's always a way to do it by adding another layer of abstraction or design pattern or whatever.\nNow I'm starting to write some serious Python code, I wonder if the same principle applies. It seems that python is designed with reflection in mind. Modules and classes store members in an easily accessible dictionary. Django's models' Meta classes, for example take strings to reference members. \nI could write C#\/Java in Python but I really don't want to. I still firmly believe in 'no reflection' for said languages. Is the Python way just fundamentally different?","AnswerCount":5,"Available Count":4,"Score":1.2,"is_accepted":true,"ViewCount":3093,"Q_Id":4745071,"Users Score":18,"Answer":"As a dynamic language Python is fundamentally different than statically typed languages, so everything is reflection in it :-) Also never use reflection in production code (for static languages) seems a bit extreme to me.","Q_Score":9,"Tags":"c#,java,python,reflection","A_Id":4745093,"CreationDate":"2011-01-20T08:53:00.000","Title":"Never use reflection in production code! What about 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},{"Question":"We have several programs generating excel documents via com automation, some written in VB6, some in python. Regardless of the programming language those programs run 5 times slower than with older excel versions. Profiling the python version shows that the additional run time is spent mostly in low level com functionality (built-in methods Bind and Invoke), so every single com call is slowed down.\nAny tips, how we can speed this up, maybe a (security?) setting in excel 2010?\nThanks,\nThomas","AnswerCount":1,"Available Count":1,"Score":0.537049567,"is_accepted":false,"ViewCount":692,"Q_Id":4746115,"Users Score":3,"Answer":"I cannot answer for Python, but for VBA\/VB6 a significant number of changes were made in XL 2010 to improve performance rather than make it slower, see:http:\/\/blogs.office.com\/b\/microsoft-excel\/archive\/2009\/09\/03\/performance-improvements-in-excel-2010.aspx Could you give a VB example of something that is 5 times slower in 2010?","Q_Score":2,"Tags":"python,performance,excel,com,automation","A_Id":4746776,"CreationDate":"2011-01-20T10:44:00.000","Title":"Automation of excel 2010 5 times slower than before","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I'm trying to write some scripts in Python and stumbled upon the need of making something to update the password of a given user in a Linux system...\nUPDATE: the objective is to achieve the script to update the password automatically from a given data\/algorithm. The important thing is to have no human intervention...\nis there a way to achieve that? or should I search through other means?\nThanks!","AnswerCount":4,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":9738,"Q_Id":4749083,"Users Score":0,"Answer":"Use subprocess to invoke passwd.","Q_Score":5,"Tags":"python,linux,authentication","A_Id":4749108,"CreationDate":"2011-01-20T15:33:00.000","Title":"is there a way to script in Python to change user passwords in Linux? if so, 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},{"Question":"I have bigs files to move to a lot of servers. For now we use rsync, but I would like to experiment with bittorent.\nI'm studing the code of Deluge, a Python bittorent client but it uses twisted and is utterly complex. Do you know anything hight level?\nEDIT: I just read that Facebook does code deployment using Bittorent. Maybe they published their lib for that, but I can't find it. Ever hear of it?","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":891,"Q_Id":4750432,"Users Score":2,"Answer":"The original BitTorrent client is written in Python. Have you checked that out?","Q_Score":7,"Tags":"python,bittorrent","A_Id":4750449,"CreationDate":"2011-01-20T17:27:00.000","Title":"Do you know Python libs to send \/ receive files using Bittorent?","Data Science and Machine Learning":0,"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},{"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},{"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},{"Question":"I'm working on a Python script that reads an XML file encoded with UTF-8, does some manipulation with it and saves it to Google's Datastore (it's an App Engine program). \nThe way I'm reading and parsing the files is just with file.readline() and a few regular expressions. The only problem is that the file I'm working with has characters from a lot of different languages in it, so for example, it might have an \u00e9 or \u00c5 or Russian or Greek characters. \nI was getting an error like this at first: \"UnicodeDecodeError: 'ascii' codec can't decode byte 0xd0 in position 0: ordinal not in range(128).\" I then tried switching the encoding on the file open to \"ISO-8859-15\" which gets rid of the error but the outputted characters aren't displayed right. \nSo my question is: how to work with a file encoded in UTF-8 in Python without Python getting stuck on all of the special characters in the file? I hope this was clear enough, and thanks in advance for any advice.","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":629,"Q_Id":4752784,"Users Score":1,"Answer":"You say you changed the encoding you use with the file to ISO-8859-1. Did you try changing it to UTF-8?","Q_Score":4,"Tags":"python,google-app-engine,file-io,localization","A_Id":4753511,"CreationDate":"2011-01-20T21:26:00.000","Title":"Doing File I\/O in Python with non-ASCII Characters","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to write a pretty heavy duty math-based project, which will parse through about 100MB+ data several times a day, so, I need a fast language that's pretty easy to use. I would have gone with C, but, getting a large project done in C is very difficult, especially with the low level programming getting in your way. So, I was about python or java. Both are well equiped with OO features, so I don't mind that. Now, here are my pros for choosing python:\n\nVery easy to use language\nHas a pretty large library of useful stuff\nHas an easy to use plotting library\n\nHere are the cons:\n\nNot exactly blazing\nThere isn't a native python neural network library that is active\nI can't close source my code without going through quite a bit of trouble\nDeploying python code on clients computers is hard to deal with, especially when clients are idiots.\n\nHere are the pros for choosing Java:\n\nHuge library\nWell supported\nEasy to deploy\nPretty fast, possibly even comparable to C++\nThe Encog Neural Network Library is really active and pretty awesome\nNetworking support is really good\nStrong typing\n\nHere are the cons for Java:\n\nI can't find a good graphing library like matplotlib for python\nNo built in support for big integers, that means another dependency (I mean REALLY big integers, not just math.BigInteger size)\nFile IO is kind of awkward compared to Python\nNot a ton of array manipulating or \"make programming easy\" type of features that python has.\n\nSo, I was hoping you guys can tell me what to use. I'm equally familiar with both languages. Also, suggestions for other languages is great too.\nEDIT: WOW! you guys are fast! 30 mins at 10 responses!","AnswerCount":8,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":12225,"Q_Id":4759485,"Users Score":0,"Answer":"What is more important for you?\nIf it's rapid application development, I found Python significantly easier to code for than Java - and I was just learning Python, while I had been coding on Java for years.\nIf it's application speed and the ability to reuse existing code, then you should probably stick with Java. It's reasonably fast and many research efforts at the moment use Java as their language of choice.","Q_Score":21,"Tags":"java,python,math,stocks","A_Id":4759549,"CreationDate":"2011-01-21T13:47:00.000","Title":"Java or Python for math?","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},{"Question":"I'm trying to write a pretty heavy duty math-based project, which will parse through about 100MB+ data several times a day, so, I need a fast language that's pretty easy to use. I would have gone with C, but, getting a large project done in C is very difficult, especially with the low level programming getting in your way. So, I was about python or java. Both are well equiped with OO features, so I don't mind that. Now, here are my pros for choosing python:\n\nVery easy to use language\nHas a pretty large library of useful stuff\nHas an easy to use plotting library\n\nHere are the cons:\n\nNot exactly blazing\nThere isn't a native python neural network library that is active\nI can't close source my code without going through quite a bit of trouble\nDeploying python code on clients computers is hard to deal with, especially when clients are idiots.\n\nHere are the pros for choosing Java:\n\nHuge library\nWell supported\nEasy to deploy\nPretty fast, possibly even comparable to C++\nThe Encog Neural Network Library is really active and pretty awesome\nNetworking support is really good\nStrong typing\n\nHere are the cons for Java:\n\nI can't find a good graphing library like matplotlib for python\nNo built in support for big integers, that means another dependency (I mean REALLY big integers, not just math.BigInteger size)\nFile IO is kind of awkward compared to Python\nNot a ton of array manipulating or \"make programming easy\" type of features that python has.\n\nSo, I was hoping you guys can tell me what to use. I'm equally familiar with both languages. Also, suggestions for other languages is great too.\nEDIT: WOW! you guys are fast! 30 mins at 10 responses!","AnswerCount":8,"Available Count":3,"Score":0.024994793,"is_accepted":false,"ViewCount":12225,"Q_Id":4759485,"Users Score":1,"Answer":"If those are the choices, then Java should be the faster for math intensive work. It is compiled (although yes it is still running byte code).\nExelian mentions NumPy. There's also the SciPy package. Both are worth looking at but only really seem to give speed improvements for work with lots of arrays and vector processing.\nWhen I tried using these with NLTK for a math-intensive routine, I found there wasn't that much of a speedup.\nFor math intensive work these days, I'd be using C\/C++ or C# (personally I prefer C# over Java although that shouldn't affect your decision). My first employer out of univ. paid me to use Fortran for stuff that is almost certainly more math intensive than anything you're thinking of. Don't laugh - the Fortran compilers are some of the best for math processing on heavy iron.","Q_Score":21,"Tags":"java,python,math,stocks","A_Id":4759596,"CreationDate":"2011-01-21T13:47:00.000","Title":"Java or Python for math?","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},{"Question":"I'm trying to write a pretty heavy duty math-based project, which will parse through about 100MB+ data several times a day, so, I need a fast language that's pretty easy to use. I would have gone with C, but, getting a large project done in C is very difficult, especially with the low level programming getting in your way. So, I was about python or java. Both are well equiped with OO features, so I don't mind that. Now, here are my pros for choosing python:\n\nVery easy to use language\nHas a pretty large library of useful stuff\nHas an easy to use plotting library\n\nHere are the cons:\n\nNot exactly blazing\nThere isn't a native python neural network library that is active\nI can't close source my code without going through quite a bit of trouble\nDeploying python code on clients computers is hard to deal with, especially when clients are idiots.\n\nHere are the pros for choosing Java:\n\nHuge library\nWell supported\nEasy to deploy\nPretty fast, possibly even comparable to C++\nThe Encog Neural Network Library is really active and pretty awesome\nNetworking support is really good\nStrong typing\n\nHere are the cons for Java:\n\nI can't find a good graphing library like matplotlib for python\nNo built in support for big integers, that means another dependency (I mean REALLY big integers, not just math.BigInteger size)\nFile IO is kind of awkward compared to Python\nNot a ton of array manipulating or \"make programming easy\" type of features that python has.\n\nSo, I was hoping you guys can tell me what to use. I'm equally familiar with both languages. Also, suggestions for other languages is great too.\nEDIT: WOW! you guys are fast! 30 mins at 10 responses!","AnswerCount":8,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":12225,"Q_Id":4759485,"Users Score":0,"Answer":"The Apache Commons Math picked up where JAMA left off.  They are quite capable for scientific computing.  \nSo is Python - NumPy and SciPy are excellent.  I also like the fact that Python is a hybrid of object-orientation and functional programming.  Functional programming is awfully handy for numerical methods.\nI'd recommend using the one that you know best, but if the choice is a toss up I might lean towards Python.","Q_Score":21,"Tags":"java,python,math,stocks","A_Id":4765700,"CreationDate":"2011-01-21T13:47:00.000","Title":"Java or Python for math?","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},{"Question":"I've got good experience in Java and web development with some experience in C++ also. Lately, I've been thinking of leaving Java (bored with it) for C++. Then came Python(didn't like Ruby). I find it too good to resist and started using it. But the C++ still stays in my mind. \nNow I want to \"stick\" with one language to be fluent with it.\nPython is great for quick programming but its too easy and I fear it would dumb me down. C++ is tougher but I doubt if I should use such a language where more time is wasted in keeping the compiler happy.\nWhich language should I stick with. Any comments?","AnswerCount":7,"Available Count":7,"Score":0.0285636566,"is_accepted":false,"ViewCount":932,"Q_Id":4778978,"Users Score":1,"Answer":"Dumb programmers are good programmers. I've maintained code of people that is much smarter than me, their code is an unreadable mess. Funnily, the same things happen with people who can't program except that the really smart programmers code actually works.\nIn both cases it's hard for other people to take over, and at the same time the smart programmer has become bored and are doing something else.\nA good programmer writes \"dumb\", easy to understand code that he can give to somebody else to maintain, so he can go on doing more interesting things instead of maintaining that annoying piece of huge software that is seriously in need of a refactoring.\nProgrammers should be smart. Code should be dumb.","Q_Score":4,"Tags":"c++,python,choice","A_Id":4781086,"CreationDate":"2011-01-24T05:38:00.000","Title":"Which language should I stick with","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've got good experience in Java and web development with some experience in C++ also. Lately, I've been thinking of leaving Java (bored with it) for C++. Then came Python(didn't like Ruby). I find it too good to resist and started using it. But the C++ still stays in my mind. \nNow I want to \"stick\" with one language to be fluent with it.\nPython is great for quick programming but its too easy and I fear it would dumb me down. C++ is tougher but I doubt if I should use such a language where more time is wasted in keeping the compiler happy.\nWhich language should I stick with. Any comments?","AnswerCount":7,"Available Count":7,"Score":0.057080742,"is_accepted":false,"ViewCount":932,"Q_Id":4778978,"Users Score":2,"Answer":"It really depends on what kind of work you are planning to do. But, really, most high level programming languages operate on very similar principles. If you understand all the underlying concepts, switching from one language to another is just a matter of changing your syntax. \nStill, if you're insistent on sticking entirely with one language, I'm a fan of java. I think you're right that C++ is a little clunky for large tasks. You can probably accomplish anything with java that you can with python, but it trades some of the smoothness of python for a more direct relationship between what you're doing and what's actually going on. (At least, that's my opinion, as someone who has spent a LOT more time using java than using python. Experts in both might disagree with me.)","Q_Score":4,"Tags":"c++,python,choice","A_Id":4779041,"CreationDate":"2011-01-24T05:38:00.000","Title":"Which language should I stick with","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've got good experience in Java and web development with some experience in C++ also. Lately, I've been thinking of leaving Java (bored with it) for C++. Then came Python(didn't like Ruby). I find it too good to resist and started using it. But the C++ still stays in my mind. \nNow I want to \"stick\" with one language to be fluent with it.\nPython is great for quick programming but its too easy and I fear it would dumb me down. C++ is tougher but I doubt if I should use such a language where more time is wasted in keeping the compiler happy.\nWhich language should I stick with. Any comments?","AnswerCount":7,"Available Count":7,"Score":0.1137907297,"is_accepted":false,"ViewCount":932,"Q_Id":4778978,"Users Score":4,"Answer":"I am of the opinion that you don't \"leave\" a language.  It's still in your toolbox, just possibly not used as often. I would recommend looking at it more like:\n\"i'm thinking of broadening my options by learning a new language.\"  \nJust this past week I have worked in C#, Java, Bash, Python and Javascript.  When you're looked at as a problem solver, you never know what you'll be asked to help with next month, but you know you'll be doing something...","Q_Score":4,"Tags":"c++,python,choice","A_Id":4779017,"CreationDate":"2011-01-24T05:38:00.000","Title":"Which language should I stick with","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've got good experience in Java and web development with some experience in C++ also. Lately, I've been thinking of leaving Java (bored with it) for C++. Then came Python(didn't like Ruby). I find it too good to resist and started using it. But the C++ still stays in my mind. \nNow I want to \"stick\" with one language to be fluent with it.\nPython is great for quick programming but its too easy and I fear it would dumb me down. C++ is tougher but I doubt if I should use such a language where more time is wasted in keeping the compiler happy.\nWhich language should I stick with. Any comments?","AnswerCount":7,"Available Count":7,"Score":0.057080742,"is_accepted":false,"ViewCount":932,"Q_Id":4778978,"Users Score":2,"Answer":"I personally keep my main activity on C\/C++\/Assembly, and explore other languages on the side. This is because my goals are to stay as sharp as possible, whether that be on problem solving part or hardware friendly side. Personally I find it much more exciting to be next to the hardware amongst other things. Also, when you code regularly in the latter languages, managing pointers, memory etc. become natural and intrinsically makes you that much better as a coder and even more so problem solver ;^).\nHope this helps!","Q_Score":4,"Tags":"c++,python,choice","A_Id":4779018,"CreationDate":"2011-01-24T05:38:00.000","Title":"Which language should I stick with","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've got good experience in Java and web development with some experience in C++ also. Lately, I've been thinking of leaving Java (bored with it) for C++. Then came Python(didn't like Ruby). I find it too good to resist and started using it. But the C++ still stays in my mind. \nNow I want to \"stick\" with one language to be fluent with it.\nPython is great for quick programming but its too easy and I fear it would dumb me down. C++ is tougher but I doubt if I should use such a language where more time is wasted in keeping the compiler happy.\nWhich language should I stick with. Any comments?","AnswerCount":7,"Available Count":7,"Score":0.0855049882,"is_accepted":false,"ViewCount":932,"Q_Id":4778978,"Users Score":3,"Answer":"I'd suggest looking into a more esoteric language, at least for a little while.  Write up a small GUI in Smalltalk, or a utility in Common Lisp or Scheme.  Don't just try to adapt your Java knowledge to those languages, really try to use the languages the way the Ron Jeffries and Paul Grahams of the world use them.\nIf you just want to learn something applicable in the job market, then those won't be as good as Python or C++.  However, learning languages that are very different from languages that you already know should provide an interesting challenge, and permanently alter the way you think about programming.","Q_Score":4,"Tags":"c++,python,choice","A_Id":4779127,"CreationDate":"2011-01-24T05:38:00.000","Title":"Which language should I stick with","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've got good experience in Java and web development with some experience in C++ also. Lately, I've been thinking of leaving Java (bored with it) for C++. Then came Python(didn't like Ruby). I find it too good to resist and started using it. But the C++ still stays in my mind. \nNow I want to \"stick\" with one language to be fluent with it.\nPython is great for quick programming but its too easy and I fear it would dumb me down. C++ is tougher but I doubt if I should use such a language where more time is wasted in keeping the compiler happy.\nWhich language should I stick with. Any comments?","AnswerCount":7,"Available Count":7,"Score":1.2,"is_accepted":true,"ViewCount":932,"Q_Id":4778978,"Users Score":3,"Answer":"I have mostly experience in a few of domain-specific languages and a few general purpose languages (C, C++, Java, Delphi, etc.), and I have no experience with Python (only a general idea of it).\nYou must not judge languages on a basis of how hard they are. You say you have to consider the fact that you have to spend time debugging code to please the C++ compiler. I'm an experienced C++ programmer, and I can write several thousands of lines of code at a time, then compile and run, and everything works on the first try (well there are a few inevitable typos and stuff, like in any programming). So, that argument really only refers to your skill level in a programming language. I always favour C++ for any projects I have, because it is so effective (for me) to code in this language. That can surely factor in as a pragmatic view that you should program in the language in which you can actually be productive (in the short term).\nBut, when it comes to learning, you have to steer towards what seems applicable in your domain. I do artificial intelligence for controlling robots, so I need the hardware access and I need the complex programming constructs that OOP, GP and TMP offer. So, the C++ choice is a no-brainer for me. You have to ask what are the common tasks in your domain? Where do they stand on scales like low- vs. high-level, networking vs numerical analysis, user-oriented vs. computationally-oriented? What are the most widely used languages in your field (or the one you would like to get into)?\nI also want to point out that, as a Linux user, a setup that seems quite prevalent amongst the open-source developers of the Linux software ecosystem is to implement low-level drivers in C, complex software in C++, and high-level software interfaces and plugins in Python. That's just what I seem to observe in many of the open-source software, and I think it makes sense that it seems to use the best sides of all three languages.. that's why I'm considering starting to learn Python on the side.","Q_Score":4,"Tags":"c++,python,choice","A_Id":4779510,"CreationDate":"2011-01-24T05:38:00.000","Title":"Which language should I stick with","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've got good experience in Java and web development with some experience in C++ also. Lately, I've been thinking of leaving Java (bored with it) for C++. Then came Python(didn't like Ruby). I find it too good to resist and started using it. But the C++ still stays in my mind. \nNow I want to \"stick\" with one language to be fluent with it.\nPython is great for quick programming but its too easy and I fear it would dumb me down. C++ is tougher but I doubt if I should use such a language where more time is wasted in keeping the compiler happy.\nWhich language should I stick with. Any comments?","AnswerCount":7,"Available Count":7,"Score":1.0,"is_accepted":false,"ViewCount":932,"Q_Id":4778978,"Users Score":13,"Answer":"I suggest you don't worry about \"sticking\" with a language and learn to move in and out of whatever is the best solution for your problem.  \nThe best programmers are simply great problem solvers - the particular language doesn't really matter.","Q_Score":4,"Tags":"c++,python,choice","A_Id":4778995,"CreationDate":"2011-01-24T05:38:00.000","Title":"Which language should I stick with","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I can't find the answer on SO but it's very likely that the argument has been already discussed. \nI'm trying to write a quite small size program using the Python language. It's my first \"real\" experience with a dynamic language and I would prefer to do everything in the right way. One of the practice that I would try to apply since the beginning is unit-testing.\nHow can I quickly test that the parameters of a method are of the right type? Should I do it?\nWith right type I mean for instance to check that a method that works with float numbers is not called with a String. In this case consider the possibility that the method should obviously accept even integers and not only float.","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":313,"Q_Id":4783257,"Users Score":1,"Answer":"Unit testing with complete coverage is really the only way to handle any development work which relies on dynamic languages.  Clearly it's very beneficial to have strong coverage tests for statically typed languages but in my experience it's even more important when you have dynamic typing.\nIf you aren't covering all the code that can run in your tests, then really you are asking for trouble.  So you want to use a coverage analysis tool in tandem with your unit tests to prove that you are reaching all of your code.\nEven that won't guard against all pitfalls \u2013 your tests really need to exercise all the possibly erroneous input data errors your program may receive.","Q_Score":2,"Tags":"python,unit-testing,dynamic-languages","A_Id":4783323,"CreationDate":"2011-01-24T14:37:00.000","Title":"How to deal with wrong parameters types in dynamic-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},{"Question":"I'm gathering basic metadata for images - mainly their dimensions, although it'd be nice to get any other available metadata as well. The image formats I'm interested in are png, jpg, and gif. \nI'm using PIL at the moment, but it occurred to me there may be a simpler way that doesn't involve external dependencies or binary libraries. Is there one?","AnswerCount":3,"Available Count":2,"Score":0.1973753202,"is_accepted":false,"ViewCount":1574,"Q_Id":4800425,"Users Score":3,"Answer":"I don't think there is anything built in, but if you look up those file formats, you will find that the size is encoded near the beginning of the file.\nYou can use the struct module to parse just enough of the header to work out the size","Q_Score":2,"Tags":"python","A_Id":4800509,"CreationDate":"2011-01-26T00:39:00.000","Title":"Python: Simplest (non-PIL) way to get image metadata (mainly size)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm gathering basic metadata for images - mainly their dimensions, although it'd be nice to get any other available metadata as well. The image formats I'm interested in are png, jpg, and gif. \nI'm using PIL at the moment, but it occurred to me there may be a simpler way that doesn't involve external dependencies or binary libraries. Is there one?","AnswerCount":3,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":1574,"Q_Id":4800425,"Users Score":1,"Answer":"Answer: No there is not a simpler way than using an external library.\nIf you are only going to care about one and one file format only, then yes. Then it's easy to implement something specific for that. But if you want to be generic, you need to support a lot of file formats, and then you don't want to do all that work yourself.\nTo simplify install of PIL, you might look at Pillow, a friendly fork\u00a7 that makes PIL easy_installable.","Q_Score":2,"Tags":"python","A_Id":4804100,"CreationDate":"2011-01-26T00:39:00.000","Title":"Python: Simplest (non-PIL) way to get image metadata (mainly size)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I would like to ideally set up a user interface for designing emails that include text, html, and images, and would like this interface to output the raw encoded email so I can then pipe it to my mail application, save it in a database, etc..  \nAre there any libraries that I could look at for generating raw emails, and\/or the necessary HTML?\nFor example:  You can create a document in MS Word (interface) and merge it with outlook to send.   Ideally I'd like a Jquery based library that would let me visually create the mail, and output the result as a long string.   \nHowever, even any server-based libraries in any languages would be helpful:  Javascript, Ruby, Python, Java, etc..\nI think what I'm looking for is a mail generation library (or as mentioned in the answer below, a mime-generation framework\nEDIT:  I know this question is pretty general.. If it can be rephrased better let me know.  If its like asking for a \"Facebook\", and naive and unrealizable, let me know.  Useless comments that don't add anything not needed though","AnswerCount":4,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":220,"Q_Id":4803499,"Users Score":1,"Answer":"Python has modules both for creating and sending emails in the standard library. Don't know about Java or Ruby. For generating HTML I'd use some HTML template language. There are tons of them for Python. Pick one you like.","Q_Score":1,"Tags":"java,jquery,python,ruby,email","A_Id":4803954,"CreationDate":"2011-01-26T10:30:00.000","Title":"What libraries exist for creating raw multipart 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},{"Question":"I'm using the pyBluez module on Python 2.6 on WindowsXP. I'd like to get the RSSI of other bluetooth devices around.\nI foudn some code but it makes use of _bluetooth, which I cannto find anywhere for Windows.\nIs it available \/ is there another way to circumvent the problem, getting the RSSI without using _bluetooth?\nThank you all!","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1917,"Q_Id":4815088,"Users Score":0,"Answer":"The _bluetooth module is a part of PyBluez. If you have installed a Windows release of PyBluez, it should work.\nI don't know enough about Bluetooth to even know what \"getting the RSSI without using it\" means or why it should be a problem, so can't help you there. :)","Q_Score":1,"Tags":"python,windows,bluetooth,rssi","A_Id":4815494,"CreationDate":"2011-01-27T10:17:00.000","Title":"RSSI with pyBluez on WindowsXP","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},{"Question":"I am trying to create a small application for Symbian mobile phones using Python. Being a beginner i am having some trouble in setting up the environment for development. I installed Symbian3 SDK,PyS60 Application Manager ( for creating the .sis files to be installed on phones) and python 2.5.2 . I created a small hello world program and created its equivalent .sis file. But when i try to install it in Symbian 3 SDK, it gives me a 'Python Run time Error' ; i suppose it is because there isnt any python installed on the SDK. But when i tried to install the PythonForS60.sis file, it gives me a certificate error. I tried downloading the file through SDK, again it gives me a certificate error. I tried certifying the application through SymbianSigned.com, then it gives this error \n\"The .sis file contains capabilities that are not permitted for Open Signed (Online)\nFAILURE: Submitted .sis file uses a UID that is not allocated to the account holder matching this email address (0x20022ee8 )\nFAILURE: Submitted .sis file uses a UID that is in protected range and is not allocated to the account holder matching this email address (0x20022ee8)\" . Can somebody help me to solve this..??","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":900,"Q_Id":4825055,"Users Score":1,"Answer":"Open Application Manager on your Symbian phone, go to settings and select Software installation. Change it from Signed to All. This will allow you to install applications which don't have a certificate, such as the SIS file you just packaged. \nAlso note that PythonForS60 2.0 works only with Python 2.5.","Q_Score":1,"Tags":"python,symbian,pys60","A_Id":4825096,"CreationDate":"2011-01-28T05:11:00.000","Title":"Certificate Error on installing PythonForS60","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},{"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},{"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},{"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},{"Question":"Is there a simple way or code to delete the account from a user? I want to delete the username, email address, first_name, last_name and the profile-data.\nI do have two apps\nThanks!","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":405,"Q_Id":4837591,"Users Score":0,"Answer":"Can You Explain What kind of application you Use? If you use some kind of database with your application then simply run delete query with some specific condition","Q_Score":1,"Tags":"python,django,web","A_Id":4837665,"CreationDate":"2011-01-29T15:11:00.000","Title":"Simple way to delete users account?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I downloaded the Wikipedia article titles file which contains the name of every Wikipedia article. I need to search for all the article titles that may be a possible match.  For example, I might have the word \"hockey\", but the Wikipedia article for hockey that I would want is \"Ice_hockey\".  It should be a case-insensitive search too.\nI'm using Python, and is there a more efficient way than to just do a line by line search?  I'll be performing this search like 500 or a 1000 times per minute ideally.  If line by line is my only option, are there some optimizations I can do within this?\nI think there are several million lines in the file.\nAny ideas?\nThanks.","AnswerCount":3,"Available Count":3,"Score":1.2,"is_accepted":true,"ViewCount":2903,"Q_Id":4839597,"Users Score":3,"Answer":"Greg's answer is good if you want to match on individual words.  If you want to match on substrings you'll need something a bit more complicated, like a suffix tree (http:\/\/en.wikipedia.org\/wiki\/Suffix_tree).  Once constructed, a suffix tree can efficiently answer queries for arbitrary substrings, so in your example it could match \"Ice_Hockey\" when someone searched for \"hock\".","Q_Score":6,"Tags":"python,string,search,large-files","A_Id":4840359,"CreationDate":"2011-01-29T21:36:00.000","Title":"most efficient way to find partial string matches in large file of strings (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},{"Question":"I downloaded the Wikipedia article titles file which contains the name of every Wikipedia article. I need to search for all the article titles that may be a possible match.  For example, I might have the word \"hockey\", but the Wikipedia article for hockey that I would want is \"Ice_hockey\".  It should be a case-insensitive search too.\nI'm using Python, and is there a more efficient way than to just do a line by line search?  I'll be performing this search like 500 or a 1000 times per minute ideally.  If line by line is my only option, are there some optimizations I can do within this?\nI think there are several million lines in the file.\nAny ideas?\nThanks.","AnswerCount":3,"Available Count":3,"Score":0.2605204458,"is_accepted":false,"ViewCount":2903,"Q_Id":4839597,"Users Score":4,"Answer":"If you've got a fixed data set and variable queries, then the usual technique is to reorganise the data set into something that can be searched more easily. At an abstract level, you could break up each article title into individual lowercase words, and add each of them to a Python dictionary data structure. Then, whenever you get a query, convert the query word to lower case and look it up in the dictionary. If each dictionary entry value is a list of titles, then you can easily find all the titles that match a given query word.\nThis works for straightforward words, but you will have to consider whether you want to do matching on similar words, such as finding \"smoking\" when the query is \"smoke\".","Q_Score":6,"Tags":"python,string,search,large-files","A_Id":4839646,"CreationDate":"2011-01-29T21:36:00.000","Title":"most efficient way to find partial string matches in large file of strings (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},{"Question":"I downloaded the Wikipedia article titles file which contains the name of every Wikipedia article. I need to search for all the article titles that may be a possible match.  For example, I might have the word \"hockey\", but the Wikipedia article for hockey that I would want is \"Ice_hockey\".  It should be a case-insensitive search too.\nI'm using Python, and is there a more efficient way than to just do a line by line search?  I'll be performing this search like 500 or a 1000 times per minute ideally.  If line by line is my only option, are there some optimizations I can do within this?\nI think there are several million lines in the file.\nAny ideas?\nThanks.","AnswerCount":3,"Available Count":3,"Score":0.0665680765,"is_accepted":false,"ViewCount":2903,"Q_Id":4839597,"Users Score":1,"Answer":"I'd suggest you put your data into an sqlite database, and use the SQL 'like' operator for your searches.","Q_Score":6,"Tags":"python,string,search,large-files","A_Id":4841314,"CreationDate":"2011-01-29T21:36:00.000","Title":"most efficient way to find partial string matches in large file of strings (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},{"Question":"Is there any way to disable a module from being loaded on my system? Let's say i would like to restrict my users from accessing the subprocess or popen2 module. Something like PHP's 'disabled_functions' or any similar method to achieve the same thing.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":3339,"Q_Id":4842049,"Users Score":1,"Answer":"As @Thomas points out, blacklisting is a pretty poor mechanism for implementing any security mechanisms. Whitelisting is a much safer approach.\nBut a mechanism inside the interpreter isn't particularly excellent for any number of reasons: flaws in the interpreter that are exploitable at the source code level would allow users to walk right past any mechanisms built in at that level (and the PHP team asked Linux vendors to stop calling this a security problem, because (a) they fixed one of these every week and (b) trying to confine an untrusted user-supplied script is pretty much an impossible task -- use FastCGI or similar tools for potentially untrusted scripts).\nThe Python interpreter is probably not designed to handle malicious input, so don't treat it as such.\nIf you really want to confine what untrusted users can do with Python scripts, a few pieces of advice: Do not use mod_python or anything like it. Use FastCGI or similar tools that you let specify the user account that should run the script and won't execute the script as your webserver user. And learn how to configure SELinux or AppArmor to confine what that process can do -- an hour setting up one of these tools might save you huge headaches down the road, plus you get to laugh at all the cute little exploit attempts that fail.","Q_Score":5,"Tags":"python","A_Id":4842172,"CreationDate":"2011-01-30T09:03:00.000","Title":"DIsable 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":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"Is it possible to acquire the global interpreter lock from python code? Or is that purely implemented in the C side?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":914,"Q_Id":4855903,"Users Score":7,"Answer":"If your code executes then you have the GIL, no need to acquire it manually.","Q_Score":3,"Tags":"python,multithreading,gil","A_Id":4855924,"CreationDate":"2011-01-31T20:46:00.000","Title":"Acquiring the global interpreter lock 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":1,"System Administration and DevOps":0,"Web Development":0},{"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},{"Question":"I am trying to build Python from source and need to include the SSL module for my web scraper to work with it.\nI ran into the problem of SSL not being found, so I downloaded and built OpenSSL from source. The problem is, I need to install the development libraries along with OpenSSL in order for Python to run the -lssl parameter correctly when running make. I can't seem to find any documentation on how to build OpenSSL with the development libs, even though I'm sure it's got to be something simple I'm just missing.\nI must do this from source; with no package managers. I have my reasons.\nEDIT:\nI have changed a few of the python configuration settings to try and fix the problem, and this is the compile error I am getting now:\n\ngcc -pthread  -Xlinker -export-dynamic -o python \\\n                Modules\/python.o \\\n                libpython2.7.a -lpthread -ldl  -lutil -L\/home\/[username]\/openssl-src -lssl -lcrypto   -lm\nlibpython2.7.a(posixmodule.o)(.text+0x4016): In function posix_tmpnam':
\n.\/Modules\/posixmodule.c:7346: warning: the use oftmpnam_r' is dangerous, better use mkstemp'\nlibpython2.7.a(posixmodule.o)(.text+0x3f76): In functionposix_tempnam':\n.\/Modules\/posixmodule.c:7301: warning: the use of tempnam' is dangerous, better usemkstemp'\n.\/python: error while loading shared libraries: libssl.so.1.0.0: cannot open shared object file: No such file or directory\nmake: * [sharedmods] Error 127\nThe \"no such file or directory\" is being thrown looking for a file that does exist in the \/home\/[username]\/openssl-src directory.","AnswerCount":3,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":2122,"Q_Id":4862598,"Users Score":1,"Answer":"This answer doesn't EXACTLY answer my question, but I did find out what I needed to know so I will post it here. I had to change the location of the SSL files it was looking for to just \/usr rather than \/usr\/local. RedHat by default has all the shared libraries in \/usr\/lib rather than \/usr\/local\/lib, which is where it was looking by default.","Q_Score":1,"Tags":"python,linux,openssl","A_Id":4927502,"CreationDate":"2011-02-01T12:31:00.000","Title":"Building OpenSSL to compile portable version 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":0},{"Question":"In Python, am using the LightBlue module for Bluetooth connectivity. How do I get the speed at which I am sending file to my phone from my laptop (Ubuntu)?","AnswerCount":3,"Available Count":2,"Score":-0.0665680765,"is_accepted":false,"ViewCount":1146,"Q_Id":4863727,"Users Score":-1,"Answer":"You need a binding for the Bluetooth driver\/OS service that handles the Bluetooth device.\nMost drivers are written in C, some in C++. If you can get the source code\/API or if it's provided you might be able to access it from python. You might need to code some custom binding to your OS service to do so.","Q_Score":0,"Tags":"python,bluetooth","A_Id":4863792,"CreationDate":"2011-02-01T14:27:00.000","Title":"Python bluetooth transfer speed?","Data Science and Machine Learning":0,"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},{"Question":"In Python, am using the LightBlue module for Bluetooth connectivity. How do I get the speed at which I am sending file to my phone from my laptop (Ubuntu)?","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":1146,"Q_Id":4863727,"Users Score":0,"Answer":"The simplest solution is to figure out how large the file is, capture the system time before the transfer and after the transfer, and then do the math. To compute a more fine-grained transfer rate that changes over the course of the transfer, you would need to use the size of your transmit buffers and the time interval between sends.","Q_Score":0,"Tags":"python,bluetooth","A_Id":4870002,"CreationDate":"2011-02-01T14:27:00.000","Title":"Python bluetooth transfer speed?","Data Science and Machine Learning":0,"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},{"Question":"I wrote a method that does some stuff and catches bad filenames. what should happen is if the path doesn't exist, it throws an IOError. however, it thinks my exception handling is bad syntax... why??\n\ndef whatever():\n try:\n # do stuff\n # and more stuff\n except IOError:\n # do this\n pass\nwhatever()\n\nbut before it even gets to calling whatever(), it prints the following:\n\nTraceback (most recent call last):\n File \"\", line 1, in \n File \"getquizzed.py\", line 55\n except IOError:\n ^\nSyntaxError: invalid syntax\n\nwhen imported...help?!","AnswerCount":4,"Available Count":2,"Score":1.0,"is_accepted":false,"ViewCount":36567,"Q_Id":4869476,"Users Score":6,"Answer":"there's 1 more possible if you're privileged to have an older installation \nand\nyou're using the 'as' syntax:\n\u00a0\u00a0\u00a0\u00a0\u00a0except IOError as ioe:\nand\nthe parser's getting tripped up on 'as'.\nUsing as is the preferred syntax in Python 2.6 and better.\nIt's a syntax error in Python 2.5 and older. For pre-2.6, use this:\n\u00a0\u00a0\u00a0\u00a0\u00a0except IOError, ioe:","Q_Score":13,"Tags":"python,exception,exception-handling,try-catch,ioerror","A_Id":18236796,"CreationDate":"2011-02-02T00:14:00.000","Title":"catching an IOError 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},{"Question":"I wrote a method that does some stuff and catches bad filenames. what should happen is if the path doesn't exist, it throws an IOError. however, it thinks my exception handling is bad syntax... why??\n\ndef whatever():\n try:\n # do stuff\n # and more stuff\n except IOError:\n # do this\n pass\nwhatever()\n\nbut before it even gets to calling whatever(), it prints the following:\n\nTraceback (most recent call last):\n File \"\", line 1, in \n File \"getquizzed.py\", line 55\n except IOError:\n ^\nSyntaxError: invalid syntax\n\nwhen imported...help?!","AnswerCount":4,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":36567,"Q_Id":4869476,"Users Score":2,"Answer":"Just missing something in your try block, i.e. pass or anything, otherwise it gives an indentation error.","Q_Score":13,"Tags":"python,exception,exception-handling,try-catch,ioerror","A_Id":4869511,"CreationDate":"2011-02-02T00:14:00.000","Title":"catching an IOError 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},{"Question":"We have developed a web application running on Linux that is quite popular. We now wish to release it as an appliance so customers can run it internally on their own networks. \nWe are unsure of the best approach. We are flexible on areas such as: the Linux distro, whether it's a hardware or software only appliance. Does anyone have any advice on the best way to go about this? Links to any good resources on the subject? Questions we should be asking ourselves? Legal considerations for a commercial app? Security considerations?\nUPDATE:\nIt's a Python based web application. We would like the user to be able to do everything via a web interface. No command line stuff etc.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":124,"Q_Id":4872722,"Users Score":0,"Answer":"It depends on what langauge\/tecnology application is written.\nIf it is java, release war file + tomcat\/jboss.\nIf it is python, release eggs.\nIf it is php... not sure, probably just .tar.bz2.\nLinux distro or virtual image mught be advantage, but I dislike using them, because they are usually does not fits to my infra (why do I have to install some custom debian-based distro to my rhel-only infrastructure?).","Q_Score":3,"Tags":"python,appliance","A_Id":4872968,"CreationDate":"2011-02-02T09:33:00.000","Title":"Considerations for moving our web app to an appliance","Data Science and Machine Learning":0,"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},{"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},{"Question":"We want to parse our huge C++ source tree to gain enough info to feed to another tool to make diagrams of class and object relations, discern the overall organization of things etc. \nMy best try so far is a Python script that scans all .cpp and .h files, runs regex searches to try to detect class declarations, methods, etc. We don't need a full-blown analyzer to capture every detail, or some heavy UML diagram generator - there's a lot of detail we'd like to ignore and we're inventing new types of diagrams. The script sorta works, but by gosh it's true: C++ is hard to parse! \nSo I wonder what tools exist for extracting the info we want from our sources? I'm not a language expert, and don't want something with a steep learning curve. Something we low-brow blue-collar programmer grunts can use :P\nPython is preferred as one of the standard languages here, but it's not essential.","AnswerCount":7,"Available Count":4,"Score":0.0,"is_accepted":false,"ViewCount":6163,"Q_Id":4881377,"Users Score":0,"Answer":"If you can bring yourself to run this analysis using a Windows-platform application, save yourself a lot of time and trouble, and spend $200 on Enterprise Architect by Sparx Systems (I have no affiliation with this company, just a satisfied customer). (Note: this should not be confused with Microsoft's own \"Enterprise Architect\" bundle for Visual Studio.)\nEA can reverse-engineer a number of languages, including C++, C, Java, and Python, generating some very nice UML class diagrams. (EA comes in a number of different packages, Desktop is the cheapest but you have to by Professional, the 2nd cheapest, to get the code engineering feature included.) I also like the integration between the generated class diagrams and sequence diagramming, where you can drag a line between object lifelines and a menu of defined methods is presented to you based on the class definition of the target object. At my former consulting business, we used this tool quite a bit to develop system architectural proposals which we then included as part of our project bid (just copy\/paste the diagram into a Word doc). It wont take long to make back your $200.","Q_Score":13,"Tags":"c++,python,parsing,code-analysis","A_Id":4882258,"CreationDate":"2011-02-02T23:59:00.000","Title":"How to parse C++ source 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},{"Question":"We want to parse our huge C++ source tree to gain enough info to feed to another tool to make diagrams of class and object relations, discern the overall organization of things etc. \nMy best try so far is a Python script that scans all .cpp and .h files, runs regex searches to try to detect class declarations, methods, etc. We don't need a full-blown analyzer to capture every detail, or some heavy UML diagram generator - there's a lot of detail we'd like to ignore and we're inventing new types of diagrams. The script sorta works, but by gosh it's true: C++ is hard to parse! \nSo I wonder what tools exist for extracting the info we want from our sources? I'm not a language expert, and don't want something with a steep learning curve. Something we low-brow blue-collar programmer grunts can use :P\nPython is preferred as one of the standard languages here, but it's not essential.","AnswerCount":7,"Available Count":4,"Score":0.0855049882,"is_accepted":false,"ViewCount":6163,"Q_Id":4881377,"Users Score":3,"Answer":"Can you run a preprocessing step? Doxygen parses most C++ syntax and creates xml with all the relationships. Compilers also create debug databases (typically dwarf format from gcc and codeview format from MSC).","Q_Score":13,"Tags":"c++,python,parsing,code-analysis","A_Id":4881763,"CreationDate":"2011-02-02T23:59:00.000","Title":"How to parse C++ source 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},{"Question":"We want to parse our huge C++ source tree to gain enough info to feed to another tool to make diagrams of class and object relations, discern the overall organization of things etc. \nMy best try so far is a Python script that scans all .cpp and .h files, runs regex searches to try to detect class declarations, methods, etc. We don't need a full-blown analyzer to capture every detail, or some heavy UML diagram generator - there's a lot of detail we'd like to ignore and we're inventing new types of diagrams. The script sorta works, but by gosh it's true: C++ is hard to parse! \nSo I wonder what tools exist for extracting the info we want from our sources? I'm not a language expert, and don't want something with a steep learning curve. Something we low-brow blue-collar programmer grunts can use :P\nPython is preferred as one of the standard languages here, but it's not essential.","AnswerCount":7,"Available Count":4,"Score":0.0285636566,"is_accepted":false,"ViewCount":6163,"Q_Id":4881377,"Users Score":1,"Answer":"From what you say of our requirements, Tony's answer of GccXML will probably be the best option. If that doesn't work, you could try to generate an outline of your program with cscope or ctags, and then work your way to the info you want from it's output.","Q_Score":13,"Tags":"c++,python,parsing,code-analysis","A_Id":4881710,"CreationDate":"2011-02-02T23:59:00.000","Title":"How to parse C++ source 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},{"Question":"We want to parse our huge C++ source tree to gain enough info to feed to another tool to make diagrams of class and object relations, discern the overall organization of things etc. \nMy best try so far is a Python script that scans all .cpp and .h files, runs regex searches to try to detect class declarations, methods, etc. We don't need a full-blown analyzer to capture every detail, or some heavy UML diagram generator - there's a lot of detail we'd like to ignore and we're inventing new types of diagrams. The script sorta works, but by gosh it's true: C++ is hard to parse! \nSo I wonder what tools exist for extracting the info we want from our sources? I'm not a language expert, and don't want something with a steep learning curve. Something we low-brow blue-collar programmer grunts can use :P\nPython is preferred as one of the standard languages here, but it's not essential.","AnswerCount":7,"Available Count":4,"Score":1.0,"is_accepted":false,"ViewCount":6163,"Q_Id":4881377,"Users Score":6,"Answer":"You could check out GccXML and OpenC++, as well as doxygen.","Q_Score":13,"Tags":"c++,python,parsing,code-analysis","A_Id":4881402,"CreationDate":"2011-02-02T23:59:00.000","Title":"How to parse C++ source 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},{"Question":"Normally Fabric quits as soon as a run() call returns a non-zero exit code. For some calls, however, this is expected. For example, PNGOut returns an error code of 2 when it is unable to compress a file.\nCurrently I can only circumvent this limitation by either using shell logic (do_something_that_fails || true or do_something_that_fails || do_something_else), but I'd rather be able to keep my logic in plain Python (as is the Fabric promise).\nIs there a way to check for an error code and react to it rather than having Fabric panic and die? I still want the default behaviours for other calls, so changing its behaviour by modifying the environment doesn't seem like a good option (and as far as I recall, you can only use that to tell it to warn instead of dying anyway).","AnswerCount":4,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":44680,"Q_Id":4888568,"Users Score":4,"Answer":"Apparently messing with the environment is the answer.\nfabric.api.settings can be used as a context manager (with with) to apply it to individual statements. The return value of run(), local() and sudo() calls isn't just the output of the shell command, but also has special properties (return_code and failed) that allow reacting to the errors.\nI guess I was looking for something closer to the behaviour of subprocess.Popen or Python's usual exception handling.","Q_Score":70,"Tags":"python,error-handling,fabric","A_Id":4888891,"CreationDate":"2011-02-03T16:11:00.000","Title":"Can I catch error codes when using Fabric to run() calls in a remote 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},{"Question":"In another question I asked for \"the best\" language for a certain purpose. Realizing this goal was a bit too much to start, I simplified my idea :) But there were really useful language hints. So I decided on Scala for the desktop-app and consider between Perl and Python on the webserver.\nI want to program something like an asynchronous chat (little bit like an email). So you start your program pick your name and add a friend with his unique id. Then you can write him a simple message and when your friends start up his pc, launches the \"chat.exe\" he receives the mail (internet is required) and is able to answer. No special functions, smiley's or text formatting, just simple for learning purpose.\nMy concept is: Use Scala for the \"chat.exe\" (Or is just a \"chat.jar\" possible?) which communicates via SOCKET with a Perl\/Python Framework which handles the requests.\nSo you type \"Hello there\" and click on send. This message is transfered via SOCKET to a Perl\/Python script which reads the request an put this message in a MySQL database. On the otherside the chat.exe of your friend checks for new messages and if there is one, the Perl\/Python script transfer the message. Also via SOCKET.\nDo you think this works out? Is SOCKET appropriate and fits in? Or perhaps REST? But I think for REST-Requests you have to use the URI (http:\/\/example.com\/newmessage\/user2\/user3\/Hi_how_are_you). This looks very unsecure.\nLook forward to your comments!\nHave a nice day,\nKurt","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":609,"Q_Id":4891911,"Users Score":0,"Answer":"To implement something like that you would need to go through a MQ System like perhaps ActiveMQ instead of using plain sockets.","Q_Score":0,"Tags":"python,perl,sockets,scala,client-server","A_Id":4891991,"CreationDate":"2011-02-03T21:25:00.000","Title":"Does this Scala Perl\/Python architecture make sense","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},{"Question":"In another question I asked for \"the best\" language for a certain purpose. Realizing this goal was a bit too much to start, I simplified my idea :) But there were really useful language hints. So I decided on Scala for the desktop-app and consider between Perl and Python on the webserver.\nI want to program something like an asynchronous chat (little bit like an email). So you start your program pick your name and add a friend with his unique id. Then you can write him a simple message and when your friends start up his pc, launches the \"chat.exe\" he receives the mail (internet is required) and is able to answer. No special functions, smiley's or text formatting, just simple for learning purpose.\nMy concept is: Use Scala for the \"chat.exe\" (Or is just a \"chat.jar\" possible?) which communicates via SOCKET with a Perl\/Python Framework which handles the requests.\nSo you type \"Hello there\" and click on send. This message is transfered via SOCKET to a Perl\/Python script which reads the request an put this message in a MySQL database. On the otherside the chat.exe of your friend checks for new messages and if there is one, the Perl\/Python script transfer the message. Also via SOCKET.\nDo you think this works out? Is SOCKET appropriate and fits in? Or perhaps REST? But I think for REST-Requests you have to use the URI (http:\/\/example.com\/newmessage\/user2\/user3\/Hi_how_are_you). This looks very unsecure.\nLook forward to your comments!\nHave a nice day,\nKurt","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":609,"Q_Id":4891911,"Users Score":1,"Answer":"Use Scala for the \"chat.exe\" (Or is just a \"chat.jar\" possible?) \n\nStep 1. Figure that out. Actually write some stuff and see what you can build.\n\nwhich communicates via SOCKET with a Perl\/Python Framework which handles the requests. \n\nNot meaningful. All internet communication is done with sockets. Leave this sentence out and you don't lose any meaning.\n\nThis message is transfered via SOCKET to a Perl\/Python script which reads the request an put this message in a MySQL database. \n\nA little useful information. Sockets, however, go without saying.\n\nOn the otherside the chat.exe of your friend checks for new messages and if there is one, the Perl\/Python script transfer the message. Also via SOCKET.\n\nRight. Sockets, again, don't mean much.\nOn top of sockets there are dozens of protocols. FTP, Telnet, HTTP, SMTP, etc., etc.\nStep 2 is to figure out which protocol you want to use. REST, by the way is a particular use of HTTP. You should really, really look very closely at HTTP and REST before dismissing them. \n\nThis looks very unsecure\n\nNot clear why you're saying this. I can only guess that you don't know about HTTP security features.\n\nA lazy programmer might do this.\n\nInstall Python, Django, MySQL-Python and Piston.\nDefine a Django Model, configure the defaults so that model is exposed as a secure RESTful set of services.\n\nThat's sort of it for the server side message GET, POST, PUT and DELETE are all provided by Django, Piston and the Django ORM layer. Authentication can be any of a variety of mechanisms. I'm a big fan of HTTP Digest authentication.","Q_Score":0,"Tags":"python,perl,sockets,scala,client-server","A_Id":4892391,"CreationDate":"2011-02-03T21:25:00.000","Title":"Does this Scala Perl\/Python architecture make sense","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},{"Question":"I am a 3rd year CS engineering student, I have done some basic programming in languages like C,C++,Java,Shell,Perl,PHP,Ruby on Rails, Python. But now I wanted to settle for one language, so I thought of finally mastering one scripting language and other compiled one. So I decided to stick with C++ and Python. Can someone suggest me, would these be sufficient for any kind of programming, or for web designing I should stick to ROR?","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":436,"Q_Id":4896361,"Users Score":0,"Answer":"Language should be a means to an end. Pick a project you want to work on, then figure out what you will need to know to get the job done. It's very difficult to get any language-learning to stick without some practical application. \nAnd \"knowing a language\" is not particularly difficult or useful. Knowing how to use most of the important libraries and platforms associated with a language is usually much more time-intensive and useful.\nAs far as picking a project if you can't think of one, maybe try for something on a mobile platform -- Android \/ iOS \/ Windows Phone. These are generally useful for learning not only a language, but a complete set of tools to take an idea from concept to published.","Q_Score":2,"Tags":"c++,python,ruby-on-rails","A_Id":4896404,"CreationDate":"2011-02-04T09:22:00.000","Title":"Which programming language to choose?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I am a 3rd year CS engineering student, I have done some basic programming in languages like C,C++,Java,Shell,Perl,PHP,Ruby on Rails, Python. But now I wanted to settle for one language, so I thought of finally mastering one scripting language and other compiled one. So I decided to stick with C++ and Python. Can someone suggest me, would these be sufficient for any kind of programming, or for web designing I should stick to ROR?","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":436,"Q_Id":4896361,"Users Score":0,"Answer":"Presently ROR is high in demand for web. As a professional i'll suggest to learn ROR.","Q_Score":2,"Tags":"c++,python,ruby-on-rails","A_Id":4896389,"CreationDate":"2011-02-04T09:22:00.000","Title":"Which programming language to choose?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I already know there are ssh modules for Python, that's not for what I'm looking for.\nWhat I want to have is an python script to do the following:\n\n> connect to an [ input by user ] SSH host\n> connect using the credentials [ provided by the user ]\n> run command on the SSH host [ telnet to [host - input by user ]\n> Select menu item in the telnet session\n\nThanks in advance,\nBest regards,","AnswerCount":7,"Available Count":1,"Score":0.0285636566,"is_accepted":false,"ViewCount":74237,"Q_Id":4896785,"Users Score":1,"Answer":"There are many libraries to do that.\n\nSubprocess\nPexpect \nParamiko (Mostly used)\nFabric\nExscript\n\nYou can check their documentation for the implementation.","Q_Score":10,"Tags":"python,automation,ssh,telnet","A_Id":39664919,"CreationDate":"2011-02-04T10:12:00.000","Title":"Python script - connect to SSH and run 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":1,"Web Development":0},{"Question":"i've built a com component which utilizes libxml2 python bindings , the build is successfull but when i try to register the component i get \"specified module could not be found , unable to load python dll\" this is the error i get when the component is built using the bundle files option set as 1\nif i build the component with bundle files set as 3 ,then i get a different error saying that the component was loaded but the call to DllRegisterServer Failed with error code 80040201\nif the libxml2 import is removed all works fine.\nany help wold be simply great.\nthanks","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":240,"Q_Id":4899158,"Users Score":1,"Answer":"Most likely, regsvr32.exe which registers you COM component couldn't find a DLL that your COM component needs.\nI'm not familiar with Python COM components but is there some way you can run depends.exe on it? This is the usual way to track down binary dependency problems.","Q_Score":0,"Tags":"python,com","A_Id":4899486,"CreationDate":"2011-02-04T14:33:00.000","Title":"python com component does not register when using libxml2 on win7","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},{"Question":"I have a PHP\/mySQL site that is no longer going to get any new content added. But I'd like to keep what I do have as an archive and keep it online. Ideally I'd like to convert it to a static site so that it no longer requires a database.\nIf anyone else has gone through this process, are there any tools, scripts, or methodologies that can automate this or at least make this easier? I'd want to be able to do things like make sure that all the links still work (so they'd have to somehow be converted to correctly point to the new static versions), things like that.\nI have ssh access to the server in question. I'm relatively comfortable with both PHP and Python so tools using those languages would be ideal.\nNote: there are two basic reasons I'm doing this:\n\ncost, as it's much cheaper to host just a collection of static files than a dynamic website (I'm using NearlyFreeSpeech and with the bandwidth I'm using I estimate my costs would go down to well under $1\/month). \nspammers have somehow found my site and keep signing up for accounts (at which point, they're blocked from making comments anyway, but it's still annoying).","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":1156,"Q_Id":4901039,"Users Score":1,"Answer":"Using PHP you could write a simple script that would do this:\n\nSave current page.\nFollow links from that page and saving those pages (and for each page repeat from 1).\nReplace URLs on current page with those leading to saved pages.","Q_Score":1,"Tags":"php,python,dynamic,static,archive","A_Id":4901187,"CreationDate":"2011-02-04T17:30:00.000","Title":"Converting a dynamic PHP\/mySQL website to an archived HTML 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":1},{"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},{"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},{"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},{"Question":"I'm currently writing a set of unit tests for a Python microblogging library, and following advice received here have begun to use mock objects to return data as if from the service (identi.ca in this case).\nHowever, surely by mocking httplib2 - the module I am using to request data - I am tying the unit tests to a specific implementation of my library, and removing the ability for them to function after refactoring (which is obviously one primary benefit of unit testing in the firt place).\nIs there a best of both worlds scenario? The only one I can think of is to set up a microblogging server to use only for testing, but this would clearly be a large amount of work.","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":223,"Q_Id":4914582,"Users Score":1,"Answer":"Not sure what your problem is. The mock class is part of the tests, conceptually at least. It is ok for the tests to depend on particular behaviour of the mock objects that they inject into the code being tested. Of course the injection itself should be shared across unit tests, so that it is easy to change the mockup implementation.","Q_Score":1,"Tags":"python,unit-testing","A_Id":4914696,"CreationDate":"2011-02-06T16:35:00.000","Title":"Using mock objects without tying down unit 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},{"Question":"I'm currently writing a set of unit tests for a Python microblogging library, and following advice received here have begun to use mock objects to return data as if from the service (identi.ca in this case).\nHowever, surely by mocking httplib2 - the module I am using to request data - I am tying the unit tests to a specific implementation of my library, and removing the ability for them to function after refactoring (which is obviously one primary benefit of unit testing in the firt place).\nIs there a best of both worlds scenario? The only one I can think of is to set up a microblogging server to use only for testing, but this would clearly be a large amount of work.","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":223,"Q_Id":4914582,"Users Score":1,"Answer":"You are right that if you refactor your library to use something other than httplib2, then your unit tests will break. That isn't such a horrible dependency, since when that time comes it will be a simple matter to change your tests to mock out the new library.\nIf you want to avoid that, then write a very minimal wrapper around httplib2, and your tests can mock that. Then if you ever shift away from httplib2, you only have to change your wrapper. But notice the number of lines you have to change is the same either way, all that changes is whether they are in \"test code\" or \"non-test code\".","Q_Score":1,"Tags":"python,unit-testing","A_Id":4915281,"CreationDate":"2011-02-06T16:35:00.000","Title":"Using mock objects without tying down unit 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},{"Question":"I have a couple versions of python on my box. My app uses python 2.7 which is found in \/usr\/local\/bin\/python. Apache seems to be using an earlier version in \/usr\/bin\/python. How can I configure Apache to use a later version of Python for my app?","AnswerCount":3,"Available Count":3,"Score":0.1325487884,"is_accepted":false,"ViewCount":2129,"Q_Id":4927688,"Users Score":2,"Answer":"To use with Python 3, you need to install the right mod_wsgi for python 3.\nOn Debian or Ubuntu : sudo apt-get install libapache2-mod-wsgi-py3.\nFor older versions of Python, when installing mod_wsgi, type : .\/configure --with-python=\/usr\/local\/bin\/python2.5 for version 2.5 for instance.","Q_Score":2,"Tags":"python,apache","A_Id":29809235,"CreationDate":"2011-02-07T22:59:00.000","Title":"Apache Config - Multiple python versions","Data Science and Machine Learning":0,"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},{"Question":"I have a couple versions of python on my box. My app uses python 2.7 which is found in \/usr\/local\/bin\/python. Apache seems to be using an earlier version in \/usr\/bin\/python. How can I configure Apache to use a later version of Python for my app?","AnswerCount":3,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":2129,"Q_Id":4927688,"Users Score":0,"Answer":"I could be mistaking, but whatever user apache is started with has a profile which likely has the search path in it. You could change the search path to search \/usr\/local\/bin before \/usr\/bin, though this is not an ideal approach. Whatever default shell is set for the account used by Apache, just check that you have an rc-file for that shell, and if not, create one.","Q_Score":2,"Tags":"python,apache","A_Id":4928096,"CreationDate":"2011-02-07T22:59:00.000","Title":"Apache Config - Multiple python versions","Data Science and Machine Learning":0,"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},{"Question":"I have a couple versions of python on my box. My app uses python 2.7 which is found in \/usr\/local\/bin\/python. Apache seems to be using an earlier version in \/usr\/bin\/python. How can I configure Apache to use a later version of Python for my app?","AnswerCount":3,"Available Count":3,"Score":1.2,"is_accepted":true,"ViewCount":2129,"Q_Id":4927688,"Users Score":1,"Answer":"You can't. Either rebuild mod_wsgi against the other version of Python, or change the shebang line in your CGI scripts to the other executable.","Q_Score":2,"Tags":"python,apache","A_Id":4927767,"CreationDate":"2011-02-07T22:59:00.000","Title":"Apache Config - Multiple python versions","Data Science and Machine Learning":0,"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},{"Question":"Every time I read either WSGI or CGI I cringe. I've tried reading on it before but nothing really has stuck.\nWhat is it really in plain English?\nDoes it just pipe requests to a terminal and redirect the output?","AnswerCount":4,"Available Count":3,"Score":1.0,"is_accepted":false,"ViewCount":27805,"Q_Id":4929626,"Users Score":275,"Answer":"From a totally step-back point of view, Blankman, here is my \"Intro Page\" for Web Server Gateway Interface:\nPART ONE: WEB SERVERS\nWeb servers serve up responses. They sit around, waiting patiently, and then with no warning at all, suddenly:\n\na client process sends a request. The client process could be a web server, a bot, a mobile app, whatever. It is simply \"the client\"\nthe web server receives this request\ndeliberate mumble various things happen (see below)\nThe web server sends back something to the client\nweb server sits around again\n\nWeb servers (at least, the better ones) are VERY good at this. They scale up and down processing depending on demand, they reliably hold conversations with the flakiest of clients over really cruddy networks, and we never really have to worry about it. They just keep on serving.\nThis is my point: web servers are just that: servers. They know nothing about content, nothing about users, nothing in fact other than how to wait a lot and reply reliably.\nYour choice of web server should reflect your delivery preference, not your software. Your web server should be in charge of serving, not processing or logical stuff.\nPART TWO: (PYTHON) SOFTWARE\nSoftware does not sit around. Software only exists at execution time. Software is not terribly accommodating when it comes to unexpected changes in its environment (files not being where it expects, parameters being renamed etc). Although optimisation should be a central tenet of your design (of course), software itself does not optimise. Developers optimise. Software executes. Software does all the stuff in the 'deliberate mumble' section above. Could be anything.\nYour choice or design of software should reflect your application, your choice of functionality, and not your choice of web server.\nThis is where the traditional method of \"compiling in\" languages to web servers becomes painful. You end up putting code in your application to cope with the physical server environment or, at least, being forced to choose an appropriate 'wrapper' library to include at runtime, to give the illusion of uniformity across web servers.\nSO WHAT IS WSGI?\nSo, at last, what is WSGI? WSGI is a set of rules, written in two halves. They are written in such a way that they can be integrated into any environment that welcomes integration.\nThe first part, written for the web server side, says \"OK, if you want to deal with a WSGI application, here's how the software will be thinking when it loads. Here are the things you must make available to the application, and here is the interface (layout) that you can expect every application to have. Moreover, if anything goes wrong, here's how the app will be thinking and how you can expect it to behave.\"\nThe second part, written for the Python application software, says \"OK, if you want to deal with a WSGI server, here's how the server will be thinking when it contacts you. Here are the things you must make available to the server, and here is the interface (layout) that you can expect every server to have. Moreover, if anything goes wrong, here's how you should behave and here's what you should tell the server.\"\nSo there you have it - servers will be servers and software will be software, and here's a way they can get along just great without one having to make any allowances for the specifics of the other. This is WSGI.\nmod_wsgi, on the other hand, is a plugin for Apache that lets it talk to WSGI-compliant software, in other words, mod_wsgi is an implementation - in Apache - of the rules of part one of the rule book above.\nAs for CGI.... ask someone else :-)","Q_Score":141,"Tags":"python,cgi,wsgi","A_Id":5120610,"CreationDate":"2011-02-08T04:42:00.000","Title":"What are WSGI and CGI in plain English?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Every time I read either WSGI or CGI I cringe. I've tried reading on it before but nothing really has stuck.\nWhat is it really in plain English?\nDoes it just pipe requests to a terminal and redirect the output?","AnswerCount":4,"Available Count":3,"Score":1.0,"is_accepted":false,"ViewCount":27805,"Q_Id":4929626,"Users Score":22,"Answer":"Both CGI and WSGI define standard interfaces that programs can use to handle web requests. The CGI interface is at a lower level than WSGI, and involves the server setting up environment variables containing the data from the HTTP request, with the program returning something formatted pretty much like a bare HTTP server response.\nWSGI, on the other hand, is a Python-specific, slightly higher-level interface that allows programmers to write applications that are server-agnostic and which can be wrapped in other WSGI applications (middleware).","Q_Score":141,"Tags":"python,cgi,wsgi","A_Id":4929678,"CreationDate":"2011-02-08T04:42:00.000","Title":"What are WSGI and CGI in plain English?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Every time I read either WSGI or CGI I cringe. I've tried reading on it before but nothing really has stuck.\nWhat is it really in plain English?\nDoes it just pipe requests to a terminal and redirect the output?","AnswerCount":4,"Available Count":3,"Score":1.2,"is_accepted":true,"ViewCount":27805,"Q_Id":4929626,"Users Score":68,"Answer":"WSGI runs the Python interpreter on web server start, either as part of the web server process (embedded mode) or as a separate process (daemon mode), and loads the script into it. Each request results in a specific function in the script being called, with the request environment passed as arguments to the function.\nCGI runs the script as a separate process each request and uses environment variables, stdin, and stdout to \"communicate\" with it.","Q_Score":141,"Tags":"python,cgi,wsgi","A_Id":4929656,"CreationDate":"2011-02-08T04:42:00.000","Title":"What are WSGI and CGI in plain English?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I cant seem to find a reliable asymmetric encryption solution to secure data between a python based server application and a client over an open data channel.\nI need some way for my client to prevent a man in the middle attack over an open data channel, my current exchange has me sending my clients a token they use to verify they are talking to my server application by checking the token is valid with a php script on my site.\nThis is far from ideal and could easily be compromised by waiting to be sent the token and passing it off to another user.\nI have tried as3crypto's rsa encryption but it is an old implementation that is not supported by many libraries as well as having a known vulnerability.\nI would really like a solution that lets me hard code public\/private keys into both the client and server to prevent something like this from happening.","AnswerCount":3,"Available Count":3,"Score":1.2,"is_accepted":true,"ViewCount":191,"Q_Id":4931126,"Users Score":0,"Answer":"After doing some research I have decided to code the part of rsa I need from scratch.\nI found some python code that will generate raw integer keys of any length and looked up how the rsa algorithm works.\nT^P = X (mod R) to encrypt\nX^Q = T (mod R) to decrypt\nWhere T is the starting data, X is the ending data, P is the public half of the key, Q is the private half of the key, and R is the shared part of the key (all integers).\nData will have a nonice whenever possible to prevent replay attacks and the message as a whole will be converted to a long integer to prevent traditional bit by bit cryptanalysis.","Q_Score":0,"Tags":"python,actionscript,cryptography,token,encryption-asymmetric","A_Id":4999135,"CreationDate":"2011-02-08T08:53:00.000","Title":"Actionscript Three Asymmetric Encryption","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I cant seem to find a reliable asymmetric encryption solution to secure data between a python based server application and a client over an open data channel.\nI need some way for my client to prevent a man in the middle attack over an open data channel, my current exchange has me sending my clients a token they use to verify they are talking to my server application by checking the token is valid with a php script on my site.\nThis is far from ideal and could easily be compromised by waiting to be sent the token and passing it off to another user.\nI have tried as3crypto's rsa encryption but it is an old implementation that is not supported by many libraries as well as having a known vulnerability.\nI would really like a solution that lets me hard code public\/private keys into both the client and server to prevent something like this from happening.","AnswerCount":3,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":191,"Q_Id":4931126,"Users Score":0,"Answer":"Hardcoding they public keys won't help you, if someone really plans an attack, because the SWF itself is transfered over an unsafe channel, thus the keys can be exchanged just as if they were transmitted individually.\nThere is basically nothing you can do to prevent man in the middle attacks, you can only make them harder. I think HTTPS is about the best you can get and it's also a fairly easy solution.","Q_Score":0,"Tags":"python,actionscript,cryptography,token,encryption-asymmetric","A_Id":4947928,"CreationDate":"2011-02-08T08:53:00.000","Title":"Actionscript Three Asymmetric Encryption","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I cant seem to find a reliable asymmetric encryption solution to secure data between a python based server application and a client over an open data channel.\nI need some way for my client to prevent a man in the middle attack over an open data channel, my current exchange has me sending my clients a token they use to verify they are talking to my server application by checking the token is valid with a php script on my site.\nThis is far from ideal and could easily be compromised by waiting to be sent the token and passing it off to another user.\nI have tried as3crypto's rsa encryption but it is an old implementation that is not supported by many libraries as well as having a known vulnerability.\nI would really like a solution that lets me hard code public\/private keys into both the client and server to prevent something like this from happening.","AnswerCount":3,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":191,"Q_Id":4931126,"Users Score":0,"Answer":"Since decompiling swf content is not a major problem for experienced hackers, I would strongly advise against hardcoding keys. Have you thought about using SSL at all?","Q_Score":0,"Tags":"python,actionscript,cryptography,token,encryption-asymmetric","A_Id":4947858,"CreationDate":"2011-02-08T08:53:00.000","Title":"Actionscript Three Asymmetric Encryption","Data Science and Machine Learning":0,"Database and SQL":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},{"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\/\/ 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},{"Question":"I'm looking for a good way to estimate the power of a signal (regularly sampled say at 10 kHz) vs. time at just one frequency (say 50 Hz). I could calculate the spectrogram, and then take a slice of it at the target frequency. This seems inefficient though, since I only care about the power at one frequency vs. time. I realize that the power at exactly one frequency is zero (in the limit), I'd like to calculate the power of the signal within a small frequency interval around the target frequency.\nMy current \"solution\" is to use Matplotlib's mlab.specgram() function which returns a 2d array of power, and I just slice it. I'm not satisified with this though because I don't totally trust the mab.specgram() function as it takes drastically different amounts of time to compute the spectrogram on different signals (even if they are the same length).","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1962,"Q_Id":4953250,"Users Score":7,"Answer":"There's a ton of ways of doing this. One crude but effective way is to apply a bandpass filter (at 50Hz), thereby eliminating all other signals, and then calculate the RMS power of the last N samples.\nAnother is you can do a windowed FFT, but not actually FFT - just calculate the bin you want. The window can be whatever you want (e.g Kaiser with alpha 8). The DFT of a single bin is just the sum of products of the signal with e^(i*n*w) (where w is 50Hz at your sampling rate, and n the iterator).\nThere's probably simpler ways than that. It depends on what you're trying to be resilient to, how fast the signal moves, and whether you expect noise or other signals in the mix. If you're not trying to pick a signal out of a cacophony of others, you don't have to go to great lengths.","Q_Score":4,"Tags":"python,matplotlib,signal-processing,scientific-computing","A_Id":4953341,"CreationDate":"2011-02-10T04:06:00.000","Title":"how to estimate the (power of a signal at a given frequency) vs. time 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},{"Question":"I have a custom module that's basically a thin wrapper around a database connection with cx_Oracle. I'd like to re-use this module on computers with both the unicode version of cx_Oracle installed, and with the non-unicode version. \nTo do this, I need to \"detect\" the version installed. I could \"try\" making a connection using a string connection descriptor; and if I get a TypeError back, then assume it's the unicode version installed. This just seems a bit kludgy. \nIs there a better\/preferred way of doing this?\nThanks.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":227,"Q_Id":4961707,"Users Score":1,"Answer":"Using try ... except is a perfectly suitable way to do this kind of detection. The same technique is used to write portable apps using SQLITE that will work on newer 2.7 Python with SQLITE in the library and older 2.4 where SQLITE was an addon module with a more cryptic name.","Q_Score":1,"Tags":"python,cx-oracle","A_Id":5087119,"CreationDate":"2011-02-10T19:32:00.000","Title":"Is this the preferred way to detect if the unicode or non-unicode version of cx_oracle was installed?","Data Science and Machine Learning":0,"Database and SQL":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},{"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},{"Question":"Hi\nI use twisted library to connect to FTP server but I have problem with filename encoding.\nI receive 'Illusion-N\\xf3z.txt' so its not unicode. Is there any FTP command to force specific encoding? \nThanks in advance!\nMK","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":3170,"Q_Id":4966856,"Users Score":2,"Answer":"FTP ignores encodings; as long as a filename does not contain a '\\0' (null character) and '\/' (slash) separates directories, it happily accepts anything.\nDo your own decoding and encoding of the filenames. It is quite probable that the encoding used in your example is \"cp1252\", which is the \u201cWindows Western\u201d or something like that.\nIn your case, when you receive 'Illusion-N\\xf3z.txt', convert it to Unicode by 'Illusion-N\\xf3z.txt'.decode('cp1252').","Q_Score":1,"Tags":"python,encoding,ftp,twisted","A_Id":5210013,"CreationDate":"2011-02-11T08:12:00.000","Title":"FTP filename encoding","Data Science and Machine Learning":0,"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},{"Question":"Is there a difference (in terms of execution time) between implementing a function in Python and implementing it in C and then calling it from Python? If so, why?","AnswerCount":4,"Available Count":3,"Score":1.2,"is_accepted":true,"ViewCount":330,"Q_Id":4968235,"Users Score":5,"Answer":"Python (at least the \"standard\" CPython implementation) never actually compiles to native machine code; it compiles to bytecode which is then interpreted. So a C function which is in fact compiled to machine code will run faster; the question is whether it will make a relevant difference. So what's the actual problem you're trying to solve?","Q_Score":1,"Tags":"python,c,compilation","A_Id":4968256,"CreationDate":"2011-02-11T11:00:00.000","Title":"Implementing a function in Python vs 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},{"Question":"Is there a difference (in terms of execution time) between implementing a function in Python and implementing it in C and then calling it from Python? If so, why?","AnswerCount":4,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":330,"Q_Id":4968235,"Users Score":0,"Answer":"Typically, a function written in C will be substantially faster that the Python equivalent. It is also much more difficult to integrate, since it involves:\n\ncompiling C code that #includes the Python headers and exposes appropriate wrapper code so that it is callable from Python;\nlinking against the correct Python libraries;\ndeploying the resulting shared library to the appropriate location, so that your Python code can import it.\n\nYou would want to be very certain that the benefits outweigh the costs before trying this, which means this should only be reserved for performance-critical sections of your code that you simply can't make fast enough with pure Python.\nIf you really need to go down this path, Boost.Python can make the task much less painful.","Q_Score":1,"Tags":"python,c,compilation","A_Id":4968264,"CreationDate":"2011-02-11T11:00:00.000","Title":"Implementing a function in Python vs 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},{"Question":"Is there a difference (in terms of execution time) between implementing a function in Python and implementing it in C and then calling it from Python? If so, why?","AnswerCount":4,"Available Count":3,"Score":0.049958375,"is_accepted":false,"ViewCount":330,"Q_Id":4968235,"Users Score":1,"Answer":"If I understand and restate your question properly, you are asking, if wrapping python over a c executable be anyway faster than a pure python module itself? The answer to it is, it depends upon the executable and the kind of task you are performing. \n\nThere are a set of modules in Python that are written using Python C-API's. Performance of those would be comparable to wrapping a C executable\nOn the other hand, wrapping c program would be faster than pure python both implementing the same functionality with a sane logic. Compare difflib usage vs wrapping subprocess over diff.","Q_Score":1,"Tags":"python,c,compilation","A_Id":4968320,"CreationDate":"2011-02-11T11:00:00.000","Title":"Implementing a function in Python vs 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},{"Question":"I have to use some legacy .pyc modules (with no source) but I'm also forced to use python in optimized mode (python -O): so, when trying to import those modules, I get an import error (as python looks for .py or .pyo files).\nIs there a way to make it use pyc modules as well? Or to convert .pyc into .pyo?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":666,"Q_Id":4971066,"Users Score":3,"Answer":"One way to \"convert\" them is simply renaming them. Of course they won't be optimised, but at least you can use them.","Q_Score":2,"Tags":"python,import,compiler-optimization,pyc","A_Id":4971101,"CreationDate":"2011-02-11T15:49:00.000","Title":"Make Python import .pyc when run in optimized 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},{"Question":"Is it possible to find out the process id of the process which has caused some signal. In my scenario, I have multiple children of a process running, and I want to know which one of them sent the signal.","AnswerCount":4,"Available Count":1,"Score":-1.0,"is_accepted":false,"ViewCount":4214,"Q_Id":4974140,"Users Score":-4,"Answer":"I believe it is not possible - the OS just does not pass this information to the target process.","Q_Score":8,"Tags":"python,signals","A_Id":4974239,"CreationDate":"2011-02-11T21:16:00.000","Title":"Get pid of the process which has triggered some 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},{"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},{"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},{"Question":"I want my program by default to stdout, but give the option of writing it to a file. Should I create my own print function and call that testing that there is an output file or is there a better way? That seems inefficient to me, but every way I can think of calls an additional if test for every print call. I know this really doesn't matter in the long run probably, at least of this script, but I'm just trying to learn good habits.","AnswerCount":6,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":222,"Q_Id":4981444,"Users Score":0,"Answer":"I recommend you using the logging module and logging.handlers... stream, output files, etc..","Q_Score":0,"Tags":"python,redirect","A_Id":4981494,"CreationDate":"2011-02-12T23:51:00.000","Title":"What's the best way to handle output redirection?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I want my program by default to stdout, but give the option of writing it to a file. Should I create my own print function and call that testing that there is an output file or is there a better way? That seems inefficient to me, but every way I can think of calls an additional if test for every print call. I know this really doesn't matter in the long run probably, at least of this script, but I'm just trying to learn good habits.","AnswerCount":6,"Available Count":3,"Score":1.2,"is_accepted":true,"ViewCount":222,"Q_Id":4981444,"Users Score":2,"Answer":"Write to a file object, and when the program starts either have that object point to sys.stdout or to a file specified by the user. \nMark Byers' answer is more unix-like, where most command line tools just use stdin and stdout and let the user do redirection as they see fit.","Q_Score":0,"Tags":"python,redirect","A_Id":4981549,"CreationDate":"2011-02-12T23:51:00.000","Title":"What's the best way to handle output redirection?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I want my program by default to stdout, but give the option of writing it to a file. Should I create my own print function and call that testing that there is an output file or is there a better way? That seems inefficient to me, but every way I can think of calls an additional if test for every print call. I know this really doesn't matter in the long run probably, at least of this script, but I'm just trying to learn good habits.","AnswerCount":6,"Available Count":3,"Score":-0.0333209931,"is_accepted":false,"ViewCount":222,"Q_Id":4981444,"Users Score":-1,"Answer":"My reaction would be to output to a temp file, then either dump that to stdio, or move it to where they requested.","Q_Score":0,"Tags":"python,redirect","A_Id":4981465,"CreationDate":"2011-02-12T23:51:00.000","Title":"What's the best way to handle output redirection?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I have some problems whith IntelliJ IDEA Python plugin.\nI've got a Java project with a few modules. And I want to add one module for Python tools-scripts which I use to generate some files.\nI downloaded and installed Python plugin (version 2.6.6.) for my IDEA (10.0.2 Ultimate). Then I added Python SDK to the project and created new Python module. Then I added \/src dir to this new module.\nWhen I right-click on this module, I have a context menu item New -> Python file. I can add my .py file to my module. Also I can create Python Run\/Debug Configuration. And IDEA can launch my script. But IDEA doesn't highlight Python syntax. It marks Python module with Python icon, but my Python file is marked as a text file.\nI have inspected all settings, but I failed solving this problem. \/src is marked as 'Source folder' in 'Project Structure' dialog.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":6090,"Q_Id":4983715,"Users Score":12,"Answer":"See Settings | File Types, verify that .py extension is associated with Python file type.","Q_Score":5,"Tags":"python,intellij-idea","A_Id":4984030,"CreationDate":"2011-02-13T10:52:00.000","Title":"IntelliJ IDEA: Python plugin does not highlight 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":0},{"Question":"Many applications include a python interpreter, so now when I try to run a program, Subversion's 2.5 interpreter is used to execute it.\nI've already changed environment path order, putting subversion's last.\nNow when I run python from command line, the 2.7 is run, but when I pass the script's filename, version 2.5 seems to be running it, as a few exceptions reveal the path.\nSo specifically, python 2.7 tries to imports module from subversions path.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":453,"Q_Id":4984124,"Users Score":0,"Answer":"If you are having problems with PATH in windows, set the one you want to use at the start of the path variable. Plus, you might want to use User variables instead of system ones.\nBut I don't know if that answers your question because you didn't really ask anything.","Q_Score":0,"Tags":"python,path,interpreter","A_Id":4984297,"CreationDate":"2011-02-13T12:27:00.000","Title":"Python interpreter path search order on 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":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"What do I have to do in Python to figure out which encoding a string has?","AnswerCount":12,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":424066,"Q_Id":4987327,"Users Score":0,"Answer":"For py2\/py3 compatibility simply use \n\nimport six\nif isinstance(obj, six.text_type)","Q_Score":300,"Tags":"python,unicode,encoding,utf-8","A_Id":50565892,"CreationDate":"2011-02-13T22:27:00.000","Title":"How do I check if a string is unicode or ascii?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Trying to achieve:\n\nsame firefox profile throughout tests\n\nProblem:\n\nTests are spread over 30 different files, instantiating a selenium object, and thus creating a firefox profile, in the first test won't persist to the following test because the objects die once script ends IIRC\nCan't specify profile because I'm writing a test suite supposed to be run on different machines \n\nPossible solutions:\n\nCreating a selenium object in some common code that stays in memory throughout the tests. I am running each test by spawning a new python process and waiting for it to end. I am unsure how to send objects in memory to a new python object.\n\nAny help is appreciated, thanks. \nedit: just thought of instead of spawning a child python process to run the test, I just instantiate the test class that selenium IDE generated, removing the setUp and tearDown methods in all 30 tests, instantiating one selenium object in the beginning, then passing said selenium object to every test that's instantiated.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1706,"Q_Id":4987773,"Users Score":0,"Answer":"You can specify the firefox profile while running the server itself. The command would look like\njava -jar selenium-server.jar -firefoxProfileTemplate \"C:\\Selenium\\Profiles\" where \"C:\\Selenium\\Profiles\" would be your path where firefox template files are stored.","Q_Score":6,"Tags":"python,selenium","A_Id":5481430,"CreationDate":"2011-02-14T00:04:00.000","Title":"Keeping Firefox profile persistent in multiple Selenium tests without specifying a profile","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},{"Question":"which one is faster:\nUsing Lattice Multiplication with threads(big numbers) OR\nUsing common Multiplication with threads(big numbers)\nDo you know any source code, to test them?\n-----------------EDIT------------------\nThe theads should be implemented in C, or Java for testing","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":519,"Q_Id":4988830,"Users Score":1,"Answer":"If I understand you correctly, \"lattice multiplication\" is different way of doing base-10 multiplication by hand that is supposed to be easier for kids to understand than the classic way. I assume \"common multiplication\" is the classic way.\nSo really, I think that the best answer is:\n\nNeither \"lattice multiplication\" or \"common multiplication\" are good (efficient) ways of doing multiplication on a computer. For small numbers (up to 2**64), built-in hardware multiplication is better. For large numbers, you are best of breaking the numbers into 8 or 32 bit chunks ...\nMulti-threading is unlikely to speed up multiplication unless you have very large numbers. The inherent cost of creating (or recycling) a thread is likely to swamp any theoretical speedup for smaller numbers. And for larger numbers (and larger numbers of threads) you need to worry about the bandwidth of copying the data around.\n\nNote there is a bit of material around on parallel multiplication (Google), but it is mostly in the academic literature ... which maybe says something about how practical it really is for the kind of hardware used today for low and high end computing.","Q_Score":0,"Tags":"java,python,c,multiplication","A_Id":4989194,"CreationDate":"2011-02-14T04:31:00.000","Title":"Lattice Multiplication with threads, is it more efficient?","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},{"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},{"Question":"Eclipse is able to utilize compiled bytecode to enable \"magic refactor\" functionality--renaming methods, tracing up and down class hierarchies and tracing through method calls.\nWhat technical barriers exist that make this harder to do for languages like Python and Javascript?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1299,"Q_Id":4995842,"Users Score":1,"Answer":"so it turns out that tracing of static information like methods and class hierarchies is perfectly possible in python. PyDev eclipse plugin does it. PyLint plugin attempts to do static analysis even on stuff like dynamic variables by assuming that nothing funky happens at runtime and does a pretty good job.","Q_Score":4,"Tags":"javascript,python,eclipse,refactoring,automated-refactoring","A_Id":5358618,"CreationDate":"2011-02-14T18:28:00.000","Title":"why doesn't eclipse-python have magic refactor?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"No flame wars please. I am admittedly no fan of Java, but I consider the JVM to be a fairly decent and well-optimized virtual machine. It's JIT-enabled and very close to the common denominator of the prevalent CPU architectures. I'd assume that the CPython runtime would be farther from the metal than a corresponding JVM-based runtime.\nIf my assumptions are correct, could someone explain to me why Jython suffers such a major loss in performance compared to CPython? My initial assumption was that the JVM was simply designed for static languages, and it was difficult to port a dynamic one to it. However, Clojure seems to be an counterexample to that line of argument.\nOn the other hand, IronPython seems to be doing fine. I believe the the lead developer on both projects were\/are the same, so the argument that code design and implementation in one is significantly better than the other does not seem likely.\nI can't figure out what the precise reason is; any help will be appreciated.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":17795,"Q_Id":5000360,"Users Score":25,"Answer":"Keep in mind that IronPython was started by one of the original Jython devs (Jim Huginin) in an attempt to prove that the .NET CLR was a poor platform for dynamic languages. He ended up proving himself wrong and the core of IronPython eventually became the .NET Dynamic Language Runtime (making other dynamic language implementations on .NET, such as IronRuby, significantly easier to build).\nSo there's two major points of difference there:\n\nthe original .NET CLR devs benefited from additional industry VM experience relative to the early versions of the JVM, allowing them to avoid known problems without backwards compatibility concerns\nthe same applied for Jim in knowing what traps to avoid based on his Jython experience\n\nAdd in a simple lack of development resources devoted to Jython relative to both CPython and IronPython, and Jython development priorities that focused on bringing it up to feature parity with recent versions of Python moreso than speed optimisations and it's quite understandable that Jython would lag when it came to speed.\nThat said, Jython is similar to both CPython and IronPython, in that the use of better algorithms often trumps poorer performance at microbenchmarks. The JVM\/CLR also mean that dropping down to Java or C# for particular components is easier than dropping down into a C extension for CPython (although tools like Cython try to close that gap a bit).","Q_Score":42,"Tags":"python,jvm,jython","A_Id":5000542,"CreationDate":"2011-02-15T05:55:00.000","Title":"Why is Jython much slower than CPython, despite the JVM's advances?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I am using M2Crypto's AES for encrypting message, but confused about how to generate a strong random session key and of what length. Does M2Crypto provide any function for generation random key.","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":21236,"Q_Id":5000946,"Users Score":0,"Answer":"If you are encrypting to send to another party then you want to do something like Diffie Hellman or ECDH key exchange to establish a shared secret. If you just want to encrypt for storage, then you need a secure random number generator. I do not believe M2Crypto provides this?\nIt looks like M2Crypto does support Diffie Hellman.","Q_Score":9,"Tags":"python,m2crypto","A_Id":5002066,"CreationDate":"2011-02-15T07:35:00.000","Title":"How to generate strong one time session key for AES 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},{"Question":"I need to compare values that i have by executing wmi commands(using python) and values from inside a db.. is it best to compare them without storing in separate files or is storing and then comparing is the only possible way?\ncan someone pls direct me in the right way.. also, where should i look for, for getting more knowledge regarding this?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":43,"Q_Id":5002359,"Users Score":1,"Answer":"If in doubt, go for the simplest solution. In this case, compare them in memory.\nIf you want to be ultra-reliable (i.e. survive after crashes of your application \/ power outage) or cache values for long times (i.e. it's a requirement to continue working even when the database is down), you may consider files. Be warned though - anything but an extremely careful implementation (you should have lots of try..except..finallys and at least one call to flock and fsync, storing in files tends to be less reliable. So unless you're interested in consistency research and willing to put up a few weeks, go for a simple Python comparison.","Q_Score":0,"Tags":"python,comparison","A_Id":5002512,"CreationDate":"2011-02-15T10:17:00.000","Title":"i need some directions in comparing values from different sources 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},{"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},{"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},{"Question":"I'm trying to determine which files in the Python library are strictly necessary for my script to run. Right now I'm trying to determine where _io.py is located. In io.py (no underscore), the _io.py module (with underscore) is imported on line 60.","AnswerCount":4,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":2239,"Q_Id":5003276,"Users Score":0,"Answer":"Try the DLLs folder under your base python install directory if you are on windows. It contains .pyd modules Ignacio mentions. I had a similar problem with a portable install. Including the DLLs folder contents to my install fixed it. I am using python 2.5.","Q_Score":3,"Tags":"python,embed,portability","A_Id":5003499,"CreationDate":"2011-02-15T11:50:00.000","Title":"Python: import _io","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},{"Question":"I'm trying to determine which files in the Python library are strictly necessary for my script to run. Right now I'm trying to determine where _io.py is located. In io.py (no underscore), the _io.py module (with underscore) is imported on line 60.","AnswerCount":4,"Available Count":2,"Score":0.049958375,"is_accepted":false,"ViewCount":2239,"Q_Id":5003276,"Users Score":1,"Answer":"Not all Python modules are written in Python. Try looking for _io.so or _io.pyd.","Q_Score":3,"Tags":"python,embed,portability","A_Id":5003294,"CreationDate":"2011-02-15T11:50:00.000","Title":"Python: import _io","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},{"Question":"I am searching to download the python dlls email, getpass, imaplib, os and use that in vb.net to get the gmail email with attachments","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":183,"Q_Id":5005613,"Users Score":0,"Answer":"Python doesn't have DLLs which you can simply use with VB.net. Your fundamental understanding of the modules libraries is flawed.","Q_Score":0,"Tags":"python","A_Id":5005639,"CreationDate":"2011-02-15T15:27:00.000","Title":"From where can we download the python dlls email, getpass, imaplib, os","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a MATLAB function that needs to communicate (not rapidly, and not often) with python code. I have MATLAB write numbers to a file. Python reads the file, does some calculations, and writes some results to another file. MATLAB then reads that file and continues on its way.\nThe problem I am having is when I want to execute the python script from MATLAB. I have found in the past that simply performing a system call within MATLAB has been sufficient:\n\nsystem('python myscript.py')\n\nHowever, it seems to not like the numpy function 'loadtxt' when it reaches that point in the python script:\n\nNameError: name 'loadtxt' is not defined\n\nI am defining it (from numpy import *). If I just execute the script from terminal, it reads in the file using loadtxt just fine. It is only when I execute the script using the system call do I get that error. The python .py file is in the same directory as the MATLAB .m file that is making the system call. I have executed other scripts without loadtxt just fine using this same method.\nAny suggestions?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2383,"Q_Id":5006837,"Users Score":0,"Answer":"The shell on your system and the shell opened by Matlab when you execute the system command are not necessarily the same. \nImportantly, there could be different environment variables. Try e.g. executing system('echo $PATH') to check whether you have access to all your libraries.","Q_Score":0,"Tags":"python,matlab,numpy","A_Id":5007373,"CreationDate":"2011-02-15T17:01:00.000","Title":"Problem with using system call to execute python script from MATLAB","Data Science and Machine Learning":0,"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},{"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},{"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},{"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},{"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},{"Question":"I have a command line program written in Python, and when I pipe it through another program on the command line, sys.stdout.encoding is None. This makes sense, I suppose -- the output could be another program, or a file you're redirecting it into, or whatever, and it doesn't know what encoding is desired. But neither do I! This program will be used by many different people (humor me) in different ways. Should I play it safe and output only ascii (replacing non-ascii chars with question marks)? Or should I output UTF-8, since it's so widespread these days?","AnswerCount":4,"Available Count":2,"Score":0.049958375,"is_accepted":false,"ViewCount":430,"Q_Id":5013599,"Users Score":1,"Answer":"if your application doesn't really deal with a whole lot of internationalisation, ascii should suffice. but if not, i'd say utf-8 or better still utf-16 should be the order of the day.","Q_Score":7,"Tags":"python,linux,shell,command-line,unicode","A_Id":5013663,"CreationDate":"2011-02-16T07:22:00.000","Title":"If a command line program is unsure of stdout's encoding, what encoding should it 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":1,"Web Development":0},{"Question":"I have a command line program written in Python, and when I pipe it through another program on the command line, sys.stdout.encoding is None. This makes sense, I suppose -- the output could be another program, or a file you're redirecting it into, or whatever, and it doesn't know what encoding is desired. But neither do I! This program will be used by many different people (humor me) in different ways. Should I play it safe and output only ascii (replacing non-ascii chars with question marks)? Or should I output UTF-8, since it's so widespread these days?","AnswerCount":4,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":430,"Q_Id":5013599,"Users Score":0,"Answer":"You should output UTF-8 because thats what everyone should be using. It's a bug not to be. ;)","Q_Score":7,"Tags":"python,linux,shell,command-line,unicode","A_Id":5013662,"CreationDate":"2011-02-16T07:22:00.000","Title":"If a command line program is unsure of stdout's encoding, what encoding should it 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":1,"Web Development":0},{"Question":"This has been bugging me for awhile now. \nIn a deployed PHP web application one can upload a changed php script and have the updated file picked up by the web server without having to restart.\nThe problem? Ruby, Groovy, & Python, etc. are all \"better\" than PHP in terms of language expressiveness, concision, power, ...your-reason-here.\nCurrently, I am really enjoying Groovy (via Grails), but the reality is that the JVM does not do well (at all) with production dynamic reloading of application code. Basically, Permgen out of memory errors are a virtual guarantee, and that means application crash at anytime -- not good.\nRuby frameworks seem to have this solved somewhat from what I have read: Passenger has an option to dynamically reload changed files in polled directories on the next request (thus preventing connected users from being disconnected, session lost, etc.).\nStandalone Python I am not sure about at all; it may, like PHP allow dynamic reloading of python scripts without web server restart.\nAs far as our web work is concerned, invariably clients wind up wanting to make changes to a deployed application regardless of how detailed and well planned the spec was. Telling the client, \"sure, we'll implement that [simple] change at 4AM tomorrow [so as to not wreak havoc with connected users]\", won't go over too well. \nAs of 2011 where are we at in terms of dynamic reloading and scripting languages? Are we forever doomed, relegated to the convenience of PHP, or the joys of non-PHP and being forced to restart a deployed application?\nBTW, I am not at all a fan of JSPs, GSPs, and Ruby, Python templating equivalents, despite their reloadability. This is a cake & eat it too thread, where we can make a change to any aspect of the application and not have to restart.","AnswerCount":2,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":368,"Q_Id":5013863,"Users Score":4,"Answer":"I think you're making a bigger deal out of this than it really is.\nAny application for which it is that important that it never be down for 1\/2 a minute (which is all it takes to reboot a server to pick up a file change) really needs to have multiple application server instances in order to handle potential failures of individual instances. Once you have multiple application servers to handle failures, you can also safely restart individual instances for maintenance without causing a problem.","Q_Score":5,"Tags":"php,python,ruby,groovy,reloading","A_Id":5014150,"CreationDate":"2011-02-16T07:56:00.000","Title":"2011 Web Scripting Languages and Dynamic Reloading","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"Hi\nI am trying to Understand if tornado\/eventlet based http sever are better than threaded sever. While goggling the subject I am seeing that these are single thread event base server which run a single handler function after select\/poll\/epoll on socket.\n\nMy first question is that is this tornado\/eventlet similar to nio library in java and is a java nio server non-blocking and fast.\nMy second question is that since this event based Server are single thread If one connection blocks on file io or solw client will it hang the entire server\nMy third question is that what is the trade off , if non blocking server is fast why isn't it is more common than apache\n\nThese questions are related and I would apprecite as I am not understanding these issues correctly \nThanks","AnswerCount":1,"Available Count":1,"Score":0.6640367703,"is_accepted":false,"ViewCount":2292,"Q_Id":5025770,"Users Score":4,"Answer":"Nonblocking servers are the best choice provided all your libraries provides nonblocking apis. As mentioned in your second question if a library blocks (eg database lib making a blocking call), the entire process\/thread blocks and the system hangs. Not all of the libraries available are asynchronous which makes it difficult to use tornado\/eventlet for all usecases. Also in a multi-core box multiple instances of nonblocking servers needs to be started to use the box capacity completly.\nTornado\/Event servers are similar to java nio based servers. There is one conceptual difference between a Tornado and Eventlet. Tornado follows a reactor pattern where the single process waits for IO(socket) events and dispatches them to appropriate handlers. If handlers are nonblocking, best performance can be expected. Typically code written for these frameworks consists of a series of callbacks making it a bit less readable than a synchronous server .Java NIO servers comes under this category.\nEventlet performs the same task but with a cleaner interface. Code can be written as in the case of synchronous server without using callbacks. When an IO is encountered, eventlet schedules another userspace process(not right terminology). \nApache webapps are more popular that these because of few reasons\n\nIt is relatively easy to write synchronous code\nNot all required libraries are asynchronous.\n\nBut for writing a chat application which handles lots of connections a multi-threaded server will not scale. You have to use async frameworks like twisted\/event\/Java NIO.","Q_Score":4,"Tags":"java,python,http,asynchronous,nonblocking","A_Id":5049188,"CreationDate":"2011-02-17T06:31:00.000","Title":"Non-blocking http server , java nio , python tornado eventlet","Data Science and Machine Learning":0,"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},{"Question":"my Django tests run really slowly, but it's not the test's fault.\nAt the moment, the whole process takes 14s, but only 0.1s of that is running tests. The first few seconds are creating tables & indexes, the rest is applying the project's many fixtures.\nWhat's the best way to deal with this? I think there is a way of specifying which fixtures to load in each test, but I need most of them to do most tests...\nA solution I think would work is if the tests didn't drop the tables after each run, that way there would be no need to create & populate the database each run-through of the tests. Most tests don't even write to the DB.\nWhat's the best way to optimise the fixture-loading part of Django tests?\nThanks!\n(I'm using nose, but otherwise just plain Django and sqlite)\nEDIT: I should have mentioned that I'm using an in-memory sqlite database. What I'm looking for - specifically - is an optimisation of the fixture-loading section of the test.","AnswerCount":2,"Available Count":2,"Score":0.3799489623,"is_accepted":false,"ViewCount":1206,"Q_Id":5029415,"Users Score":4,"Answer":"You may use sqlite in-memory database for tests - it really fast","Q_Score":9,"Tags":"python,django,testing,performance,fixtures","A_Id":5029483,"CreationDate":"2011-02-17T13:16:00.000","Title":"What's the best way to optimise the fixture-loading part of Django 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},{"Question":"my Django tests run really slowly, but it's not the test's fault.\nAt the moment, the whole process takes 14s, but only 0.1s of that is running tests. The first few seconds are creating tables & indexes, the rest is applying the project's many fixtures.\nWhat's the best way to deal with this? I think there is a way of specifying which fixtures to load in each test, but I need most of them to do most tests...\nA solution I think would work is if the tests didn't drop the tables after each run, that way there would be no need to create & populate the database each run-through of the tests. Most tests don't even write to the DB.\nWhat's the best way to optimise the fixture-loading part of Django tests?\nThanks!\n(I'm using nose, but otherwise just plain Django and sqlite)\nEDIT: I should have mentioned that I'm using an in-memory sqlite database. What I'm looking for - specifically - is an optimisation of the fixture-loading section of the test.","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":1206,"Q_Id":5029415,"Users Score":4,"Answer":"\"but I need most of them to do most tests\"... \n\nSorry about this, but to speed things up you're going to have to do some thinking. \n\n\"I think there is a way of specifying which fixtures to load in each test\" \n\nThis is a disturbing thing to read. Have you looked at your tests recently? \nYour tests do -- specifically -- list the fixtures. You need to minimize that list.","Q_Score":9,"Tags":"python,django,testing,performance,fixtures","A_Id":5029700,"CreationDate":"2011-02-17T13:16:00.000","Title":"What's the best way to optimise the fixture-loading part of Django 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},{"Question":"I want to make units fight in space just to try out some stuff it would need to print whats going on and results. I'm planing on loading each unit from a separate file or similar (units will be modifiable so i think it should be better this way, no need to keep each unit stats for instancing). I'm not sure how i would load the units.\nIs the question too broad? A link to something similar would be helpfull i couldn't find anything","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":375,"Q_Id":5035460,"Users Score":0,"Answer":"There are a bunch of different ways of handling this, depending on exactly what you are trying to save and how you want to use it.\nIf you want to save basic unit-type stats so they can be easily modified, a plain-text file or csv file would work nicely. (If you have a copy of the game Alpha Centauri, look at the faction definition files - should give you lots of ideas!).\nFor the ultimate in flexibility, you could save your units as Python source-files and import as needed. But too much \"flexibility\" can also make debugging nasty. A half-way step would be to definite your own 'unit definition language'\nYou could use cPickle if you just want to save and reload units, not edit them; this might be useful for savegames.\nFor graphics or 3d models, a lot of game engines (Panda, pyOgre, etc) have binary-format support built in.","Q_Score":0,"Tags":"python","A_Id":5035919,"CreationDate":"2011-02-17T22:24:00.000","Title":"How to make RTS units","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I want to create an application which needs from time to time do\nfile transfer (I want to write the server as well as the client).\nWhat is the best way to do this file transfer?\nThanks in advance..\nNimmy...","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":662,"Q_Id":5038255,"Users Score":0,"Answer":"FTP Tunneled over SSH.\nUse twisted and a good linux shell.","Q_Score":0,"Tags":"python,file,rtp","A_Id":5039698,"CreationDate":"2011-02-18T06:18:00.000","Title":"Real Time File Transfer using 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},{"Question":"I'm developing a game and now I want to make script system for it.\nNow I have abstract class Object which is inherited by all game objects. I have to write a lot of technical code, add new object type into enum, register parser function for each object (that function parses object's params from file).\nI don't want to make such work. So the idea is to get some script system (boost.python for example, because I'm using boost in my project). Each object will be a simple python-script, at c++ side I just load and run all that scripts.\nPython isn't hard -typed so I can register functions, build types dynamically without storing enum, etc. The only bad part is writing a lot of binding-code but It makes only once.\nAre my ideas right?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":203,"Q_Id":5050372,"Users Score":0,"Answer":"Can you give us a rough idea of how large the game is going to be?\nIf you're not careful, you could give yourself a lot of extra work without much benefit, but with some planning it sounds like it might help. The important questions are \"What parts of the program do I want to simplify?\", \"Do I need a scripting language to simplify them? and \"Can the scripting language simplify them?\". \nYou mentioned that you don't want to have to manually parse files. Python's pickle module could handle serialization for you, but so could .NET. If you're using Visual Studio, then you may find it easier to write the code in C# than in Python. \nYou should also look for ways to simplify your code without adding a new language. For example, you might be able to create a simple binary file format and store your data structures without much parsing. There are probably other things you can do, but that would require more detailed knowledge of the program.","Q_Score":1,"Tags":"c++,python,boost,system","A_Id":5055236,"CreationDate":"2011-02-19T10:57:00.000","Title":"Script system in application","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},{"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},{"Question":"I want to get email notifications to the portal email address whenever a new user joins the portal.\nMy guess is that I should code a new product to do that.\nDoes such product already exist (for Plone 4)?\nI checked content rules, but AFAICT it could work only if I made the users contentish themselves with something like membrane\/remember, but for my requirements that would be overkill.","AnswerCount":4,"Available Count":3,"Score":0.049958375,"is_accepted":false,"ViewCount":1115,"Q_Id":5070055,"Users Score":1,"Answer":"You can easily customize the registered.pt template add a simple call to a PythonScript sending out an email through the MailHost api.\nDoing a proper customization of plone.app.users.browser.register.py is much more complex.","Q_Score":2,"Tags":"python,notifications,plone","A_Id":5070368,"CreationDate":"2011-02-21T19:03:00.000","Title":"Is there an easy way in Plone to get email notifications when new users join the portal?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I want to get email notifications to the portal email address whenever a new user joins the portal.\nMy guess is that I should code a new product to do that.\nDoes such product already exist (for Plone 4)?\nI checked content rules, but AFAICT it could work only if I made the users contentish themselves with something like membrane\/remember, but for my requirements that would be overkill.","AnswerCount":4,"Available Count":3,"Score":0.049958375,"is_accepted":false,"ViewCount":1115,"Q_Id":5070055,"Users Score":1,"Answer":"You can also just have login_next traverse to a Controller Python Script (you'll fine other similar ones in the \/plone_login area of the core Plone product that end with the extension '.cpy') that you write that sends the email (perhaps notifyMangersUponLogin ) rather than it's default of traversing to login_success.\nThen, have your CPT script traverse to login_success to continue the sript\/page MVC flow that Plone ships with, if that's what you want.\nTo leverage Controller Page Templates (.cpt files)\/Scripts (.cpy files), it's key to not only copy the custom version of login_next.cpy to your custom product's skin path, but also the login.cpy.metadata file that specifies the success\/failure actions of the MVC page\/script logic flow.\nWith Plone 4.0.2, you'll find the Plone login-related scripts\/templates under a path such as:\n\/buildout-cache\/eggs\/plone-4.0.2-py2.6.egg\/Products\/CMFPlone\/skins\/plone_login\nrelative to your buildout structure.","Q_Score":2,"Tags":"python,notifications,plone","A_Id":5146475,"CreationDate":"2011-02-21T19:03:00.000","Title":"Is there an easy way in Plone to get email notifications when new users join the portal?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I want to get email notifications to the portal email address whenever a new user joins the portal.\nMy guess is that I should code a new product to do that.\nDoes such product already exist (for Plone 4)?\nI checked content rules, but AFAICT it could work only if I made the users contentish themselves with something like membrane\/remember, but for my requirements that would be overkill.","AnswerCount":4,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":1115,"Q_Id":5070055,"Users Score":0,"Answer":"If you want to do it the right way, follow Martijn's directions above. If you want another dirty solution, do the following:\n\nmake a copy of register.cpy\ninsert the following code:\ncontext.MailHost.send('Content-Type: text\/plain\\n\\n' + 'User has registered: ' + str(username),\n mfrom='me@gmail.com',\n mto='you@gmail.com',\n subject='User Registration',\n )","Q_Score":2,"Tags":"python,notifications,plone","A_Id":5318895,"CreationDate":"2011-02-21T19:03:00.000","Title":"Is there an easy way in Plone to get email notifications when new users join the portal?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"On a host with multiple network interfaces, is it possible to bind the connect method from the Python smtplib to an specific source address?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":984,"Q_Id":5073575,"Users Score":0,"Answer":"No such option - at least not without hacking smtplib.connect() yourself.","Q_Score":1,"Tags":"python,ip-address,connect,smtplib","A_Id":5073815,"CreationDate":"2011-02-22T03:01:00.000","Title":"Python smtplib: bind to specific source IP address in a machine with multiple network interfaces","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},{"Question":"Seems simple but I just don't know.\nI'm interested in serializing a date to a string or integer and sending it from Objective-C to Python, and I want to know if there's a way I should be doing it.\nSending the integer seconds since the Unix epoch seems pretty reasonable (and NSDate supplies that readily) but does Python datetime support that?\nIs there an accepted string format for dates and serialization?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":125,"Q_Id":5085365,"Users Score":0,"Answer":"Yes, Python supports creating Date objects from Unix epoch time (although I'm not 100% sure it's in seconds, may be in ms)\nMost languages should have built-in support for Unix time, and if not it wouldn't be hard to create a function to do so.","Q_Score":1,"Tags":"python,objective-c,datetime,serialization,date","A_Id":5085395,"CreationDate":"2011-02-22T23:38:00.000","Title":"Are there standard rules and practices for Date serialization between two languages or frameworks?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"We are having a problem with individual apache processes utilizing large amounts of memory, depending on the request, and never releasing it back to the main system. Since these requests can happen at any time, over time the web server is pushed into swap, rendering it unresponsive even to SSH. Worse, after the request has finished, Python fails to release the memory back into the wild, which results in a number 500mb - 1gb Apache processes lying around.\nWe push very few requests per second, but each request has the potential to be very heavy.\nWhat I would like to do is have a way to kill an individual apache process child after it has finished serving a request if its resident memory exceeds a certain threshold. I have tried several ways of actually doing this inside mod_python, but it appears that any form of system exit results in the response not completing to the client. \nOutside of gracefuling all the processes (which we really want to avoid) whenever this happens, is there anyway to tell Apache to arbitrarily kill off a process after it has finished serving a request? All ideas are welcome.\nAs an additional caveat, due to the legacy nature of the system, we can\u2019t upgrade to a later version of Python, so we can\u2019t utilize the improved memory performance of 2.5. Similarly, we are stuck with our current OS.\nVersions:\nSystem: Red Hat Enterprise 4\nApache: 2.0.55\nPython: 2.3.5","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":318,"Q_Id":5096057,"Users Score":0,"Answer":"I'd say that even it is possible, it would be a tremendous hack (and instable) - you should set-up a process external to apache in this case, that would supervise running processes and kill an individual apache when it goes beyond memory\/time predefined limits.\nSuch a script can be kept running continuously with a mainloop that is performs it's checks every few seconds, or could even be put in crontab to run every minute.\nI see no reason to try to that from inside the serving processes themselves.","Q_Score":1,"Tags":"python,apache,mod-python","A_Id":5098486,"CreationDate":"2011-02-23T19:33:00.000","Title":"Killing individual Apache processes in mod_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},{"Question":"EDIT\nOkay, rookie here so please bear with me. What I'm trying to ask is the following:\n\nIs it plausible for a Python-syntax fan to use one of these options while other team members \"plain vanilla\" version? Is it a matter of personal preference, or would it require converting other people to using these technologies as well?\nIs it possible to easily convert between, say, Jython and Java or Pyjamas and Javascript?\nAlso, in general, what advantages\/disadvantages have people experienced from using these in the \"real world\"?\n\nI think that states a little more clearly what I'm looking for. Input from anyone who uses these technologies in the industry would be very helpful.\nThanks in advance for your insights.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":3513,"Q_Id":5098183,"Users Score":0,"Answer":"But how does it scale? \n\nAs well as anything else. Scalability is about architecture, not language.\n\nAnyone use these frameworks in industry?\n\nYes.","Q_Score":6,"Tags":"python,ironpython,jython,pyjamas","A_Id":5099381,"CreationDate":"2011-02-23T22:44:00.000","Title":"What are the advantages\/disadvantages of using Jython\/IronPython\/Pyjamas?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"EDIT\nOkay, rookie here so please bear with me. What I'm trying to ask is the following:\n\nIs it plausible for a Python-syntax fan to use one of these options while other team members \"plain vanilla\" version? Is it a matter of personal preference, or would it require converting other people to using these technologies as well?\nIs it possible to easily convert between, say, Jython and Java or Pyjamas and Javascript?\nAlso, in general, what advantages\/disadvantages have people experienced from using these in the \"real world\"?\n\nI think that states a little more clearly what I'm looking for. Input from anyone who uses these technologies in the industry would be very helpful.\nThanks in advance for your insights.","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":3513,"Q_Id":5098183,"Users Score":5,"Answer":"You are talking about two different things.\nFirst, Jython and IronPython are Python implementations that you can embed in a Java or C# application to provide scripting capability. This reduces the amount of code that you have to write overall. Or you can look at them as a way to glue together and leverage an existing collection of class libraries. However you look at it, these are good things and lots of people use them.\nBut Pyjamas is something else entirely. It complicates your web stack and makes it harder to pass projects on to other programmers. The main use case is if you have a shop of Python programmers and they need to provide a rich Internet application client side but cannot afford the time to learn Javascript. Not as broadly useful.\nAlso, my personal experience is that most Python programmers already know Javascript reasonably well from building web apps. It really is not much of a learning curve to just dive into Javascript. I've written JSCRIPT scripts on Windows as a batch file replacement and bits of Javascript with Jquery in numerous web pages. When I wanted to learn server-side Javascript for node.js, it really only took a couple of weeks to round out my knowledge of Javascript. In my opinion, Pyjamas should be avoided. Sooner, rather than later, Javascript engines will be supporting version 1.8 of the language which greatly narrows the gap between the languages other than the curly braces issue.","Q_Score":6,"Tags":"python,ironpython,jython,pyjamas","A_Id":5209736,"CreationDate":"2011-02-23T22:44:00.000","Title":"What are the advantages\/disadvantages of using Jython\/IronPython\/Pyjamas?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I'm trying out a new Python mode for Emacs 23, but I'm not sure how to tell if I'm using the new mode (source code located at ~\/.elisp\/python.el) or the bundled python.el mode.\nIs there a way to find out where the current (or any active) mode was loaded from? C-h m does not seem to provide that information, and I don't know where else to look.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":318,"Q_Id":5098356,"Users Score":8,"Answer":"C-hf python-mode RET will tell you which file it lives in, and you can browse to that file by following the link.\nYou can also use M-x find-function RET python-mode RET to go there directly.\n(I find it handy to have find-function bound to C-hC-f)\nIn general, you could use the following:\nM-: (find-function major-mode) RET","Q_Score":3,"Tags":"emacs,path,mode,python-mode","A_Id":5098431,"CreationDate":"2011-02-23T22:58:00.000","Title":"Determine path to source code of current mode in Emacs 23","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"i want to create a webservice (SOAP & REST) in python which cab be called from iphone,\nnow i have install python 2.7.1 on Ubuntu 10.04.2 LTS using Putty. so now i am searching for a nice and easy framework that helps me in creating webservices and web programming. \nI have searched a lot but confused with the combination of framworks.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":931,"Q_Id":5104215,"Users Score":0,"Answer":"For REST, I am very satisfied with Flask.","Q_Score":0,"Tags":"python,web-services,frameworks","A_Id":5104394,"CreationDate":"2011-02-24T11:48:00.000","Title":"webservices 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":1},{"Question":"I have some Python code abstracting the database and the business logic on it. This code is already covered by unit tests but now I need to test this code against different DBs (MySQL, SQLite, etc...)\nWhat is the default pattern for passing the same set of tests with different configurations? My goal is making sure that that abstraction layer works as expected independently of the underlying database. If that could help, I'm using nosetests for running tests but it seems that it lacks the Suite Test concept\nBest regards.","AnswerCount":3,"Available Count":2,"Score":-0.0665680765,"is_accepted":false,"ViewCount":414,"Q_Id":5104276,"Users Score":-1,"Answer":"Nose supports test suites just import and use unittest.TestSuite. In fact nose will happily run any tesys written using the standard lib's unittest module so tesys do not need to be written in the nose style to be discovered by the nose test runner. \nHowever, I suspect you need morw than test suite support to do the kind of testing you are talking about but more detail about your application is necessary to really address that.","Q_Score":5,"Tags":"python,database,unit-testing,nosetests","A_Id":5105166,"CreationDate":"2011-02-24T11:53:00.000","Title":"Running the same tests with different configurations","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I have some Python code abstracting the database and the business logic on it. This code is already covered by unit tests but now I need to test this code against different DBs (MySQL, SQLite, etc...)\nWhat is the default pattern for passing the same set of tests with different configurations? My goal is making sure that that abstraction layer works as expected independently of the underlying database. If that could help, I'm using nosetests for running tests but it seems that it lacks the Suite Test concept\nBest regards.","AnswerCount":3,"Available Count":2,"Score":-0.0665680765,"is_accepted":false,"ViewCount":414,"Q_Id":5104276,"Users Score":-1,"Answer":"use --attrib plugin, and in the commadn line \n\n1. nosetests -s -a 'sqlite'\n2. nosetests -s -a 'mysql'","Q_Score":5,"Tags":"python,database,unit-testing,nosetests","A_Id":6515097,"CreationDate":"2011-02-24T11:53:00.000","Title":"Running the same tests with different configurations","Data Science and Machine Learning":0,"Database and SQL":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},{"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},{"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},{"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},{"Question":"I would to pick up a new programming language - Java, having been using Python for some time. But it seems most things that can be done with Java can be done with Python. So I would like to know\n\nWhat kind of things can be done with Java but not Python?\n\nmobile programming (Android).\nPOSIX Threads Programming.\n\nConversely, What kind of things can be done with Python but not Java if any?\n\nclarification:\nI hope to get an answer from a practical point of view but not a theoretical point of view and it should be about the current status, not future. So theoretically all programming languages can perform any task, practically each is limited in some way.","AnswerCount":5,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":13215,"Q_Id":5126346,"Users Score":0,"Answer":"CPython has a lot of libraries with bindings to native libraries--not so Java.","Q_Score":13,"Tags":"java,python,programming-languages","A_Id":5126443,"CreationDate":"2011-02-26T10:26:00.000","Title":"What kind of things can be done with Java but not 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},{"Question":"Am just curious and wondering why it takes longer for python code to execute when run from inside Stani Python Editor in comparison to when run from IDLE or the terminal or even inside gvim.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":177,"Q_Id":5127521,"Users Score":0,"Answer":"SPE has an object explorer, and debugger. Maybe these slow things down a bit.","Q_Score":2,"Tags":"python,performance","A_Id":5128723,"CreationDate":"2011-02-26T14:43:00.000","Title":"Performance of running code in stani python editor vs IDLE\/terminal\/gvim","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":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},{"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},{"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},{"Question":"I'm wondering if someone could help guide the approach to this fairly common problem:\nI'm building a simple site which a user connects their twitter account to sign up. I'd like to create an interface which shows them which of their twitter friends are already using the site.\nSo I can get a list the user's twitter friends, and a list of the site's users (which all have the twitter screen name as username, but I'm wondering the most efficient method to compare these lists and create a variable with the commonalities.\nAs an aside, given the Twitter API returns IDs, should I save the twitter user's ID (in addition to their username) when they create an account?\nThanks in advance!","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":323,"Q_Id":5137126,"Users Score":1,"Answer":"You should store the twitter user's ID because the username can change at any time, but the id will always be the same. You should be comparing the id's, not the usernames in the intersection_set that Ofri recommends.","Q_Score":2,"Tags":"python,django,twitter","A_Id":5137217,"CreationDate":"2011-02-28T00:32:00.000","Title":"Comparing user's facebook\/twitter friends to site's users in 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},{"Question":"I'm a PHP programmer. What module can I use in Python to do the same that cURL does?\nBest Regards,","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":602,"Q_Id":5143325,"Users Score":1,"Answer":"you can do the same stuff with urllib2, pycurl hasn't been updated in a while, so I wouldn't recommend it. Especially on Windows. Always better to use a native module rather than a 3rd party plugin","Q_Score":0,"Tags":"python,curl","A_Id":5143397,"CreationDate":"2011-02-28T14:36:00.000","Title":"What module to use in Python to do the same as cURL 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},{"Question":"A problem I frequently run into when using Python, R, Matlab etc. is installing packages or libraries when I don't have admin privileges on the server I'm using. I was wondering if there is a way to get around this?\nI was thinking of \"installing\" the libraries somewhere in my own account, and adding that directory to my path, rather than somewhere like \/usr\/bin, \/usr\/lib etc. Does anyone have any tips \/ pointers on this? This must be a frequent problem for college \/ graduate students.\nThanks!","AnswerCount":4,"Available Count":3,"Score":0.1973753202,"is_accepted":false,"ViewCount":1195,"Q_Id":5145846,"Users Score":4,"Answer":"For R you can do install.packages(\"foo\",lib=\"~\/R\/\") - create the directory ~\/R\/ first - and then the packages will install there. Then do library(foo,lib=\"~\/R\/\") to load it.\nYou can use the .libPaths function in your R startup files to add this automatically. Most of the Ubuntu boxes I've used are set up something like this by default. If a plain user tries to install a package it goes into their ~\/R\/ library, if root tries to do it, it goes into a site library for everyone.\nSince generally there's no point backing up these installed packages, I tend to put my ~\/R\/ library on a non-backed up part of my filesystem.\n[Note the correct use of 'library' here - in R-speak a library is a place where packages are installed]","Q_Score":1,"Tags":"python,r,matlab,installation,administrator","A_Id":5148866,"CreationDate":"2011-02-28T18:13:00.000","Title":"Install Python \/ Matlab libraries without admin priviledges?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"A problem I frequently run into when using Python, R, Matlab etc. is installing packages or libraries when I don't have admin privileges on the server I'm using. I was wondering if there is a way to get around this?\nI was thinking of \"installing\" the libraries somewhere in my own account, and adding that directory to my path, rather than somewhere like \/usr\/bin, \/usr\/lib etc. Does anyone have any tips \/ pointers on this? This must be a frequent problem for college \/ graduate students.\nThanks!","AnswerCount":4,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":1195,"Q_Id":5145846,"Users Score":0,"Answer":"In python you can do python setup.py install --user or pip install --user foo. This will install it in a user-specific directory appropriate for your platform.","Q_Score":1,"Tags":"python,r,matlab,installation,administrator","A_Id":30807406,"CreationDate":"2011-02-28T18:13:00.000","Title":"Install Python \/ Matlab libraries without admin priviledges?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"A problem I frequently run into when using Python, R, Matlab etc. is installing packages or libraries when I don't have admin privileges on the server I'm using. I was wondering if there is a way to get around this?\nI was thinking of \"installing\" the libraries somewhere in my own account, and adding that directory to my path, rather than somewhere like \/usr\/bin, \/usr\/lib etc. Does anyone have any tips \/ pointers on this? This must be a frequent problem for college \/ graduate students.\nThanks!","AnswerCount":4,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":1195,"Q_Id":5145846,"Users Score":0,"Answer":"In Matlab you typically can just download the m files anywhere you like, and then add their location to the path. Not sure but I would suspect that getting a complete toolbox may require admin rights but for anything less you should be fine.\nTo conveniently add the location to your path automatically when you run matlab you can edit startup.m","Q_Score":1,"Tags":"python,r,matlab,installation,administrator","A_Id":14704458,"CreationDate":"2011-02-28T18:13:00.000","Title":"Install Python \/ Matlab libraries without admin priviledges?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I love Python and Ruby equally and I simply cannot standardize on one. I love Heroku, but it can get a speck pricey and is totally specific to Rails.\nIs there a decently inexpensive host, or many, that adequately supports both Ruby and Python frameworks as well as offering common LAMPish support?\nYeah... I wanna know if I can just have it all for cheap (sigh).\nI'm mostly interested in this for development and startups... scalability is not a big deal, but very welcome.","AnswerCount":5,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":1466,"Q_Id":5149127,"Users Score":0,"Answer":"I use rackspace, it's 10$ \/month for the basic setup, they just give you a clean install of whatever OS you want so it will support any packages\/configurations you choose to install.","Q_Score":2,"Tags":"python,ruby,django,apache,ruby-on-rails-3","A_Id":5149250,"CreationDate":"2011-03-01T00:12:00.000","Title":"Good Web hosts that support Ruby 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":1},{"Question":"I love Python and Ruby equally and I simply cannot standardize on one. I love Heroku, but it can get a speck pricey and is totally specific to Rails.\nIs there a decently inexpensive host, or many, that adequately supports both Ruby and Python frameworks as well as offering common LAMPish support?\nYeah... I wanna know if I can just have it all for cheap (sigh).\nI'm mostly interested in this for development and startups... scalability is not a big deal, but very welcome.","AnswerCount":5,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":1466,"Q_Id":5149127,"Users Score":0,"Answer":"I'm in accordance with elithrar. I switched to webfaction and I'm very happy with the change. They've a very good support (I got answers in less than half hour for my problems\/questions) and when my question is got by one of the IT guys, the same guy cares about all the subsequent communications until problem, doubts are resolved.\nThey're cheap too and have very good support to do almost anythong you could need. Just compile what you need and install it in your home by ssh access and ready to go.\nI'm not from webfaction, but this is my experience with them.\nHope this could help you.","Q_Score":2,"Tags":"python,ruby,django,apache,ruby-on-rails-3","A_Id":5149489,"CreationDate":"2011-03-01T00:12:00.000","Title":"Good Web hosts that support Ruby 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":1},{"Question":"Are there libraries for email message parsing (particularly, from Gmail's IMAP server) in Python (except for the standard email library)?\nOr if not, maybe there is some C++ library for this purpose (and I'll be able to use it through SWIG)?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":909,"Q_Id":5156422,"Users Score":0,"Answer":"This question does not make sense. You can access GMail either using IMAP or POP3.\nAnd for parsing retrieved emails you use the 'email' module of Python. Python provides support for all this out-of-the-box \"all batteries included\".","Q_Score":0,"Tags":"python,email","A_Id":5156532,"CreationDate":"2011-03-01T15:17:00.000","Title":"python: libraries for parsing 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},{"Question":"I want to embark on learning a totally new language for web back-end development and I've narrowed down my choice between these three:\n\nGWT \nRuby\nPython\n\nDo you know or recommend of any sites that walks you through building a simple site using these technologies that could be easily deployed and tested?\nBy the way, I am running a Windows OS, so please let me know if there is anything I may need to configure on my machine to start learning these tools.\nOn the front end side of development, I would also like to see some samples that greatly exemplifies being able to use the technologies in its full potentials.\nTotally appreciate your suggestions and responses. Thank you.\nAngelo","AnswerCount":6,"Available Count":3,"Score":0.0333209931,"is_accepted":false,"ViewCount":3022,"Q_Id":5156496,"Users Score":1,"Answer":"GWT is really a frontend development technology. It includes components that make it play nice with the backend, but it is primarily a UI framework.","Q_Score":1,"Tags":"python,ruby,gwt","A_Id":5156600,"CreationDate":"2011-03-01T15:24:00.000","Title":"GWT or Python or Ruby for Web 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":1},{"Question":"I want to embark on learning a totally new language for web back-end development and I've narrowed down my choice between these three:\n\nGWT \nRuby\nPython\n\nDo you know or recommend of any sites that walks you through building a simple site using these technologies that could be easily deployed and tested?\nBy the way, I am running a Windows OS, so please let me know if there is anything I may need to configure on my machine to start learning these tools.\nOn the front end side of development, I would also like to see some samples that greatly exemplifies being able to use the technologies in its full potentials.\nTotally appreciate your suggestions and responses. Thank you.\nAngelo","AnswerCount":6,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":3022,"Q_Id":5156496,"Users Score":0,"Answer":"@Finbarr...but it contains a full fledged Java Servlet Backend. \nAnd this is probably why I'd suggest you to use RoR or Django or something too cook up a simple website. \nGWT Applications are usually made of Server components written in Java and Client Side code (mostly JavaScript) that has been generated from Java. Ususally GWT is not what you want for a simple company website.","Q_Score":1,"Tags":"python,ruby,gwt","A_Id":5156700,"CreationDate":"2011-03-01T15:24:00.000","Title":"GWT or Python or Ruby for Web 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":1},{"Question":"I want to embark on learning a totally new language for web back-end development and I've narrowed down my choice between these three:\n\nGWT \nRuby\nPython\n\nDo you know or recommend of any sites that walks you through building a simple site using these technologies that could be easily deployed and tested?\nBy the way, I am running a Windows OS, so please let me know if there is anything I may need to configure on my machine to start learning these tools.\nOn the front end side of development, I would also like to see some samples that greatly exemplifies being able to use the technologies in its full potentials.\nTotally appreciate your suggestions and responses. Thank you.\nAngelo","AnswerCount":6,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":3022,"Q_Id":5156496,"Users Score":0,"Answer":"I would personally go with Python\/Django (you can get nice overview of the technology on djangobook.com) but Ruby\/Rails is probably equally good.\nAnd about GWT ... hmm we are about to start GWT project at work and I am really scared. Code looks terrible bloated , generated HTML is huge , performance can be a problem and no SEO.","Q_Score":1,"Tags":"python,ruby,gwt","A_Id":5164844,"CreationDate":"2011-03-01T15:24:00.000","Title":"GWT or Python or Ruby for Web 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":1},{"Question":"I started using SWIG on a huge C++ library (made of of several inter-dependent static libs) to expose it to python. This library defines many primitive classes that are used throughout as parameters (images of different types for example). There is extensive use of STL, inheritance and templating in the lib as well.\nSo far I have a minimal portion of the lib usable from Python but would like to progressively add the remaining 90+%.\nFor my part, working with SWIG is really no fun: Battling with template instantiations, learning all that SWIG syntax and keywords, etc. I recently played a bit with CTypes and found it so enjoyable that I am now considering writing an extern C interface for the whole library instead of using SWIG.\nI would rather be coding in C\/C++ and\/or Python than learning an obscure set of SWIG commands (that counts for SIP also).\nThere are quite a few questions out there already asking similar advice so I'll add something new and specific: \nI would like for the library's internal images classes to be visible from python as PIL images transparently, not as SWIG-Wrapped native classes. Will I have to resort to the plain-old Python External API to accomplish that?\nI welcome any and all advice!","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":982,"Q_Id":5160308,"Users Score":1,"Answer":"Have you considered looking into using Boost.Python?","Q_Score":3,"Tags":"c++,python,python-imaging-library","A_Id":5161325,"CreationDate":"2011-03-01T21:03:00.000","Title":"Exposing C++ library to Python + PIL","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},{"Question":"Is there a way of writing Python embedded in HTML like I do with PHP or JSP?","AnswerCount":5,"Available Count":3,"Score":0.0399786803,"is_accepted":false,"ViewCount":41257,"Q_Id":5168588,"Users Score":1,"Answer":"Use Cheetah or another templating engine.","Q_Score":24,"Tags":"python,html","A_Id":5168637,"CreationDate":"2011-03-02T14:10:00.000","Title":"Can Python be embedded in HTML like PHP and JSP?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"Is there a way of writing Python embedded in HTML like I do with PHP or JSP?","AnswerCount":5,"Available Count":3,"Score":1.0,"is_accepted":false,"ViewCount":41257,"Q_Id":5168588,"Users Score":7,"Answer":"There is... But you're highly suggested to use a templating engine, or some other means of separating the presentation from the business layer.\nThere are some available that use python as the templating language, but it's nasty because python is sensitive to whitespace, so special syntax hacks have to be added.","Q_Score":24,"Tags":"python,html","A_Id":5168640,"CreationDate":"2011-03-02T14:10:00.000","Title":"Can Python be embedded in HTML like PHP and JSP?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"Is there a way of writing Python embedded in HTML like I do with PHP or JSP?","AnswerCount":5,"Available Count":3,"Score":0.0798297691,"is_accepted":false,"ViewCount":41257,"Q_Id":5168588,"Users Score":2,"Answer":"Several templating engines support this in one way or another: Mako, Jinja, and Genshi are all popular choices.\nDifferent engines support different features of Python and may be better suited to your needs. Your best bet is to try them out and see what works.","Q_Score":24,"Tags":"python,html","A_Id":5168647,"CreationDate":"2011-03-02T14:10:00.000","Title":"Can Python be embedded in HTML like PHP and JSP?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"While trying to get a python application to talk to a C++ application using an encrypt link, we could not get them to talk. Trying various combinations of parameters we accidentally found that if we told python to encrypt in OFB mode it would successfully decrypt in the C++ in CFB mode.\nBoth the python pycrypt library and the C++ Gladman library are highly regarded, so which could be wrong?\nStrangely, the first byte seems to decrypt OK when using either OFB or CFB at both ends. Since the standard test vectors only seem to test the first byte (I'm not an expert on this stuff and might not be understanding the test vectors), is it possible that both algorithms would pass the standard test?","AnswerCount":1,"Available Count":1,"Score":0.537049567,"is_accepted":false,"ViewCount":1060,"Q_Id":5170442,"Users Score":3,"Answer":"PyCrypto uses 8-bit CFB mode by default. I guess the other end uses block-size CFB mode. The segment size in bits is set by the segment_size keyword argument to AES.new, for block-size CFB mode it should be AES.block_size*8.\nFor the first block OFB mode is identical to block-size CFB mode.","Q_Score":2,"Tags":"c++,python,encryption,aes","A_Id":5171081,"CreationDate":"2011-03-02T16:29:00.000","Title":"AES encryption problem: Python pycrypt OFB = C++ Gladman CFB","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"First, sorry for my bad English.\nI'm writing a python script, which compares the files in two different directories. But for performance, I want to know that: \"Are the directories on the same physical disk or not?\", so I can read them simultaneously for performance gain.\nMy current idea is getting \"mount\" commands output, and getting the \/dev\/sd* directories path and use them for identify the disks. But sometimes you can mount an already mounted directory on somewhere else(or something like that, i'm not so sure), so things get complicated.\nIs there a better way to do that, like a library?\n(If there is a cross-platform way, I will be more appreciated, but it seems it's hard to find a cross-platform library like this.)","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":515,"Q_Id":5171511,"Users Score":1,"Answer":"An easier alternative to using mount might be to invoke df .\nThis prints out the filesystem. Also, on my Ubuntu box, passing -P to df makes the output a little bit easier to parse.","Q_Score":1,"Tags":"python,linux","A_Id":5171542,"CreationDate":"2011-03-02T18:05:00.000","Title":"Learning the directory's physical disk on Linux 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},{"Question":"what happens to my script in python that does not run through crontab every minute.\nMy script has execute permissions and then calls two other scripts in python.\n\nThis is the content of my crontab (#crontab -l):\n*\/1 * * * * \/usr\/bin\/rsm\/samplesMonitor.py\n\nThank you guys.","AnswerCount":4,"Available Count":2,"Score":0.049958375,"is_accepted":false,"ViewCount":7385,"Q_Id":5174080,"Users Score":1,"Answer":"I believe it should be *\/1, not *\\1.","Q_Score":2,"Tags":"python,cron,execution,crontab","A_Id":5174130,"CreationDate":"2011-03-02T22:00:00.000","Title":"python script execution through 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},{"Question":"what happens to my script in python that does not run through crontab every minute.\nMy script has execute permissions and then calls two other scripts in python.\n\nThis is the content of my crontab (#crontab -l):\n*\/1 * * * * \/usr\/bin\/rsm\/samplesMonitor.py\n\nThank you guys.","AnswerCount":4,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":7385,"Q_Id":5174080,"Users Score":0,"Answer":"It should be *\/1 instead of *\\1 (forward slash instead of backslash). Also, make sure the path is correct; there usually are no subdirectories under \/usr\/bin.","Q_Score":2,"Tags":"python,cron,execution,crontab","A_Id":5174140,"CreationDate":"2011-03-02T22:00:00.000","Title":"python script execution through 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},{"Question":"I have 10,000 binary files, named like this:\nfile0.bin\nfile1.bin\n............\n............\nfile10000.bin\nEach of the above files contains exactly 391 float values (1564 bytes per file).\nmy goal is to read all of the files into a python array in the fastest way possible. If I open & close each file using a script, it takes a lot of time (about 8min!). \nare there any other creative ways to read these files FAST? \nI am using Ubuntu Linux and would prefer a solution that can work with Python. Thanks.","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":669,"Q_Id":5187705,"Users Score":0,"Answer":"Iterate over them and use optimise flag you might also want to parse them using pypy it compiles python via a JIT compiler allowing for a somewhat marked increase in speed.","Q_Score":3,"Tags":"python,linux","A_Id":5187734,"CreationDate":"2011-03-03T23:00:00.000","Title":"Fast Reading of 10000 Binary 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":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"So I have been developing my first website. I have a cgi script that allows users to sign up for e-mail updates. However, I don't trust the security of cgi-bin with the api-key I am using to sign people up to a mailing list. So I put the api-key in another folder in home with chmod 711 on the directory (as opposed to 755 on the cgi-bin directory). I then import the api-key into the python cgi script. With something like:\n\nsys.append.path(\"\/home\/otherfolder\")\nimport apikeyfile\n\nDoes this actually provide any extra security to my script? Is there something else I should be doing instead?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":227,"Q_Id":5200635,"Users Score":0,"Answer":"This is a good idea. chmod 500 is better in this case. The rule of th You have to have the most restrictive privileges as possible. Keep in mind your app might hacked and then you don't want your app to write to its self. (unless it has too...)","Q_Score":1,"Tags":"python,cgi,security","A_Id":5200797,"CreationDate":"2011-03-05T00:09:00.000","Title":"Basic python cgi security question: Storing sensitive information in another 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},{"Question":"So I have been developing my first website. I have a cgi script that allows users to sign up for e-mail updates. However, I don't trust the security of cgi-bin with the api-key I am using to sign people up to a mailing list. So I put the api-key in another folder in home with chmod 711 on the directory (as opposed to 755 on the cgi-bin directory). I then import the api-key into the python cgi script. With something like:\n\nsys.append.path(\"\/home\/otherfolder\")\nimport apikeyfile\n\nDoes this actually provide any extra security to my script? Is there something else I should be doing instead?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":227,"Q_Id":5200635,"Users Score":0,"Answer":"This isn't a Python question (the fact that you're using Python is totally incidental), but the answer is: yeah, it's a good idea to have your sensitive data in a place where your Web server can't, even if somewhat misconfigured, send it to an attacker. So outside of whatever directory hierarchy your Web documents and scripts are in. It won't stop an attacker if they root your server, but a lot of exploits don't require root, and so putting as many obstacles in the way of a hacker as possible is considered good pracitce. (This is called \"defense in depth\" by network security wonks.)","Q_Score":1,"Tags":"python,cgi,security","A_Id":5200769,"CreationDate":"2011-03-05T00:09:00.000","Title":"Basic python cgi security question: Storing sensitive information in another 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},{"Question":"How to check for a string that for every character in it, there exists all the characters which are alphabetically smaller than it before it e.g aab is correct while aacb is not, because the second case, we have 'c' but 'b' is not present before it. \nAlso aac is not correct as it does not have 'b' before 'c'.","AnswerCount":7,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":155,"Q_Id":5202362,"Users Score":0,"Answer":"I believe to understand your question correctly, and here is my attempt at answering it, if I have mis-understood please correct me.\nThe standard comparisons (<, <=, >, >=, ==, !=) apply to strings. These comparisons use the standard character-by-character comparison rules for ASCII or Unicode. That being said, the greater and less than operators will compare strings using alphabetical order.","Q_Score":1,"Tags":"python,algorithm,string","A_Id":5202394,"CreationDate":"2011-03-05T07:22:00.000","Title":"a string that for every character in it, there exists all the characters which are alphabetically smaller than it before 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},{"Question":"How to check for a string that for every character in it, there exists all the characters which are alphabetically smaller than it before it e.g aab is correct while aacb is not, because the second case, we have 'c' but 'b' is not present before it. \nAlso aac is not correct as it does not have 'b' before 'c'.","AnswerCount":7,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":155,"Q_Id":5202362,"Users Score":0,"Answer":"The idea is very simple, for each char in the string, it should not less than its preceding, and it shouldn't larger than its preceding + 1.","Q_Score":1,"Tags":"python,algorithm,string","A_Id":5202661,"CreationDate":"2011-03-05T07:22:00.000","Title":"a string that for every character in it, there exists all the characters which are alphabetically smaller than it before 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},{"Question":"I'm writing a script in Python that saves attachments from Gmail, only from unseen emails. To save on bandwidth I want to make sure that every file only gets downloaded once.\n-I can't check the folder where I save them, because the file could be removed already, and then it shouldn't download again. (The scripts accesses the Inbox read_only, so it doesn't mark the email as read. As soon as the script runs again it will download the same attachments again, until the email gets marked read via another channel.)\n-Right now I save the filename to a sqlite database, but there's 2 problems: I haven't figured out how to check the database for the filename the next time I run the script, and there's also a chance that somewhen down the line an attachment arrives with the same filename, which then wouldn't get downloaded.\nWhat's a safe and scalable way to make sure I don't download the files more than once?","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":292,"Q_Id":5204339,"Users Score":0,"Answer":"You could fetch the headers for the message, and use the message's Date and\/or Message-Id header value to construct a \"unique id prefix\" for all of the attachments in that message. Then create a key of the form [unique_id]_[filename], check if that key exists in your database or filesystem. If not, download all attachments for that message, and save each with the modified unique id key.","Q_Score":2,"Tags":"python,imaplib","A_Id":5204450,"CreationDate":"2011-03-05T14:19:00.000","Title":"Way to avoid downloading file twice via IMAP","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I'm writing a script in Python that saves attachments from Gmail, only from unseen emails. To save on bandwidth I want to make sure that every file only gets downloaded once.\n-I can't check the folder where I save them, because the file could be removed already, and then it shouldn't download again. (The scripts accesses the Inbox read_only, so it doesn't mark the email as read. As soon as the script runs again it will download the same attachments again, until the email gets marked read via another channel.)\n-Right now I save the filename to a sqlite database, but there's 2 problems: I haven't figured out how to check the database for the filename the next time I run the script, and there's also a chance that somewhen down the line an attachment arrives with the same filename, which then wouldn't get downloaded.\nWhat's a safe and scalable way to make sure I don't download the files more than once?","AnswerCount":3,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":292,"Q_Id":5204339,"Users Score":0,"Answer":"You could not only save the filename to the database but save, for example, the Date:-header of the mail, too. (Or any combination of headers of which you are sure that they define a mail uniquely).","Q_Score":2,"Tags":"python,imaplib","A_Id":5204367,"CreationDate":"2011-03-05T14:19:00.000","Title":"Way to avoid downloading file twice via IMAP","Data Science and Machine Learning":0,"Database and SQL":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},{"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},{"Question":"I'd like to ask you about your experiences in developing facebook applications in Python. Which of the popular web frameworks for this language you think best suits this purpose? I know \"best\" is a very subjective word, so I'm specifically interested in the following:\n\nMost reusable libraries. For example one might want to automatically create accounts for new logged in facebook users, but at the same time provide an alternative username + password logging functionality. I need authentication to fit into this nicely.\nFacebook applications tend to differ from CMS-like sites. They are action intensive. For more complicated use-cases, usually some kind of caching for the data fetched from Open Graph API is required in order to be able to perform some queries on local and facebook data at once (for example join some tables based on friendship relation).\nI'd definitely prefer popular solutions. They just seem to be much more stable and better thought through. I've previously developed a facebook application in Grails and I as much as I liked the architecture and the general ideas, the amount of bugs and complication that I ran into was just a little bit too much. Also Groovy is still quite an exotic language to develop in, and this time I'm not going to work on my own.\n\nI'm not new to Python, but definitely new to web development in Python. Though after the experience with Grails and all its twists and turns I doubt Python could really scare me.","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2182,"Q_Id":5210692,"Users Score":0,"Answer":"If you do not want to start on Django now. Try learning Flask(which is comparatively a lot easier to begin than Django) and then start building app with Flask.","Q_Score":6,"Tags":"python,facebook","A_Id":23464883,"CreationDate":"2011-03-06T13:13:00.000","Title":"Python frameworks for developing facebook apps","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"Is it possible to programmatically detect dependencies given a python project residing in SVN?","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1336,"Q_Id":5215195,"Users Score":0,"Answer":"Absolutely! If you are working from a UNIX or Linux shell, a simple combination of grep and awk would work; basically, all you want to do is search for lines containing the \"import\" keyword.\nHowever, if you are working from any environment, you could just write a small Python script to do the searching for you (don't forget that strings are treated as immutable sequences, so you can do something like if \"import\" in line: ....\nThe one sticky spot, would be associating those imported modules to their package name (the first one that comes to mind is the PIL module, in Ubuntu it's provided by the python-imaging package).","Q_Score":2,"Tags":"python,svn,dependencies,detection","A_Id":5215273,"CreationDate":"2011-03-07T02:27:00.000","Title":"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":0,"Web Development":0},{"Question":"I am automatically generating unit tests for some Python code which number in the thousands. The unittest module uses classes to contain the tests however I'm guessing there is an upper limit to the number of methods a class may contain - is this the case?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1932,"Q_Id":5227198,"Users Score":8,"Answer":"Methods (and in fact all attributes) of a class are stored in a dict. There is no limit to the number of items a dict can contain, save that each key must be unique.","Q_Score":4,"Tags":"python,unit-testing,class,methods","A_Id":5227226,"CreationDate":"2011-03-08T01:03:00.000","Title":"What is the maximum number of methods on a Python 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},{"Question":"I want to know what exactly is lambda in python? and where and why it is used.\nthanks","AnswerCount":12,"Available Count":4,"Score":0.0,"is_accepted":false,"ViewCount":3299,"Q_Id":5233508,"Users Score":0,"Answer":"lambda is an anonymous function, usually used for something quick that needs computing.\nExample (This is used in a LexYacc command parser):\nassign_command = lambda dictionary, command: lambda command_function: dictionary.setdefault(command, command_function)\nThis is a decorator. Put before a command we'd have from the LexYacc parser:\n@assign_command(_command_handlers, 'COMMAND')\nThis essentially builds a python script from the LexYacc language defined.\nOr, a bit simpler:\n`x = lambda x: return x > 0 and x & (x-1) == 0","Q_Score":8,"Tags":"python,lambda","A_Id":5233599,"CreationDate":"2011-03-08T14:04:00.000","Title":"What exactly is \"lambda\" 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},{"Question":"I want to know what exactly is lambda in python? and where and why it is used.\nthanks","AnswerCount":12,"Available Count":4,"Score":0.0831409664,"is_accepted":false,"ViewCount":3299,"Q_Id":5233508,"Users Score":5,"Answer":"Lambdas are not anonymous functions. Lambdas are anonymous expressions.\nThey're accessed like functions, but they're not the same thing. Functions allow complex tasks: flow control, variable declarations and lists of statements containing expressions. Expressions are merely one part of a function, and that's what lambdas give you. They're severely limited compared to functions.\nPython does not support anonymous functions. For examples of languages that do, see Javascript and Lua.\n(Note: It's correct to call lambdas anonymous functions in functional languages, where the mathematical definition of \"function\" is used, but in procedural languages the word has a very different meaning than in mathematics.)","Q_Score":8,"Tags":"python,lambda","A_Id":5233898,"CreationDate":"2011-03-08T14:04:00.000","Title":"What exactly is \"lambda\" 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},{"Question":"I want to know what exactly is lambda in python? and where and why it is used.\nthanks","AnswerCount":12,"Available Count":4,"Score":0.0,"is_accepted":false,"ViewCount":3299,"Q_Id":5233508,"Users Score":0,"Answer":"It's an inline anonymous function.","Q_Score":8,"Tags":"python,lambda","A_Id":5233587,"CreationDate":"2011-03-08T14:04:00.000","Title":"What exactly is \"lambda\" 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},{"Question":"I want to know what exactly is lambda in python? and where and why it is used.\nthanks","AnswerCount":12,"Available Count":4,"Score":0.0,"is_accepted":false,"ViewCount":3299,"Q_Id":5233508,"Users Score":0,"Answer":"I would like to explain this with a little layman approach in terms of the usage perspective, since all the technical points are already covered.\nA lambda function is just like any other function, only thing that makes it different (other than the syntax and the fact that it can't be reused), is that it is used when we want to quickly write a function which takes an argument and just returns a value using only one expression.\nFor instance:\nIf all that a function does is take a argument and add 1 to it then using a lambda function is a better approach than a normal function.\nBut if your function requires more than one line of processing before returning the value, then we need to use a normal function definition and then call it.","Q_Score":8,"Tags":"python,lambda","A_Id":71792193,"CreationDate":"2011-03-08T14:04:00.000","Title":"What exactly is \"lambda\" 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},{"Question":"I would like to send email through a proxy. \nMy current implementation is as follows:\nI connect to the smtp server with authentication. After I've successfully logged in, I send an email. It works fine but when I look at the email header I can see my host name. I would like to tunnel it through a proxy instead. \nAny help will be highly appreciated.","AnswerCount":8,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":25028,"Q_Id":5239797,"Users Score":0,"Answer":"This code has earned from me.\n1. The file name must not be email.py Rename file name for example emailSend.py\n2. It is necessary to allow Google to send messages from unreliable sources.","Q_Score":14,"Tags":"python,proxy,smtp,smtplib","A_Id":44179874,"CreationDate":"2011-03-08T23:51:00.000","Title":"Python smtplib proxy 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},{"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},{"Question":"I have a relatively large dictionary. How do I know the size? well when I save it using cPickle the size of the file will grow approx. 400Mb. cPickle is supposed to be much faster than pickle but loading and saving this file just takes a lot of time. I have a Dual Core laptop 2.6 Ghz with 4GB RAM on a Linux machine. Does anyone have any suggestions for a faster saving and loading of dictionaries in python? thanks","AnswerCount":6,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":25562,"Q_Id":5248958,"Users Score":0,"Answer":"That is a lot of data...\nWhat kind of contents has your dictionary? If it is only primitive or fixed datatypes, maybe a real database or a custom file-format is the better option?","Q_Score":24,"Tags":"python,file,dictionary,pickle","A_Id":5249005,"CreationDate":"2011-03-09T16:35:00.000","Title":"Fastest way to save and load a large dictionary 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},{"Question":"I have a relatively large dictionary. How do I know the size? well when I save it using cPickle the size of the file will grow approx. 400Mb. cPickle is supposed to be much faster than pickle but loading and saving this file just takes a lot of time. I have a Dual Core laptop 2.6 Ghz with 4GB RAM on a Linux machine. Does anyone have any suggestions for a faster saving and loading of dictionaries in python? thanks","AnswerCount":6,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":25562,"Q_Id":5248958,"Users Score":2,"Answer":"I have tried this for many projects and concluded that shelve is faster than pickle in saving data. Both perform the same at loading data. \nShelve is in fact a dirty solution. \nThat is because you have to be very careful with it. If you do not close a shelve file after opening it, or due to any reason some interruption happens in your code when you're in the middle of opening and closing it, the shelve file has high chance of getting corrupted (resulting in frustrating KeyErrors); which is really annoying given that we who are using them are interested in them because of storing our LARGE dict files which clearly also took a long time to be constructed \nAnd that is why shelve is a dirty solution... It's still faster though. So!","Q_Score":24,"Tags":"python,file,dictionary,pickle","A_Id":58051642,"CreationDate":"2011-03-09T16:35:00.000","Title":"Fastest way to save and load a large dictionary 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},{"Question":"I created a module named util that provides classes and functions I often use in Python.\nSome of them need imported features. What are the pros and the cons of importing needed things inside class\/function definition? Is it better than import at the beginning of a module file? Is it a good idea?","AnswerCount":6,"Available Count":3,"Score":0.0665680765,"is_accepted":false,"ViewCount":54351,"Q_Id":5262406,"Users Score":2,"Answer":"I believe that it's best practice (according to some PEP's) that you keep import statements at the beginning of a module. You can add import statements to an __init__.py file, which will import those module to all modules inside the package.\nSo...it's certainly something you can do the way you're doing it, but it's discouraged and actually unnecessary.","Q_Score":58,"Tags":"python,function,class,import","A_Id":5262474,"CreationDate":"2011-03-10T16:10:00.000","Title":"Import statement inside class\/function definition - is it a good idea?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I created a module named util that provides classes and functions I often use in Python.\nSome of them need imported features. What are the pros and the cons of importing needed things inside class\/function definition? Is it better than import at the beginning of a module file? Is it a good idea?","AnswerCount":6,"Available Count":3,"Score":0.1325487884,"is_accepted":false,"ViewCount":54351,"Q_Id":5262406,"Users Score":4,"Answer":"Like flying sheep's answer, I agree that the others are right, but I put imports in other places like in __init__() routines and function calls when I am DEVELOPING code. After my class or function has been tested and proven to work with the import inside of it, I normally give it its own module with the import following PEP8 guidelines. I do this because sometimes I forget to delete imports after refactoring code or removing old code with bad ideas. By keeping the imports inside the class or function under development, I am specifying its dependencies should I want to copy it elsewhere or promote it to its own module...","Q_Score":58,"Tags":"python,function,class,import","A_Id":30221106,"CreationDate":"2011-03-10T16:10:00.000","Title":"Import statement inside class\/function definition - is it a good idea?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I created a module named util that provides classes and functions I often use in Python.\nSome of them need imported features. What are the pros and the cons of importing needed things inside class\/function definition? Is it better than import at the beginning of a module file? Is it a good idea?","AnswerCount":6,"Available Count":3,"Score":0.0665680765,"is_accepted":false,"ViewCount":54351,"Q_Id":5262406,"Users Score":2,"Answer":"While the other answers are mostly right, there is a reason why python allows this.\nIt is not smart to import redundant stuff which isn\u2019t needed. So, if you want to e.g. parse XML into an element tree, but don\u2019t want to use the slow builtin XML parser if lxml is available, you would need to check this the moment you need to invoke the parser.\nAnd instead of memorizing the availability of lxml at the beginning, I would prefer to try importing and using lxml, except it\u2019s not there, in which case I\u2019d fallback to the builtin xml module.","Q_Score":58,"Tags":"python,function,class,import","A_Id":5302566,"CreationDate":"2011-03-10T16:10:00.000","Title":"Import statement inside class\/function definition - is it a good idea?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"should be dumb as everybody seems to installed it without trouble.\nI spent hours within a fresh squeeze and tried different configurations (easy_install, aptitude and from source 0.81p.tar.gz) the best I got is a page from the localhost:9989 \nwithout any slave started.\nKnowing that I made the 2 accounts : buildmaster and buildslave \nhow to clean and reinstall it to have server and 1 slave for git ?\nthanks in advance\n\nAdded :\nYou are right some details are missing:\nI use buildbot from virtualBox with a Debian squeeze 6.0 in 32bits\nThe both accounts : buildmaster and buildslave are running within this same Virtual environment.\nI just tried the little example (this seems really interesting) :\neasy_install buildbot\nbuildbot create-master \/tmp\/experimental_buildmaster\nbuildbot start \/tmp\/experimental_buildmaster\n\nas root the jinja2 was missing whereas from buildmaster there were no complain (??)\ncommented the Git calls that created errors to try to start the simplest demo\nbuildslave create-slave \/tmp\/experimental_buildslave 127.0.0.1:9989 slave-name mypasswd\nin the log something appear allways : \"No address associated with hostname\"\n\nit seems I'm closer with this no ?","AnswerCount":4,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1638,"Q_Id":5262977,"Users Score":0,"Answer":"Some additional information about configuring abd running buildslave after it's creation.\nAfter installing buildbot package int.d script \/etc\/init.d\/buildbot is added to enable running buildbot as a service (starting automatically after system restart and so on).\nFor this script to run successfully you need to edit conf file for this script. File name is specified inside the script, typically it is \/etc\/default\/buildbot. Options in this file are pretty clear. One interesting thing you can tune here - the user from which buildbot will be running (default is buildbot). Small example of when it is useful:\nI had to write a buildbot task, one part of which was managing virtual machines running on builslave machine (starting, stopping, managing snapshots). But rights for doing this had only vbox user (I used Virtual Box VMs). So I simply changed the user field in \/etc\/buildbot\/default to accomplish this.\nI hope this information will be useful to you.","Q_Score":0,"Tags":"python,buildbot","A_Id":5692993,"CreationDate":"2011-03-10T16:49:00.000","Title":"buildbot from 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":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Why does Python compile libraries that are used in a script, but not the script being called itself?\nFor instance,\nIf there is main.py and module.py, and Python is run by doing python main.py, there will be a compiled file module.pyc but not one for main. Why?\nEdit\nAdding bounty. I don't think this has been properly answered.\n\nIf the response is potential disk permissions for the directory of main.py, why does Python compile modules? They are just as likely (if not more likely) to appear in a location where the user does not have write access. Python could compile main if it is writable, or alternatively in another directory.\nIf the reason is that benefits will be minimal, consider the situation when the script will be used a large number of times (such as in a CGI application).","AnswerCount":7,"Available Count":2,"Score":1.0,"is_accepted":false,"ViewCount":11900,"Q_Id":5268017,"Users Score":29,"Answer":"Nobody seems to want to say this, but I'm pretty sure the answer is simply: there's no solid reason for this behavior.\nAll of the reasons given so far are essentially incorrect:\n\nThere's nothing special about the main file. It's loaded as a module, and shows up in sys.modules like any other module. Running a main script is nothing more than importing it with a module name of __main__.\nThere's no problem with failing to save .pyc files due to read-only directories; Python simply ignores it and moves on.\nThe benefit of caching a script is the same as that of caching any module: not wasting time recompiling the script every time it's run. The docs acknowledge this explicitly (\"Thus, the startup time of a script may be reduced ...\").\n\nAnother issue to note: if you run python foo.py and foo.pyc exists, it will not be used. You have to explicitly say python foo.pyc. That's a very bad idea: it means Python won't automatically recompile the .pyc file when it's out of sync (due to the .py file changing), so changes to the .py file won't be used until you manually recompile it. It'll also fail outright with a RuntimeError if you upgrade Python and the .pyc file format is no longer compatible, which happens regularly. Normally, this is all handled transparently.\nYou shouldn't need to move a script to a dummy module and set up a bootstrapping script to trick Python into caching it. That's a hackish workaround.\nThe only possible (and very unconvincing) reason I can contrive is to avoid your home directory from being cluttered with a bunch of .pyc files. (This isn't a real reason; if that was an actual concern, then .pyc files should be saved as dotfiles.) It's certainly no reason not to even have an option to do this.\nPython should definitely be able to cache the main module.","Q_Score":44,"Tags":"python","A_Id":5321733,"CreationDate":"2011-03-11T01:27:00.000","Title":"Why does Python compile modules but not the script being run?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Why does Python compile libraries that are used in a script, but not the script being called itself?\nFor instance,\nIf there is main.py and module.py, and Python is run by doing python main.py, there will be a compiled file module.pyc but not one for main. Why?\nEdit\nAdding bounty. I don't think this has been properly answered.\n\nIf the response is potential disk permissions for the directory of main.py, why does Python compile modules? They are just as likely (if not more likely) to appear in a location where the user does not have write access. Python could compile main if it is writable, or alternatively in another directory.\nIf the reason is that benefits will be minimal, consider the situation when the script will be used a large number of times (such as in a CGI application).","AnswerCount":7,"Available Count":2,"Score":0.0285636566,"is_accepted":false,"ViewCount":11900,"Q_Id":5268017,"Users Score":1,"Answer":"Because the script being run may be somewhere where it is inappropriate to generate .pyc files, such as \/usr\/bin.","Q_Score":44,"Tags":"python","A_Id":5268020,"CreationDate":"2011-03-11T01:27:00.000","Title":"Why does Python compile modules but not the script being run?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have got a list of files in txt files and I need to check them out in edit mode, and make some changes(there are word documents), and check them back in via WinCVS.\nI know I can write tcl scripts or macro, or python scripts in wincvs shell but I have some problems with them.\nI have installed TCL 8.5 and selected tcl DLL in Admin>Preferences, tcl is now available, but whenever I type and execute a tcl script, it says\n\ncan not find channel named \"stdout\"\n\nDo you have any idea regarding this error?\nAlso, I cannot see admin macros, it says Shell is not available. I have installed the latest version of python and select related dll in preferences.\nCould anyone give me a hint for checking a list of files via wincvs?\nmany thanks in advance,\nregards","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":2712,"Q_Id":5272116,"Users Score":1,"Answer":"The problem is that Tcl's trying to build the standard file descriptors into available-by-default channels (i.e., stdin, stdout and stderr) but this goes wrong when they're not opened by default. That's the case on Windows when running disconnected (which is what happens inside GUI applications on that platform). When you're running with a full Tcl shell such as wish, this is worked around, but you're embedded so that's not going to work; the code to fix things isn't run because it's part of the shell startup and not the library initialization (after all, replacing a process-global resource like file descriptors is a little unfriendly for any library to do without the app or user asking it to!)\nThe simplest workaround is to not write to stdout \u2013 note that it's the default destination of the puts command, so you have to be careful \u2013 and to take care not to write to stderr either, as that's probably under the same restrictions (which means that you've got to be careful how you trap errors, especially while testing your script).","Q_Score":1,"Tags":"python,tcl,wincvs","A_Id":5296594,"CreationDate":"2011-03-11T11:05:00.000","Title":"WinCVS - Python - TCL","Data Science and Machine Learning":0,"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},{"Question":"I have a python script that output\/prints a large array (50MB in size) to the screen. This script is running on machineA. Is it at all possible to 'pipe' this output to machineB, where it will be processed?\nI know I can save the output in a file on machineA and then send the file to machineB. I was just wondering if it is possible to do so without having to save the data first to a file (on machineA).\nAny solutions (python, bash shell, other ideas) will be appreciated.","AnswerCount":5,"Available Count":1,"Score":0.0399786803,"is_accepted":false,"ViewCount":3563,"Q_Id":5278044,"Users Score":1,"Answer":"You can do it on different levels - here are a few options\n\nuse ssh to pipe \n myprog | ssh remotemachine myotherprog\nuse nfs (if going to a file\nuse netcat (nc)\nuse something like thrift\n\nIt depends on how solid & permanent the solution needs to be","Q_Score":1,"Tags":"python,linux,bash,shell","A_Id":5278104,"CreationDate":"2011-03-11T20:38:00.000","Title":"Piping output from a python script to a remote machine?","Data Science and Machine Learning":0,"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},{"Question":"This might be something obvious that I'm missing.\nI would like to have my host encrypt a message to a client using the client's public key, and also have that message signed using the hosts private key.\nIt seems like an obvious scenario, but perhaps my concept is simply wrong. I think that you should be able to do with with a single message, much like you see using PGP. Can this be done with M2Crypto easily?\nI tried first encrypting the message and then signing it but I get the message \"RSAError: digest too big for rsa key\".\nI would rather not send the encrypted message and its signature as two separate pieces of data.\nEdit:\nFor the time being I'm using a custom delimiter, to separate the message from the signature, but I feel like this is bad form, and that the format should have provisions for what I'm attempting.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":641,"Q_Id":5279102,"Users Score":1,"Answer":"It sounds like you're looking for a hybrid cryptosystem which takes care of encryption and signature together, using appropriate crypto primitives to allow it to work whatever the size of the data, and encapsulating all the components of the cryptogram in one place. PGP, HTTPS and DHIES are good examples. While it seems to me that you could implement such a system using m2crypto, you probably shouldn't; you're much better off reusing an existing protocol than rolling your own. It's far too easy to make mistakes which are hard to spot and render the security useless.","Q_Score":1,"Tags":"python,cryptography,rsa,m2crypto","A_Id":5340010,"CreationDate":"2011-03-11T22:36:00.000","Title":"M2Crypto, Encrypt and Sign at once?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I cannot find much advantage in them besides kind of documentation purpose. Python will warn me if I forget to implement a method I defined in a ABC but since I do not reference my objects by their interfaces I can forget to declare methods in their interfaces and I won't event notice it.\nIs it common practice to use ABC's for interface-like behaviour?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":2095,"Q_Id":5283995,"Users Score":6,"Answer":"Personally, I find abstract classes to be most useful when writing libraries or other code which interfaces between one developer and another.\nOne of the advantages of statically-typed languages is that when you use the wrong type, it fails early (often, as early as compile time). ABCs allow Python to gain this same advantage with dynamic typing.\nIf your library code duck types an object which lacks a vital method, it likely won't fail until that method is needed (which could take significant time or put resources into an inconsistent state, depending on how it's used). With ABCs, however, a missing method either isn't using the correct ABC (and fails an instanceof check) or is \"validated\" by the ABC.\nAdditionally, ABCs serve as an excellent way to document interfaces, both conceptually and, via docstrings, literally.","Q_Score":12,"Tags":"python,interface,abstract-class","A_Id":5284403,"CreationDate":"2011-03-12T17:03:00.000","Title":"Is it pythonic to use interfaces \/ abstract base classes?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":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},{"Question":"I hope you don't mind if I ask for a bit of advice regarding modelling robotic systems. I've recently become rather interested in using inverse kinematics (IK) to control a 5 dof robotic manipulator. I have a solid foundation in IK but what I'm having trouble with is a way to visualize how the manipulator moves with respect to joint angles. \nI've looked into using 3D toolkits (such as Blender, Panda3D, vPython) to create a 3d model of the arm, but I'm not sure if I should be looking something with physics support. I'm also not sure how well I can model motion with these packages. Anyone have any suggestions? What I'm NOT looking for is a full blown robotic simulator like Microsoft's Robotic Studio, I'd like to start with the basics and learn how everything works first, ie code the IK in Python, then visualize the motion in 3D. I'm very familiar with Python, so something that interfaces with Python would be preferable. \nThanks!","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2937,"Q_Id":5287575,"Users Score":0,"Answer":"This isn't really a hard problem, is it? Presumably you're working out the math on your own; so if your robotic arm is visualized as, say, a few rectangular solids then all you need is something that will render these at the x,y,z coordinates and with the orientation vector you supply, updating when need be. OpenGL should do just fine for this, you could probably do it in <50 lines.","Q_Score":2,"Tags":"python,modeling,robotics,robot,inverse-kinematics","A_Id":5287632,"CreationDate":"2011-03-13T05:06:00.000","Title":"Modelling a robotic arm motion in 3D, ideas?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"Imagine a python script that will take a long time to run, what will happen if I modify it while it's running? Will the result be different?","AnswerCount":8,"Available Count":4,"Score":1.2,"is_accepted":true,"ViewCount":69356,"Q_Id":5296977,"Users Score":372,"Answer":"Nothing, because Python precompiles your script into a PYC file and launches that.\nHowever, if some kind of exception occurs, you may get a slightly misleading explanation, because line X may have different code than before you started the script.","Q_Score":315,"Tags":"python","A_Id":5296992,"CreationDate":"2011-03-14T09:47:00.000","Title":"What will happen if I modify a Python script while it's running?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Imagine a python script that will take a long time to run, what will happen if I modify it while it's running? Will the result be different?","AnswerCount":8,"Available Count":4,"Score":-1.0,"is_accepted":false,"ViewCount":69356,"Q_Id":5296977,"Users Score":-5,"Answer":"depending. if a python script links to other modified file, then will load newer version ofcourse. but if source doesnt point to any other file it'll just run all script from cache as long as its run. changes will be visible next time...\nand if about auto-applying changes when they're made - yes, @pcbacterio was correct. its possible to do thar but script which does it just remembers last action\/thing what was doing and checks when the file is modified to rerun it (so its almost invisible)\n=]","Q_Score":315,"Tags":"python","A_Id":70072657,"CreationDate":"2011-03-14T09:47:00.000","Title":"What will happen if I modify a Python script while it's running?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Imagine a python script that will take a long time to run, what will happen if I modify it while it's running? Will the result be different?","AnswerCount":8,"Available Count":4,"Score":-0.024994793,"is_accepted":false,"ViewCount":69356,"Q_Id":5296977,"Users Score":-1,"Answer":"It happens nothing. Once the script is loaded in memory and running it will keep like this.\nAn \"auto-reloading\" feature can be implemented anyway in your code, like Flask and other frameworks does.","Q_Score":315,"Tags":"python","A_Id":70066818,"CreationDate":"2011-03-14T09:47:00.000","Title":"What will happen if I modify a Python script while it's running?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Imagine a python script that will take a long time to run, what will happen if I modify it while it's running? Will the result be different?","AnswerCount":8,"Available Count":4,"Score":0.024994793,"is_accepted":false,"ViewCount":69356,"Q_Id":5296977,"Users Score":1,"Answer":"No, the result will not reflect the changes once saved. The result will not change when running regular python files. You will have to save your changes and re-run your program.","Q_Score":315,"Tags":"python","A_Id":70108346,"CreationDate":"2011-03-14T09:47:00.000","Title":"What will happen if I modify a Python script while it's running?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have difficulty understanding the difference between zipfile.ZIP_DEFLATED and zipfile.ZIP_STORED compression modes of the zipfile module.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":10717,"Q_Id":5298169,"Users Score":25,"Answer":"ZIP_DEFLATED correspond to an archive member (a file inside the archive) which is compressed (or deflated). ZIP_STORED correspond to an archive member which is simply stored, without being compressed, quite the same as an archive member inside a tar file.","Q_Score":13,"Tags":"python,python-zipfile","A_Id":5298221,"CreationDate":"2011-03-14T11:51:00.000","Title":"Python zipfile module: difference between zipfile.ZIP_DEFLATED and zipfile.ZIP_STORED","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"How would I DKIM sign an email I've constructed using email.mime.text.MIMEText and am sending using smtplib?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1800,"Q_Id":5299025,"Users Score":0,"Answer":"You don't. It's the mail server's job to add this signature.","Q_Score":2,"Tags":"python,email,smtplib,dkim","A_Id":5299099,"CreationDate":"2011-03-14T13:13:00.000","Title":"Sending a DKIM signed email - 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},{"Question":"I'm using python and virtualenv\/pip. I have a module installed via pip called test_utils (it's django-test-utils). Inside one of my django apps, I want to import that module. However I also have another file test_utils.py in the same directory. If I go import test_utils, then it will import this local file.\nIs it possible to make python use a non-local \/ non-relative \/ global import? I suppose I can just rename my test_utils.py, but I'm curious.","AnswerCount":6,"Available Count":2,"Score":0.0333209931,"is_accepted":false,"ViewCount":3449,"Q_Id":5299199,"Users Score":1,"Answer":"I was able to force python to import the global one with\nfrom __future__ import absolute_import\nat the beginning of the file (this is the default in python 3.0)","Q_Score":2,"Tags":"python,django,import,python-module","A_Id":46303381,"CreationDate":"2011-03-14T13:28:00.000","Title":"Python - Importing a global\/site-packages module rather than the file of the same name in the local 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":0,"Web Development":1},{"Question":"I'm using python and virtualenv\/pip. I have a module installed via pip called test_utils (it's django-test-utils). Inside one of my django apps, I want to import that module. However I also have another file test_utils.py in the same directory. If I go import test_utils, then it will import this local file.\nIs it possible to make python use a non-local \/ non-relative \/ global import? I suppose I can just rename my test_utils.py, but I'm curious.","AnswerCount":6,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":3449,"Q_Id":5299199,"Users Score":0,"Answer":"Since my test_utils was in a django project, I was able to go from ..test_utils import ... to import the global one.","Q_Score":2,"Tags":"python,django,import,python-module","A_Id":5351006,"CreationDate":"2011-03-14T13:28:00.000","Title":"Python - Importing a global\/site-packages module rather than the file of the same name in the local 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":0,"Web Development":1},{"Question":"I have created my own simple logger class which uses COM interop to redirect to a company-standard logger. I would like to create logger instance near the beginning of my script and then use this logger to allow all modules in my script to log centrally.\nIs there an idiomatic way to share this logger instance between all modules, without specifically adding a logger parameter to the constructor of every class that needs to log?\nShould I use a global variable, or a singleton, or is there another recommended way to shar the logger between modules?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":2563,"Q_Id":5300563,"Users Score":6,"Answer":"Why don't you use Python standard logging and write a handler to interface with your company-standard logging system? Python logging is specifically designed so you don't need to pass logger instances between layers of your code - Python loggers are essentially singletons already.\nHandlers for stdlib logging are pretty easy to write, too - there are many examples of third party handlers.\nDisclosure: I'm the maintainer of Python's standard library logging package.","Q_Score":5,"Tags":"python,singleton","A_Id":5300658,"CreationDate":"2011-03-14T15:16:00.000","Title":"What is the idiomatic way to share a logger instance between modules in my 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},{"Question":"I use optparse module to parse the options that I make, and it automatically generates usage message to print with -h option.\nHow can I get the usage message as a string in a python script? I'd like to print out it when something's wrong with parsing.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":1826,"Q_Id":5306852,"Users Score":1,"Answer":"How about parser.format_help()?","Q_Score":1,"Tags":"python,optparse","A_Id":5306963,"CreationDate":"2011-03-15T02:26:00.000","Title":"Usage message string that optparse makes 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},{"Question":"I have a Python script that is connecting to the database. To that, obviously, I need the password. I need to hide it somewhere.\nMy problem is that this code is stored in a folder that everybody who has access to the server can look. So, if I write this password encrypted in a file, in the code will appear the key to discover it and people can figured it out.\nSo, please, if anyone has an idea..","AnswerCount":5,"Available Count":4,"Score":-0.0399786803,"is_accepted":false,"ViewCount":8940,"Q_Id":5315829,"Users Score":-1,"Answer":"A more advanced idea is to do the mysql authentication manually. That is, learn the mysql protocol (it's a standard handshake with a challenege and a response) and do the procedure yourself. This way, you never send the password directly.","Q_Score":13,"Tags":"python,passwords","A_Id":5316042,"CreationDate":"2011-03-15T17:48:00.000","Title":"What is the best way of hide a password?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I have a Python script that is connecting to the database. To that, obviously, I need the password. I need to hide it somewhere.\nMy problem is that this code is stored in a folder that everybody who has access to the server can look. So, if I write this password encrypted in a file, in the code will appear the key to discover it and people can figured it out.\nSo, please, if anyone has an idea..","AnswerCount":5,"Available Count":4,"Score":0.0,"is_accepted":false,"ViewCount":8940,"Q_Id":5315829,"Users Score":0,"Answer":"Just to reinforce what Brian said, if a program runs automatically (i.e., without the opportunity to prompt the user for a password), any program that runs under the same user authority has the same access to any password. It's not clear what else you could do. Perhaps if the (trusted) operating system on the client machine could certify to the host that it was being accessed by a program run from a particular path, the host could be told \"Only open the database to \/var\/lib\/tomcat\/bin\/tomcat on appserver.example.com\". If you accomplish all that, an attacker would have to compromise the tomcat executable to get to the database.","Q_Score":13,"Tags":"python,passwords","A_Id":5316392,"CreationDate":"2011-03-15T17:48:00.000","Title":"What is the best way of hide a password?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I have a Python script that is connecting to the database. To that, obviously, I need the password. I need to hide it somewhere.\nMy problem is that this code is stored in a folder that everybody who has access to the server can look. So, if I write this password encrypted in a file, in the code will appear the key to discover it and people can figured it out.\nSo, please, if anyone has an idea..","AnswerCount":5,"Available Count":4,"Score":1.2,"is_accepted":true,"ViewCount":8940,"Q_Id":5315829,"Users Score":10,"Answer":"You're using a scripting language and accessing a database directly with a password. No matter what you do, at some level that password is going to be easily accessible. Obscuring it doesn't really buy you much.\nYou have to rely on the machine's security and permissions, and perhaps the database (restricting access from that particular machine and user).","Q_Score":13,"Tags":"python,passwords","A_Id":5315927,"CreationDate":"2011-03-15T17:48:00.000","Title":"What is the best way of hide a password?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I have a Python script that is connecting to the database. To that, obviously, I need the password. I need to hide it somewhere.\nMy problem is that this code is stored in a folder that everybody who has access to the server can look. So, if I write this password encrypted in a file, in the code will appear the key to discover it and people can figured it out.\nSo, please, if anyone has an idea..","AnswerCount":5,"Available Count":4,"Score":1.0,"is_accepted":false,"ViewCount":8940,"Q_Id":5315829,"Users Score":7,"Answer":"Don't store the database connection credentials in the Python file at all. Instead, store them in a secure place, readable only by the user account that the script will run under.\nFor example, create a user account for running this job, and create a file in that user account's home directory (readable only by that user) called database.ini and put the database connection string and password there. Then use the Python ConfigParser class in the standard library to read the file in.\nThen the job can be always run under that user account. You can also run it under your account by putting a database.ini file in your home directory with the correct credentials, but anyone who doesn't have the credentials cannot run it.","Q_Score":13,"Tags":"python,passwords","A_Id":5316011,"CreationDate":"2011-03-15T17:48:00.000","Title":"What is the best way of hide a password?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"Has anyone here done any benchmarking of Chameleon versus Jinja2, in respect to performance? I'm more used to the Jinja syntax, since I come from Django, but as Pyramid suggests to use Chameleon, I'm thinking if it would be nice to give it a try - despite having an awkward syntax, IMO.","AnswerCount":3,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":6518,"Q_Id":5321789,"Users Score":19,"Answer":"Template engines are rarely the cause of performance problems, even if chameleon is slightly faster than Jinja2 I doubt the effort of learning a new template language etc. is worth it. \nOptimization of database queries and caching will probably result in more performance than you could gain by switching the template engine and take little effort.","Q_Score":12,"Tags":"python,performance,jinja2,pyramid,chameleon","A_Id":5324691,"CreationDate":"2011-03-16T06:28:00.000","Title":"Speed comparisons between Chameleon and Jinja2","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"How do you configure fabric to connect to remote hosts using SSH keyfiles (for example, Amazon EC2 instances)?","AnswerCount":8,"Available Count":1,"Score":0.024994793,"is_accepted":false,"ViewCount":58539,"Q_Id":5327465,"Users Score":1,"Answer":"As stated above, Fabric will support .ssh\/config file settings after a fashion, but using a pem file for ec2 seems to be problematic. IOW a properly setup .ssh\/config file will work from the command line via 'ssh servername' and fail to work with 'fab sometask' when env.host=['servername'].\nThis was overcome by specifying the env.key_filename='keyfile' in my fabfile.py and duplicating the IdentityFile entry already in my .ssh\/config. \nThis could be either Fabric or paramiko, which in my case was Fabric 1.5.3 and Paramiko 1.9.0.","Q_Score":101,"Tags":"python,fabric","A_Id":14738198,"CreationDate":"2011-03-16T15:20:00.000","Title":"Using an SSH keyfile with Fabric","Data Science and Machine Learning":0,"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},{"Question":"I used MailSlots with Delphi for my softwares when I needed dialogs between them (on MS Windows on the same coputer).\nNow I need to do the same things but with Python and on MS Windows but also on Linux.\nSo : what is the best way to communicate between Python written software running on the same computer ?\nFor some firewall problemes I would prefer to avoid IP dialogs.\nAs I tested it, I don't want all the DIsk File share solutions. \nSo in brief : \n\n\n2 Python software on the same computer need to dialog.\nNo IP\nNo Disk File share.","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":368,"Q_Id":5343264,"Users Score":0,"Answer":"How about one of them being a thread started by the another one?","Q_Score":1,"Tags":"python,pipe","A_Id":5343298,"CreationDate":"2011-03-17T18:05:00.000","Title":"What is the best way to communicate between Python softwares running on the same 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":0},{"Question":"How can i detect mouse movement in a python script in linux?\nI want to then send those events to a handler which will dispatch that where i can process it later.\nThere is no gui installed if that matters.","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":3099,"Q_Id":5350491,"Users Score":2,"Answer":"You could try reading \/dev\/input\/mice.","Q_Score":0,"Tags":"python,linux","A_Id":5350513,"CreationDate":"2011-03-18T10:10:00.000","Title":"How can i simply detect mouse movement 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},{"Question":"We are moving from latin1 to UTF-8 and have 100k lines of python code.\nPlus I'm new in python (ha-ha-ha!).\nI already know that str() function fails when receiving Unicode so we should use unicode() instead of it with almost the same effect.\nWhat are the other \"dangerous\" places of code?\nAre there any basic guidelines\/algorithms for moving to UTF-8? Can it be written an automatic 'code transformer'?","AnswerCount":3,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":1414,"Q_Id":5350958,"Users Score":4,"Answer":"str and unicode are classes, not functions. When you call str(u'abcd') you are initialising a new string which takes 'abcd' as a variable. It just so happens that str() can be used to convert a string of any type to an ascii str.\nOther areas to look out for are when reading from a file\/input, or basically anything you get back as a string from a function that was not written for unicode. \nEnjoy :)","Q_Score":4,"Tags":"python,unicode","A_Id":5351400,"CreationDate":"2011-03-18T10:56:00.000","Title":"How to move a python 2.6 project to UTF-8?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"We are moving from latin1 to UTF-8 and have 100k lines of python code.\nPlus I'm new in python (ha-ha-ha!).\nI already know that str() function fails when receiving Unicode so we should use unicode() instead of it with almost the same effect.\nWhat are the other \"dangerous\" places of code?\nAre there any basic guidelines\/algorithms for moving to UTF-8? Can it be written an automatic 'code transformer'?","AnswerCount":3,"Available Count":2,"Score":0.1325487884,"is_accepted":false,"ViewCount":1414,"Q_Id":5350958,"Users Score":2,"Answer":"Can it be written an automatic 'code transformer'? =)\n\nNo. str and unicode are two different types which have different purposes. You should not attempt to replace every occurrence of a byte string with a Unicode string, neither in Python 2 nor Python 3.\nContinue to use byte strings for binary data. In particular anything you're writing to a file or network socket is bytes. And use Unicode strings for user-facing text.\nIn between there is a grey area of internal ASCII-character strings which could equally be bytes or Unicode. In Python 2 these are typically bytes, in Python 3 typically Unicode. In you are happy to limit your code to Python 2.6+, you can mark your definitely-bytes strings as b'' and bytes, your definitely-characters strings as u'' and unicode, and use '' and str for the \u201cwhatever the default type of string is\u201d strings.","Q_Score":4,"Tags":"python,unicode","A_Id":5357350,"CreationDate":"2011-03-18T10:56:00.000","Title":"How to move a python 2.6 project to UTF-8?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a need to add module attributes at run time. For example, when a module is loaded, it reads the file where the data is contained. I would like that data to be available as a module attribute, but the data is only available at run time. \nHow can I add module attributes at run time?","AnswerCount":7,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":16367,"Q_Id":5354676,"Users Score":39,"Answer":"Thanks @Dharmesh. That was what I needed. There is only one change that needs to be made. The module won't be importing itself so to get the module object I can do:\nsetattr(sys.modules[__name__], 'attr1', 'attr1')","Q_Score":23,"Tags":"python","A_Id":5356035,"CreationDate":"2011-03-18T16:04:00.000","Title":"How can I add attributes to a module at run 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},{"Question":"I was looking at a book on python network programming and i wanted to know what would be the benefits to learning python network programming comprehensively? This would be in the context of being able to develop some really cool, ground breaking web apps. I am a python newbe so all opinions woul be appreciated.\nKind Regards\n4 Years later:\nThis was 4yrs ago, its crazy how much I've grown as a developer. Regarding how it has helped, I've developed an email application, a chat application using Objective C, python Twisted on the server side, it also helped with developing my apns push notification pipeline.","AnswerCount":5,"Available Count":5,"Score":0.1194272985,"is_accepted":false,"ViewCount":2411,"Q_Id":5357103,"Users Score":3,"Answer":"If you want to develop wed apps, than you should rather focus on web frameworks like Django or Pylons.","Q_Score":1,"Tags":"python,network-programming","A_Id":5357120,"CreationDate":"2011-03-18T19:49:00.000","Title":"benefits of learning python network programming?","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},{"Question":"I was looking at a book on python network programming and i wanted to know what would be the benefits to learning python network programming comprehensively? This would be in the context of being able to develop some really cool, ground breaking web apps. I am a python newbe so all opinions woul be appreciated.\nKind Regards\n4 Years later:\nThis was 4yrs ago, its crazy how much I've grown as a developer. Regarding how it has helped, I've developed an email application, a chat application using Objective C, python Twisted on the server side, it also helped with developing my apns push notification pipeline.","AnswerCount":5,"Available Count":5,"Score":0.0,"is_accepted":false,"ViewCount":2411,"Q_Id":5357103,"Users Score":0,"Answer":"The network is and always will be the sexiest arena for a hacker. An attacker can do almost anything with simple network access, such as scan for hosts, inject packets, sniff data, remotely exploit hosts, and much more. But if you are an attacker who has worked your way into the deepest depths of an enterprise target, you may find yourself in a bit of a conundrum: you have no tools to execute network attacks. No netcat. No Wireshark. No compiler and no means to install one. However, you might be surprised to find that in many cases, you\u2019ll find a Python install.\nHence, the one benefit of python network programming I see is that one has a chance of becoming a penetration tester or an Offensive security guy.\nEdit (10-06-2020):\nI have no knowledge of what I was thinking when I was writing this answer. It's clearly not helpful. \nRegarding the question, making web apps is not equivalent to network programming. In network programming with python, you can start with lower level of the OSI model by using libraries like scapy. Here you can make raw packets and understand the various protocols with it. And then maybe move to application level with libraries like Scrapy which involves web scraping, making http requests, etc. But develping python web apps would use tools like flask, django, jinja, etc and the development of a web app can take the form totally different than that of a regular scripting tool.","Q_Score":1,"Tags":"python,network-programming","A_Id":31816130,"CreationDate":"2011-03-18T19:49:00.000","Title":"benefits of learning python network programming?","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},{"Question":"I was looking at a book on python network programming and i wanted to know what would be the benefits to learning python network programming comprehensively? This would be in the context of being able to develop some really cool, ground breaking web apps. I am a python newbe so all opinions woul be appreciated.\nKind Regards\n4 Years later:\nThis was 4yrs ago, its crazy how much I've grown as a developer. Regarding how it has helped, I've developed an email application, a chat application using Objective C, python Twisted on the server side, it also helped with developing my apns push notification pipeline.","AnswerCount":5,"Available Count":5,"Score":1.2,"is_accepted":true,"ViewCount":2411,"Q_Id":5357103,"Users Score":2,"Answer":"\"Network programming\" isn't about \"cool web apps\". It's more about creating servers, and creating clients that talk to servers. It's about sockets, tcp\/ip communication, XMLRPC, http protocols and all the technologies that let two computers talk to each other.\nIf all you're interested in is web apps, learning network programming won't benefit you a whole lot.","Q_Score":1,"Tags":"python,network-programming","A_Id":5357140,"CreationDate":"2011-03-18T19:49:00.000","Title":"benefits of learning python network programming?","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},{"Question":"I was looking at a book on python network programming and i wanted to know what would be the benefits to learning python network programming comprehensively? This would be in the context of being able to develop some really cool, ground breaking web apps. I am a python newbe so all opinions woul be appreciated.\nKind Regards\n4 Years later:\nThis was 4yrs ago, its crazy how much I've grown as a developer. Regarding how it has helped, I've developed an email application, a chat application using Objective C, python Twisted on the server side, it also helped with developing my apns push notification pipeline.","AnswerCount":5,"Available Count":5,"Score":0.0399786803,"is_accepted":false,"ViewCount":2411,"Q_Id":5357103,"Users Score":1,"Answer":"\"python network programming\" isn't any special kind of network programming. It sounds like if you had a better grasp on network programming you would be able to see where python would fit in to your overall design. And instead of reading a generic book about it, you would dig through the python API's and go from there.\nThe cool thing about python is that it's a huge collection of libraries which are optimized to each task. At work we use python to do all our server-side heavy lifting. We then use jquery and the Objective-J based Cappuccino to present an interface to the user.","Q_Score":1,"Tags":"python,network-programming","A_Id":5359594,"CreationDate":"2011-03-18T19:49:00.000","Title":"benefits of learning python network programming?","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},{"Question":"I was looking at a book on python network programming and i wanted to know what would be the benefits to learning python network programming comprehensively? This would be in the context of being able to develop some really cool, ground breaking web apps. I am a python newbe so all opinions woul be appreciated.\nKind Regards\n4 Years later:\nThis was 4yrs ago, its crazy how much I've grown as a developer. Regarding how it has helped, I've developed an email application, a chat application using Objective C, python Twisted on the server side, it also helped with developing my apns push notification pipeline.","AnswerCount":5,"Available Count":5,"Score":0.0,"is_accepted":false,"ViewCount":2411,"Q_Id":5357103,"Users Score":0,"Answer":"Python's stronger web tool is definitely Django.\nSaid that the biggest benefit of learning it is to achieve a pretty robust backend on your web project.","Q_Score":1,"Tags":"python,network-programming","A_Id":62314047,"CreationDate":"2011-03-18T19:49:00.000","Title":"benefits of learning python network programming?","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},{"Question":"What is the role of python for writing dynamic web pages? Does it play an equivalent role to php?\nIf so, can it do all the same things as php (MySql, file manipulation, sending emails, ...)","AnswerCount":8,"Available Count":5,"Score":-0.0748596907,"is_accepted":false,"ViewCount":963,"Q_Id":5363912,"Users Score":-3,"Answer":"I think that since go-lang has gone into a release, weekly, tip release cycle, it's starting to show serious stability and it might be worth adding to this conversation. web.go, it's db connections, it's built-in http server, goinstall, ubuntu has packages already. It's website runs on it's include godoc server.","Q_Score":4,"Tags":"php,python","A_Id":5365686,"CreationDate":"2011-03-19T18:18:00.000","Title":"What is the role of python on the internet?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"What is the role of python for writing dynamic web pages? Does it play an equivalent role to php?\nIf so, can it do all the same things as php (MySql, file manipulation, sending emails, ...)","AnswerCount":8,"Available Count":5,"Score":1.2,"is_accepted":true,"ViewCount":963,"Q_Id":5363912,"Users Score":5,"Answer":"Everything that is possible in PHP is possible in Python. I'm not sure the opposite is true. And if it is, it would require jumping hoops you don't want to jump through.\nMost of the things that are laughingly easy to do in PHP for the web are not so straigtforward to do in Python (by just using the standard library).\nAs an example making a page with a 3 field form that sends you email without any validation is pretty straightforwared in PHP compared to Python (without any framework).\nFor less-trivial applications that you build from scratch the numerous Python frameworks and utility libraries for web development will make your life much easier in the long run compared to if you're using anything that exists for PHP.\nIt's position on the web... Well, facebook is obviously not using it :)\nBut, companies like Disqus, Quora, Reddit, Digg, NASA and many more use it heavily for web stuff.\nThere's also lack of cheap (for 5 visits a day) and easy-to-deploy to hosting solutions for python applications. Although that's changing recently.","Q_Score":4,"Tags":"php,python","A_Id":5364337,"CreationDate":"2011-03-19T18:18:00.000","Title":"What is the role of python on the internet?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"What is the role of python for writing dynamic web pages? Does it play an equivalent role to php?\nIf so, can it do all the same things as php (MySql, file manipulation, sending emails, ...)","AnswerCount":8,"Available Count":5,"Score":-0.049958375,"is_accepted":false,"ViewCount":963,"Q_Id":5363912,"Users Score":-2,"Answer":"Looks like you don't know the most basic web development uses in Python. Some web frameworks that use Python are:\n\nDjango\nFlask\nPyramid\n\nSome of the most popular websites also use these frameworks such as Pinterest (which uses Django). EVE was made in stackless python, a form a python used on the web. In conclusion, Python is a very reliable programming language for the web along with Ruby on Rails, Dart, Hack, PHP, Perl, and JavaScript.\nEDIT:\nWhy did I get a reputation of -2?","Q_Score":4,"Tags":"php,python","A_Id":31680575,"CreationDate":"2011-03-19T18:18:00.000","Title":"What is the role of python on the internet?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"What is the role of python for writing dynamic web pages? Does it play an equivalent role to php?\nIf so, can it do all the same things as php (MySql, file manipulation, sending emails, ...)","AnswerCount":8,"Available Count":5,"Score":-0.024994793,"is_accepted":false,"ViewCount":963,"Q_Id":5363912,"Users Score":-1,"Answer":"Python's main (only?) limitation compared to PHP is its syntax. Although in most situations it doesn't matter whether you're delimiting statements and blocks with semi-colons and braces (PHP) or line breaks and indentation (Python), this does become a bit of an issue when doing templating. Templating typically requires inserting chunks of code at an indentation level dictated by the surrounding context rather than the embedded code itself. This runs very much against the grain of Python syntax.\nThere have been some attempts made to create a useful mapping of Python into something that can be injected into templates, but it seems that there is inevitably some loss of expressiveness. Whether the compromise is nonetheless still more powerful than PHP is another matter.","Q_Score":4,"Tags":"php,python","A_Id":5366919,"CreationDate":"2011-03-19T18:18:00.000","Title":"What is the role of python on the internet?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"What is the role of python for writing dynamic web pages? Does it play an equivalent role to php?\nIf so, can it do all the same things as php (MySql, file manipulation, sending emails, ...)","AnswerCount":8,"Available Count":5,"Score":-0.049958375,"is_accepted":false,"ViewCount":963,"Q_Id":5363912,"Users Score":-2,"Answer":"Python is a multi purpose language and not limited to the web like PHP.\nNumerous web frameworks like Zope, Django or Pylons are build with Python. Apart from that: Php and php-based apps have very bad security record e.g. compared to Zope-based apps.","Q_Score":4,"Tags":"php,python","A_Id":5364008,"CreationDate":"2011-03-19T18:18:00.000","Title":"What is the role of python on the internet?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"Folks,\nI believe there are two questions I have: one python specific and the other NFS.\nThe basic point is that my program gets the 'username', 'uid', NFS server IP and exported_path as input from the user. It now has to verify that the NFS exported path is readable\/writable by this user\/uid.\nMy program is running as root on the local machine. The straight-forward approach is to 'useradd' a user with the given username and uid, mount the NFS exported path (run as root for mount) on some temporary mount_point and then execute 'su username -c touch \/mnt_pt\/tempfile'. IF the username and userid input were correct (and the NFS server was setup correctly) this touch of tempfile will succeed creating tempfile on the NFS remote directory. This is the goal.\nNow the two questions are:\n(i) Is there a simpler way to do this than creating a new unix user, mounting and touching a file to verify the NFS permissions?\n(ii) If this is what needs to be done, then I wonder if there are any python modules\/packages that will help me execute 'useradd', 'userdel' related commands? I currently intend to use the respective binaries(\/usr\/sbin\/useradd etc) and then invoke subprocess.Popen to execute the command and get the output.\nThank you for any insight.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":798,"Q_Id":5366298,"Users Score":0,"Answer":"There is a python suite to test NFS server functionality.\ngit:\/\/git.linux-nfs.org\/projects\/bfields\/pynfs.git\nWhile it's for NFSv4 you can simply adopt it for v3 as well.","Q_Score":0,"Tags":"python,nfs","A_Id":10356745,"CreationDate":"2011-03-20T02:02:00.000","Title":"Python: Verifying NFS authentication","Data Science and Machine Learning":0,"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},{"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},{"Question":"I have been plagued with this problem ever since I started with Python, I want to write a Python script, and then export it as an EXE that I can run on any Windows XP (and up) machine.\ncx_Freeze covers all of this perfectly, the only problem is that it required Visual C++ Runtime to be installed on the client computer before the resulting EXE will run on it...\nIs it possible to convert my beautiful *.py file into a nice distributable EXE that will run on a fresh install of Windows XP and up?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":746,"Q_Id":5373558,"Users Score":0,"Answer":"AFAIK if you have a Visual Studio licence, you have the right to bundle the appropriate msvcrXY.dll with your application. That will make it run without having to install the runtime files.\nIf you don't have a Visual Studio licence, I can think of two solutions:\nOne is to bundle the VS runtime installer with your application (if that is allowed by the licence), and make a tiny batch file\/program that runs the installer if necessary, and then your program. This is not ideal if e.g. the user doesn't have admin rights.\nThe other option I can think of is for you to compile Python with Mingw-gcc, and then use that Python to create your frozen executable. Then it won't depend on the VS runtime libraries. This approach is of course much more complicated and will probably require quite a bit of tinkering. Perhaps someone has already done it though.","Q_Score":1,"Tags":"python,windows,windows-xp,msvcrt,cx-freeze","A_Id":5373639,"CreationDate":"2011-03-21T03:30:00.000","Title":"Using cx_Freeze (Python 2.7) on a Windows box OOTB","Data Science and Machine Learning":0,"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},{"Question":"I need know that if a email is sent correctly for to do several operations but the function always return True.\nAny idea?\nThanks you.","AnswerCount":4,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":7759,"Q_Id":5374818,"Users Score":9,"Answer":"There is no way to check that a mail has actually been received. This is not because of a failing in Django, but a consequence of the way email works.\nIf you need some form of definite delivery confirmation, you need to use something other than email.","Q_Score":3,"Tags":"python,django","A_Id":5375529,"CreationDate":"2011-03-21T07:18:00.000","Title":"How can I know if a email is sent correctly with Django\/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},{"Question":"I am being told that Python is far superior to C in the ease of programming. I am an average( dont want to praise myself) user of C. Will it be helpful if I learn Python to implement my codes in future?","AnswerCount":2,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":23885,"Q_Id":5377123,"Users Score":4,"Answer":"It's always useful to learn another language. If you're familiar with C then I'd invest some time in learning C++ and this is likely to be more immediately useful and will build on your existing skillset, but if you've got the time then learning Python is a great idea!","Q_Score":8,"Tags":"python,c","A_Id":5377151,"CreationDate":"2011-03-21T11:42:00.000","Title":"Which is better C Vs 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},{"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},{"Question":"I have started using Python in a real-time application (serial communication with to gps modules at once), but have found out recently about Lua. Which language would be more suited to the application?\nMy definition of real-time in this context is the fastest possible time to receive, process and output the data. (Feedback system)","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":2435,"Q_Id":5383145,"Users Score":7,"Answer":"Both are fine languages. Neither should take you years to learn. An easy way to make the decision is to look at what modules are out there already.\nFor example, you mentioned that your application is related to GPS. Take a look at what libraries are already written to hook Python and Lua into your particular GPS hardware. Maybe someone's already done most of the hard work for you. If not, then go down a step. If you're talking to your GPS over an I2C link, look at I2C libraries in both languages. See which ones are more popular and better maintained.\nThat said, garbage collected languages have historically had problems with meeting real time requirements. Depending on yours, you may need to go with a lower level language. You should also ensure that whatever system you're running on will support your programming environment. I've worked with systems where Python would have been great but it doesn't fit in 5K of code space.","Q_Score":4,"Tags":"python,lua","A_Id":5383274,"CreationDate":"2011-03-21T20:19:00.000","Title":"Python or Lua - Realtime 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":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm getting a bunch of .docs emailed to me which I'm writing a python script to extract the body and any .doc or .pdf as well as any message they may have sent and depending on the answer it may do more, and then I want to send it to my web server and have a php script format it for display.\nI want to do any converting on my home pc because I don't have shell access to the web server and php is the only language supported which I (kind of) know. On the desktop I'm opened up to python, C, and C++ all of which I know better and are more suited for the job. I would really like to keep the formatting if possible, and I'm not trying to make a big project out of this so if it's too complicated I can always just upload the .doc and open it locally.","AnswerCount":4,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":916,"Q_Id":5384599,"Users Score":2,"Answer":"There are various Word to HTML converters - commercial and open source converters. The most common converter (open source) is likely \"wv\". You can also using Open-Office e.g. using the PyUNO bridge (requires a running OpenOffice server). If you are on Windows there are various commercial solutions available re-using an installed Office installation. In general: Google yourself and choose a converter according to your needs and requirements.","Q_Score":0,"Tags":"c++,python,c,ms-word","A_Id":5384992,"CreationDate":"2011-03-21T22:40:00.000","Title":"Need an easy way to display a word document in html","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"What's the best way to temporarily hide an installed module from a python script to test how it handles environments that don't have the module installed?\nI'd like to avoid having to uninstall the module just to test.","AnswerCount":2,"Available Count":1,"Score":0.2913126125,"is_accepted":false,"ViewCount":88,"Q_Id":5386194,"Users Score":3,"Answer":"Change your Python Path.\nThe order of directories in sys.path shows the order of a search. \nYou can change sys.path in a test to alter the search order.","Q_Score":4,"Tags":"python,testing,module,import,dependencies","A_Id":5386248,"CreationDate":"2011-03-22T02:51:00.000","Title":"Simulating lack of a dependency when testing 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":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a webapp with some functionality that I'd like to be made accessible via an API or webservice. My problem is that I want to control where my API can be accessed from, that is, I only want the apps that I create or approve to have access to my API. The API would be a web-based REST service. My users do not login, so there is no authentication of the user. The most likely use case, and the one to work with now, is that the app will be an iOS app. The API will be coded with django\/python.\nGiven that it is not possible to view the source-code of an iOS app (I think, correct me if I'm wrong), my initial thinking is that I could just have some secret key that is passed in as a parameter to the API. However, anyone listening in on the connection would be able to see this key and just use it from anywhere else in the world.\nMy next though is that I could add a prior step. Before the app gets to use API it must pass a challenge. On first request, my API will create a random phrase and encrypt it with some secret key (RSA?). The original, unencrypted phrase will be sent to the app, which must also encrypt the phrase with the same secret key and send back the encrypted text with their request. If the encryptions match up, the app gets access but if not they don't.\nMy question is: Does this sound like a good methodology and, if so, are there any existing libraries out there that can do these types of things? I'll be working in python server-side and objective-c client side for now.","AnswerCount":3,"Available Count":1,"Score":0.1325487884,"is_accepted":false,"ViewCount":334,"Q_Id":5395588,"Users Score":2,"Answer":"The easiest solution would be IP whitelisting if you expect the API consumer to be requesting from the same IP all the time. \nIf you want to support the ability to 'authenticate' from anywhere, then you're on the right track; it would be a lot easier to share an encryption method and then requesting users send a request with an encrypted api consumer handle \/ password \/ request date. Your server decodes the encrypted value, checks the handle \/ password against a whitelist you control, and then verifies that the request date is within some timeframe that is valid; aka, if the request date wasnt within 1 minute ago, deny the request (that way, someone intercepts the encrypted value, it's only valid for 1 minute). The encrypted value keeps changing because the request time is changing, so the key for authentication keeps changing. \nThat's my take anyways.","Q_Score":2,"Tags":"python,objective-c,security,api,rsa","A_Id":5395647,"CreationDate":"2011-03-22T17:44:00.000","Title":"Security measures for controlling access to web-services\/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":0,"Web Development":1},{"Question":"My python file has \"from .. import\" statement to package under C:\\Python27\\Lib\\site-packages.\nIf my file name does not have any extension (e.g. foo ) then \"python foo\" works. \nIf I rename file from foo to foo.py then the \"from .. import\" statement to that package fails in foo.py:\n\ntry:\n from my_package.System.prefix import ...\nexcept ImportError:\n print \"ERROR: Could not import modules.\"\n\nI have:\n PYTHONPATH=C:\\Python27\\Lib\\site-packages \n Environment: Windows XP\/ Python 2.7","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":578,"Q_Id":5399827,"Users Score":1,"Answer":"I'm going to make a wild guess here: is your filename the same as the package that you're trying to import (my_package in your example)?\nI was able to reproduce behavior similar to what you describe by creating a file, django.py, that contained the import statement from django.db import models. When I ran python django.py, I got ImportError: No module named db. When I moved code to a file named django (without a .py extension), deleted the django.pyc file, and ran python django, the import succeeded.\nWhy Python tries to import the django module, it starts by looking for a django.py file in the directory that contains the program being executed. In the first case, it imports the django.py file that I created instead of the django module that's installed in site-packages. In the second case, where I renamed my file django, Python can't find a django.py in the same directory as my file, so it properly import django from site-packages.","Q_Score":0,"Tags":"python","A_Id":5399984,"CreationDate":"2011-03-23T01:18:00.000","Title":"python file without extension works, but with .py extension fails to import my 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},{"Question":"Is there a way to reduce the I\/O's associated with either mysql or a python script? I am thinking of using EC2 and the costs seem okay except I can't really predict my I\/O usage and I am worried it might blindside me with costs. \nI basically develop a python script to parse data and upload it into mysql. Once its in mysql, I do some fairly heavy analytic on it(creating new columns, tables..basically alot of math and financial based analysis on a large dataset). So is there any design best practices to avoid heavy I\/O's? I think memcached stores a everything in memory and accesses it from there, is there a way to get mysql or other scripts to do the same?\nI am running the scripts fine right now on another host with 2 gigs of ram, but the ec2 instance I was looking at had about 8 gigs so I was wondering if I could use the extra memory to save me some money.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":202,"Q_Id":5425289,"Users Score":0,"Answer":"You didn't really specify whether it was writes or reads. My guess is that you can do it all in a mysql instance in a ramdisc (tmpfs under Linux).\nOperations such as ALTER TABLE and copying big data around end up creating a lot of IO requests because they move a lot of data. This is not the same as if you've just got a lot of random (or more predictable queries).\nIf it's a batch operation, maybe you can do it entirely in a tmpfs instance. \nIt is possible to run more than one mysql instance on the machine, it's pretty easy to start up an instance on a tmpfs - just use mysql_install_db with datadir in a tmpfs, then run mysqld with appropriate params. Stick that in some shell scripts and you'll get it to start up. As it's in a ramfs, it won't need to use much memory for its buffers - just set them fairly small.","Q_Score":2,"Tags":"python,mysql,amazon-ec2,mysql-management","A_Id":5426527,"CreationDate":"2011-03-24T20:44:00.000","Title":"reducing I\/O on application and database","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":0},{"Question":"I have a C# module which can be imported into IronPython (well, technically the all can, but one that's meant to be imported). However, the default help used for C# modules by IronPython just isn't sufficient enough.\nIs there a way to grab and attach the VS exported xml documentation to a C# module with IronPython's help system? Or is there some way in the C# code to specify what IronPython should put in lieu of the default documentation?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":547,"Q_Id":5428298,"Users Score":2,"Answer":"If the XML file is in the same location as the assembly and has the same filename just with \".xml\" instead of \".exe\" or \".dll\" then IronPython should pick it up and include it in relevant doc strings for types, methods, etc...","Q_Score":4,"Tags":"c#,ironpython","A_Id":5439443,"CreationDate":"2011-03-25T03:39:00.000","Title":"IronPython use C# module documentation","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I am facing a problem here which I could not find a good solution for it. I am developing a mobile web app using php and I need a rule based inference engine (open source) - expert system. The only one I could find was Pyke in Python. So I need to integrate Pykes' source code with my php implementation. My service provider is not allowing any commands such as exec for security reasons. I tried PiP (Python to PHP module) but it has a lot of bugs.","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":1667,"Q_Id":5431887,"Users Score":2,"Answer":"I'm not familiar with Pyke; but when this type of situation arises for me, I usually end up wrapping the Python code with a web-service. I then use PHP to make SOAP or cURL calls to the webservice.","Q_Score":4,"Tags":"php,python","A_Id":5433000,"CreationDate":"2011-03-25T11:37:00.000","Title":"Python PHP Integration","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"Is it possible to run webservice based on SOAPpy with mod_wsgi under Apache?\nif yes can you post link to sample(example)?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":227,"Q_Id":5431958,"Users Score":1,"Answer":"No. SOAPpy has its own HTTP server based on BaseHTTPServer which means that it is not possible to turn it into a WSGI app without a non-trivial amount of hacking.","Q_Score":0,"Tags":"python,apache,mod-wsgi,soappy","A_Id":5432043,"CreationDate":"2011-03-25T11:44:00.000","Title":"Is it possible to run webservice based on SOAPpy with mod_wsgi under 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":0,"Web Development":1},{"Question":"I normally web develop in PHP. I am working on a python based project, and want to make a front-end web site for it. \nI looked at web.py, and I was wondering if PHP can be used together with web.py, or would I have to rely completely on python as the server side scripting?\nThanks.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":915,"Q_Id":5444445,"Users Score":1,"Answer":"Combining web.py and PHP doesn't really make sense. But you can definitely set up Apache to have both. You just install mod_php and mod_wsgi. Point mod_wsgi to your web.py WSGI function, and set up your PHP web app in some directory where Apache can find it. You won't be combining the two technologies, but you will have separate web applications on your server that separately use the two technologies.","Q_Score":1,"Tags":"python,web.py","A_Id":12962245,"CreationDate":"2011-03-26T18:45:00.000","Title":"How to run PHP and Web.py together","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I have some .png images and I want to be able to quickly:\n(a) Load a .png from a file.\n(b) Draw some simple lines on top of the .png.\n(c) Get the contents (bytes) of the resulting image to return as the result of an http request.\nIt sounds like PIL is a good candidate for doing this with relatively little code. However, I'm trying to understand how efficient it is, especially when I have, say, thousands of lines to draw in step (b). The alternative is using PyOpenGL, but before getting into that I wanted to understand if PIL was already fast enough.\nI was going to ask if PIL used OpenGL under the covers. But that might be the wrong question, because my understanding is that to get the real speed benefit from PyOpenGL I'd want to submit my line vertexes as NumPy arrays. So presumably even if PIL uses OpenGL, I'm going to lose a lot of that benefit when I make an individual PIL call to draw each of my lines?\nAnybody have concrete data for speed of PIL when drawing lots of primitives?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":2486,"Q_Id":5446816,"Users Score":2,"Answer":"\"Draw some simple lines on top of the .png\" is not a computationally intensive task. \nThis doesn't seems to be a good candidate for the GPU since they are better suited for more complex tasks. You've got to realize that the image is initially loaded on the RAM, making it your job to send this data to the GPU memory and then retrieve it back. This operation consumes a few milliseconds, depending on the size of the image, that could be better used for CPU processing.\nYour application would only benefit from the GPU if it had high arithmetic intensity.","Q_Score":0,"Tags":"python,opengl,python-imaging-library,gpu","A_Id":5446952,"CreationDate":"2011-03-27T02:23:00.000","Title":"How fast is Python Image Library's (PIL) ImageDraw Module, for instance as compared to OpenGL?","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},{"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},{"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},{"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},{"Question":"I have recently converted a library, I originally wrote in C++ with Boost Python wrapping, to C with SWIG wrapping to support more languages.\nI switched from C++ to C because the library consists only of a set of functions and I also want the library to be callable from C (without having to compile the whole program with a C++ compiler).\nHowever there is one thing that was not easy to port, a very small subset of the functions needs the ability to report errors back.\nIn C++\/Boost Python that was very elegantly accomplished with throw and exception translation.\nWhat would be the most elegant way (on both the C and wrapped language side) to have a subset of functions report errors?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1235,"Q_Id":5448257,"Users Score":0,"Answer":"Take a look at Chapter 4 in C Interfaces and Implementations by Richard R. Hanson.","Q_Score":4,"Tags":"python,c,swig","A_Id":5521222,"CreationDate":"2011-03-27T09:11:00.000","Title":"Most elegant way for SWIG wrapped C library to raise exceptions","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},{"Question":"I am trying to send an email (through gmail) using python script that someone once wrote on this site, but I'm getting an error:\nUnicodeDecodeError: 'utf8' codec can't decode byte 0xe8 in position 2: invalid continuation byte\nthe script:\n\n\nimport smtplib\nfrom email.mime.text import MIMEText\n#mail setup\nFROMMAIL = \"xxx@gmail.com\"\nLOGIN = FROMMAIL\nPASSWORD = \"yyy\"\nSUBJECT = \"test subject\"\nTOMAIL = \"xxx@gmail.com\"\n\nmsg = MIMEText('testcontent')\nmsg['Subject'] = 'test'\nmsg['From'] = FROMMAIL\nmsg['To'] = TOMAIL\nserver = smtplib.SMTP('smtp.gmail.com', 587)\nserver.set_debuglevel(1)\nserver.ehlo()\nserver.starttls()\nserver.login(LOGIN, PASSWORD)\nserver.sendmail(FROMMAIL, [TOMAIL], msg.as_string())\nserver.quit()\n\n\nThe stacktrace:\n\n\nTraceback (most recent call last):\n File \"C:\\Users\\xxx\\Desktop\\test.py\", line 11, in \n server = smtplib.SMTP('smtp.gmail.com', 587)\n File \"C:\\Program Files\\Python31\\lib\\smtplib.py\", line 248, in __init__\n fqdn = socket.getfqdn()\n File \"C:\\Program Files\\Python31\\lib\\socket.py\", line 290, in getfqdn\n name = gethostname()\nUnicodeDecodeError: 'utf8' codec can't decode byte 0xe8 in position 2: invalid continuation byte\n\n\nI am using python v3.1.3.\nHow to resolve this?\nThank you.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":548,"Q_Id":5449084,"Users Score":0,"Answer":"Use the 'email' module of Python in order to generate proper formatted emails.\nDealing yourself with encoding issues on the application level while composing emails directly through Python is not the way to go.","Q_Score":0,"Tags":"python,email,unicode,gmail,decode","A_Id":5449108,"CreationDate":"2011-03-27T12:03:00.000","Title":"Python : sending mail through gmail issue","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},{"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},{"Question":"Has anyone tried to compare those python implementations?\n\npypy\npsyco\nunladen swallow (is it dead?)\ncpython\n\nI am planning to squeeze something more from my server.\nSetup:\n\nDjango 1.3\nPython 2.7\nPsycopg2 1.4\napache 2\nmod_wsgi\nand... Windows server\n\nI am not a windows fanboy, but it has to be :{ There is some legacy code working on it.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":611,"Q_Id":5451246,"Users Score":0,"Answer":"One thing you should considerate is the C extensions. Different implementations require different extension ways. At present, the CTYPES may be the most common one.\nSo I recommend you take CPython, in case of possible C extensions.","Q_Score":3,"Tags":"python,django,compiler-construction,comparison,benchmarking","A_Id":5497595,"CreationDate":"2011-03-27T18:16:00.000","Title":"django: on pypy, psyco, unladen swallow or cpython, which one is the fastest?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"Looking for a low volume, probably no more that 20-30 users, Open Source message\/bulletin board. Obviously must be written in something which our web server supports, PHP\/Python\/Ruby etc. Any suggestions?\nThanks,\n Nick","AnswerCount":5,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":462,"Q_Id":5459896,"Users Score":0,"Answer":"PhpBB is an excellent. It's very easy to set up and has many great features, but it is more difficult to customize right out of the box. For a superfast \"community\" solution, try using WordPress with the BuddyPress plugin.","Q_Score":1,"Tags":"php,python,html,ruby","A_Id":5460038,"CreationDate":"2011-03-28T13:46:00.000","Title":"Low volume Open source Message Board suggestions?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I am doing research on routing protocols. Currently I perform simulations written in Python of a new protocol. The next step would be to build a real prototype which can really run on top of a Linux-based operating system (as a routing daemon such as ospfd).\nWhat would be a well-suited programming environment\/language to quickly build a prototype of a routing protocol? Anyone having experience with building distributed protocol prototypes? \nI would like to focus as much as possible on high-level protocol logic instead of on low-level machine-related instructions. I am willing to learn new languages (such as Erlang or Haskell), in case they are better adapted for such a task. Alternatively, I have read about the twisted framework available in Python (which would probably allow to re-use some code), but it is unclear to me if this only would help me in case I write client\/server-based protocols. \nDoes anyone know about an elegant tutorial or example implementation of a (distributed) protocol implementation?","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":1573,"Q_Id":5465010,"Users Score":1,"Answer":"Erlang is very well suited for just a logical prototype without concrete implementation as well as implementing real world capable implementations of the protocols.\nYou don't need any other framework, just Erlang and OTP which comes with it is enough.\nEven if you have to work down to packet level Erlang helps you with its binary patterns which are gread for working with protocol packets.\nEven if you want high performance you can move the most time critical stuff into whats called \"Ports\" in Erlang implementing it in C or another low level language.","Q_Score":2,"Tags":"python,routing,network-programming,erlang,protocols","A_Id":5473481,"CreationDate":"2011-03-28T21:00:00.000","Title":"Environment for quickly developing routing protocol prototype","Data Science and Machine Learning":0,"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},{"Question":"in python,can i load a module from remote server to local?\nwhat i do this is want to protect my source code.\nwhat should i do ,thanks","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":5926,"Q_Id":5470161,"Users Score":0,"Answer":"Yes, you can import your code in creative ways.\nNo, it will not protect the code from being seen. Rethink your strategy, not tactics.","Q_Score":1,"Tags":"python,module,load","A_Id":5471112,"CreationDate":"2011-03-29T09:04:00.000","Title":"python can load modules from remote server?","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},{"Question":"I would like to look at the way Python does computes square roots, so I tried to find the definition for math.sqrt(), but I can't find it anywhere. I have looked in _math.c, mathmodule.c, and elsewhere.\nI know that python uses C's math functions, but are these somewhere in the Python distribution, or are they linked to code elsewhere? I am using Mac OS X.\nWhere is the algorithm in math.sqrt()?","AnswerCount":4,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":16849,"Q_Id":5476189,"Users Score":2,"Answer":"Some modules are written in C and not in python so you wouldn't be able to find the .py files. For a list of these you can use:\nimport sys\nprint sys.builtin_module_names\nSince it's written in C you will have to find it in the source code. If you have the source already it's in the modules directory.","Q_Score":27,"Tags":"python,math,sqrt","A_Id":5476318,"CreationDate":"2011-03-29T17:03:00.000","Title":"Where can I inspect Python's math functions?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Hello How can I enable syntax highlighting for HTML\/CSS\/JS in Eclipse I am mainly developing in python using the PyDev package but right now I am creating Cheetah templates and they are very hard to read unhighlighted.\nAny plugin\/package suggestions related to Cheetah or just highlighting any file as html would be greatly appreciated.\nthank you.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":8276,"Q_Id":5477078,"Users Score":5,"Answer":"Can I somehow trick Eclipse into treating .tmpl files as if they were .html?\n\nIt's not a trick.\nUnder Windows -> Preferences, General -> Editors -> File Associations, you can associate *.tmpl files with your HTML editor.","Q_Score":7,"Tags":"python,html,eclipse,syntax,cheetah","A_Id":5477725,"CreationDate":"2011-03-29T18:19:00.000","Title":"HTML\/CSS\/JS Syntax Highlighting 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":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have something simple right now, userdb schema is:\n\nuserid - autoincrement id email\nemail address\npassword\n\nI want to incorporate Facebook and twitter, how would i deal with it on the DB side?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":105,"Q_Id":5480742,"Users Score":3,"Answer":"You can do this many ways, either you store most of the data in a generic usertable (as you are about to) and the provider details separated.\nOr you make a design where you can connect multiple logins to same user. This will end up with something like\n\nid user\nid facebookuser (nullable)\nid twitteruser (nullable)\n\nThis will maybe get you N many e-mail adresses (and still no password! since you arent the provider of the account); or none at all. It depends how much this user trust you in each provider.\nEdit:\nYou might also want to normalize the data without nullables.\nYou can do this by having\n\nid_user\nid_facebookuser id_user\nid_twitteruser id_user","Q_Score":1,"Tags":"python,database,database-design,login","A_Id":5480782,"CreationDate":"2011-03-30T00:58:00.000","Title":"Incorporating multiple login systems?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"Is there a messaging solution out there (preferably supporting Python) that I can use like a mailbox, e.g. retrieve messages from any given queue without having to subscribe? I suppose message queues could work, but I would have to repeatedly subscribe, grab messages from the queue, then unsubscribe, which does not sound optimal.","AnswerCount":3,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":423,"Q_Id":5482097,"Users Score":0,"Answer":"Most (if not all) Messaging solutions support two modes of messaging\n\nPublish \\ Subscribe -that is, you need to subscribe to get the message.\nQueuing - one party sends a message to the queue, the other reads the message from the Queue - no subscription needed, and the message is consumed when it's read.\n\nActually, standard Queuing is more common then publish subscribe - you have better chances of finding a tool that supports queuing, but not pub\\sub, then find a tool that supports pub\\sub but not queuing.\nYou are probably looking for the 2nd mode","Q_Score":0,"Tags":"python,email,scalability,message-queue,messaging","A_Id":5483282,"CreationDate":"2011-03-30T05:05:00.000","Title":"Protocol for retrieving and publishing messages (message queues without the pub\/sub)","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},{"Question":"I read that mmap is advantageous than fileinput, because it will read a page into kernel pagecache and shares the page in user address space. Whereas, fileinput actually brings a page into kernel and copies a line to user address space. So, there is this extra space overhead with fileinput. \nSo, I am planning to move to mmap, but I want to know from advanced python hackers whether it improves performance?\nIf so, is there a similar implementation of fileinput that uses mmap?\nPlease point me to any opensource code, if you are aware of.\nthank you","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":2184,"Q_Id":5483163,"Users Score":1,"Answer":"mmap takes a file and sticks it in RAM so that you can index it like an array of bytes or as a big data structure.\nIts a lot faster if you are accessing your file in a \"random-access\" manner -- that is doing a lot of fseek(), fread(), fwrite() combinations.\nBut if you are just reading the file in and processing each line once (say), then it is unlikely to be significantly faster. In fact, for any reasonable file size (remember with mmap it all must fit in RAM -- or paging occurs which begins to reduce the efficiency of mmap) it probably is indistinguishable.","Q_Score":5,"Tags":"python,performance","A_Id":5506495,"CreationDate":"2011-03-30T07:20:00.000","Title":"Advantages of mmap vs fileinput","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have some code written in PHP, but I have also developed a script written in Python. Is it possible to call this Python script from the PHP code?\nIf yes, how can I pass parameters to the Python script from the PHP?\nI have tried to find an answer without any success.\nCan someone give me a clue?","AnswerCount":4,"Available Count":1,"Score":0.049958375,"is_accepted":false,"ViewCount":43993,"Q_Id":5497540,"Users Score":1,"Answer":"You can try this:\npython scripts:\n test.py:\n print \"hello\"\n\nthen php Scripts\nindex.php:\n $i =`python test.py`;\n echo $i;","Q_Score":13,"Tags":"php,python","A_Id":45145842,"CreationDate":"2011-03-31T09:11:00.000","Title":"How to call a Python Script from 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},{"Question":"I've got a python crawler crawling a few webpages every few minutes. I'm now trying to implement a user interface to be accessed over the web and to display the data obtained by the crawler. I'm going to use php\/html for the interface. Anyway, the user interface needs some sort of button which triggers the crawler to crawl a specific website straight away (and not wait for the next crawl iteration).\nNow, is there a way of sending data from the php script to the running python script? I was thinking about standard input\/output, but could not find a way this can be done (writing from one process to another process stdin). Then I was thinking about using a shared file which php writes into and python reads from. But then I would need some way to let the python script know, that new data has been written to the file and a way to let the php script know when the crawler has finished its task. Another way would be sockets - but then I think, this would be a bit over the top and not as simple as possible.\nDo you have any suggestions to keep everything as simple as possible but still allowing me to send data from a php script to a running python process?\nThanks in advance for any ideas!\nEdit: I should note, that the crawler saves the obtained data into a sql database, which php can access. So passing data from the python crawler to the php script is no problem. It's the other way round.","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":1079,"Q_Id":5499558,"Users Score":0,"Answer":"Since i don't know too much about how python works just treat this like a wild idea.\n\nCreate an XML on your server which is accessible by both of python and PHP\nOn the PHP side you can insert new nodes to this XML about new urls with a processed=false flag\nPython come and see for unprocessed tasks then fetch data and put sources onto your db\nAfter successful fetching, toggle the processed flag\nWhen next time PHP touch this XML, delete nodes with processed=true attributes\n\nHope it helps you in some way.","Q_Score":1,"Tags":"php,python,stdout,stdin,web-crawler","A_Id":5499681,"CreationDate":"2011-03-31T12:06:00.000","Title":"Passing Data to a Python Web Crawler from PHP 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":1},{"Question":"I've got a python crawler crawling a few webpages every few minutes. I'm now trying to implement a user interface to be accessed over the web and to display the data obtained by the crawler. I'm going to use php\/html for the interface. Anyway, the user interface needs some sort of button which triggers the crawler to crawl a specific website straight away (and not wait for the next crawl iteration).\nNow, is there a way of sending data from the php script to the running python script? I was thinking about standard input\/output, but could not find a way this can be done (writing from one process to another process stdin). Then I was thinking about using a shared file which php writes into and python reads from. But then I would need some way to let the python script know, that new data has been written to the file and a way to let the php script know when the crawler has finished its task. Another way would be sockets - but then I think, this would be a bit over the top and not as simple as possible.\nDo you have any suggestions to keep everything as simple as possible but still allowing me to send data from a php script to a running python process?\nThanks in advance for any ideas!\nEdit: I should note, that the crawler saves the obtained data into a sql database, which php can access. So passing data from the python crawler to the php script is no problem. It's the other way round.","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":1079,"Q_Id":5499558,"Users Score":1,"Answer":"Best possible way to remove dependencies of working with different languages is to use a message queuing library (like rabbitMQ or ActiveMQ)\nBy using this you can send direct messages from php to python or vice versa...\nIf you want an easy way out you need to modify your python script(more on the lines of what fabrik said) to poll a database(or a file) for any new jobs...and process it if it finds one...","Q_Score":1,"Tags":"php,python,stdout,stdin,web-crawler","A_Id":5500025,"CreationDate":"2011-03-31T12:06:00.000","Title":"Passing Data to a Python Web Crawler from PHP 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":1},{"Question":"How easy is it to reverse engineer an auto-generated C code? I am working on a Python project and as part of my work, am using Cython to compile the code for speedup purposes.\nThis does help in terms of speed, yet, I am concerned that where I work, some people would try to \"peek\" into the code and figure out what it does.\nCython code is basically an auto-generated C. Is it very hard to reverse engineer it?\nAre there any recommendations that would make the code safer and reverse-engineering harder to do? (I assume that with enough effort, everything can be reversed engineered).","AnswerCount":3,"Available Count":3,"Score":1.2,"is_accepted":true,"ViewCount":2870,"Q_Id":5507531,"Users Score":7,"Answer":"Okay -- to attempt to answer your question more directly: most auto-generated C code is fairly ugly, so somebody would need to be fairly motivated to reverse engineer it. At the same time, I don't believe I've never looked at what Cython generates, so I'm not sure how it looks.\nIn addition, a lot of auto-generated code is done in the form of things like state machine tables, that most programmers find fairly difficult to follow even at best. The tendency (in many cases) is to have a generic framework, with tables of data that the framework more or less \"interprets\" at run-time. This isn't necessarily impossible to follow, but it's enough different from most typical code that most people will give up on it fairly quickly (and if they do much, they'll typically waste a lot of time looking at the framework instead of the data, which is what really matters in cases like this).\nI'll repeat, however, that I'm pretty sure I haven't looked at what Cython produces, so I can't say much about it with any real certainty.\nThere are (or at least used to be) commercial obfuscators intended to make C source code difficult to understand. I suspect the availability of Perl has taken a lot of the market share from them, but if you look you may still be able to find one and use it.\nAbsent that, it's not terribly difficult to write an obfuscator of your own, but the degree of effectiveness will probably vary with the amount of effort you're willing to put into it. Just systematically renaming any meaningful variable names into things like _ and __ can do quite a bit (e.g., profit = sales - costs; is a lot more meaningful than _ = _I_ - _i_;). Depending on the machine generated code in question, however, this may not really accomplish much -- obfuscating a generic framework may not make much difference in understanding what your code does -- and if they figure out the procedure you're following, they may be able to simply replicate the correct framework code and transplant the pieces specific to your program into the un-obfuscated framework.","Q_Score":7,"Tags":"python,c,reverse-engineering,cython","A_Id":5507763,"CreationDate":"2011-03-31T23:18:00.000","Title":"Reverse Engineer Auto-Generated 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},{"Question":"How easy is it to reverse engineer an auto-generated C code? I am working on a Python project and as part of my work, am using Cython to compile the code for speedup purposes.\nThis does help in terms of speed, yet, I am concerned that where I work, some people would try to \"peek\" into the code and figure out what it does.\nCython code is basically an auto-generated C. Is it very hard to reverse engineer it?\nAre there any recommendations that would make the code safer and reverse-engineering harder to do? (I assume that with enough effort, everything can be reversed engineered).","AnswerCount":3,"Available Count":3,"Score":0.1325487884,"is_accepted":false,"ViewCount":2870,"Q_Id":5507531,"Users Score":2,"Answer":"You should really take a look at the code that Cython produces. To help with debugging, for example, it copies the complete Python source code into the generated file, marking each source line before generating C code for it. That makes it very easy to find the code section that you are interested in.\nA very nice feature is that you can compile your code with the \"-a\" (annotate) option, and it will spit out an HTML file next to the C file that contains the annotated Python code. When you click on a line, you'll see the C code for that line. As a bonus, it marks lines that do a lot of Python processing in dark yellow, so that you get a simple indicator where to look for potential optimisations.\nThere's also special gdb support in Cython now, so you can do Cython source level debugging etc.","Q_Score":7,"Tags":"python,c,reverse-engineering,cython","A_Id":5687219,"CreationDate":"2011-03-31T23:18:00.000","Title":"Reverse Engineer Auto-Generated 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},{"Question":"How easy is it to reverse engineer an auto-generated C code? I am working on a Python project and as part of my work, am using Cython to compile the code for speedup purposes.\nThis does help in terms of speed, yet, I am concerned that where I work, some people would try to \"peek\" into the code and figure out what it does.\nCython code is basically an auto-generated C. Is it very hard to reverse engineer it?\nAre there any recommendations that would make the code safer and reverse-engineering harder to do? (I assume that with enough effort, everything can be reversed engineered).","AnswerCount":3,"Available Count":3,"Score":0.1325487884,"is_accepted":false,"ViewCount":2870,"Q_Id":5507531,"Users Score":2,"Answer":"Ah, I guess I missed the bit that you were talking about the compiled module, whereas I was only referring to the source code that Cython generates. I agree with Jerry that it will be fairly tricky to extract something useful from the compiled module, as long as you keep the gdb support disabled (the default) and strip the debugging symbols. That is because the C compiler will do lots of inlining of helper functions all over the place and apply various low-level code optimisations, thus making it harder to extract the original macro level code patterns. However, you will see named C-API calls to CPython, and you will also see function names from your own code. Cython isn't specifically designed for code obfuscation, quite the opposite. But readable assembly has certainly never been a design goal.","Q_Score":7,"Tags":"python,c,reverse-engineering,cython","A_Id":5687328,"CreationDate":"2011-03-31T23:18:00.000","Title":"Reverse Engineer Auto-Generated 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},{"Question":"C++ has a set of functions, ffs(), ffsl(), and ffsll(), that return the least significant bit that is set in a given binary integer.\nI'm wondering if there is an equivalent function already available in Python. I don't see one described for bitarray, but perhaps there's another. I am hoping to avoid calculating the answer by looping through all possible bit masks, though of course that's an option of last resort; ffs() simply returns a single integer and I'd like to know of something comparable in Python.","AnswerCount":9,"Available Count":1,"Score":0.022218565,"is_accepted":false,"ViewCount":14720,"Q_Id":5520655,"Users Score":1,"Answer":"It's a little silly to try and aggressively optimize Python code, so a simple for loop with counter and right-shift should be fine. If you wanted to go faster (which would make more sense in C, Java, or Assembly) you could binary-search for the right-most 1-bit and even use lookup tables to help you.\nSuppose x is 64-bits and you want the LSB. Mask off the lower 32-bits. Assume x is nonzero:\n\nif x & 0xffffffff == 0:\n if x & 0xffff00000000 == 0:\n # the LSB is in the highest two bytes\n else:\n # the LSB is in the 5th or 6th byte\nelse:\n if x & 0xffff0000:\n # the LSB is in the 3rd or 4th byte\n else:\n # the LSB is in the 1st or 2nd byte\n\nHow you handle the commented section above depends on how aggressive you want to be: you could do further binary searching analogous to what we have, or you could use a lookup table. As it stands, we have 16-bits of uncertainty, so our table would be 65,536 entries. I have actually made tables like this for extremely performance-sensitive code, but that was a C program that played Chess (the 64-bit string there was a binary representation of the board).","Q_Score":16,"Tags":"python,bit-manipulation","A_Id":5520784,"CreationDate":"2011-04-02T02:10:00.000","Title":"return index of least significant bit 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},{"Question":"The question is quite clear, ... note however that I am NOT asking about a feature comparison (there are a lot of them already), nor am I asking about which one you prefer !\nI have myself a clear preference for doctests, I use them for everything, even if those are not to be used for documentation. But what I am wondering is : is there anything you can do with unitests that you cannot do with doctests ???","AnswerCount":4,"Available Count":4,"Score":0.0,"is_accepted":false,"ViewCount":370,"Q_Id":5522334,"Users Score":0,"Answer":"Some tests will need things like databases set up and initialised. \nThis could make doctests:\n\nvery verbose (and therefore not good\ndocumentation); and\nprobably inefficient because in doctests you would typically set \nup the database for each function or class. In comparison, \nunit tests more easily could use the\nsame database to test many functions\nor classes.","Q_Score":0,"Tags":"python,unit-testing,doctest","A_Id":5523349,"CreationDate":"2011-04-02T09:23:00.000","Title":"Python: Does 'unittest' have something that 'doctest' hasn't?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"The question is quite clear, ... note however that I am NOT asking about a feature comparison (there are a lot of them already), nor am I asking about which one you prefer !\nI have myself a clear preference for doctests, I use them for everything, even if those are not to be used for documentation. But what I am wondering is : is there anything you can do with unitests that you cannot do with doctests ???","AnswerCount":4,"Available Count":4,"Score":0.0,"is_accepted":false,"ViewCount":370,"Q_Id":5522334,"Users Score":0,"Answer":"Doctests are limited to per function (or per class) tests. You cannot do things like taking the output of one function and trying it with another etc. It's best used for \"example\" type tests (i.e. how do I use this function?)\nUnit tests can be larger and more involved than doctests.","Q_Score":0,"Tags":"python,unit-testing,doctest","A_Id":5522673,"CreationDate":"2011-04-02T09:23:00.000","Title":"Python: Does 'unittest' have something that 'doctest' hasn't?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"The question is quite clear, ... note however that I am NOT asking about a feature comparison (there are a lot of them already), nor am I asking about which one you prefer !\nI have myself a clear preference for doctests, I use them for everything, even if those are not to be used for documentation. But what I am wondering is : is there anything you can do with unitests that you cannot do with doctests ???","AnswerCount":4,"Available Count":4,"Score":1.0,"is_accepted":false,"ViewCount":370,"Q_Id":5522334,"Users Score":6,"Answer":"There is a widespread misconception that doctest is for testing your code. doctest is intended for testing your documentation. doctest is intended to test that your documentation matches what the function\/class\/module is actually doing, and alerts you if sample code in your documentation becomes obsolete as the module evolves.\nWhile doctest might reveal bugs in the code, it is not its primary purpose (e.g. like a change in code might unravel bugs in a unittest's testcase code, but testing the testcase code is not unitetest's primary purpose)\n\neven if those are not to be used for documentation\n\ndocstring are automatically extracted out by help() function to become documentation for your \nfunction\/class\/module; you cannot make a docstring not a documentation. Users of your module\/function\/class (or you in a few days) might try to do help() on your function\/class\/module and get a surprise that the documentation is a bunch of codes.","Q_Score":0,"Tags":"python,unit-testing,doctest","A_Id":5522962,"CreationDate":"2011-04-02T09:23:00.000","Title":"Python: Does 'unittest' have something that 'doctest' hasn't?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"The question is quite clear, ... note however that I am NOT asking about a feature comparison (there are a lot of them already), nor am I asking about which one you prefer !\nI have myself a clear preference for doctests, I use them for everything, even if those are not to be used for documentation. But what I am wondering is : is there anything you can do with unitests that you cannot do with doctests ???","AnswerCount":4,"Available Count":4,"Score":1.2,"is_accepted":true,"ViewCount":370,"Q_Id":5522334,"Users Score":3,"Answer":"There are some test scenarios doctests simply don't cover very well. That's OK since, as Lie pointed out, doctests aren't meant to be a comprehensive testing solution - they're meant to ensure that simple interactive-prompt style examples in your documentation (including docstrings) don't get out of date.\nWriting actual unit tests, on the other hand, allows you to unlimber the full power of Python in deciding how to compose your test suite (e.g. using inheritance to share not only test set up and tear down operations, but also actual test methods).\ndoctests may be a part of that, but they aren't a complete testing solution (except for small, relatively self-contained operations).\nIt's probably worth browsing Python's own test suite (the test package) and taking a look at some of the tests in there. While doctests play their part, most of it is written using unittest.","Q_Score":0,"Tags":"python,unit-testing,doctest","A_Id":5523855,"CreationDate":"2011-04-02T09:23:00.000","Title":"Python: Does 'unittest' have something that 'doctest' hasn't?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"What is the equivalent of template context in Pyramid?\nDoes the IBeforeRender event in pyramid have anything to with this? I've gone through the official documentation but diffcult to understand what the IBeforeRender event is exactly.","AnswerCount":6,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":2766,"Q_Id":5523546,"Users Score":2,"Answer":"It seems to me, that the solutions above do not exactly copy the behavior of Pylons template context. If one renders a page request in Pylons and adds some value a to the context c, it is accessible in the template as c.a. However, if one renders another request, this key\/value will be dropped.\nThe Pyramid solutions above show another behavior. the key\/value c.a will stay in the template context. Sometimes, this is not desired. Are there any suggestions to fix this difference?","Q_Score":14,"Tags":"python,pylons,pyramid","A_Id":8312263,"CreationDate":"2011-04-02T13:51:00.000","Title":"Equivalent of template context in Pyramid (pylons 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":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've got a python script that outputs unicode to the console, and I'd like to redirect it to a file. Apparently, the redirect process in python involves converting the output to a string, so I get errors about inability to decode unicode characters. \nSo then, is there any way to perform a redirect into a file encoded in UTF-8?","AnswerCount":4,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":7460,"Q_Id":5530708,"Users Score":14,"Answer":"Set the environment variable PYTHONIOENCODING to the encoding you want before redirecting a python script to a file. Then you won't have to modify the original script. Make sure to write Unicode strings as well, otherwise PYTHONIOENCODING will have no effect. If you write byte strings, the bytes are sent as-is to the terminal (or redirected file).","Q_Score":30,"Tags":"python,unicode,console","A_Id":5531730,"CreationDate":"2011-04-03T16:02:00.000","Title":"Can I redirect unicode output from the console directly into 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},{"Question":"Suppose I'd like to run a python script like this: python my_script.py MY_INPUT.\nIn this case, MY_INPUT will be transmitted to sys.argv[1].\nIs there a limit to the number of characters MY_INPUT can contain? \nIs there a limit to the type of characters MY_INPUT can contain? \nAny other limitations with regards to MY_INPUT?\nUPDATE: I am using Ubuntu Linux 10.04","AnswerCount":2,"Available Count":1,"Score":0.2913126125,"is_accepted":false,"ViewCount":11527,"Q_Id":5533704,"Users Score":3,"Answer":"Python itself doesn't impose any limitations on the length or content of sys.argv. However, your operating system and\/or command shell definitely will. This question cannot be completely answered without detailed consideration of your operating environment.","Q_Score":13,"Tags":"python","A_Id":5533719,"CreationDate":"2011-04-04T01:18:00.000","Title":"python sys.argv limitations?","Data Science and Machine Learning":0,"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},{"Question":"Say we have project that requires web scraping. (parsing strings (< 40) and scraping web pages (geting meta datas and such)\nI am aware of that perl has great and suited cpan modules for this job, so i can take that way and don't bother myself that much. But i don't have a clue about speed and memory related stuff.\nSo, which would you choose? (May be Python??) And in terms of speed which one is better for this job? Explain please...\nThanks in advance.","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":2213,"Q_Id":5538386,"Users Score":1,"Answer":"I would go with perl... I haired a rumor that was the language that google used initially... Python is a good performance language as well.","Q_Score":4,"Tags":"php,python,perl,performance,web-scraping","A_Id":5538463,"CreationDate":"2011-04-04T12:24:00.000","Title":"Perl vs PHP to web scraping","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"How does boost.python deal with Python 3? Is it Python 2 only?","AnswerCount":8,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":44365,"Q_Id":5539557,"Users Score":0,"Answer":"In my case adding \"Using Python : 3 etc.\" into user-config.jam in my home directory didn't work. I had to add the line into project-config.jam instead, which resides in the root directory of unpacked boost.\nSpecifically the line was:\nusing python : 3.9 : \/usr\/bin\/python3 : \/usr\/include\/python3.9 : \/usr\/lib ;\nand the version of boost was 1_78_0","Q_Score":30,"Tags":"c++,python,boost,python-3.x,boost-python","A_Id":71157876,"CreationDate":"2011-04-04T13:58:00.000","Title":"Boost 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":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am a great python fan. Recently I got an idea to write RTS engine and\/or maybe a simple RTS game based upon this engine. There are a couple of things I need to think about and maybe you can give me some advice on these:\n\nPerformance. Most games are written in C++. Isn't python too slow for game engine? I am aiming only at 2D, but still it may be too demnading.\nGraphics. Are there any good graphics libraries for python? SDL\/OpenGL bindings or maybe something more suitable for python?\nGame engines. Do you know of any existing RTS engine written in python?\nAny tools\/libraries for python that maybe helpful in developing RTS\n\nThanks in advance!","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":2553,"Q_Id":5544634,"Users Score":7,"Answer":"Performance may be an issue with heavy graphics\/math processing. If so, see Panda3D, NumPy, Cython, and PyPy.\nUse Pyglet, PyOpenGL with Pyglet, Panda3D (although you are writing in 2D, you can still use a 3D engine), or perhaps some other library.\nThere don't seem to be existing RTS libraries, but there are definitely pre-existing generalized engines.\nTry searching for RTS-related libraries in general: you'll need AI, pathfinding, networking, and so on. Therefore, you may be interested in Twisted, for instance, since it helps with networking.","Q_Score":3,"Tags":"python,performance,graphics,real-time-strategy","A_Id":5544725,"CreationDate":"2011-04-04T21:36:00.000","Title":"2D RTS in 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":0,"Web Development":0},{"Question":"I am a great python fan. Recently I got an idea to write RTS engine and\/or maybe a simple RTS game based upon this engine. There are a couple of things I need to think about and maybe you can give me some advice on these:\n\nPerformance. Most games are written in C++. Isn't python too slow for game engine? I am aiming only at 2D, but still it may be too demnading.\nGraphics. Are there any good graphics libraries for python? SDL\/OpenGL bindings or maybe something more suitable for python?\nGame engines. Do you know of any existing RTS engine written in python?\nAny tools\/libraries for python that maybe helpful in developing RTS\n\nThanks in advance!","AnswerCount":2,"Available Count":2,"Score":0.2913126125,"is_accepted":false,"ViewCount":2553,"Q_Id":5544634,"Users Score":3,"Answer":"I can answer your first two.\n\nPython isn't too slow for games. That all games must be written in C++ is a myth. Sure C++ (or C) might give you the best performance, but it doesn't mean you're unable to write a game in another language.\nTry PyGame: SDL bindings for Python.","Q_Score":3,"Tags":"python,performance,graphics,real-time-strategy","A_Id":5544672,"CreationDate":"2011-04-04T21:36:00.000","Title":"2D RTS in 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":0,"Web Development":0},{"Question":"How can I ignore .pyc files in git?\nIf I put it in .gitignore it doesn't work. I need them to be untracked and not checked for commits.","AnswerCount":7,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":164905,"Q_Id":5551269,"Users Score":0,"Answer":"if you have committed in the repo, just\n\ngo to the folder \/__pycache__,\ndelete all of them (no worries, they are temporary files and generated repeatedly)\nhave a new commit, such as 'update gitignore'\nyou are done! .pyc will not appear again.","Q_Score":137,"Tags":"python,git","A_Id":67986868,"CreationDate":"2011-04-05T11:45:00.000","Title":"Ignore .pyc files in git 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},{"Question":"How can I ignore .pyc files in git?\nIf I put it in .gitignore it doesn't work. I need them to be untracked and not checked for commits.","AnswerCount":7,"Available Count":2,"Score":1.0,"is_accepted":false,"ViewCount":164905,"Q_Id":5551269,"Users Score":94,"Answer":"You have probably added them to the repository before putting *.pyc in .gitignore.\nFirst remove them from the repository.","Q_Score":137,"Tags":"python,git","A_Id":5551629,"CreationDate":"2011-04-05T11:45:00.000","Title":"Ignore .pyc files in git 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},{"Question":"I have a Python command line script that connects to a database, generates files from the data and sends e-mails. I already have some unit-tests for the important components. Now I'd like to do tests that use several or all components together, load the test database with sample data and check for the correct output. \nAre there Python libraries that support this kind of testing? Specifically, I'm looking for easy ways to \n\nput sample data in the database\ncheck for specific changes in the database\ncheck for existence and content of specific files\n\nShould I even do these tests in Python or should I just write a bunch of shell scripts?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":522,"Q_Id":5554429,"Users Score":1,"Answer":"Yes. The unittest libraries can be used for this. \nDon't be fooled by the name. A \"unit\" is not always a single, standalone class (or function).\nA \"unit\" can be a composite \"unit\" of one or more classes or modules or packages.","Q_Score":0,"Tags":"python,shell,integration-testing","A_Id":5554478,"CreationDate":"2011-04-05T15:33:00.000","Title":"How to do integration tests for 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":0},{"Question":"I very like the \"battery included\" philosophy of Python but now I have to perform a slim installation with only core features and some other which I'd like to choose one by one.\nIs it possible to download Python with only selected modules?","AnswerCount":5,"Available Count":1,"Score":0.0399786803,"is_accepted":false,"ViewCount":287,"Q_Id":5569652,"Users Score":1,"Answer":"AFAIK it's not possible to download Python with only selected modules, but after an install you can remove everything (read: the libraries) you don't need (never going to use JSON? Gone!, etc).","Q_Score":5,"Tags":"python,distribution","A_Id":5569750,"CreationDate":"2011-04-06T16:13:00.000","Title":"Get Python without (selected) batteries","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"For the work I am currently doing I need similar functionality as Bittorrent, only difference is I need to do some sort of extra analysis on every block received by client from peers. Though I am fairly new with Python, I found official Bittorrent client source code easy to understand (as compared to Transmission's C source code). But I can't seem to figure out the part in the source code where it deals\/handles every block received.\nIt'd be great if anyone, who is acquainted with Bittorrent official client source code (or Transmission), can provide me some pointers for the same.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":168,"Q_Id":5579047,"Users Score":0,"Answer":"For Transmission, try looking at libtransmission\/peer-mgr.c for code specific to each type of message received from a particular peer. This file represents the peer manager and all communication with it.\nIt uses libtransmission\/peer-msgs.c for handling the exact messages.","Q_Score":2,"Tags":"python,c,bittorrent","A_Id":5582728,"CreationDate":"2011-04-07T09:42:00.000","Title":"Block handling in bittorent","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},{"Question":"I've been coding php for years, and now i have to finally make my own project, and i want it very optimized and shiny. So, i've been searching around the net about which programming language should i use for my needs (fast, secure, easy-understandable, customizable) and all points to -> Python. So I decided to go on, but i just can't feel \"home\" when writing python (inc Django app...). I got used to PHP's syntax, and my IDE (PHP Expert Editor 4.3) makes php look awesome, so now i just can't go with python.\nMaybe there is something which has php's syntax (let's say per example: Perl)...but the advantages of a high-level programming language (aka Python)?","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":155,"Q_Id":5582450,"Users Score":1,"Answer":"If you've been coding in PHP for years, then maybe PHP is still the right choice for you? As long as your project is related to web (by the way Facebook uses PHP!) you should stick to it. \nPython is really easy and fun to learn, but as any other programming language - it requires time to get into it. And for web projects, you'll have to catch up with frameworks and maybe servers (e.g. tornado).\nIf you'd like to do something on enterprise level, Java is also a good choice. But never as easy and as fun as Python :)","Q_Score":2,"Tags":"php,python","A_Id":5582849,"CreationDate":"2011-04-07T14:08:00.000","Title":"From PHP to Python accommodation","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I've been coding php for years, and now i have to finally make my own project, and i want it very optimized and shiny. So, i've been searching around the net about which programming language should i use for my needs (fast, secure, easy-understandable, customizable) and all points to -> Python. So I decided to go on, but i just can't feel \"home\" when writing python (inc Django app...). I got used to PHP's syntax, and my IDE (PHP Expert Editor 4.3) makes php look awesome, so now i just can't go with python.\nMaybe there is something which has php's syntax (let's say per example: Perl)...but the advantages of a high-level programming language (aka Python)?","AnswerCount":3,"Available Count":2,"Score":0.1325487884,"is_accepted":false,"ViewCount":155,"Q_Id":5582450,"Users Score":2,"Answer":"This line of work requires you to adjust to different syntaxes (even in PHP alone you need to know sql and js and Css and html too...).\nSo the answer is no, there is nothing like what you ask, and you better get used to that :-)\nb.t.w is Python really faster than PHP?","Q_Score":2,"Tags":"php,python","A_Id":5582510,"CreationDate":"2011-04-07T14:08:00.000","Title":"From PHP to Python accommodation","Data Science and Machine Learning":0,"Database and SQL":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},{"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},{"Question":"I'm trying to use distutils with a Python module that contains extensions written in C. The program code is housed on a Linux server, but I sometimes upload changes from a Windows machine using the file transfer program WinSCP (editing is done in Notepad++). I've noticed that distutils often does not notice these changes in the C code (i.e. python setup.py build does not trigger gcc if the code was previously compiled). A check of the C source code on the server shows that it really has been updated correctly. On the other hand, changing the code directly on the server using a text editor like vim always causes python setup.py build to recompile the changed files. Any idea why uploading changed files might not cause distutils to recompile them?\nThanks.\nEDIT:\nAfter investigating this further I am noticing the same problem if I just create a plain C program with a Makefile. Thus this problem does not look like it is a distutils problem.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":938,"Q_Id":5599414,"Users Score":0,"Answer":"Looking into the source for distutils and seeing how it enforces rebuilds it looks like it checks timestamps of files to determine whether a file is out of date or not.\nCan you make sure the timestamp is changing when winscp is uploading the file? Otherwise it looks like the build command has a \"force\" option that forces a rebuild no matter what.","Q_Score":0,"Tags":"python,distutils","A_Id":5599557,"CreationDate":"2011-04-08T18:39:00.000","Title":"distutils does not recompile C extension 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":1,"Web Development":0},{"Question":"I'm probably doing something really dumb here, but it's driving me crazy.\nI have two PyDev projects in Eclipse. One project, 'Analysis' depends on the other, 'PyCommon'. I'm 100% sure of this as when I look at the project references for Analysis, PyCommon is checked, and automatic import\/code completion works when I reference elements in PyCommon from Analysis.\nI'm trying to write\/run a module in Analysis. The module is fhb\/analysis\/log_parsers.py.\nI'm trying to import the element OrderStatus from fhb\/pycommon\/types\/order_status in the PyCommon project. So, my import statement is \n'from fhb.pycommon.types.order_status import OrderStatus'\nPyDev clearly knows where this is because that import statement was written automatically by PyDev on a quickfix correction. Nonetheless, when I try to run the main function in log_parsers.py, I get this:\n\nTraceback (most recent call last):\n File \"\/workspace\/Analysis\/src\/fhb\/analysis\/log_parsers.py\", line 6, in \n from fhb.pycommon.types.order_type import OrderType\n ImportError: No module named pycommon.types.order_status\n\nAll of these packages are under a proper source folder ('src') in each project.\nAlso, even though Analysis absolutely is set to reference PyCommon , when I look under PyDev-PYTHONPATH in Analysis's properties, only Analysis's own src folder appears under the 'Source Folder' tab, and it's the only project I see if I click on 'Add source folder'","AnswerCount":4,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":5179,"Q_Id":5601566,"Users Score":0,"Answer":"I believe you have to add the path of PyCommon into PYTHONPATH or else it won't be able to find the actual modules to import.","Q_Score":9,"Tags":"python,module,import,dependencies,pydev","A_Id":5637508,"CreationDate":"2011-04-08T22:51:00.000","Title":"Can't import module from dependent project in 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":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm probably doing something really dumb here, but it's driving me crazy.\nI have two PyDev projects in Eclipse. One project, 'Analysis' depends on the other, 'PyCommon'. I'm 100% sure of this as when I look at the project references for Analysis, PyCommon is checked, and automatic import\/code completion works when I reference elements in PyCommon from Analysis.\nI'm trying to write\/run a module in Analysis. The module is fhb\/analysis\/log_parsers.py.\nI'm trying to import the element OrderStatus from fhb\/pycommon\/types\/order_status in the PyCommon project. So, my import statement is \n'from fhb.pycommon.types.order_status import OrderStatus'\nPyDev clearly knows where this is because that import statement was written automatically by PyDev on a quickfix correction. Nonetheless, when I try to run the main function in log_parsers.py, I get this:\n\nTraceback (most recent call last):\n File \"\/workspace\/Analysis\/src\/fhb\/analysis\/log_parsers.py\", line 6, in \n from fhb.pycommon.types.order_type import OrderType\n ImportError: No module named pycommon.types.order_status\n\nAll of these packages are under a proper source folder ('src') in each project.\nAlso, even though Analysis absolutely is set to reference PyCommon , when I look under PyDev-PYTHONPATH in Analysis's properties, only Analysis's own src folder appears under the 'Source Folder' tab, and it's the only project I see if I click on 'Add source folder'","AnswerCount":4,"Available Count":3,"Score":0.0996679946,"is_accepted":false,"ViewCount":5179,"Q_Id":5601566,"Users Score":2,"Answer":"I think pydev is having trouble with similar package names near the root of the package name \"fhb\". I'm having the same problem. Removing the packages in one of the projects let me reference the other one without a problem. \nI couldn't solve the problem, but I think it has to do with the root folder of the package being the same.","Q_Score":9,"Tags":"python,module,import,dependencies,pydev","A_Id":16126724,"CreationDate":"2011-04-08T22:51:00.000","Title":"Can't import module from dependent project in 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":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm probably doing something really dumb here, but it's driving me crazy.\nI have two PyDev projects in Eclipse. One project, 'Analysis' depends on the other, 'PyCommon'. I'm 100% sure of this as when I look at the project references for Analysis, PyCommon is checked, and automatic import\/code completion works when I reference elements in PyCommon from Analysis.\nI'm trying to write\/run a module in Analysis. The module is fhb\/analysis\/log_parsers.py.\nI'm trying to import the element OrderStatus from fhb\/pycommon\/types\/order_status in the PyCommon project. So, my import statement is \n'from fhb.pycommon.types.order_status import OrderStatus'\nPyDev clearly knows where this is because that import statement was written automatically by PyDev on a quickfix correction. Nonetheless, when I try to run the main function in log_parsers.py, I get this:\n\nTraceback (most recent call last):\n File \"\/workspace\/Analysis\/src\/fhb\/analysis\/log_parsers.py\", line 6, in \n from fhb.pycommon.types.order_type import OrderType\n ImportError: No module named pycommon.types.order_status\n\nAll of these packages are under a proper source folder ('src') in each project.\nAlso, even though Analysis absolutely is set to reference PyCommon , when I look under PyDev-PYTHONPATH in Analysis's properties, only Analysis's own src folder appears under the 'Source Folder' tab, and it's the only project I see if I click on 'Add source folder'","AnswerCount":4,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":5179,"Q_Id":5601566,"Users Score":0,"Answer":"Your problem may come from __init__.py being missing from some of your module folders. \nFor your example, for using OrderStatus from order_status.py in fhb.pycommon.types.order_status, you need to have a (possibly empty) __init__.py file in fhb, fhb\/pycommon, and fhb\/pycommon\/types.\nAlso note that for pylint to work correctly for fhb\/analysis\/log_parsers.py, you need to have an __init__.py in fhb\/analysis as well.","Q_Score":9,"Tags":"python,module,import,dependencies,pydev","A_Id":24829182,"CreationDate":"2011-04-08T22:51:00.000","Title":"Can't import module from dependent project in 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":1,"System Administration and DevOps":0,"Web Development":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},{"Question":"I would need to run a python script for some random amount of time, pause it, get a stack traceback, and unpause it. I've googled around for a way to do this, but I see no obvious solution.","AnswerCount":8,"Available Count":1,"Score":0.049958375,"is_accepted":false,"ViewCount":3341,"Q_Id":5616446,"Users Score":2,"Answer":"To implement an external statistical profiler for Python, you're going to need some general debugging tools that let you interrogate another process, as well as some Python specific tools to get a hold of the interpreter state.\nThat's not an easy problem in general, but you may want to try starting with GDB 7 and the associated CPython analysis tools.","Q_Score":18,"Tags":"python,profile,stochastic","A_Id":5616811,"CreationDate":"2011-04-11T03:15:00.000","Title":"Is there a statistical profiler for python? If not, how could I go about writing 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":0},{"Question":"One can send messages to an AT&T customer via [10-digit-cell-numer]@txt.att.net from their email client. I tried to send a file to my iPhone using this method (specifically an audio file) to no avail. The message came through but the file attachment was not present.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1545,"Q_Id":5628715,"Users Score":2,"Answer":"It seems you can send MMS messages to @mms.att.net\nThat was easy.","Q_Score":1,"Tags":"python,email,scripting,mms","A_Id":5628773,"CreationDate":"2011-04-11T23:25:00.000","Title":"Sending file via email to MMS for ATT","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I would like to access R from within a Python program. I am aware of Rpy2, pyrserve and PypeR.\nWhat are the advantages or disadvantages of these three options?","AnswerCount":4,"Available Count":3,"Score":0.2449186624,"is_accepted":false,"ViewCount":18829,"Q_Id":5630441,"Users Score":5,"Answer":"in pyper, i can't pass large matrix from python to r instance with assign(). however, i don't have issue with rpy2. \nit is just my experience.","Q_Score":63,"Tags":"python,r,rpy2,pyrserve,pyper","A_Id":13636318,"CreationDate":"2011-04-12T04:32:00.000","Title":"How do Rpy2, pyrserve and PypeR 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":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I would like to access R from within a Python program. I am aware of Rpy2, pyrserve and PypeR.\nWhat are the advantages or disadvantages of these three options?","AnswerCount":4,"Available Count":3,"Score":0.2449186624,"is_accepted":false,"ViewCount":18829,"Q_Id":5630441,"Users Score":5,"Answer":"From a developer's prospective, we used to use rpy\/rpy2 to provide statistical and drawing functions to our Python-based application. It has caused huge problems in delivering our application because rpy\/rpy2 needs to be compiled for specific combinations of Python and R, which makes it infeasible for us to provide binary distributions that work out of box unless we bundle R as well. Because rpy\/rpy2 are not particularly easy to install, we ended up replacing relevant parts with native Python modules such as matplotlib. We would have switched to pyrserve if we had to use R because we could start a R server locally and connect to it without worrying about the version of R.","Q_Score":63,"Tags":"python,r,rpy2,pyrserve,pyper","A_Id":28990370,"CreationDate":"2011-04-12T04:32:00.000","Title":"How do Rpy2, pyrserve and PypeR 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":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I would like to access R from within a Python program. I am aware of Rpy2, pyrserve and PypeR.\nWhat are the advantages or disadvantages of these three options?","AnswerCount":4,"Available Count":3,"Score":1.2,"is_accepted":true,"ViewCount":18829,"Q_Id":5630441,"Users Score":40,"Answer":"I know one of the 3 better than the others, but in the order given in the question:\nrpy2: \n\nC-level interface between Python and R (R running as an embedded process)\nR objects exposed to Python without the need to copy the data over\nConversely, Python's numpy arrays can be exposed to R without making a copy\nLow-level interface (close to the R C-API) and high-level interface (for convenience)\nIn-place modification for vectors and arrays possible\nR callback functions can be implemented in Python\nPossible to have anonymous R objects with a Python label\nPython pickling possible\nFull customization of R's behavior with its console (so possible to implement a full R GUI)\nMSWindows with limited support\n\npyrserve:\n\nnative Python code (will\/should\/may work with CPython, Jython, IronPython)\nuse R's Rserve\nadvantages and inconveniences linked to remote computation and to RServe\n\npyper:\n\nnative Python code (will\/should\/may work with CPython, Jython, IronPython) \nuse of pipes to have Python communicate with R (with the advantages and inconveniences linked to it)\n\nedit: Windows support for rpy2","Q_Score":63,"Tags":"python,r,rpy2,pyrserve,pyper","A_Id":5643423,"CreationDate":"2011-04-12T04:32:00.000","Title":"How do Rpy2, pyrserve and PypeR 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":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have an Android appthat originally posted some strings in json format to a python cgi script, which all worked fine. The problem is when the json object contains lists, then python (Using simplejson) when it gets them is still treating them as a big string\nHere is a text dump of the json once it reaches python before I parse it:\n{\"Prob1\":\"[1, 2, 3]\",\"Name\":\"aaa\",\"action\":1,\"Prob2\":\"[20, 20, 20]\",\"Tasks\":\"[1 task, 2 task, 3 task]\",\"Description\":\"\"}\nif we look at the \"Tasks\" key, the list after is clearly a single string with the elements all treated as one string (i.e. no quotes around each element). it's the same for prob1 and prob2. action, Name etc are all fine. I'm not sure if this is what python is expecting but I'm guessing not?\nJust in case the android data was to blame i added quotes around each element of the arraylist like this:\nTasks.add('\"'+row.get(1).toString()+'\"'); instead of Tasks.add(row.get(1).toString());\nOn the webserver it's now received as\n{\"Prob1\":\"[1, 2, 3]\",\"Name\":\"aaa\",\"action\":1,\"Prob2\":\"[20, 20, 20]\",\"Tasks\":\"[\\\"1 task\\\", \\\"2 task\\\", \\\"3 task\\\"]\",\"Description\":\"\"}\nbut i still get the same problem; when i iterate through \"Tasks\" in a loop it's looping through each individual character as if the whole thing were a string :\/\nSince I don't know what the json structure should look like before it gets to Python I'm wondering whether it's a probem with the Android sending the data or my python interpreting it.. though from the looks of that script I've been guessing it's been the sending.\nIn the Android App I'm sending one big JSONObject containing \"Tasks\" and the associated arraylist as one of the key value pairs... is this correct? or should JSONArray be involved anywhere?\nThanks for any help everyone, I'm new to the whole JSON thing as well as to Android\/Java (And only really a novice at Python too..). I can post additional code if anyone needs it, I just didn't want to lengthen the post too much\nEDIT:\nwhen I add\njson_data=json_data.replace(r'\"[','[')\n json_data=json_data.replace(r']\"',']')\n json_data=json_data.replace(r'\\\"','\"')\nto the python it WORKS!!!! but that strikes me as a bit nasty and just papering over a crack..","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":439,"Q_Id":5630870,"Users Score":1,"Answer":"Tasks is just a big string. To be a valid list, it would have to be [\"1 task\", \"2 task\", \"3 task\"]\n\nSame goes for Prob1 and Prob2. To be a valid list, the brackets should not be enclosed in quotes.","Q_Score":0,"Tags":"python,android,json","A_Id":5630896,"CreationDate":"2011-04-12T05:41:00.000","Title":"Python grabbing JSON from POST method","Data Science and Machine Learning":0,"Database and SQL":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},{"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},{"Question":"I'm venturing in unknown territory here... \nI am trying to work out how hard it could be to implement an Email client using Python:\n\nEmail retrieval \nEmail sending\nEmail formatting\nEmail rendering\n\nAlso I'm wondering if all protocols are easy\/hard to support e.g. SMTP, IMAP, POP3, ...\n\nHopefully someone could point me in the right direction :)","AnswerCount":4,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":40032,"Q_Id":5647487,"Users Score":2,"Answer":"If I were you, I'd check out the source code of existing email-clients to get an idea: thunderbird, sylpheed-claws, mutt...\nDepending on the set of features you want to support, it is a big project.","Q_Score":23,"Tags":"python,email,smtp,imap,email-client","A_Id":5647584,"CreationDate":"2011-04-13T10:08:00.000","Title":"How hard is it to build an Email client? - 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},{"Question":"I'm venturing in unknown territory here... \nI am trying to work out how hard it could be to implement an Email client using Python:\n\nEmail retrieval \nEmail sending\nEmail formatting\nEmail rendering\n\nAlso I'm wondering if all protocols are easy\/hard to support e.g. SMTP, IMAP, POP3, ...\n\nHopefully someone could point me in the right direction :)","AnswerCount":4,"Available Count":2,"Score":1.0,"is_accepted":false,"ViewCount":40032,"Q_Id":5647487,"Users Score":8,"Answer":"I think you will find much of the clients important parts prepackaged:\nEmail retrieval - I think that is covered by many of the Python libraries.\nEmail sending - This would not be hard and it is most likely covered as well.\nEmail formatting - I know this is covered because I just used it to parse single and multipart emails for a client.\nEmail rendering - I would shoot for an HTML renderer of some sort. There is a Python interface to the renderer from the Mozilla project. I would guess there are other rendering engines that have python interfaces as well. I know wxWidgets has some simple HTML facilities and would be a lot lighter weight. Come to think about it the Mozilla engine may have a bunch of the other functions you would need as well. You would have to research each of the parts.\nThere is lot more to it than what is listed above. Like anything worth while it won't be built in a day. I would lay out precisely what you want it to do. Then start putting together a prototype. Just build a simple framework that does basic things. Like only have it support the text part of a message with no html. Then build on that.\nI am amazed at the wealth of coding modules available with Python. I needed to filter html email messages, parse stylesheets, embed styles, and whole host of other things. I found just about every function I needed in a Python library somewhere. I was especially happy when I found out that some css sheets are gzipped that there was a module for that!\nSo if you are serious about then dig in. You will learn a LOT. :)","Q_Score":23,"Tags":"python,email,smtp,imap,email-client","A_Id":6868304,"CreationDate":"2011-04-13T10:08:00.000","Title":"How hard is it to build an Email client? - 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},{"Question":"I am working on a realtime data website that has a data-mining backend side to it. I am highly experienced in both Python and C++\/C#, and wondering which one would be preferable for the backend development.\nI am strongly leaning towards Python for its available libraries and ease of use. But am I wrong? If so, why?\nAs I side question, would you recommend using SQLAlchemy? Are there any drawback to it (performance is crucial) compared to _mysql or MySQLdb? \nThanks!","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":1302,"Q_Id":5658529,"Users Score":1,"Answer":"We do backend development based on Zope, Python and other Python-related stuff since almost 15 years. Python gives you great flexibility and all-batteries included (likely true for C#, not sure about C++).\nIf you do RDBMS development with Python: SQLAlchemy is the way to go. It provides a huge functionality and saved my a** over the last years a couple of times...Sqlalchemy can be complex and complicated but the advantages is that you can hide a complex database schema behind an OO facade..very handy like any ORM in general. \n_mysql vs MySQLdb...I only know of the python-mysql package.","Q_Score":1,"Tags":"c#,c++,python,backend","A_Id":5658631,"CreationDate":"2011-04-14T04:27:00.000","Title":"Designing a Website Backend - Python or C++\/C#?","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},{"Question":"I'm currently creating a website using PHP and the Kohana framework. I want to site to be able to use real time (or near real time) data (e.g. for chat and real time feeds). I need it to be able to scale to thousands of concurrent users. I've done a lot of reading and still have no idea what the best method is for this.\nDoes anyone have any experience with StreamHub? Is it possible to use this with PHP?\nAm I digging myself into a hole here and need to switch languages? I've looked at node js and nowjs, but I'm weary about coding a while site in Express (I wonder about security holes, code maintainability, lack of a good ORM). I've read about Twisted Python, but have no idea what web framework would work well on top of that, and I'd prefer not to use Nevow - maybe Django can be used well with Twisted Python? I'm just looking to be pointed in the right direction, so I don't go too far in PHP and realize I can't get the near real-time results that I need.\nThanks for the help.","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":1845,"Q_Id":5664225,"Users Score":2,"Answer":"I've looked at node js and nowjs, but\n I'm weary about coding a while site in\n Express (I wonder about security\n holes, code maintainability, lack of a\n good ORM).\n\nI can personally vouch for code maintainability if you can do JavaScript. I personally find JavaScript more maintainable then PHP but that's probably due to lack of PHP experience.\nORM is not an issue as node.js favours document based databases. Document based databases and JSON go hand in hand, I find couch db and it's map\/reduce system easy to use and it feels natural with json.\nIn terms of security holes, yes a node.js server is young and there may be holes. These are un avoidable. There are currently no known exploits and I would say it's not much more vulnerable \nthen IIS\/apache\/nginx until someone points a big flaw.\n\nI want to site to be able to use real\n time (or near real time) data (e.g.\n for chat and real time feeds). I need\n it to be able to scale to thousands of\n concurrent users.\n\nScalability like that requires non-blocking IO. This requires a non-blocking IO server likes nginx or node.js (Yes blocking IO could work but you need so much more hardware).\nPersonally I would advice using node.js over PHP as it's easier to write non blocking IO in node. You can do it in PHP but you have to make all the right design and architecture decisions. I doubt there are any truly async non-blocking PHP frameworks.\nPython's twisted \/ Ruby's EventMachine together with nginx, can work but I have no expertise with those. At least with node you can't accidentally call a blocking library or make use of the native blocking libraries since JavaScript has no native IO.","Q_Score":3,"Tags":"php,python,node.js,real-time","A_Id":5664340,"CreationDate":"2011-04-14T13:46:00.000","Title":"Creating a real time website using 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":1},{"Question":"I've been searching for an IDE with code completion (intellisence) for IronPython on Linux systems (typically Ubuntu).\nI've found references to MonoDevelop and Eclipse (PyDev) supporting IronPython, but I can't get any of them to work.\nIs this because MonoDevelop and PyDev only support IronPython code completion on Windows? Are there any installation guides that I could follow to make these IDEs work on Ubuntu \/ Linux.\nMany thanks for your help,\nChris","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":2128,"Q_Id":5664513,"Users Score":1,"Answer":"I don't know about Eclipse, but there isn't currently an IronPython addin for MonoDevelop. If anyone's interested in developing one, please contact the MonoDevelop mailing list for advice on getting started.","Q_Score":2,"Tags":"linux,ide,ironpython,monodevelop,pydev","A_Id":5667841,"CreationDate":"2011-04-14T14:08:00.000","Title":"IronPython IDE for Ubuntu and 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},{"Question":"I've been searching for an IDE with code completion (intellisence) for IronPython on Linux systems (typically Ubuntu).\nI've found references to MonoDevelop and Eclipse (PyDev) supporting IronPython, but I can't get any of them to work.\nIs this because MonoDevelop and PyDev only support IronPython code completion on Windows? Are there any installation guides that I could follow to make these IDEs work on Ubuntu \/ Linux.\nMany thanks for your help,\nChris","AnswerCount":3,"Available Count":2,"Score":0.1325487884,"is_accepted":false,"ViewCount":2128,"Q_Id":5664513,"Users Score":2,"Answer":"Try JetBrains PyCharm","Q_Score":2,"Tags":"linux,ide,ironpython,monodevelop,pydev","A_Id":5883279,"CreationDate":"2011-04-14T14:08:00.000","Title":"IronPython IDE for Ubuntu and 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},{"Question":"I am trying to load a *.pyd with Python, but I receive the well known \"Import Error: DLL load failed: the specified procedure can not be found.\" error.\nI have already done the following:\n1.) Investigated the *.pyd with Dependency Walker. GPSVC.DLL and IESHIMS.DLL came up as missing, but delay loaded, IEFRAME.DLL aslo came up as missing an export, but was also delay-loaded. It's my understanding that these are not used, and are delay load anyway, so they should not be the problem.\n2.) Did an \"import foo\" on foo.pyd in the python command window, with ProcMon watching. ProcMon shows event \"LoadImage\" on \"foo.pyd\" with result SUCCESS.\nThis seems to imply that the *.pyd file loaded correctly.\nSo what am I missing. My windows diagnostics are telling me all is well, but python is telling me the thing cannot be loaded (usually due to a missing dll or symbol).\nIdeas?\nThanks!","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":9402,"Q_Id":5667556,"Users Score":1,"Answer":"Ok here is the answer: \nThe windows diagnostics (depends, procmon, etc) were showing the DLL (or pyd) loading fine.\nPython was showing that it was not loading fine.\nI found that the windows tools were referring to a different Python26.dll hiding in my C:\\Window\\SysWOW64 folder.\nThis second Python26.dll (found in SysWOW64) has a symbol that is missing in the primary python26.dll (installed by the windows python installer, found in C:\\Python26).\nThis symbol \"_PyByteArray_empty_string\", was apparently needed by my *.pyd file. \nSo when loading via windows diagnostics, the SysWOW64 dll was found, and the *.pyd loaded properly. When loading from python, the dll in C:\\Python26\\ was found, the symbol was missing, and load failed.\nSo that is WHY the problem manifested. The question now is: Why are there two versions of Python26.dll floating around, one with _PyByteArray_empty_string, and one without?\nI'm using Python 2.6.6. Perhaps this symbol is removed in 2.6.6 but present in some older 2.6.x release?","Q_Score":5,"Tags":"python,dll,procmon,pyd","A_Id":5687105,"CreationDate":"2011-04-14T18:05:00.000","Title":"*.pyd file fails to load, but DependancyWalker comes up clean, and ProcMon shows it loaded","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I am trying to load a *.pyd with Python, but I receive the well known \"Import Error: DLL load failed: the specified procedure can not be found.\" error.\nI have already done the following:\n1.) Investigated the *.pyd with Dependency Walker. GPSVC.DLL and IESHIMS.DLL came up as missing, but delay loaded, IEFRAME.DLL aslo came up as missing an export, but was also delay-loaded. It's my understanding that these are not used, and are delay load anyway, so they should not be the problem.\n2.) Did an \"import foo\" on foo.pyd in the python command window, with ProcMon watching. ProcMon shows event \"LoadImage\" on \"foo.pyd\" with result SUCCESS.\nThis seems to imply that the *.pyd file loaded correctly.\nSo what am I missing. My windows diagnostics are telling me all is well, but python is telling me the thing cannot be loaded (usually due to a missing dll or symbol).\nIdeas?\nThanks!","AnswerCount":3,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":9402,"Q_Id":5667556,"Users Score":5,"Answer":"Is the .pyd file for the same version of Python you're using? Loading a .pyd file for the wrong Python version can produce that error message.\nDependency Walker can show you which pythonNN.dll it links to.","Q_Score":5,"Tags":"python,dll,procmon,pyd","A_Id":5669041,"CreationDate":"2011-04-14T18:05:00.000","Title":"*.pyd file fails to load, but DependancyWalker comes up clean, and ProcMon shows it loaded","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I hi have just ordered a couple of beaglboards for experimenting. I know that it can rub Ubuntu and many other flavors of linux. \nDoes that mean it can run all the trivial software that run on Ubuntu? \nWill the python and ruby interpreters work just the way they work on PC ?","AnswerCount":4,"Available Count":3,"Score":0.049958375,"is_accepted":false,"ViewCount":3513,"Q_Id":5669785,"Users Score":1,"Answer":"The interpreters do not need to be compiled from source, as the Ubuntu arm distribution has python in its repository as a deb. I was able to write my python scripts on my Ubuntu box and transfer them to the beagleboard without any changes. Performance so far has been surprisingly good, as I'm using the python script as a bridge between the real-time sound processing\/synthesis language supercollider and a motor control board that communicates over USB-serial.","Q_Score":3,"Tags":"python,ruby,beagleboard","A_Id":6601437,"CreationDate":"2011-04-14T21:14:00.000","Title":"Can beagleboard run python or Ruby programs?","Data Science and Machine Learning":0,"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},{"Question":"I hi have just ordered a couple of beaglboards for experimenting. I know that it can rub Ubuntu and many other flavors of linux. \nDoes that mean it can run all the trivial software that run on Ubuntu? \nWill the python and ruby interpreters work just the way they work on PC ?","AnswerCount":4,"Available Count":3,"Score":1.2,"is_accepted":true,"ViewCount":3513,"Q_Id":5669785,"Users Score":4,"Answer":"The Beagleboard can run both of them, but you may have to compile the interpreters from source. And don't expect the performance of a desktop.","Q_Score":3,"Tags":"python,ruby,beagleboard","A_Id":5669819,"CreationDate":"2011-04-14T21:14:00.000","Title":"Can beagleboard run python or Ruby programs?","Data Science and Machine Learning":0,"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},{"Question":"I hi have just ordered a couple of beaglboards for experimenting. I know that it can rub Ubuntu and many other flavors of linux. \nDoes that mean it can run all the trivial software that run on Ubuntu? \nWill the python and ruby interpreters work just the way they work on PC ?","AnswerCount":4,"Available Count":3,"Score":0.049958375,"is_accepted":false,"ViewCount":3513,"Q_Id":5669785,"Users Score":1,"Answer":"The Angstrom Linux distribution (which runs on the Beagle Board) has binary packages for both Python and Ruby. I've worked on an application that uses Python and PyGTK. Never had any problems.","Q_Score":3,"Tags":"python,ruby,beagleboard","A_Id":8717516,"CreationDate":"2011-04-14T21:14:00.000","Title":"Can beagleboard run python or Ruby programs?","Data Science and Machine Learning":0,"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},{"Question":"Fabric is a tool for \"executing local or remote shell commands.\" \nWhy would you re-implement a remote shell script line by line in a long Fabric script? \nThat is, why not just write a brief Fabric script that runs a long remote shell script instead?","AnswerCount":3,"Available Count":3,"Score":0.1325487884,"is_accepted":false,"ViewCount":1058,"Q_Id":5673154,"Users Score":2,"Answer":"Also, I think the path you'd choose would depend on what you're trying to do. Some things are easier in python (write it in your fabfile), while others are easier in shell-land (take one of the shell approaches mentioned).\nEither way, fabric is geared towards centralization and portability, and it doesn't really matter what's actually doing the lifting.","Q_Score":4,"Tags":"python,shell,deployment,fabric","A_Id":8855653,"CreationDate":"2011-04-15T06:31:00.000","Title":"Why re-implement shell commands line by line in a Fabric 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},{"Question":"Fabric is a tool for \"executing local or remote shell commands.\" \nWhy would you re-implement a remote shell script line by line in a long Fabric script? \nThat is, why not just write a brief Fabric script that runs a long remote shell script instead?","AnswerCount":3,"Available Count":3,"Score":0.2605204458,"is_accepted":false,"ViewCount":1058,"Q_Id":5673154,"Users Score":4,"Answer":"It wont be a good idea if I have to run the same script on, lets say, 10 servers. This means I've to not only stick the same long script on 10 servers, but also make sure if I change it on 1 server, the change has to be applied to all servers. I know this can be averted by keeping that script on a shared location, but its much more organized to have the script in the fabfile, which can not only be version controlled but kept uniform across all the roles.","Q_Score":4,"Tags":"python,shell,deployment,fabric","A_Id":5674298,"CreationDate":"2011-04-15T06:31:00.000","Title":"Why re-implement shell commands line by line in a Fabric 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},{"Question":"Fabric is a tool for \"executing local or remote shell commands.\" \nWhy would you re-implement a remote shell script line by line in a long Fabric script? \nThat is, why not just write a brief Fabric script that runs a long remote shell script instead?","AnswerCount":3,"Available Count":3,"Score":1.2,"is_accepted":true,"ViewCount":1058,"Q_Id":5673154,"Users Score":4,"Answer":"lobster1234 raises a good point that you don't want to have to manually stick a long, remote shell script on 10 servers. However, if you still want to avoid rewriting the long, remote shell script as a long Fabric script, you could write a Fabric script that copies that remote shell script to the designated server, executes that script, and then removes the script. This way you can revision control both the fabfile and shell script together but avoid rewriting the shell script into a Fabric script.","Q_Score":4,"Tags":"python,shell,deployment,fabric","A_Id":5676599,"CreationDate":"2011-04-15T06:31:00.000","Title":"Why re-implement shell commands line by line in a Fabric 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},{"Question":"Chef is commonly used for provisioning servers, right? So is LibCloud, right?\nWhat's an example use case of why someone would use both tools together?","AnswerCount":2,"Available Count":2,"Score":0.1973753202,"is_accepted":false,"ViewCount":739,"Q_Id":5673599,"Users Score":2,"Answer":"I use chef to bootstrap ec2 instances. I also use boto to do further modifications of ec2 instances such as creating tags etc. I will be now be using libcloud more often since I will I will have a mix between rackspace and ec2.\nAs a side, when bootstrap a ec2 or rackspace instance, I do not use knife, I use libcload to boot a machine and ssh into into machine and install chef client since I fond it to be more reliable and even faster then knife by 3-5 minutes.\nNet net, both are used together. Its a happy marriage.","Q_Score":0,"Tags":"python,deployment,chef-infra","A_Id":10241015,"CreationDate":"2011-04-15T07:22:00.000","Title":"Example of using Chef with LibCloud","Data Science and Machine Learning":0,"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},{"Question":"Chef is commonly used for provisioning servers, right? So is LibCloud, right?\nWhat's an example use case of why someone would use both tools together?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":739,"Q_Id":5673599,"Users Score":0,"Answer":"Chef works with a variety of cloud computing providers:\n\nAmazon AWS EC2\nRackspace Cloud\nTerremark vCloud\nBluebox Group\nOpenstack\nSlicehost\n\nIt does this through the Ruby library, fog.","Q_Score":0,"Tags":"python,deployment,chef-infra","A_Id":5919135,"CreationDate":"2011-04-15T07:22:00.000","Title":"Example of using Chef with LibCloud","Data Science and Machine Learning":0,"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},{"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},{"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},{"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},{"Question":"I'd like to start developing an existing Python module. It has a source folder and the setup.py script to build and install it. The build script just copies the source files since they're all python scripts.\nCurrently, I have put the source folder under version control and whenever I make a change I re-build and re-install. This seems a little slow, and it doesn't settle well with me to \"commit\" my changes to my python install each time I make a modification. How can I cause my import statement to redirect to my development directory?","AnswerCount":4,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":4136,"Q_Id":5679359,"Users Score":2,"Answer":"Install the distrubute package then use the developer mode. Just use python setup.py develop --user and that will place path pointers in your user dir location to your workspace.","Q_Score":16,"Tags":"python","A_Id":5679488,"CreationDate":"2011-04-15T15:56:00.000","Title":"Developing 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},{"Question":"I'd like to start developing an existing Python module. It has a source folder and the setup.py script to build and install it. The build script just copies the source files since they're all python scripts.\nCurrently, I have put the source folder under version control and whenever I make a change I re-build and re-install. This seems a little slow, and it doesn't settle well with me to \"commit\" my changes to my python install each time I make a modification. How can I cause my import statement to redirect to my development directory?","AnswerCount":4,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":4136,"Q_Id":5679359,"Users Score":0,"Answer":"Change the PYTHONPATH to your source directory. A good idea is to work with an IDE like ECLIPSE that overrides the default PYTHONPATH.","Q_Score":16,"Tags":"python","A_Id":5679437,"CreationDate":"2011-04-15T15:56:00.000","Title":"Developing 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},{"Question":"I have an embedded linux device and here's what I would like to do using python:\n\nGet the device console over serial port. I can do it like this:\n>>> ser = serial.Serial('\/dev\/ttyUSB-17', 115200, timeout=1)\nNow I want to run a tail command on the embedded device command line, like this:\n# tail -f \/var\/log\/messages\n\nand capture the o\/p and display on my python >>> console.\nHow do I do that ?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":4870,"Q_Id":5690599,"Users Score":0,"Answer":"very first you need to get log-in into the device.\nthen you can run the specified command on that device.\nnote:command which you are going to run must be supported by that device.\nNow after opening a serial port using open() you need to find the login prompt using Read() and then write the username using write(), same thing repeat for password.\nonce you have logged-in you can now run the commands you needed to execute","Q_Score":0,"Tags":"python,serial-port","A_Id":23190516,"CreationDate":"2011-04-17T00:22:00.000","Title":"how to read command output from serial device 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},{"Question":"I am looking for a Twitter Streaming API Python library with proxy support. I love tweepy, but unfortunately I haven't seen a way to use an HTTP proxy. Any ideas?","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":1810,"Q_Id":5700302,"Users Score":2,"Answer":"Tweepy uses httplib internally which is too low level to have proxy settings. You have to change Stream._run() method to connect to proxy instead of target host and use full (with scheme and host) URL in request.","Q_Score":2,"Tags":"python,api,twitter,proxy,streaming","A_Id":5755092,"CreationDate":"2011-04-18T08:29:00.000","Title":"Twitter Streaming API Python library with proxy 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},{"Question":"We are mostly a .NET shop and want to cover everything with the Fitness acceptance testing framework. Recently we had to write a couple of scripts for unix and we used python. Now the suggestion has been made that we should write Fitness tests for these python scripts and integrate them into our automated test process.\nWhat would be the general strategy for doing this? Should I start a python project in visual studio and add the python scripts to it and expect it to work? Should I use a normal c# project and some look for some sort of compiler or interpreter in IronPython that can load these python scripts and either run them as is, or generate a .net assembly out of them or something?\nDoes anyone with experience in IronPython have a good suggestion?\nAlso what is the latest version of IronPython (and visual studio integration tools) that supports .net 3.5 and visual studio 2008 without compiling anything?\nI tried the latest but it only supports .net 4 and vs 2010. So I tried 2.6 but it doesn't seem to come with visual studio integration.\nThanks","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":342,"Q_Id":5700318,"Users Score":1,"Answer":"You can do it either way. We use IronPython runtime embedded in our code so we use the hosting options to test any python via c# unit test classes. Remember you can use fire up an Iron Python Engine (3.5) or DLR based script host (4.0) and give it a string.\nIn 3.5 there is no DLR to the Iron Python 1.1 is the order of the day, whereas in 4.0 the DLR supports IronPython 2.6 out of the box, and there is a codeplex update that is python 2.7 level. \nHowever of the key aspects of automated unit testing is to use the language that's close to the original language so the other way is probably 'more' classical!","Q_Score":0,"Tags":"visual-studio-2008,.net-3.5,ironpython,fitnesse,cpython","A_Id":5700447,"CreationDate":"2011-04-18T08:30:00.000","Title":"Using IronPython so I can test normal Python scripts 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":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am a newbie in python.\nI have a unicode in Tamil.\nWhen I use the sys.getdefaultencoding() I get the output as \"Cp1252\"\nMy requirement is that when I use text = testString.decode(\"utf-8\") I get the error \"UnicodeEncodeError: 'charmap' codec can't encode characters in position 0-8: character maps to undefined\"","AnswerCount":3,"Available Count":2,"Score":0.1973753202,"is_accepted":false,"ViewCount":879,"Q_Id":5701569,"Users Score":3,"Answer":"When I use the\n sys.getdefaultencoding() I get the\n output as \"Cp1252\"\n\nTwo comments on that: (1) it's \"cp1252\", not \"Cp1252\". Don't type from memory. (2) Whoever caused sys.getdefaultencoding() to produce \"cp1252\" should be told politely that that's not a very good idea.\nAs for the rest, let me guess. You have a unicode object that contains some text in the Tamil language. You try, erroneously, to decode it. Decode means to convert from a str object to a unicode object. Unfortunately you don't have a str object, and even more unfortunately you get bounced by one of the very few awkish\/perlish warts in Python 2: it tries to make a str object by encoding your unicode string using the system default encoding. If that's 'ascii' or 'cp1252', encoding will fail. That's why you get a Unicode*En*codeError instead of a Unicode*De*codeError.\nShort answer: do text = testString.encode(\"utf-8\"), if that's what you really want to do. Otherwise please explain what you want to do, and show us the result of print repr(testString).","Q_Score":0,"Tags":"python","A_Id":5702742,"CreationDate":"2011-04-18T10:30:00.000","Title":"Conversion of Unicode","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am a newbie in python.\nI have a unicode in Tamil.\nWhen I use the sys.getdefaultencoding() I get the output as \"Cp1252\"\nMy requirement is that when I use text = testString.decode(\"utf-8\") I get the error \"UnicodeEncodeError: 'charmap' codec can't encode characters in position 0-8: character maps to undefined\"","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":879,"Q_Id":5701569,"Users Score":0,"Answer":"you need to know which character-encoding is testString using. if not utf8, an error will occur when using decode('utf8').","Q_Score":0,"Tags":"python","A_Id":9630980,"CreationDate":"2011-04-18T10:30:00.000","Title":"Conversion of Unicode","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"How can i change password of ubuntu root user by python script? Thanks.","AnswerCount":3,"Available Count":1,"Score":0.1325487884,"is_accepted":false,"ViewCount":4855,"Q_Id":5706597,"Users Score":2,"Answer":"You can modify \/etc\/passwd (\/etc\/shadow) with Python script which will need root permissions sudo python modify.py \/etc\/passwd (where modify.py is your script that will change password)","Q_Score":1,"Tags":"python,linux,change-password","A_Id":5706671,"CreationDate":"2011-04-18T17:31:00.000","Title":"Changing password, python, 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},{"Question":"I don't know a whole lot about the technical details for constructing and sending email (I figure that's what libraries are for). Seems like both of these classes can be used to construct a basic text email, so which one should I use?\nWhat are the differences between these? When is appropriate to use one vs. the other?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":783,"Q_Id":5709688,"Users Score":4,"Answer":"One difference I found was that MIMEText has the Content-Type header set to something like 'text\/plain'; whereas, Message does not set this header. For me, that's a good enough reason to default to MIMEText, but I'd be interested to know if there are other differences.","Q_Score":8,"Tags":"python,email,mime","A_Id":5710604,"CreationDate":"2011-04-18T22:38:00.000","Title":"When should I use email.message.Message vs. email.mime.text.MIMEText when constructing an email 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},{"Question":"I'm trying to change my remote server's timezone via Fabric like so:\n\nrun(\"export TZ=\\\":Pacific\/Auckland\\\"\")\nrun(\"date\")\n\nThis doesn't seem to work. run(\"date\") gives me:\nTue Apr 19 00:19:58 CDT 2011 which is not the timezone I just set.\nIf I just log into the server and run the same bash commands, everything's just as expected:\n\n[lazo@lazoweb]$ date\nTue Apr 19 00:20:00 CDT 2011\n[lazo@lazoweb]$ export TZ=\":Pacific\/Auckland\"\n[lazo@lazoweb]$ date\nTue Apr 19 17:20:20 NZST 2011\n\nCan anyone shed some light on this? What am I missing?","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":733,"Q_Id":5712062,"Users Score":1,"Answer":"This only works for the current shell. Close the shell, start a new one and type date, you will see that the TZ has reset to the default timezone. Even for Fabric if you capture the output, you'd see that the TimeZone does get set correctly but as the script ends, so does the shell and hence the TZ variable is no longer available.","Q_Score":4,"Tags":"python,bash,fabric","A_Id":5712086,"CreationDate":"2011-04-19T05:39:00.000","Title":"How do I set remote server TimeZone via Fabric?","Data Science and Machine Learning":0,"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},{"Question":"I have a project which is mostly written in C, but it also has a Python API which uses Python extension modules written in C.\nWhat is the best way to write installation\/deployment scripts for a Linux\/UNIX environment? Usually, I use the make utility to compile and install projects written in C. Most of the time, I just have the make utility compile all the source code into executables, and then copy the executables to \/usr\/local\/bin.\nHowever, my Python API requires the compilation\/installation of shared library (.so) files for use with Python. This basically involves compiling the necessary C files, and then copying the shared libraries to some directory that is part of the Python sys.path, such as \/usr\/local\/lib\/pythonX.X\/dist-packages\/.\nBut how can the appropriate directory for Python extension modules be detected by the Make utility? Is there an environment variable or something that lists the directories in Python's sys.path?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":146,"Q_Id":5719506,"Users Score":0,"Answer":"I would separate the project out into two parts. Your C part can use make as usual. Your python module can use the python setup tools, which are capable of building extensions.\n(You can also write install targets, so you don't have to copy things manually)","Q_Score":4,"Tags":"python,c,linux,unix,makefile","A_Id":5727575,"CreationDate":"2011-04-19T16:19:00.000","Title":"Install script for C project with 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},{"Question":"Yes, I've searched. So after spending about 4-5 hours struggling just to get Python files running, I recently stumbled over the solution to get it running through the environment variables like this: cmd -> python -> Python starts, yay yay\nSince it didn't work to do it through the command line and similar I had to do it manually through the Windows interface. Now that it's working, however I cannot open .py files without typing out the full path like this: python C:\\X\\X\\X\\test.py which is obviously also starting to get annoying.\nSo now I'm trying to find out which variable I have to change (yet again) to only be able to type 'python test.py' and have it running. Sorry if I come off vague, but it's always a major pain to setup a new programming language for me and it kills my mood.\nThanks for help, it'll be really appreciated.","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":694,"Q_Id":5721948,"Users Score":2,"Answer":"To make python executable on your command line, you need to add it to your PATH environment variable, which it sounds like you have done on the command line. It is quite simple to add directories to the PATH in Windows if you know where to look. Essentially, you need to get to the Environment Variables dialog box, which is slightly different for each version of Windows.\n\nFor Windows XP: Start -> Control Panel -> System -> Advanced -> Environment Variables\nFor Windows Vista, 7: Click the Start Orb, right-click Computer and select Properties -> Advanced -> Environment Variables\n\nThen, in the lower of the two boxes, find Path and click Edit. Change it so that C:\\Python27 (or whichever version of Python you have) is at one end of the list, separated from the other entries by a semicolon (e.g. C:\\Python27;C:\\Program Files ...)\nOnce you've done this, python will work at the command line whenever you open a command window.\nRegarding your second issue, however, there isn't much you can do. You must either specify the complete path to your script or already be in the same directory as the script. That is, if the script is in C:\\X\\X\\X you will either need to invoke it as C:\\X\\X\\X\\test.py or first cd C:\\X\\X\\X.","Q_Score":1,"Tags":"python,windows,development-environment","A_Id":5722080,"CreationDate":"2011-04-19T19:58:00.000","Title":"Setting up a Python development environment on 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":1,"System Administration and DevOps":1,"Web Development":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},{"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},{"Question":"please advise me some good Python IDE, I was using netbeans but it does not have suitable code completion (when I press \".\" it gives me methods of all classes of python. It would be nice if netbeans would work as for ex. for PHP..\nThank you.","AnswerCount":8,"Available Count":4,"Score":0.049958375,"is_accepted":false,"ViewCount":1928,"Q_Id":5742472,"Users Score":2,"Answer":"Eclipse with Pydev\nnothing better out there","Q_Score":1,"Tags":"python,ide","A_Id":5742542,"CreationDate":"2011-04-21T09:59:00.000","Title":"Python IDE with auto 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},{"Question":"please advise me some good Python IDE, I was using netbeans but it does not have suitable code completion (when I press \".\" it gives me methods of all classes of python. It would be nice if netbeans would work as for ex. for PHP..\nThank you.","AnswerCount":8,"Available Count":4,"Score":1.2,"is_accepted":true,"ViewCount":1928,"Q_Id":5742472,"Users Score":1,"Answer":"well, many IDEs now come with pretty good code completion. Eclipse with pydev is nice, or you can get aptana studio 3 to perform similar to it.\nTheres also jetbrain's PyCharm, if you don't mind paying for a licence (they do give a trial version too if you want to test it before buying). There are a lot of such IDEs, guess you have to try them out to see which suits your code completion tastes better.","Q_Score":1,"Tags":"python,ide","A_Id":5742663,"CreationDate":"2011-04-21T09:59:00.000","Title":"Python IDE with auto 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},{"Question":"please advise me some good Python IDE, I was using netbeans but it does not have suitable code completion (when I press \".\" it gives me methods of all classes of python. It would be nice if netbeans would work as for ex. for PHP..\nThank you.","AnswerCount":8,"Available Count":4,"Score":0.024994793,"is_accepted":false,"ViewCount":1928,"Q_Id":5742472,"Users Score":1,"Answer":"PyCharm for pay or Komodo Edit for free.","Q_Score":1,"Tags":"python,ide","A_Id":5743360,"CreationDate":"2011-04-21T09:59:00.000","Title":"Python IDE with auto 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},{"Question":"please advise me some good Python IDE, I was using netbeans but it does not have suitable code completion (when I press \".\" it gives me methods of all classes of python. It would be nice if netbeans would work as for ex. for PHP..\nThank you.","AnswerCount":8,"Available Count":4,"Score":0.024994793,"is_accepted":false,"ViewCount":1928,"Q_Id":5742472,"Users Score":1,"Answer":"Try Geany and Ctrl+Enter. Foo bar <= wrote this because SO said answer was to short ;)","Q_Score":1,"Tags":"python,ide","A_Id":5742508,"CreationDate":"2011-04-21T09:59:00.000","Title":"Python IDE with auto 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},{"Question":"Let's say Tight Ars & Co. is a company with incredibly tight security policies, and lets assume I work for this company. Assume they've one task that requires a python script to write to excel files, and I find this incredibly wonderful library called xlwt. Now my script is able to write to excel files, everything is wonderful and the sun is shining, I release the code, and suddenly I'm asked what is this thingamajig setup.py, why should we run it? wait, we'll not even run it, we want the environment to be clean from third party code etc etc, since I'm unaware of any wizardry or voo doo is there any way I can package the dependent libraries and import them in my script?","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":458,"Q_Id":5749326,"Users Score":2,"Answer":"All setup.py typically does with any pure-Python package is copy files into a standard place and compile the .py files to .pyc. I can't imagine why your employer would regard that as (nasty) third-party software, but the source of the package is OK, your IDE is OK, Python itself is OK, etc ...\nOptions:\n(1) Copy the xlwt directory from a source distribution to somewhere that's listed in sys.path\n(2) Make a ZIP file xlwt.zip containing the contents of the xlwt directory and copy it to ditto.\n(3) As (2) but compile the .py files to .pyc first.\nIf somebody points out that the above involves error-prone manual steps, you can:\n(a) write a script to do that\nor\n(b) copy setup.py, change its name, pretend that you wrote it yourself, use it, ...","Q_Score":0,"Tags":"python,module,package,archive,xlwt","A_Id":5750297,"CreationDate":"2011-04-21T20:14:00.000","Title":"Python import module (xlwt) from archive","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"Let's say Tight Ars & Co. is a company with incredibly tight security policies, and lets assume I work for this company. Assume they've one task that requires a python script to write to excel files, and I find this incredibly wonderful library called xlwt. Now my script is able to write to excel files, everything is wonderful and the sun is shining, I release the code, and suddenly I'm asked what is this thingamajig setup.py, why should we run it? wait, we'll not even run it, we want the environment to be clean from third party code etc etc, since I'm unaware of any wizardry or voo doo is there any way I can package the dependent libraries and import them in my script?","AnswerCount":2,"Available Count":2,"Score":0.1973753202,"is_accepted":false,"ViewCount":458,"Q_Id":5749326,"Users Score":2,"Answer":"Unless I am misunderstanding the question you should be able to obtain the source archive and simply copy the \"xlwt\" directory to the same directory as your script and it should be importable from the local directory.","Q_Score":0,"Tags":"python,module,package,archive,xlwt","A_Id":5749670,"CreationDate":"2011-04-21T20:14:00.000","Title":"Python import module (xlwt) from archive","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I have a GNU Radio application which utilizes both Python and C++ code. I want to be able to signal the C++ code of an event. If they were in the same scope I would normally use a simple boolean, but the code is separate to the point where some form of shared memory is required. The code in question is performance-critical so an efficient method is required.\nI was initially thinking about a shared memory segment that is accessible by both Python and C++. Therefore I could set a flag in the python code and check it from C++. Since I just need a simple flag to pause the C++ code, would a semaphore suffice?\nTo be clear, I need to set a flag from Python and the C++ code will simply check this flag, and if it is set enter a busy loop.\nSo would trying to implement a shared memory segment between Python\/C++ be a reasonable approach? How about a semaphore? On Linux, which is easier to implement?\nThanks!","AnswerCount":5,"Available Count":3,"Score":0.0399786803,"is_accepted":false,"ViewCount":16031,"Q_Id":5756813,"Users Score":1,"Answer":"DBus looks promising. It supports signals, so you should be able to stop an application on demand. However, I'm not sure if it's performance will be enough for you.","Q_Score":12,"Tags":"c++,python,linux,ipc","A_Id":5756950,"CreationDate":"2011-04-22T15:11:00.000","Title":"Simple but fast IPC method for a Python and C++ 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},{"Question":"I have a GNU Radio application which utilizes both Python and C++ code. I want to be able to signal the C++ code of an event. If they were in the same scope I would normally use a simple boolean, but the code is separate to the point where some form of shared memory is required. The code in question is performance-critical so an efficient method is required.\nI was initially thinking about a shared memory segment that is accessible by both Python and C++. Therefore I could set a flag in the python code and check it from C++. Since I just need a simple flag to pause the C++ code, would a semaphore suffice?\nTo be clear, I need to set a flag from Python and the C++ code will simply check this flag, and if it is set enter a busy loop.\nSo would trying to implement a shared memory segment between Python\/C++ be a reasonable approach? How about a semaphore? On Linux, which is easier to implement?\nThanks!","AnswerCount":5,"Available Count":3,"Score":0.1973753202,"is_accepted":false,"ViewCount":16031,"Q_Id":5756813,"Users Score":5,"Answer":"Why not open a unix socket? Or use DBus","Q_Score":12,"Tags":"c++,python,linux,ipc","A_Id":5756983,"CreationDate":"2011-04-22T15:11:00.000","Title":"Simple but fast IPC method for a Python and C++ 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},{"Question":"I have a GNU Radio application which utilizes both Python and C++ code. I want to be able to signal the C++ code of an event. If they were in the same scope I would normally use a simple boolean, but the code is separate to the point where some form of shared memory is required. The code in question is performance-critical so an efficient method is required.\nI was initially thinking about a shared memory segment that is accessible by both Python and C++. Therefore I could set a flag in the python code and check it from C++. Since I just need a simple flag to pause the C++ code, would a semaphore suffice?\nTo be clear, I need to set a flag from Python and the C++ code will simply check this flag, and if it is set enter a busy loop.\nSo would trying to implement a shared memory segment between Python\/C++ be a reasonable approach? How about a semaphore? On Linux, which is easier to implement?\nThanks!","AnswerCount":5,"Available Count":3,"Score":0.0399786803,"is_accepted":false,"ViewCount":16031,"Q_Id":5756813,"Users Score":1,"Answer":"You can try using custom signals. I don't know about Python code being able to send custom signals, but your C\/C++ can certainly define custom signals with SIGIO.\nIf you have stringent response-time requirements, you might need to look beyond your application code and into some time of OS with support for real-time signals (rt-linux, muOs, etc.)","Q_Score":12,"Tags":"c++,python,linux,ipc","A_Id":5757091,"CreationDate":"2011-04-22T15:11:00.000","Title":"Simple but fast IPC method for a Python and C++ 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},{"Question":"In default installation of cedet-1.0 completion can only track global scope symbols in current file. This is not much differs from built-in completion functions (dabbrev-expand or hippie-expand).\nIt can complete symbols from neither imported modules, nor class properties.\nNot saying it cannot handle 'self'.\nIs it possible to tweak semantic to do the things?\nP.S.\nECB code browser sucesfully sees all imports\/base classess and stuff.\nIt is symbol completion workd incorrectly, or not properly set up.","AnswerCount":1,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":2830,"Q_Id":5766832,"Users Score":8,"Answer":"CEDET support for each language is slightly different. In the case of python, the 1.0 release for CEDET hadn't been configured to convert a python import into a file-name. In addition, 'self' is similar to 'this' in c++, which needs to be added by completion logic since it isn't declared. These two features were added to the bzr repository in January of this year. I am not a python programmer, but I recall reports that this fixed a range of the most basic features of smart completion so that symbols from imported libraries works. There was also new code in bzr for python system paths.\nThus, I recommend downloading CEDET from bzr to get these features to see if it now does what you would expect for smart completion.","Q_Score":10,"Tags":"python,emacs,code-completion,cedet","A_Id":5770424,"CreationDate":"2011-04-23T20:46:00.000","Title":"using emacs CEDET completion 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":1,"Web Development":0},{"Question":"I'm starting up a distributed computing project, somewhat like the various @home projects out there (though not doing simple scientific computing, but instead occasionally engaging the remote user in tasks involving presentation of audio and visual stimuli) and I need to get a sense of the relative system performance across machines that run my app so i can exclude data from machines that are very sub par (because these might not have presented the stimuli faithfully). The app is written in python, and I see that the pystone module provides a benchmark of sorts, but I also see that pystone has been disparaged as a benchmark in some cases. To my relatively novice understanding of benchmarking, pystone may not be good for general benchmarking because it collapses performance to a single score, but for my purposes where all I want is a single score to compare across machines, I think it should suffice. Are there any downsides I'm missing to using pystone for obtaining relative overall system performance?","AnswerCount":1,"Available Count":1,"Score":0.6640367703,"is_accepted":false,"ViewCount":447,"Q_Id":5774685,"Users Score":4,"Answer":"The big problem with Pystone as a benchmark of anything (whether it be Python interpreter versions or the underlying hardware) is that it simply doesn't exercise enough different aspects of the computing environment.\nInteger arithmetic, floating point arithmetic, vector operations, dedicated media hardware, memory throughput, I\/O throughput, cache sizes, threading architecture, pipelining architecture... the list of hardware features that can vary across machines goes on and on, and is the biggest reason why the first question in reply to \"Which is faster, A or B?\" will usually be \"Well, what do you plan to use them for?\". The answer to the speed question is likely to be different depending on whether you're building a home media centre or a web server or a database server, etc.\nModern computer systems are complex beasts, and the layering of interpreter virtual machines with their own complex object and execution models on top don't make things any easier. A naive benchmark like Pystone will let you get a general idea of the basic computing grunt of the CPU, but won't tell you anything about the other potentially limiting factors of the machine.","Q_Score":1,"Tags":"python,benchmarking","A_Id":5775608,"CreationDate":"2011-04-25T02:27:00.000","Title":"What are the arguments against using pystone to estimate overall relative system performance across multiple systems?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have simple example:\n\nimport netsnmp\nvar = netsnmp.Varbind('ifHCInOctets','0')\nres = netsnmp.snmpgetnext(var,Version = 2,DestHost='localhost',Community='public',Timeout=1000000)\nprint res[0]\n\n\n time python2 test.py show me:\n\nreal 0m4.086s\nuser 0m0.073s\nsys 0m0.007s\n\nWhy 4 seconds = 1000000 ? snmpd server not work on localhost","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":3013,"Q_Id":5792497,"Users Score":4,"Answer":"When you pass Timeout=? you are setting the maximum time that snmp's internal select loop should wait before registering a timeout. Setting this to 1000000 means \"wait 1 million microseconds\", which is 1 second.\nHowever there is also a Retries=? argument that specifies the number of times the snmp client will re-attempt the request after a timeout, so for Timeout=1000000, Retries=0 select will attempt only 1 request and timeout in 1 second. If Retries=1 it will try twice and timeout in 2 seconds.\nSo depending on the combination of Timeout and Retries you will see different amounts of delay.\nThe default number of Retries is 3, so 1 try + 3 retries of 1 seconds each = 4 seconds.","Q_Score":1,"Tags":"python,net-snmp","A_Id":5794510,"CreationDate":"2011-04-26T15:17:00.000","Title":"problem with timeout in netsnmp lib","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I'm relatively new to programming, and I would like to write a simple scripting language as an exercise, and to learn a bit. I have experience with Python, C, and Ruby, and would like to learn to write a scripting language in Python. What should be my first step? How should I start?","AnswerCount":4,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2946,"Q_Id":5798173,"Users Score":0,"Answer":"draw out a finite state automata of how your language is going to work, write a syntax analyzer, draw some diagrams. Hack on!","Q_Score":2,"Tags":"python,scripting,scripting-language","A_Id":5798276,"CreationDate":"2011-04-27T00:56:00.000","Title":"write a scripting language 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},{"Question":"I'm wandering what the best way is to send a fully scaled (1:1) dxf drawing to a cad plotter using python. Has anyone here ever done this?\nFor those who want to know why: \nI've written a program for my employer that automates the drawing of detailed \nschematics, apparently so our engineering dept can spend more time doing nothing. The issue now is that they would like to completely eliminate acad since it's only used to plot the finished drawing. \nMind you these drawings are used for non-trivial things like checking the dimensions of critical components used in commercial jetliners.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":686,"Q_Id":5808236,"Users Score":0,"Answer":"In case anyone else runs into this problem (pretty unlikely) I though I'd post briefly what I did in the end:\n1.) Wrote a short script to capture the dxf as a BMP (basicaly just a screen grab that appends the scale to the drawing) \n2.) Wrote a print dialog with PyQt4 that's a clone of Autocads plot window except that it has to pull the scaling info from the BMP.\nMy python skills are awfull so there's likely better solutions but this worked.","Q_Score":0,"Tags":"python,printing,cad","A_Id":5861459,"CreationDate":"2011-04-27T17:41:00.000","Title":"Cad plotters 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},{"Question":"I have two systems running the same set of Django unittests. Some of the tests use the @unittest.expectedFailure decorator. \nOn one system, these are running fine and reporting at the end of the test run OK (expected failures=10, unexpected successes=2). \nOn the other system, the same tests error, but raise _ExpectedFailure and _UnexpectedSuccess without tracebacks.\nHas anyone seen this behavior before? Is it a configuration issue? Both systems are running Python 2.7, Django 1.3, and have unittest and unittest2 installed.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":665,"Q_Id":5809333,"Users Score":1,"Answer":"I have the problem and I got it to work by deleting the \/usr\/local\/lib\/python2.7 and then reinstalling everything from scratch.\nThe reason for this I believe is that python may not have cleared it's python object and cache files(*.pyc, *.pyo) from it's working directory. That is, not YOUR project's directory but where python actually runs from.\nNot sure if that's it but it worked for me!!","Q_Score":4,"Tags":"python,unit-testing","A_Id":5810407,"CreationDate":"2011-04-27T19:16:00.000","Title":"Python raising _ExpectedFailure for unittests with @unittest.expectedFailure","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"My program does a lot of file processing, and as the files are large I prefer to write them as GZIP. One challenge is that I often need to read files as they are being written. This is not a problem without GZIP compression, but when compression is on, the reading complains about failed CRC, which I presume might have something to do with compression info not being flushed properly when writing. Is there any way to use GZIP with Python such that, when I write and flush to a file (but not necessarily close the file), that it can be read as well?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":586,"Q_Id":5829964,"Users Score":0,"Answer":"I think flushing data to file (compressed) just writes the data into file, but headers are written only on close(), so you need to close the file first, and only after you can open it and read all data you need. If you need to write large data ammounts, you can try to use database, like PostgreSQL or MySQL where you can specify table with compression (archive, compressed), and you will be able to insert data into the table, and read it, database software will do all rest for you (compression, decompression on inserts, selects).","Q_Score":3,"Tags":"python,file,io,gzip","A_Id":5832082,"CreationDate":"2011-04-29T08:48:00.000","Title":"Reading gzip file that is currently being written 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":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I need exchange data between python daemon (cluster nods send data to this daemon) and php script (apache) which, is accessed by webbrowsers. What do you recommend as technology which could establish some connection between them. Both, python daemon and apache\/php is on the same machine. \nThank you.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":568,"Q_Id":5832346,"Users Score":0,"Answer":"If you want things to be synchronous use a named socket(Amazing feature on Unix systems.)\nIf you want things to be asynchronous use pickle(there is a php version of it too.)","Q_Score":0,"Tags":"php,python","A_Id":5832407,"CreationDate":"2011-04-29T12:58:00.000","Title":"Python data passing","Data Science and Machine Learning":0,"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},{"Question":"Is it possible to write Python scripts in HTML code similarly as you write PHP between tags?\nI'd like to achieve that my Python application will run in the browser.\nthank you for help","AnswerCount":5,"Available Count":1,"Score":0.0798297691,"is_accepted":false,"ViewCount":49400,"Q_Id":5842487,"Users Score":2,"Answer":"You are mixing up client-side and server-side execution of code.\nBrowsers support only Javascript.\nAny application-server or Python-based webframework support template language where you can mix HTML and Python in some way or the other.","Q_Score":9,"Tags":"python,html","A_Id":5842534,"CreationDate":"2011-04-30T14:47:00.000","Title":"Python scripts in HTML","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"Is there a good high level library that can be used for IP address manipulation? I need to do things like:\n\nGiven a string find out if it is a valid IPv4\/IPv6 address.\nHave functionality like ntop and pton\netc\n\nI can use the low level inet_ntop() etc. But is there a better library that handles these better and fast (c\/c++\/python)?","AnswerCount":5,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":1307,"Q_Id":5857320,"Users Score":0,"Answer":"I have the mind boogling ipv4 \/ ipv6 validating regexps around, which are quite long and non-trivial to produce. I can share if you want.","Q_Score":2,"Tags":"c++,python,c,freebsd,ipv6","A_Id":5857748,"CreationDate":"2011-05-02T12:50:00.000","Title":"Efficient IP address c\/c++ library on unix","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},{"Question":"Is there a good high level library that can be used for IP address manipulation? I need to do things like:\n\nGiven a string find out if it is a valid IPv4\/IPv6 address.\nHave functionality like ntop and pton\netc\n\nI can use the low level inet_ntop() etc. But is there a better library that handles these better and fast (c\/c++\/python)?","AnswerCount":5,"Available Count":2,"Score":0.0399786803,"is_accepted":false,"ViewCount":1307,"Q_Id":5857320,"Users Score":1,"Answer":"If you are writing a sockets app it's highly unlikely that address manipulation is going to be your most important consideration. Don't waste time on this when you have network I\/O to worry about.","Q_Score":2,"Tags":"c++,python,c,freebsd,ipv6","A_Id":5857539,"CreationDate":"2011-05-02T12:50:00.000","Title":"Efficient IP address c\/c++ library on unix","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},{"Question":"Hey I've been using Linux for a while and thought it was time to finally dive into shell scripting.\nThe problem is I've failed to find any significant advantage of using Bash over something like Perl or Python. Are there any performance or power differences between the two? I'd figure Python\/Perl would be more well suited as far as power and efficiency goes.","AnswerCount":8,"Available Count":5,"Score":0.0748596907,"is_accepted":false,"ViewCount":26872,"Q_Id":5858877,"Users Score":3,"Answer":"If you want to execute programs installed on the machine, nothing beats bash. You can always make a system call from Perl or Python, but I find it to be a hassle to read return values, etc. \nAnd since you know it will work pretty much anywhere throughout all of of time...","Q_Score":31,"Tags":"python,linux,perl,bash,scripting","A_Id":5858924,"CreationDate":"2011-05-02T15:12:00.000","Title":"Is there an advantage to using Bash over Perl 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},{"Question":"Hey I've been using Linux for a while and thought it was time to finally dive into shell scripting.\nThe problem is I've failed to find any significant advantage of using Bash over something like Perl or Python. Are there any performance or power differences between the two? I'd figure Python\/Perl would be more well suited as far as power and efficiency goes.","AnswerCount":8,"Available Count":5,"Score":0.049958375,"is_accepted":false,"ViewCount":26872,"Q_Id":5858877,"Users Score":2,"Answer":"The advantage of shell scripting is that it's globally present on *ix boxes, and has a relatively stable core set of features you can rely on to run everywhere. With Perl and Python you have to worry about whether they're available and if so what version, as there have been significant syntactical incompatibilities throughout their lifespans. (Especially if you include Python 3 and Perl 6.)\nThe disadvantage of shell scripting is everything else. Shell scripting languages are typically lacking in expressiveness, functionality and performance. And hacking command lines together from strings in a language without strong string processing features and libraries, to ensure the escaping is correct, invites security problems. Unless there's a compelling compatibility reason you need to go with shell, I would personally plump for a scripting language every time.","Q_Score":31,"Tags":"python,linux,perl,bash,scripting","A_Id":5858956,"CreationDate":"2011-05-02T15:12:00.000","Title":"Is there an advantage to using Bash over Perl 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},{"Question":"Hey I've been using Linux for a while and thought it was time to finally dive into shell scripting.\nThe problem is I've failed to find any significant advantage of using Bash over something like Perl or Python. Are there any performance or power differences between the two? I'd figure Python\/Perl would be more well suited as far as power and efficiency goes.","AnswerCount":8,"Available Count":5,"Score":0.0996679946,"is_accepted":false,"ViewCount":26872,"Q_Id":5858877,"Users Score":4,"Answer":"For big projects use a language like Perl.\nThere are a few things you can only do in bash (for example, alter the calling environment (when a script is sourced rather than run). Also, shell scripting is commonplace. It is worthwhile to learn the basics and learn your way around the available docs.\nPlus there are times when knowing a shell well can save your bacon (on a fork-bombed system where you can't start any new processes, or if \/usr\/bin and or \/usr\/local\/bin fail to mount).","Q_Score":31,"Tags":"python,linux,perl,bash,scripting","A_Id":5860436,"CreationDate":"2011-05-02T15:12:00.000","Title":"Is there an advantage to using Bash over Perl 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},{"Question":"Hey I've been using Linux for a while and thought it was time to finally dive into shell scripting.\nThe problem is I've failed to find any significant advantage of using Bash over something like Perl or Python. Are there any performance or power differences between the two? I'd figure Python\/Perl would be more well suited as far as power and efficiency goes.","AnswerCount":8,"Available Count":5,"Score":1.0,"is_accepted":false,"ViewCount":26872,"Q_Id":5858877,"Users Score":10,"Answer":"bash isn't a language so much as a command interpreter that's been hacked to death to allow for things that make it look like a scripting language. It's great for the simplest 1-5 line one-off tasks, but things that are dead simple in Perl or Python like array manipulation are horribly ugly in bash. I also find that bash tends not to pass two critical rules of thumb: \n\nThe 6-month rule, which says you should be able to easily discern the purpose and basic mechanics of a script you wrote but haven't looked at in 6 months. \nThe 'WTF per minute' rule. Everyone has their limit, and mine is pretty small. Once I get to 3 WTFs\/min, I'm looking elsewhere. \n\nAs for 'shelling out' in scripting languages like Perl and Python, I find that I almost never need to do this, fwiw (disclaimer: I code almost 100% in Python). The Python os and shutil modules have most of what I need most of the time, and there are built-in modules for handling tarfiles, gzip files, zip files, etc. There's a glob module, an fnmatch module... there's a lot of stuff there. If you come across something you need to parallelize, then indent your code a level, put it in a 'run()' method, put that in a class that extends either threading.Thread or multiprocessing.Process, instantiate as many of those as you want, calling 'start()' on each one. Less than 5 minutes to get parallel execution generally. \nBest of luck. Hope this helps.","Q_Score":31,"Tags":"python,linux,perl,bash,scripting","A_Id":5860163,"CreationDate":"2011-05-02T15:12:00.000","Title":"Is there an advantage to using Bash over Perl 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},{"Question":"Hey I've been using Linux for a while and thought it was time to finally dive into shell scripting.\nThe problem is I've failed to find any significant advantage of using Bash over something like Perl or Python. Are there any performance or power differences between the two? I'd figure Python\/Perl would be more well suited as far as power and efficiency goes.","AnswerCount":8,"Available Count":5,"Score":0.0996679946,"is_accepted":false,"ViewCount":26872,"Q_Id":5858877,"Users Score":4,"Answer":"The most important advantage of POSIX shell scripts over Python or Perl scripts is that a POSIX shell is available on virtually every Unix machine. (There are also a few tasks shell scripts happen to be slightly more convenient for, but that's not a major issue.) If the portability is not an issue for you, I don't see much need to learn shell scripting.","Q_Score":31,"Tags":"python,linux,perl,bash,scripting","A_Id":5858911,"CreationDate":"2011-05-02T15:12:00.000","Title":"Is there an advantage to using Bash over Perl 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},{"Question":"In netbeans the toggle comments shortcut is control + \/, which works well for php and ruby but for python it simply does nothing, can someone help?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1001,"Q_Id":5876909,"Users Score":0,"Answer":"Which version of NetBeans are you using? \nI just tried it in NetBeans 6.9 and it works perfectly in Python source \n(I presume you have Python plugin installed )\nVersion: 0.105 Source: NetBeans Beta\nPlugin Description\nPython support: editing, refactoring, hints, etc.","Q_Score":1,"Tags":"python,netbeans,ide,keyboard-shortcuts","A_Id":5876927,"CreationDate":"2011-05-03T23:31:00.000","Title":"Toggle comment shortcut in netbeans 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},{"Question":"I have a webserver running IIS (Machine A) that is running PHP for me. When a user points their browser to a web page that is hosted on the webserver with a PHP script on it, they need to populate a few forms, and then hit a button that will then run the PHP script, which will fire off a python script I've already built. I am using the exec() command in PHP to call my Python script which is stored locally on the webserver (still Machine A). The idea here is that any user on any machine (with python installed on it) can run the script when they navigate to the webpage.\nUnfortunately, one of the forms that is needed for the python script to work is a path to an external drive plugged into the user's machine (Machine B).\nMy question then is: Is there a way that PHP can execute a python script (stored on Machine A) that is then ran locally (on Machine B) so that when the user has entered in the location of the drive (Win: F:\\, Linux: \\dev\\sda2\\, etc ), the python script will know to be looking at the user's local machine (Machine B) rather than the server the script is stored on (Machine A)?\nEDIT: Hopefully I have clarified the question above.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":937,"Q_Id":5877621,"Users Score":0,"Answer":"Is there a way that PHP can execute a python script (stored on Machine A) that is then ran locally (on Machine B) \n\nNever. The browsers forbid this kind of security hole.","Q_Score":0,"Tags":"php,python,iis","A_Id":5877854,"CreationDate":"2011-05-04T01:50:00.000","Title":"Execute a python script stored on a server\/network location on a user's local machine using 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":1,"Web Development":0},{"Question":"I have a webserver running IIS (Machine A) that is running PHP for me. When a user points their browser to a web page that is hosted on the webserver with a PHP script on it, they need to populate a few forms, and then hit a button that will then run the PHP script, which will fire off a python script I've already built. I am using the exec() command in PHP to call my Python script which is stored locally on the webserver (still Machine A). The idea here is that any user on any machine (with python installed on it) can run the script when they navigate to the webpage.\nUnfortunately, one of the forms that is needed for the python script to work is a path to an external drive plugged into the user's machine (Machine B).\nMy question then is: Is there a way that PHP can execute a python script (stored on Machine A) that is then ran locally (on Machine B) so that when the user has entered in the location of the drive (Win: F:\\, Linux: \\dev\\sda2\\, etc ), the python script will know to be looking at the user's local machine (Machine B) rather than the server the script is stored on (Machine A)?\nEDIT: Hopefully I have clarified the question above.","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":937,"Q_Id":5877621,"Users Score":1,"Answer":"The question is not exactly clear, but from my understanding, you're trying to execute code on the local user's machine and you can't do that via Python.\nYour best bet is to write JavaScript that will do the job for you (a few browsers only as you're working with local storage due to HTML5), or you can have your user upload the files.","Q_Score":0,"Tags":"php,python,iis","A_Id":5877648,"CreationDate":"2011-05-04T01:50:00.000","Title":"Execute a python script stored on a server\/network location on a user's local machine using 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":1,"Web Development":0},{"Question":"How can I run a python script in Terminal on Mac without using the \"python\" keyword, without having to edit my existing python files?\nRight now I have to do this:\npython script.py\nWhat I like to do is this:\nscript.py","AnswerCount":3,"Available Count":1,"Score":0.3215127375,"is_accepted":false,"ViewCount":8958,"Q_Id":5879869,"Users Score":5,"Answer":"Try .\/script.py instead of script.py ... or ensure your current directory is in your path and script.py should work....","Q_Score":12,"Tags":"python,macos,terminal","A_Id":5879906,"CreationDate":"2011-05-04T07:17:00.000","Title":"Run python script without the \"python\" 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":1,"Web Development":0},{"Question":"So, I created a Directory in Ubuntu called Pymouse and I put all the related Pymouse files from Github in there including setup.py. When I go to terminal I cd the directory and then once i have done that I type python setup.py install or python setup.py build and each time I enter that command I receive the following input: error: package directory 'pymouse' does not exist.\nHow do I install and set this module to path? I'm new to Ubuntu by the way.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":3996,"Q_Id":5890802,"Users Score":1,"Answer":"Go back to the PyMouse Github page, click on \"Downloads\", pick one of the options from the window that pops up, extract the archive to your hard drive, and try again.","Q_Score":0,"Tags":"python,linux,ubuntu,build,installation","A_Id":5890850,"CreationDate":"2011-05-04T22:54:00.000","Title":"Trying to install the Pymouse module on Ubuntu and receiving an error 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},{"Question":"I am looking to create a simple graph showing 2 numbers of time for my personal twitter. They are:\n\nNumber of followers per day\nNumber of mentions per day\n\nFrom my research so far, the search API does not provide a date so I am not about to do a GROUP BY. The only way I can have access to dates is through the OAuth Api but that requires interaction from the end user which I am trying to avoid. \nCan someone point me in the right direction in order to achieve this? Thanks.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":438,"Q_Id":5932111,"Users Score":0,"Answer":"The best way is to use a cron to record the data daily.\nHowever, you can query the mentions using the search api with a untill tag. Which should do the trick.","Q_Score":1,"Tags":"python,twitter","A_Id":7361262,"CreationDate":"2011-05-09T03:12:00.000","Title":"Twitter API: Getting Data for Analytics","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},{"Question":"I am looking to create a simple graph showing 2 numbers of time for my personal twitter. They are:\n\nNumber of followers per day\nNumber of mentions per day\n\nFrom my research so far, the search API does not provide a date so I am not about to do a GROUP BY. The only way I can have access to dates is through the OAuth Api but that requires interaction from the end user which I am trying to avoid. \nCan someone point me in the right direction in order to achieve this? Thanks.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":438,"Q_Id":5932111,"Users Score":0,"Answer":"We can although use the search api to fetch mentions but there is a limit in it.\nAt a given point of time you can only fetch 200 mentions.\nAny one knows how to get total mentions count?","Q_Score":1,"Tags":"python,twitter","A_Id":8756753,"CreationDate":"2011-05-09T03:12:00.000","Title":"Twitter API: Getting Data for Analytics","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},{"Question":"I've wrote several perl scripts during my internship, and I would like to simplify the use of them. The scripts asks in arg, a mac address, and returns which switch is connected, speed...etc.\nInstead of giving a mac address, I would like to give a host name of a computer. So, how can I resolve the hostname to mac address ?\nThanks, bye. \nEdit -> Solution could be : bash command or perl module or something powerfull like that...","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2670,"Q_Id":5936781,"Users Score":0,"Answer":"The ethers file on a UNIX system maps Ethernet address to IP-number (or hostname). If your \/etc\/ethers is properly maintained, you can look it up in there.","Q_Score":1,"Tags":"python,perl,ip,mac-address,hostname","A_Id":5936797,"CreationDate":"2011-05-09T12:20:00.000","Title":"Resolve mac address by host 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":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have a python script using Pyinotify that does some stuff on IN_MOVED_TO. What's the easiest way to trigger the script on specific files, using another python script, without actually moving the files out and back in?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":782,"Q_Id":5939078,"Users Score":0,"Answer":"you can avoid moving file by simply renaming the file (which is very similar on linux), for example a mv file file.sav && mv file.sav file","Q_Score":0,"Tags":"python,pyinotify","A_Id":5940630,"CreationDate":"2011-05-09T15:29:00.000","Title":"Trigger inotify events","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"urllib.urlencode could encode url's params. It seems no likely function in Mechanize.\nSo, I have to use urllib and Mechanize, because I only need urlencode.\nAny function could implement the same task like urllib.urlencode in Mechanize","AnswerCount":2,"Available Count":2,"Score":0.2913126125,"is_accepted":false,"ViewCount":612,"Q_Id":5940520,"Users Score":3,"Answer":"Why would mechanize have it? It's already in urllib, which comes with Python.","Q_Score":0,"Tags":"python,mechanize,urllib","A_Id":5940566,"CreationDate":"2011-05-09T17:45:00.000","Title":"which function of mechanize is equal with urllib.urlencode","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},{"Question":"urllib.urlencode could encode url's params. It seems no likely function in Mechanize.\nSo, I have to use urllib and Mechanize, because I only need urlencode.\nAny function could implement the same task like urllib.urlencode in Mechanize","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":612,"Q_Id":5940520,"Users Score":0,"Answer":"mechanize actually uses urllib and urllib2 for most tasks that involve urls. \nSince this functionality already exists in urllib\/2 (as mentioned by Ignacio Vazquez-Abrams) there's no need for it to be implemented elsewhere. When coding you import all the libraries that have functionality you need to use.","Q_Score":0,"Tags":"python,mechanize,urllib","A_Id":5992039,"CreationDate":"2011-05-09T17:45:00.000","Title":"which function of mechanize is equal with urllib.urlencode","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},{"Question":"I have found many posts where solutions to read PDFs has been proposed. I want to read a PDF file word by word and do some processing on it. people suggest pdfMiner which converts entire PDF file into text file. But what i want is that to read PDFs word by word. Can anyone suggest a library that does this?","AnswerCount":3,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":16310,"Q_Id":5945764,"Users Score":6,"Answer":"I'm using pdfminer and it is an excellent lib especially if you're comfortable programming in python. It reads PDF and extracts every character, and it provides its bounding box as a tuple (x0,y0,x1,y1). Pdfminer will extract rectangles, lines and some images, and will try to detect words. It has an unpleasant O(N^3) routine that analyses bounding boxes to coalesce them, so it can get very slow on some files. Try to convert your typical file - maybe it'll be fast for you, or maybe it'll take 1 hour, depends on the file.\nYou can easily dump a pdf out as text, that's the first thing you should try for your application. You can also dump XML (see below), but you can't modify PDF. XML is the most complete representation of the PDF you can get out of it.\nYou have to read through the examples to use it in your python code, it doesn't have much documentation. \nThe example that comes with PdfMiner that transforms PDF into xml shows best how to use the lib in your code. It also shows you what's extracted in human-readable (as far as xml goes) form.\nYou can call it with parameters that tell it to \"analyze\" the pdf. If you do, it'll coalesce letters into blocks of text (words and sentences; sentences will have spaces so it's easy to tokenize into words in python).","Q_Score":11,"Tags":"python,pdf","A_Id":6460926,"CreationDate":"2011-05-10T05:52:00.000","Title":"Python to read PDF 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},{"Question":"i have python web app build on top of BaseHTTPServer, which runs on specyfic port. It runs system commands and shows output. I want do limit access to this app. What are posible ways to do it? Requirements:\n\nit must not be limited to LAN\nsimple to implement\/deploy","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":517,"Q_Id":5947849,"Users Score":0,"Answer":"Easiest and most secure: Put Apache or Nginx in front of it with an HTTPS proxy.\nUpdate: Or VPN access as suggested by Jakob. Good idea.","Q_Score":0,"Tags":"python,security,web-applications","A_Id":5947923,"CreationDate":"2011-05-10T09:16:00.000","Title":"Secure python web 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":1},{"Question":"i have python web app build on top of BaseHTTPServer, which runs on specyfic port. It runs system commands and shows output. I want do limit access to this app. What are posible ways to do it? Requirements:\n\nit must not be limited to LAN\nsimple to implement\/deploy","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":517,"Q_Id":5947849,"Users Score":0,"Answer":"Common methods: VPN access. Firewalls, logging, denyhosts style defences, complicated root passwords, no su, run as its own user.\n(if it was my personal server)\nLogic bombs","Q_Score":0,"Tags":"python,security,web-applications","A_Id":5947916,"CreationDate":"2011-05-10T09:16:00.000","Title":"Secure python web 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":1},{"Question":"I have a python script which is constantly polling data. The script is constantly running and should never stop.\nThe script polls data from a track of keywords which are passed to it when the script is first run. \nWhat would be the best way to update this track without stopping the script from another python script? \nThe only solution I can think of is to store the track in a txt file and check for any updates to the file on a set timer. Seems kind of messy.","AnswerCount":5,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":862,"Q_Id":5949242,"Users Score":0,"Answer":"You can communicate both scripts using sockets","Q_Score":4,"Tags":"python","A_Id":5949332,"CreationDate":"2011-05-10T11:22:00.000","Title":"Python - update configuration while 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},{"Question":"I have a python script which is constantly polling data. The script is constantly running and should never stop.\nThe script polls data from a track of keywords which are passed to it when the script is first run. \nWhat would be the best way to update this track without stopping the script from another python script? \nThe only solution I can think of is to store the track in a txt file and check for any updates to the file on a set timer. Seems kind of messy.","AnswerCount":5,"Available Count":3,"Score":1.2,"is_accepted":true,"ViewCount":862,"Q_Id":5949242,"Users Score":5,"Answer":"It's better to encapsulate this settings file in a database. A simple SQLite DB file is enough - SQLite support is built-in with Python so no extra effort is required.\nThe advantage of a DB is that you won't run into race conditions of partially-written files, etc. The \"configuration-adding\" script adds keywords using a transaction, and the other script reading from the DB will only see it when it's wholly done. Just remember to not hold the DB open all the time in the periodic script. Once every some time, open it, read the keywords, and close it.","Q_Score":4,"Tags":"python","A_Id":5949341,"CreationDate":"2011-05-10T11:22:00.000","Title":"Python - update configuration while 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},{"Question":"I have a python script which is constantly polling data. The script is constantly running and should never stop.\nThe script polls data from a track of keywords which are passed to it when the script is first run. \nWhat would be the best way to update this track without stopping the script from another python script? \nThe only solution I can think of is to store the track in a txt file and check for any updates to the file on a set timer. Seems kind of messy.","AnswerCount":5,"Available Count":3,"Score":0.1194272985,"is_accepted":false,"ViewCount":862,"Q_Id":5949242,"Users Score":3,"Answer":"Polling a configuration-file is not messy, but a very common solution to this problem. You should go with it.","Q_Score":4,"Tags":"python","A_Id":5949274,"CreationDate":"2011-05-10T11:22:00.000","Title":"Python - update configuration while 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},{"Question":"I want to write some install scripts by python, it should know the OS to choose either apt command or yum command.\nIt seems sys.platform can tell 'win32' or the others, but how to know it is working on Debian or CentOS in Python?","AnswerCount":2,"Available Count":1,"Score":0.2913126125,"is_accepted":false,"ViewCount":1337,"Q_Id":5951930,"Users Score":3,"Answer":"If you just need to know whether to use yum or apt, one approach is simply to pick one of those commands and try it. If it works, it works; if not, catch the exception and try the other command.","Q_Score":6,"Tags":"python,debian,centos,yum,apt","A_Id":5952044,"CreationDate":"2011-05-10T14:49:00.000","Title":"How to know the system is Debian or CentOS 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},{"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},{"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},{"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},{"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},{"Question":"is it possible to check if a file is done copying of if its complete using python?\nor even on the command line.\ni manipulate files programmatically in a specific folder on mac osx but i need to check if the file is complete before running the code which makes the manipulation.","AnswerCount":6,"Available Count":2,"Score":0.0333209931,"is_accepted":false,"ViewCount":6644,"Q_Id":5967521,"Users Score":1,"Answer":"It seems like you have control of the (python?) program doing the copying. What commands are you using to copy? I would think writing your code such that it blocks until the copy operation is complete would be sufficient.\nIs this program multi-threaded or processed? If so you could add file paths to a queue when they are complete and then have the other thread only act on items in the queue.","Q_Score":3,"Tags":"python,macos,file-io","A_Id":5967726,"CreationDate":"2011-05-11T16:23:00.000","Title":"check if a file is 'complete' (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},{"Question":"is it possible to check if a file is done copying of if its complete using python?\nor even on the command line.\ni manipulate files programmatically in a specific folder on mac osx but i need to check if the file is complete before running the code which makes the manipulation.","AnswerCount":6,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":6644,"Q_Id":5967521,"Users Score":2,"Answer":"If you know where the files are being copied from, you can check to see whether the size of the copy has reached the size of the original.\nAlternatively, if a file's size doesn't change for a couple of seconds, it is probably done being copied, which may be good enough. (May not work well for slow network connections, however.)","Q_Score":3,"Tags":"python,macos,file-io","A_Id":5967724,"CreationDate":"2011-05-11T16:23:00.000","Title":"check if a file is 'complete' (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},{"Question":"What's the best way to monitor a python daemon to determine the cause of it quitting unexpectedly? Is strace my best option or is there something Python specific that does the job?","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":2169,"Q_Id":5969337,"Users Score":1,"Answer":"I would generally start by adding logging to it. At a minimum, have whatever is launching it capture stdout\/stderr so that any stack traces are saved. Examine your except blocks to make sure you're not capturing exceptions silently.","Q_Score":4,"Tags":"python,strace","A_Id":5969373,"CreationDate":"2011-05-11T19:08:00.000","Title":"Troubleshoot python daemon that quits unexpectedly?","Data Science and Machine Learning":0,"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},{"Question":"I've been trying (unsuccessfully, I might add) to scrape a website created with the Microsoft stack (ASP.NET, C#, IIS) using Python and urllib\/urllib2. I'm also using cookielib to manage cookies. After spending a long time profiling the website in Chrome and examining the headers, I've been unable to come up with a working solution to log in. Currently, in an attempt to get it to work at the most basic level, I've hard-coded the encoded URL string with all of the appropriate form data (even View State, etc..). I'm also passing valid headers.\nThe response that I'm currently receiving reads:\n\n29|pageRedirect||\/?aspxerrorpath=\/default.aspx|\n\nI'm not sure how to interpret the above. Also, I've looked pretty extensively at the client-side code used in processing the login fields.\nHere's how it works: You enter your username\/pass and hit a 'Login' button. Pressing the Enter key also simulates this button press. The input fields aren't in a form. Instead, there's a few onClick events on said Login button (most of which are just for aesthetics), but one in question handles validation. It does some rudimentary checks before sending it off to the server-side. Based on the web resources, it definitely appears to be using .NET AJAX. \nWhen logging into this website normally, you request the domian as a POST with form-data of your username and password, among other things. Then, there is some sort of URL rewrite or redirect that takes you to a content page of url.com\/twitter. When attempting to access url.com\/twitter directly, it redirects you to the main page.\nI should note that I've decided to leave the URL in question out. I'm not doing anything malicious, just automating a very monotonous check once every reasonable increment of time (I'm familiar with compassionate screen scraping). However, it would be trivial to associate my StackOverflow account with that account in the event that it didn't make the domain owners happy.\nMy question is: I've been able to successfully log in and automate services in the past, none of which were .NET-based. Is there anything different that I should be doing, or maybe something I'm leaving out?","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":1706,"Q_Id":5973245,"Users Score":1,"Answer":"When scraping a web application, I use either:\n1) WireShark ... or...\n2) A logging proxy server (that logs headers as well as payload)\nI then compare what the real application does (in this case, how your browser interacts with the site) with the scraper's logs. Working through the differences will bring you to a working solution.","Q_Score":2,"Tags":"asp.net,python,asp.net-ajax,screen-scraping,urllib2","A_Id":5974002,"CreationDate":"2011-05-12T04:17:00.000","Title":"Scraping ASP.NET with Python and urllib2","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},{"Question":"I've been trying (unsuccessfully, I might add) to scrape a website created with the Microsoft stack (ASP.NET, C#, IIS) using Python and urllib\/urllib2. I'm also using cookielib to manage cookies. After spending a long time profiling the website in Chrome and examining the headers, I've been unable to come up with a working solution to log in. Currently, in an attempt to get it to work at the most basic level, I've hard-coded the encoded URL string with all of the appropriate form data (even View State, etc..). I'm also passing valid headers.\nThe response that I'm currently receiving reads:\n\n29|pageRedirect||\/?aspxerrorpath=\/default.aspx|\n\nI'm not sure how to interpret the above. Also, I've looked pretty extensively at the client-side code used in processing the login fields.\nHere's how it works: You enter your username\/pass and hit a 'Login' button. Pressing the Enter key also simulates this button press. The input fields aren't in a form. Instead, there's a few onClick events on said Login button (most of which are just for aesthetics), but one in question handles validation. It does some rudimentary checks before sending it off to the server-side. Based on the web resources, it definitely appears to be using .NET AJAX. \nWhen logging into this website normally, you request the domian as a POST with form-data of your username and password, among other things. Then, there is some sort of URL rewrite or redirect that takes you to a content page of url.com\/twitter. When attempting to access url.com\/twitter directly, it redirects you to the main page.\nI should note that I've decided to leave the URL in question out. I'm not doing anything malicious, just automating a very monotonous check once every reasonable increment of time (I'm familiar with compassionate screen scraping). However, it would be trivial to associate my StackOverflow account with that account in the event that it didn't make the domain owners happy.\nMy question is: I've been able to successfully log in and automate services in the past, none of which were .NET-based. Is there anything different that I should be doing, or maybe something I'm leaving out?","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":1706,"Q_Id":5973245,"Users Score":2,"Answer":"For anyone else that might be in a similar predicament in the future: \nI'd just like to note that I've had a lot of success with a Greasemonkey user script in Chrome to do all of my scraping and automation. I found it to be a lot easier than Python + urllib2 (at least for this particular case). The user scripts are written in 100% Javascript.","Q_Score":2,"Tags":"asp.net,python,asp.net-ajax,screen-scraping,urllib2","A_Id":6035498,"CreationDate":"2011-05-12T04:17:00.000","Title":"Scraping ASP.NET with Python and urllib2","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},{"Question":"I want to write a program that sends an e-mail to one or more specified recipients when a certain event occurs. For this I need the user to write the parameters for the mail server into a config. Possible values are for example: serveradress, ports, ssl(true\/false) and a list of desired recipients.\nWhats the user-friendliest\/best-practice way to do this?\nI could of course use a python file with the correct parameters and the user has to fill it out, but I wouldn't consider this user friendly. I also read about the 'config' module in python, but it seems to me that it's made for creating config files on its own, and not to have users fill the files out themselves.","AnswerCount":4,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":1174,"Q_Id":5980101,"Users Score":2,"Answer":"I doesn't matter technically proficient your users are; you can count on them to screw up editing a text file. (They'll save it in the wrong place. They'll use MS Word to edit a text file. They'll make typos.) I suggest making a gui that validates the input and creates the configuration file in the correct format and location. A simple gui created in Tkinter would probably fit your needs.","Q_Score":2,"Tags":"python,configuration","A_Id":5980640,"CreationDate":"2011-05-12T15:05:00.000","Title":"Userfriendly way of handling config files 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},{"Question":"I'm developing a firefox addon which is depended on Python (which means that the user must install PyXpcomExt on his firefox). On the other hand I used PyCrypto lib (based on python) for encryption purposes.\nSo when firefox is loaded I have registered path to this library. However when the extension is run I get the following error: \nFile \"\/home\/...\/.mozilla\/firefox\/qvpgc3wq.default\/extensions\/....\/pylib\/mycryptoclass.py\", line 4, in \n from Crypto.Cipher import AES\nImportError: \/home\/...\/.mozilla\/firefox\/qvpgc3wq.default\/extensions\/...\/platform\/Linux_x86-gcc3\/pylib\/Crypto\/Cipher\/AES.so: undefined symbol: PyExc_ValueError\nI also tried:\nimport Crypto\nfrom Crypto import Cipher\nNo error is thrown!\nAny Ideas?\nThanks","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":434,"Q_Id":5981117,"Users Score":0,"Answer":"AES.so has not been linked against the Python dynamic library. It's finding other symbols it needs in the process's symbol table, but it can't find that one and doesn't know where it is.","Q_Score":0,"Tags":"python,firefox-addon,xpcom,pycrypto","A_Id":5989716,"CreationDate":"2011-05-12T16:17:00.000","Title":"PyExc_ValueError and Firefox 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":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm using Pydev on Eclipse. I have created a new project, added __init__.py and a module in a package in the src folder. The problem is, I can't see classes and functions outlines when I try to expand the module by clicking the arrow left to it. Nothing expands. I expect to see a list of classes with a capital \"C\" letter left to each class name, and \"F\" letter with functions. But nothing is displayed.\nAnother problem is, when I Ctrl+click on a function or method, it just plays a ring sound, and does not go to definiton. Under \"Preferences -> Pydev -> Interpreter -python\" menu, I added the \"src\" folder to \"Libraries\" but it again does not go to definition.\nCould you please help me with these two problems?\nThanks,\nBest regards,","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":1261,"Q_Id":5988099,"Users Score":1,"Answer":"add your code dir into the project->properties->PyDev - PYTHONPATH->sourceFolders, you can find the C mark in the package Explorer","Q_Score":1,"Tags":"python,eclipse,package,definition,pydev","A_Id":6316500,"CreationDate":"2011-05-13T06:32:00.000","Title":"Pydev problems with \"Go to definition\" and \"package Explorer\"","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"When you do something like \"test\" in a where a is a list does python do a sequential search on the list or does it create a hash table representation to optimize the lookup? In the application I need this for I'll be doing a lot of lookups on the list so would it be best to do something like b = set(a) and then \"test\" in b? Also note that the list of values I'll have won't have duplicate data and I don't actually care about the order it's in; I just need to be able to check for the existence of a value.","AnswerCount":4,"Available Count":2,"Score":0.1488850336,"is_accepted":false,"ViewCount":59073,"Q_Id":5993621,"Users Score":3,"Answer":"I think it would be better to go with the set implementation. I know for a fact that sets have O(1) lookup time. I think lists take O(n) lookup time. But even if lists are also O(1) lookup, you lose nothing with switching to sets.\nFurther, sets don't allow duplicate values. This will make your program slightly more memory efficient as well","Q_Score":34,"Tags":"python,list,search,find,set","A_Id":5993682,"CreationDate":"2011-05-13T14:45:00.000","Title":"Fastest way to search a list 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},{"Question":"When you do something like \"test\" in a where a is a list does python do a sequential search on the list or does it create a hash table representation to optimize the lookup? In the application I need this for I'll be doing a lot of lookups on the list so would it be best to do something like b = set(a) and then \"test\" in b? Also note that the list of values I'll have won't have duplicate data and I don't actually care about the order it's in; I just need to be able to check for the existence of a value.","AnswerCount":4,"Available Count":2,"Score":1.0,"is_accepted":false,"ViewCount":59073,"Q_Id":5993621,"Users Score":12,"Answer":"\"test\" in a with a list a will do a linear search. Setting up a hash table on the fly would be much more expensive than a linear search. \"test\" in b on the other hand will do an amoirtised O(1) hash look-up.\nIn the case you describe, there doesn't seem to be a reason to use a list over a set.","Q_Score":34,"Tags":"python,list,search,find,set","A_Id":5993671,"CreationDate":"2011-05-13T14:45:00.000","Title":"Fastest way to search a list 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},{"Question":"I am preparing a Test or Quiz in Django. The quiz needs to be completed in certain time frame. Say 30 minutes for 40 questions.I can always initiate a clock at start of the test, and then calculate time by the time the Quiz is completed. However it's likely that during the attempt, there may be issues such as internet connection drops, or system crashes\/power outages etc.\nI need a strategy to figure out when such an accident happened, and stop the clock, then let the user take the test again from where it stopped, and start the clock again.\nWhat is the right strategy? Any help including sample code\/examples\/ideas are most welcome","AnswerCount":4,"Available Count":4,"Score":0.0996679946,"is_accepted":false,"ViewCount":466,"Q_Id":5995674,"Users Score":2,"Answer":"Either you do the clock on the client side, in which case they can always cheat somehow, or you do it on the server side, and then you aren't taking into account these interruptions.\nTo reduce cheating somewhat and still allow for interruptions, you could do a 'keep alive'.\nHere the client side code announces to the server that it is still there every so often, say every 5 seconds. The server side notes when it stops getting these messages, and pauses\/stops the clock. However it still has the start and end time, so you know how long it really took in wall time, and also how long it took while the client was supposedly there.\nWith these two pieces of information you could very easily track down odd behaviour and blacklist people. Blacklisted people might not be aware that they are blacklisted, but their quiz scores don't show up for other users of your quiz system.","Q_Score":4,"Tags":"python,django,session,timer","A_Id":5995769,"CreationDate":"2011-05-13T17:36:00.000","Title":"Timed Quiz: How to consider internet interruptions?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I am preparing a Test or Quiz in Django. The quiz needs to be completed in certain time frame. Say 30 minutes for 40 questions.I can always initiate a clock at start of the test, and then calculate time by the time the Quiz is completed. However it's likely that during the attempt, there may be issues such as internet connection drops, or system crashes\/power outages etc.\nI need a strategy to figure out when such an accident happened, and stop the clock, then let the user take the test again from where it stopped, and start the clock again.\nWhat is the right strategy? Any help including sample code\/examples\/ideas are most welcome","AnswerCount":4,"Available Count":4,"Score":0.0996679946,"is_accepted":false,"ViewCount":466,"Q_Id":5995674,"Users Score":2,"Answer":"The simplest way would be to add a timestamp when the person starts the quiz and then compare that to when they submit. Of course, this doesn't take into account connection drops, crashes, etc... like you mentioned.\nTo account for these issues I'd probably use something like node.js. Each client has \"check-in\" when they connect to the quiz. Then at regular intervals (every 1s, 10s, 1m, etc...) the client checks in. If at these intervals the client doesn't check-in you can assume they've had the connection drop. You could keep track of when they connect again and start the timer from where they left off.\nThis is my initial thought on how to keep track of connection drops and crashes. The same could be done with a front-end ajax call to a Django view.","Q_Score":4,"Tags":"python,django,session,timer","A_Id":5995763,"CreationDate":"2011-05-13T17:36:00.000","Title":"Timed Quiz: How to consider internet interruptions?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I am preparing a Test or Quiz in Django. The quiz needs to be completed in certain time frame. Say 30 minutes for 40 questions.I can always initiate a clock at start of the test, and then calculate time by the time the Quiz is completed. However it's likely that during the attempt, there may be issues such as internet connection drops, or system crashes\/power outages etc.\nI need a strategy to figure out when such an accident happened, and stop the clock, then let the user take the test again from where it stopped, and start the clock again.\nWhat is the right strategy? Any help including sample code\/examples\/ideas are most welcome","AnswerCount":4,"Available Count":4,"Score":1.2,"is_accepted":true,"ViewCount":466,"Q_Id":5995674,"Users Score":2,"Answer":"Your strategy should depend on importance of the test and ability to retake whole test.\n\nIs test\/quiz for fun or competence\/knowledge checking?\nAre you dealing with logged users?\nAre tests generated randomly from large poll of available questions?\n\nthese are the questions you need to answer yourself first.\nRemember that:\n\nmalicious user CAN simulate connection outage \/ power failure,\nonly clock you can trust is one on server side,\neverything on browser side can be manipulated (think firebug\/console js injection)\n\nMy approach would be:\n\nInform users that TIME is important factor and connection issues may not be taken into account when grade will be given...,\nServe only one question, wait for answer, serve another one,\nWhole test time should be calculated as SUM of each answer time:\n\nsave each \"question send\" \/ \"answer received\" timestamps and calculate answer time from it,\ntime between questions wouldn't count,\nyou'd get extra scope on which questions was harder \/ took longer to answer.\n\nAdd some kind of heartbeat to your question page (like ajax request every X seconds), when heartbeat stops you can (depending on options you have):\n\ninvalidate question and notify user via dialog that he has connection issues and have to refresh to get new question instead if you have larger poll of questions to use,\npause time on server side (and for example dim question page so user cannot answer until his connection is restored) IMO only for games\/fun quiz\/tests\nsave information on server side on each interruption which would later ease decision to allow retake whole test e.g. he was fine until 20th question and then on 3-4 easy questions in a row he was dropping...","Q_Score":4,"Tags":"python,django,session,timer","A_Id":6015282,"CreationDate":"2011-05-13T17:36:00.000","Title":"Timed Quiz: How to consider internet interruptions?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I am preparing a Test or Quiz in Django. The quiz needs to be completed in certain time frame. Say 30 minutes for 40 questions.I can always initiate a clock at start of the test, and then calculate time by the time the Quiz is completed. However it's likely that during the attempt, there may be issues such as internet connection drops, or system crashes\/power outages etc.\nI need a strategy to figure out when such an accident happened, and stop the clock, then let the user take the test again from where it stopped, and start the clock again.\nWhat is the right strategy? Any help including sample code\/examples\/ideas are most welcome","AnswerCount":4,"Available Count":4,"Score":0.0,"is_accepted":false,"ViewCount":466,"Q_Id":5995674,"Users Score":0,"Answer":"The problem with pausing the clock when the connection to the user drops, is that the user could just disconnect their computer from the internet each time they received a new question, and then reconnect once they had worked out the answer.\nOne thing you could do, is give the user a certain amount of time for each question.\nThe clock is started when the user successfully receives the question to their browser, and if the user submits an answer before the time limit, it is accepted, otherwise it is void.\nThat would mean if a user lost connection it would only affect the question they are currently on. But it would also mean that the user would have no flexibility in how much time they want to allot to each question, you decide for them.\nI was thinking you could do something like removing the question from the screen unless the connection to the server was still alive, but the user could always just screen-shot the question before disconnecting.","Q_Score":4,"Tags":"python,django,session,timer","A_Id":5996776,"CreationDate":"2011-05-13T17:36:00.000","Title":"Timed Quiz: How to consider internet interruptions?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I have 1000s of custom (compiled to '.so') modules that I'd like to use in python at the same time. Each such module is of size (100 [KB]) on average.\nDoes anyone know what is the overhead (on the OS -- assuming python is not handling this) of every .so import? meaning, is the overhead equal to the size of the .so file on disk? or is it a fixed, regardless of the size of the .so file?\nI haven't yet gotten there, but would be curious to know what is the impact on the OS when one wants to import, say 10,000-50,000 custom modules at once.","AnswerCount":1,"Available Count":1,"Score":0.537049567,"is_accepted":false,"ViewCount":210,"Q_Id":6012105,"Users Score":3,"Answer":"There would be a large time overhead of importing that many shared libraries - the dynamic linker would spend a significant amount of time during the loading phase. The dynamic linker is really optimized for tens to hundreds of shared objects, not thousands to tens of thousands.\nIf at all possible, combine your shared code objects.\nHowever, the size once loaded is likely somewhat smaller than the one disk size, depending on what other information is in the file (DWARF debug symbols, extra ELF sections not required, etc).","Q_Score":3,"Tags":"python","A_Id":6012123,"CreationDate":"2011-05-16T00:00:00.000","Title":"Python -- Overhead of `.so` Imports?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have search for a while, and there is a function call get_image_dimensions(), however, as to my understanding, it works for the images which are downloaded or say local. So, any functions or solution like getimagesize in PHP, that we can just get the dimension of an image via URL, instead of path to local?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":2428,"Q_Id":6013996,"Users Score":1,"Answer":"PHP can open a URL as it does a file. This could be a boon (as in your case), or a bane (as in remote file inclusion vulnerability).\nPython opts to be explicit in that a file is a file, and a remote resource (URL, for example), is a remote one.\nIf you need some utility function to get image size from a remote resource, you probably need to write a wrapper to the local one. Usually you only need to read about 4096 bytes to determine the image size.\nA little more work, yes, but there's no magic like in PHP.","Q_Score":6,"Tags":"python,image,url,dimension","A_Id":6014083,"CreationDate":"2011-05-16T06:46:00.000","Title":"Is there a function for Python which like getimagesize 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},{"Question":"I have a python script that is using the SIGSTOP and .SIGCONT commands with os.kill to pause or resume a process. Is there a way to determine whether the related PID is in the paused or resumed state?","AnswerCount":3,"Available Count":1,"Score":0.2605204458,"is_accepted":false,"ViewCount":2298,"Q_Id":6021771,"Users Score":4,"Answer":"call ps and check the STAT value.\nD Uninterruptible sleep (usually IO)\nR Running or runnable (on run queue)\nS Interruptible sleep (waiting for an event to complete)\nT Stopped, either by a job control signal or because it is being traced.\nW paging (not valid since the 2.6.xx kernel)\nX dead (should never be seen)\nZ Defunct (\"zombie\") process, terminated but not reaped by its parent.","Q_Score":7,"Tags":"python,linux,process,controls,pid","A_Id":6021798,"CreationDate":"2011-05-16T18:35:00.000","Title":"Is there a way to determine if a Linux PID is paused or not?","Data Science and Machine Learning":0,"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},{"Question":"Is there any IDE that allows to run a script in testing mode, allowing to replace at runtime, some values, like a folder or else?\nI have a program that will have to run on a network i have no access to where I develop. Since it will use some specific folders to pick up files, I was wondering if i.e. I could use an IDE that using some parameters will translate all that is like \\corporate\\disk-c\\myfolder into a c:\\myfolder.\nThanks!\nM","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":110,"Q_Id":6023377,"Users Score":3,"Answer":"In absence of some other file based config, you could just keep the variable definitions in a a file that you import in the main script (e.g, config.py), then have two different versions of that file for 'on' and 'off' network, (or ' development' and 'production', whatever) with the appropriate settings. No IDE needed.","Q_Score":0,"Tags":"python,ide","A_Id":6024347,"CreationDate":"2011-05-16T21:00:00.000","Title":"IDE for Python: test a 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},{"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},{"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},{"Question":"I'm soon to start on a new project where I am going to do lots of text processing tasks like searching, categorization\/classifying, clustering, and so on. \nThere's going to be a huge amount of documents that need to be processed; probably millions of documents. After the initial processing, it also has to be able to be updated daily with multiple new documents.\nCan I use Python to do this, or is Python too slow? Is it best to use Java?\nIf possible, I would prefer Python since that's what I have been using lately. Plus, I would finish the coding part much faster. But it all depends on Python's speed. I have used Python for some small scale text processing tasks with only a couple of thousand documents, but I am not sure how well it scales up.","AnswerCount":4,"Available Count":3,"Score":0.0996679946,"is_accepted":false,"ViewCount":10439,"Q_Id":6030291,"Users Score":2,"Answer":"it's not language you have to evaluate, but frameworks and app servers for clustering, data storage\/retrieval etc available for the language.\nyou can use jython and use all the java enterprise technologies for high load system and do text parsing with python.","Q_Score":10,"Tags":"java,python,nlp,information-retrieval,text-mining","A_Id":6030342,"CreationDate":"2011-05-17T11:46:00.000","Title":"Python or Java for text processing (text mining, information retrieval, natural language processing)","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I'm soon to start on a new project where I am going to do lots of text processing tasks like searching, categorization\/classifying, clustering, and so on. \nThere's going to be a huge amount of documents that need to be processed; probably millions of documents. After the initial processing, it also has to be able to be updated daily with multiple new documents.\nCan I use Python to do this, or is Python too slow? Is it best to use Java?\nIf possible, I would prefer Python since that's what I have been using lately. Plus, I would finish the coding part much faster. But it all depends on Python's speed. I have used Python for some small scale text processing tasks with only a couple of thousand documents, but I am not sure how well it scales up.","AnswerCount":4,"Available Count":3,"Score":0.1488850336,"is_accepted":false,"ViewCount":10439,"Q_Id":6030291,"Users Score":3,"Answer":"Just write it, the biggest flaw in programming people have is premature optimization. Work on a project, write it out and get it working. Then go back and fix the bugs and ensure that its optimized. There are going to be a number of people harping on about speed of x vs y and y is better than x but at the end of a day its just a language. Its not what a language is but how it does it.","Q_Score":10,"Tags":"java,python,nlp,information-retrieval,text-mining","A_Id":6030330,"CreationDate":"2011-05-17T11:46:00.000","Title":"Python or Java for text processing (text mining, information retrieval, natural language processing)","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I'm soon to start on a new project where I am going to do lots of text processing tasks like searching, categorization\/classifying, clustering, and so on. \nThere's going to be a huge amount of documents that need to be processed; probably millions of documents. After the initial processing, it also has to be able to be updated daily with multiple new documents.\nCan I use Python to do this, or is Python too slow? Is it best to use Java?\nIf possible, I would prefer Python since that's what I have been using lately. Plus, I would finish the coding part much faster. But it all depends on Python's speed. I have used Python for some small scale text processing tasks with only a couple of thousand documents, but I am not sure how well it scales up.","AnswerCount":4,"Available Count":3,"Score":1.0,"is_accepted":false,"ViewCount":10439,"Q_Id":6030291,"Users Score":9,"Answer":"It's very difficult to answer questions like this without trying. So why don't you\n\nFigure out what would be a difficult operation\nImplement that (and I mean the simplest, quickest hack that you can make work)\nRun it with a lot of data, and see how long it takes\nFigure out if it's too slow\n\nI've done this in the past and it's really the way to see if something performs well enough for something.","Q_Score":10,"Tags":"java,python,nlp,information-retrieval,text-mining","A_Id":6030370,"CreationDate":"2011-05-17T11:46:00.000","Title":"Python or Java for text processing (text mining, information retrieval, natural language processing)","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"Is there a way beside checking for known signatures in the site content to find out what kind of software is the website running e.g vbbuliten,WP etc, preferably python.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":649,"Q_Id":6037379,"Users Score":0,"Answer":"Some sites will set the 'generator' meta-tag in the html head.","Q_Score":0,"Tags":"python","A_Id":6037452,"CreationDate":"2011-05-17T21:29:00.000","Title":"Detecting blog or forum software 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":1},{"Question":"Where should I see the logging output on Eclipse while debugging ? and when running ?","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":1139,"Q_Id":6044443,"Users Score":2,"Answer":"It will depends on how you configure your logging system. If you use only print statement, it should be shown in the console view of eclipse.\nIf you use logging and you configured a Console handler it should also be displayed in the console eclipse view.\nIf you configured only file handler in the logging configuration, you'll have to tail the log files ;)","Q_Score":0,"Tags":"python,eclipse,logging","A_Id":6045239,"CreationDate":"2011-05-18T12:10:00.000","Title":"Python logging module on 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":1},{"Question":"I'm creating data dumps from my site for others to download and analyze. Each dump will be a giant XML file.\nI'm trying to figure out the best compression algorithm that:\n\nCompresses efficiently (CPU-wise)\nMakes the smallest possible file\nIs fairly common\n\nI know the basics of compression, but haven't a clue as to which algo fits the bill. I'll be using MySQL and Python to generate the dump, so I'll need something with a good python library.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1128,"Q_Id":6067836,"Users Score":3,"Answer":"GZIP with standard compression level should be fine for most cases. Higher compression levels=more CPU time. BZ2 is packing better but is also slower. Well, there is always a trade-off between CPU consumption\/running time and compression efficiency...all compressions with default compression levels should be fine.","Q_Score":1,"Tags":"python,algorithm,compression,data-dump","A_Id":6067866,"CreationDate":"2011-05-20T05:33:00.000","Title":"What's the best compression algorithm for data dumps","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I have a website where people post comments, pictures, and other content. I want to add a feature that users can like\/unlike these items.\nI use a database to store all the content.\nThere are a few approaches I am looking at:\nMethod 1:\n\nAdd a 'like_count' column to the table, and increment it whenever someone likes an item\nAdd a 'user_likes' table to keep a track that everything the user has liked.\n\nPros: Simple to implement, minimal queries required.\nCons: The item needs to be refreshed with each change in like count. I have a whole list of items cached, which will break.\nMethod 2:\n\nCreate a new table 'like_summary' and store the total likes of each item in that table\nAdd a 'user_likes' table to keep a track that everything the user has liked.\nCache the like_summary data in memcache, and only flush it if the value changes\n\nPros: Less load on the main items table, it can be cached without worrying.\nCons: Too many hits on memcache (a page shows 20 items, which needs to be loaded from memcache), might be slow\nAny suggestions?","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":104,"Q_Id":6067919,"Users Score":1,"Answer":"You will actually only need the user_likes table. The like_count is calculated from that table. You will only need to store that if you need to gain performance, but since you're using memcached, It may be a good idea to not store the aggregated value in the database, but store it only in memcached.","Q_Score":0,"Tags":"python,architecture","A_Id":6067968,"CreationDate":"2011-05-20T05:46:00.000","Title":"What would be a good strategy to implement functionality similar to facebook 'likes'?","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},{"Question":"I have a website where people post comments, pictures, and other content. I want to add a feature that users can like\/unlike these items.\nI use a database to store all the content.\nThere are a few approaches I am looking at:\nMethod 1:\n\nAdd a 'like_count' column to the table, and increment it whenever someone likes an item\nAdd a 'user_likes' table to keep a track that everything the user has liked.\n\nPros: Simple to implement, minimal queries required.\nCons: The item needs to be refreshed with each change in like count. I have a whole list of items cached, which will break.\nMethod 2:\n\nCreate a new table 'like_summary' and store the total likes of each item in that table\nAdd a 'user_likes' table to keep a track that everything the user has liked.\nCache the like_summary data in memcache, and only flush it if the value changes\n\nPros: Less load on the main items table, it can be cached without worrying.\nCons: Too many hits on memcache (a page shows 20 items, which needs to be loaded from memcache), might be slow\nAny suggestions?","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":104,"Q_Id":6067919,"Users Score":1,"Answer":"One relation table that does a many-to-many mapping between user and item should do the trick.","Q_Score":0,"Tags":"python,architecture","A_Id":6067953,"CreationDate":"2011-05-20T05:46:00.000","Title":"What would be a good strategy to implement functionality similar to facebook 'likes'?","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},{"Question":"I am trying to use shutil.make_archive, but I get a \"module not found\" error.\nThen I tried using Python 2.7 and it worked.\nWhat is the lowest Python version that contains that module and function?","AnswerCount":3,"Available Count":1,"Score":0.1325487884,"is_accepted":false,"ViewCount":816,"Q_Id":6075361,"Users Score":2,"Answer":"Python 2.7 is the earliest release to include make_archive in shutils. shutils in general existed since at least 2.0.","Q_Score":2,"Tags":"python,linux,shutil","A_Id":6075406,"CreationDate":"2011-05-20T17:08:00.000","Title":"What is the lowest version of Python that has the shutil 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},{"Question":"How to clear Python shell ?\nI am writing a module in python, I want to save it in a file. what is the best way to do it?","AnswerCount":4,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":7935,"Q_Id":6078181,"Users Score":0,"Answer":"Just copy and paste the code into a new file (In file), and save it. To run, you can go to the run section and select \"Run Module\", or you can simply press F5.","Q_Score":0,"Tags":"python-3.x,python-idle","A_Id":23234123,"CreationDate":"2011-05-20T22:27:00.000","Title":"Clearing Python 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":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"How to clear Python shell ?\nI am writing a module in python, I want to save it in a file. what is the best way to do it?","AnswerCount":4,"Available Count":3,"Score":0.0996679946,"is_accepted":false,"ViewCount":7935,"Q_Id":6078181,"Users Score":2,"Answer":"Python shell does not get cleared or saved. Perhaps you are using IDLE. It's a confusing piece of software. I'd recommend you to get a real IDE, or at least a proper text editor.","Q_Score":0,"Tags":"python-3.x,python-idle","A_Id":6080090,"CreationDate":"2011-05-20T22:27:00.000","Title":"Clearing Python 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":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"How to clear Python shell ?\nI am writing a module in python, I want to save it in a file. what is the best way to do it?","AnswerCount":4,"Available Count":3,"Score":1.2,"is_accepted":true,"ViewCount":7935,"Q_Id":6078181,"Users Score":2,"Answer":"File -> New Window. Put your module in this new window, than save it. To run, just press F5.","Q_Score":0,"Tags":"python-3.x,python-idle","A_Id":6078245,"CreationDate":"2011-05-20T22:27:00.000","Title":"Clearing Python 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":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"It seems like typical crawlers that just download a small number of pages or do very little processing to decide what pages to download are IO limited.\nI am curious as to what order of magnitude estimates of sizes relevant data structures, number of stored pages, indexing requirements etc that might actually make CPU the bottleneck?\nFor example an application might want to calculate some probabilities based on the links found on a page in order to decide what page to crawl next. This function takes O(noOfLinks) and is evaluated N times (at each step)...where N is the number of pages I want to download in one round of crawling.I have to sort and keep track of these probabilities and i have to keep track of a list of O(N) that will eventually be dumped into disk and the index of a search engine. Is it not possible (assuming one machine) that N grows large enough and that storing the pages and manipulating the links gets expensive enough to compete with the IO response?","AnswerCount":4,"Available Count":4,"Score":0.0,"is_accepted":false,"ViewCount":210,"Q_Id":6079020,"Users Score":0,"Answer":"If you're using tomcat search for \"Crawler Session Manager Valve\"","Q_Score":0,"Tags":"java,c++,python,performance,web-crawler","A_Id":6081622,"CreationDate":"2011-05-21T01:26:00.000","Title":"In what scenarios might a web crawler be CPU limited as opposed to IO limited?","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},{"Question":"It seems like typical crawlers that just download a small number of pages or do very little processing to decide what pages to download are IO limited.\nI am curious as to what order of magnitude estimates of sizes relevant data structures, number of stored pages, indexing requirements etc that might actually make CPU the bottleneck?\nFor example an application might want to calculate some probabilities based on the links found on a page in order to decide what page to crawl next. This function takes O(noOfLinks) and is evaluated N times (at each step)...where N is the number of pages I want to download in one round of crawling.I have to sort and keep track of these probabilities and i have to keep track of a list of O(N) that will eventually be dumped into disk and the index of a search engine. Is it not possible (assuming one machine) that N grows large enough and that storing the pages and manipulating the links gets expensive enough to compete with the IO response?","AnswerCount":4,"Available Count":4,"Score":1.2,"is_accepted":true,"ViewCount":210,"Q_Id":6079020,"Users Score":2,"Answer":"Only when you are doing extensive processing on each page. eg if you are running some sort of AI to try to guess the semantics of the page.\nEven if your crawler is running on a really fast connection, there is still overhead creating connections, and you may also be limited by the bandwidth of the target machines","Q_Score":0,"Tags":"java,c++,python,performance,web-crawler","A_Id":6079060,"CreationDate":"2011-05-21T01:26:00.000","Title":"In what scenarios might a web crawler be CPU limited as opposed to IO limited?","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},{"Question":"It seems like typical crawlers that just download a small number of pages or do very little processing to decide what pages to download are IO limited.\nI am curious as to what order of magnitude estimates of sizes relevant data structures, number of stored pages, indexing requirements etc that might actually make CPU the bottleneck?\nFor example an application might want to calculate some probabilities based on the links found on a page in order to decide what page to crawl next. This function takes O(noOfLinks) and is evaluated N times (at each step)...where N is the number of pages I want to download in one round of crawling.I have to sort and keep track of these probabilities and i have to keep track of a list of O(N) that will eventually be dumped into disk and the index of a search engine. Is it not possible (assuming one machine) that N grows large enough and that storing the pages and manipulating the links gets expensive enough to compete with the IO response?","AnswerCount":4,"Available Count":4,"Score":0.049958375,"is_accepted":false,"ViewCount":210,"Q_Id":6079020,"Users Score":1,"Answer":"If the page contains pictures and you are trying to do face recognition on the pictures (ie to form a map of pages that have pictures of each person). That may be CPU bound because of the processing involved.","Q_Score":0,"Tags":"java,c++,python,performance,web-crawler","A_Id":6080282,"CreationDate":"2011-05-21T01:26:00.000","Title":"In what scenarios might a web crawler be CPU limited as opposed to IO limited?","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},{"Question":"It seems like typical crawlers that just download a small number of pages or do very little processing to decide what pages to download are IO limited.\nI am curious as to what order of magnitude estimates of sizes relevant data structures, number of stored pages, indexing requirements etc that might actually make CPU the bottleneck?\nFor example an application might want to calculate some probabilities based on the links found on a page in order to decide what page to crawl next. This function takes O(noOfLinks) and is evaluated N times (at each step)...where N is the number of pages I want to download in one round of crawling.I have to sort and keep track of these probabilities and i have to keep track of a list of O(N) that will eventually be dumped into disk and the index of a search engine. Is it not possible (assuming one machine) that N grows large enough and that storing the pages and manipulating the links gets expensive enough to compete with the IO response?","AnswerCount":4,"Available Count":4,"Score":0.0,"is_accepted":false,"ViewCount":210,"Q_Id":6079020,"Users Score":0,"Answer":"Not really. It takes I\/O to download these additional links, and you're right back to I\/O-limited again.","Q_Score":0,"Tags":"java,c++,python,performance,web-crawler","A_Id":6079035,"CreationDate":"2011-05-21T01:26:00.000","Title":"In what scenarios might a web crawler be CPU limited as opposed to IO limited?","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},{"Question":"I am doing backups in python script but i need to get the size of tar.gz file created in MB\nHow can i get the size in MB of that file","AnswerCount":5,"Available Count":1,"Score":0.0798297691,"is_accepted":false,"ViewCount":28504,"Q_Id":6080477,"Users Score":2,"Answer":"Use the os.stat() function to get a stat structure. The st_size attribute of that is the size of the file in bytes.","Q_Score":13,"Tags":"python,linux,file-io","A_Id":6080484,"CreationDate":"2011-05-21T08:10:00.000","Title":"How to get the size of tar.gz in (MB) 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":1,"Web Development":0},{"Question":"From what I know, when seeding or leeching torrent, your IP is on tracker and it remains there for some few hours or days How do I manually tell my the tracker using Libtorrent I am no longer going to be connected to the tracker and it should forget my IP as I am neither seeding nore leeching. Any code bits or advices would be appreciated, currently I am using Python binding provided by rasterbar but I am okay with C++ code too.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":659,"Q_Id":6081815,"Users Score":1,"Answer":"libtorrent automatically does this when stopping a torrent, or stopping the session. If it seems to fail, you might want to increase the tracker timeout when shutting down. This will add to the shutdown delay, but will give some more overloaded trackers some more time. See session_settings::stop_tracker_timeout. By default this is 5 seconds, but sometimes trackers take much longer than that to respond, up to 30 seconds.\nTrackers typically time out peers in about an hour, and you need to re-announce every 30 minutes to stay alive.\nIf you're trying to just send the stopped event to trackers, using a separate bittorrent client (in this case, assuming whatever client you're using fails to send stopped events to the trackers), it might be a bit less reliable.\nYou're supposed to include the info-hash (i.e. the unique identifier for the torrent), your key which the client generates on startup, peer-id (which is also generated by the client) and transfer statistics, in the tracker request.\nYou can get away with omitting the statistics, but if you don't know the info-hash or the client key, and in some cases the peer-id, the tracker won't be able to figure out that your request actually refers to your client's tracker request, and it won't remove your IP.\nIn practice, for the most part you might be able to get it to work by just knowing the info-hash and tracker URL. You can get the info-hash by loading the .torrent file, grabbing the info-hash and tracker URLs out of it.","Q_Score":0,"Tags":"c++,python,bittorrent,tracker","A_Id":6093419,"CreationDate":"2011-05-21T12:43:00.000","Title":"reporting end of seed or leeching to tracker Libtorrent","Data Science and Machine Learning":0,"Database and SQL":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},{"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},{"Question":"Working with Rasterbar libtorrent I dont want the downloaded data to sit on my hard drive rather a pipe or variable or something Soft so I can redirect it to somewhere else, Mysql, or even trash if it is not what I want, is there anyway of doing this in preferably python binding if not in C++ using Libtorrent?\nEDIT:--> I like to point out this is a libtorrent question not a Linux file handling or Python file handling question. I need to tell libtorrent to instead of save the file traditionally in a normal file save it to my python pipe or variable or etc.","AnswerCount":4,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":1739,"Q_Id":6089806,"Users Score":4,"Answer":"If you're on Linux, you could torrent into a tmpfs mount; this will avoid writing to disk. That said, this obviously means you're storing large files in RAM; make sure you have enough memory to deal with this.\nNote also that most Linux distributions have a tmpfs mount at \/dev\/shm, so you could simply point libtorrent to a file there.","Q_Score":3,"Tags":"c++,python,bittorrent","A_Id":6090293,"CreationDate":"2011-05-22T18:11:00.000","Title":"Keeping the downloaded torrent in memory rather than file libtorrent","Data Science and Machine Learning":0,"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},{"Question":"I want to customize robot framework test report, in order to fit my need.\nWhere can I find the related python source that handle this feature?\nOr I need to create a 3rd party library to handle this?","AnswerCount":4,"Available Count":2,"Score":0.1973753202,"is_accepted":false,"ViewCount":23583,"Q_Id":6120893,"Users Score":4,"Answer":"One method, kind of lame but workable, is to use the keyword, 'Set Test Message'. This lets you put text into the test message column of the report. Whenever the test passes, you will see the message. If it fails, you see the normal failure message. \nIt would be great to be able to dynamically insert a documentation line, though. I'd love to be able to have the keyword, \"Set Documentation Message\" so that in the keyword logic I could set it, instead of copying a '[Documentation] blah, blah, blah' onto every line that it applies to.","Q_Score":2,"Tags":"python,testing,robotframework","A_Id":9087623,"CreationDate":"2011-05-25T07:23:00.000","Title":"how to customize robot framework test reports","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I want to customize robot framework test report, in order to fit my need.\nWhere can I find the related python source that handle this feature?\nOr I need to create a 3rd party library to handle this?","AnswerCount":4,"Available Count":2,"Score":0.1973753202,"is_accepted":false,"ViewCount":23583,"Q_Id":6120893,"Users Score":4,"Answer":"One solution is to create your own report from scratch. The XML output is very easy to parse. You can turn off the generation of reports with command line options (eg: --log NONE and --report NONE). Then, create a script that generates any type of report that you want.","Q_Score":2,"Tags":"python,testing,robotframework","A_Id":7626579,"CreationDate":"2011-05-25T07:23:00.000","Title":"how to customize robot framework test reports","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I'm using imaplib for my project because I need to access gmails accounts.\nFact: With gmail's labels each message may be on an arbitrary number of folders\/boxes\/labels.\nThe problem is that I would like to get every single label from every single message.\nThe first solution it cames to my mind is to use \"All Mail\" folder to get all messages and then, for each message, check if that message is in each one of the available folders.\nHowever, I find this solution heavy and I was wondering if there's a better way to do this.\nThanks!","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":5550,"Q_Id":6123164,"Users Score":0,"Answer":"in imap you don't have labels, gmail 'emulates' them on imap, you can low at the raw source of a message picked from imap an check if it has some custom header with the label","Q_Score":9,"Tags":"python,gmail,imaplib","A_Id":6128926,"CreationDate":"2011-05-25T10:41:00.000","Title":"Python\/imaplib - How to get messages' labels?","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},{"Question":"I've just installed a base gentoo stage 3 and I get the following error when i try and call time.time():\n\nsbx \/ # python\nimport time\nPython 2.7.1 (r271:86832, May 22 2011, 14:53:09)\n[GCC 4.4.5] on linux2\nType \"help\", \"copyright\", \"credits\" or \"license\" for more information.\n>>> import time\n>>> time.time()\nTraceback (most recent call last):\n File \"\", line 1, in \nIOError: [Errno 0] Error\n\nI found this because when I try and run emerge I get:\n\nsbx \/ # emerge\nTraceback (most recent call last):\n File \"\/usr\/bin\/emerge\", line 32, in \n from _emerge.main import emerge_main\n File \"\/usr\/lib\/portage\/pym\/_emerge\/main.py\", line 6, in \n import logging\n File \"\/usr\/lib\/python2.7\/logging\/__init__.py\", line 94, in \n _startTime = time.time()\nIOError: [Errno 11] Resource temporarily unavailable\n\nThis is a custom kernel and I just made sure I compiled in RTC support, but still no luck. Any ideas on why this is happening?","AnswerCount":2,"Available Count":1,"Score":0.2913126125,"is_accepted":false,"ViewCount":757,"Q_Id":6129054,"Users Score":3,"Answer":"Did it work before your custom kernel? Boot into a rescue CD, chroot into your gentoo env, and run your script. If it works, it's your kernel. That's about as specific as I can be.","Q_Score":2,"Tags":"python,linux,gentoo","A_Id":6129347,"CreationDate":"2011-05-25T18:26:00.000","Title":"Python time.time() -> IOError","Data Science and Machine Learning":0,"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},{"Question":"I am reading a little bit on Objective-C, and since it comes from Smalltalk, like Ruby does, so I wonder, is it true that if using Ruby, (if Apple change XCode to support it), to develop iPhone or Mac app, it is not suitable really because of the speed? For example, Angry Birds probably isn't as smooth as it is now if using Ruby, vs if Objective-C, it is compiled and running as machine code.\nBut currently, is there any way of compiling Ruby or Python code into machine code so that it is running in the similar speed zone as Objective-C programs can?","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":1121,"Q_Id":6129086,"Users Score":1,"Answer":"Python and Ruby themselves are not too fast, but many programs today are written to basically do none of the heavy lifting alone. For instance, if you want to save a PNG file as a JPG, you are certainly going to use the built in system calls to do it. In that case it does not really matter if it takes 0.00001 seconds in Obj-C, or 0.001 seconds in Python to process the mouse click, when the optimized system code to convert the image is the exact same code in both programs, and takes, say 1\/2 a second to run. On the other hand if you are making a low level data munger of your own design, then you might want some C. Basically all languages that you would use on a Mac allow you to write something in C, and call it from that language, so even that does not slow you down. \nPick the language for the task based usually on what everyone else is doing for that problem, intersected with your abilities.","Q_Score":1,"Tags":"python,objective-c,ruby,ios","A_Id":6129509,"CreationDate":"2011-05-25T18:28:00.000","Title":"Is Ruby or Python not suitable for iPhone or Mac app development because of speed, and any compiler that can help boost the speed?","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},{"Question":"My Python backend (Django) has to request to a C++ library to get a result (with help of ctypes module).\nIs it normal to call a C++ method directly? Or may be I need an intermediate thread manager that starts a new thread when python script wants a result?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":339,"Q_Id":6129383,"Users Score":2,"Answer":"Basically you have to decide what kind of operation flow you want. If you prefer synchronous processing you can call you method directly, if you favor asynchronous processing you will need an intermediate solution.\nHowever, you have to be aware, that when you call the C++ routine directly form your Django app the call will end in the execution path that is triggered via the web application. If the processing takes more time than you want to wait, a job management system will be the better choice.\nIn any case I would recommend such a solution if the execution of your C++ routine takes too much time. You could then use polling to wait until the result is ready using e.g. Web Sockets.","Q_Score":2,"Tags":"c++,python,django,ctypes,backend","A_Id":6129485,"CreationDate":"2011-05-25T18:54:00.000","Title":"High Perfomance: Do call C++ methods directly from a python backend?","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},{"Question":"I added a print line to a python script while the script was executing, and now all the text is highlighted in red when I open the file. Opening and closing the file doesn't get rid of it. Opening a second python file momentarily fixed the problem, but then closing file and reopening brought the problem back. Now it wont go away at all. Any body know what could cause this?","AnswerCount":5,"Available Count":1,"Score":0.1194272985,"is_accepted":false,"ViewCount":10751,"Q_Id":6129789,"Users Score":3,"Answer":"Old thread, but hope this helps.\nBy mistake I did a \"\/.\" on my vim screen, which highlighted all lines in red. If I open any other file, the red highlighting stays. \nTry searching for some other keyword, let's say \"\/word\" - doesn't matter word exists or not. It restores the color.","Q_Score":5,"Tags":"python,vim,vi","A_Id":42373091,"CreationDate":"2011-05-25T19:30:00.000","Title":"vim highlighting everything in red","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Why would a Comet Server like Tornado be especially prone to memory leaks if written in PHP?\nAre there genuine weaknesses particular to PHP for implementing a long polling framework\/service like Tornado?\nThanks","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":254,"Q_Id":6131620,"Users Score":4,"Answer":"The gist of it is that PHP was originally written with the intent of having a brand new process for every request that you could just throw away once said request ended, at a time where things like Comet and long polling weren't really on the table.\nAs such there are quite a few areas - notably the garbage collector - where at its origin PHP just wasn't made for running during a long period of time, and it didn't care much because every http request got a brand new php instance.\nIt got clearly better in the recent years, but I still wouldn't use it for creating that sort of long-lifetime applications.","Q_Score":3,"Tags":"php,python,comet,tornado,long-polling","A_Id":6132278,"CreationDate":"2011-05-25T22:13:00.000","Title":"Memory Leaks Comet Server 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":1,"Web Development":0},{"Question":"First off , this isn't a homework assignment!!! :p What I want to do is this:\nGiven a data file(be it text or numbers) saved on the desktop i.e., I want to be able to search that file and pull out only the data I want and print it to the screen. I may want to do other stuff with it but I have no idea what options there are.\nAlso, would python or c++ be more appropriate. I'm not familiar much with python and it's been years since I've picked up c++ but I've heard that python is more efficient and although this program's efficiency may or may not be a big deal I have heard python is much easier to understand.\nExamples,Code, Templates(<-- would be awesome)\nThanks all!","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":407,"Q_Id":6146359,"Users Score":1,"Answer":"C++ will be faster (maybe, if you write it well), but, it will be harder, but easier to start since you know it.\nPython will take some time to get used to, and it will probably run a wee bit slower, but, will be easier (once you learn the language).\nThis is a very easy problem solved numerous times, so, what language you pick really doesn't matter.\nIf you like a GUI, then look at GUI libraries.","Q_Score":0,"Tags":"c++,python,search","A_Id":6146444,"CreationDate":"2011-05-26T23:50:00.000","Title":"Searching a data file: coding in python vs 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},{"Question":"Unfortunately, I'm working with an extremely large corpus which is spread into hundreds of .gz files -- 24 gigabytes (packed) worth, in fact. Python is really my native language (hah) but I was wondering if I haven't run up against a problem that will necessitate learning a \"faster\" language?\nEach .gz file contains a single document in plain text, is about 56MB gzipped, and about 210MB unzipped. \nOn each line is an n-gram (bigram, trigram, quadrigram, etc.) and, to the right, a frequency count. I need to basically create a file that stores the substring frequencies for each quadrigram alongside its whole-string frequency count (i.e., 4 unigram frequencies, 3 bigram frequencies, and 2 trigram frequencies for a total of 10 data points). Each type of n-gram has its own directory (e.g., all bigrams appear in their own set of 33 .gz files).\nI know an easy, brute force solution, and which module to import to work with gzipped files in Python, but I was wondering if there was something that wouldn't take me weeks of CPU time? Any advice on speeding this process up, however slightly, would be much appreciated!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":433,"Q_Id":6147504,"Users Score":1,"Answer":"It would help to have an example of a few lines and expected output. But from what I understand, here are some ideas.\nYou certainly don't want to process all files every time you process a single file or, worse, a single 4-gram. Ideally you'd go through each file once. So my first suggestion is to maintain an intermediate list of frequencies (these sets of 10 data points), where they first only take into account one file. Then when you process the second file, you'll update all the frequencies for items that you encounter (and presumably add new items). Then you'll keep going like this, increasing frequencies as you find more matching n-grams. At the end write everything out.\nMore specifically, at each iteration I would read a new input file into memory as a map of string to number, where the string is, say, a space-separated n-gram, and the number is its frequency. I would then process the intermediate file from the last iteration, which would contain your expected output (with incomplete values), e.g. \"a b c d : 10 20 30 40 5 4 3 2 1 1\" (kind of guessing the output you are looking for here). For each line, I'd look up in the map all the sub-grams in my map, update the count, and write out the updated line to the new output file. That one will be used in the next iteration, until I've processed all input files.","Q_Score":4,"Tags":"python,gzip,large-files,large-data-volumes,corpus","A_Id":6148016,"CreationDate":"2011-05-27T03:19:00.000","Title":"Python - Search for items in hundreds of large, gzipped 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},{"Question":"I need to send a binary file (or a Bitmap object) from Android to a PC, which runs a Python script to receive it. \nHas anybody been in the same situation or has any hints, what could be best practice here? Options are sockets or Webservice (besides from workarounds with samba etc) I guess, but what is the easiest and fastest to implement?\nCheers,\nMarc","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":490,"Q_Id":6151335,"Users Score":1,"Answer":"Just doing a HTTP POST containing data to a web server should do the job. This way you have a myriad of frameworks to choose from, which saves you from doing the dirty work of pushing bits back and forth. Sure, there is some overhead, but unless you have specific reasons to avoid that (which were not mentioned in the question), I think this is the most straightforward approach.\nAdditionally, when the application grows, you can extend this to a full REST style interface later on.","Q_Score":2,"Tags":"java,android,python,networking,binaryfiles","A_Id":6151433,"CreationDate":"2011-05-27T11:03:00.000","Title":"How to best send binary file from Android to Python script on PC?","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},{"Question":"I am trying to send sms using python and a GSM modem connected to my local machine, I have successfully sent the SMS using AT commands but now I have a technical problem for which I need help, the server of my website is located in United States while I live in Australia, so if I want to use the SMS feature on actual site I have to fly all the way to USA and attach the modem to my server, I just want to know if there is a simple solution for my problem, something like passing request from server to my machine and send SMS from my local machine.\nThanks in Advance.","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":1660,"Q_Id":6154409,"Users Score":2,"Answer":"A practical solution would be to connect to SMS gateway service instead of implementing your own service. Nowadays they are really cheap or even free.","Q_Score":1,"Tags":"python,gsm,at-command","A_Id":6154435,"CreationDate":"2011-05-27T15:26:00.000","Title":"Sending SMS 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},{"Question":"What is the difference in how they are handled?\nSpecifically, why is it common to find Python used in production-level long lived applications like web-servers while PHP isn't given their similar efficiency levels?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1270,"Q_Id":6158033,"Users Score":8,"Answer":"PHP was designed as a hypertext scripting language. Every process was designed to end after a very short time. So memory management and GC basically didn't matter.\nHowever the ease and popularity of PHP have invoked its usage in long lived programs such as daemons, extensive calculations, socket servers etc.\nPHP 5.3 introduced a lot of features and fixes that made it suitable for such applications, however in my opinion memory management was of lower significance on that matter.\nPHPs error management is quite good now, but as in every programming language that I know of you can produce memory leaks.\nYou still cannot code in the same style that you can code Java or Python applications. A lot of PHP programs will probably show severe problems where Java\/Python do not. \nYou can characterize this as \"worse\", but I would not. PHP just is a different set of tools that you have to handle different. \nThe company I work at has a lot of system programs and daemons written in PHP that run like a charm.\nI think the biggest caveat for PHP when it comes to as you describe \"production-level long lived applications\" is its multi-processing and threading ability (the 2nd is basically nonexistent). \nOf course there is the possibility to fork processes, access shared memory, do inter process communications and have message queues and stuff. But Python is far ahead on that matter, because it was designed bottom up for jobs like that.","Q_Score":9,"Tags":"php,python,memory-management,garbage-collection,webserver","A_Id":6208958,"CreationDate":"2011-05-27T21:46:00.000","Title":"How is memory management in PHP different from that 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},{"Question":"Are there any methods in (C)Python to inspect the process' current memory usage? In particular, I'd like to determine the high-water mark of memory usage in a testing script, but if necessary I don't mind periodically checking memory usage and calculating the high water mark for myself.\nEDIT: I'm looking for either a pure-python solution, or something which works on OS X.","AnswerCount":4,"Available Count":1,"Score":0.049958375,"is_accepted":false,"ViewCount":7123,"Q_Id":6159053,"Users Score":1,"Answer":"you can use os.getpid() to get your current PID and then use that PID to find the process in the output of a subprocess calling top\/free\/ps etc.\ni'm not an OSX\/BSD expert, so im unsure of the flags to which command will give you memory usage by process","Q_Score":7,"Tags":"python,macos,memory-management","A_Id":6159207,"CreationDate":"2011-05-28T01:13:00.000","Title":"Is it possible to get a \"high water mark\" of memory usage 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":1,"System Administration and DevOps":0,"Web Development":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},{"Question":"I have a pure C module for Python and I'd like to be able to invoke it using the python -m modulename approach. This works fine with modules implemented in Python and one obvious workaround is to add an extra file for that purpose. However I really want to keep things to my one single distributed binary and not add a second file just for this workaround.\nI don't care how hacky the solution is.\nIf you do try to use a C module with -m then you get an error message No code object available for .","AnswerCount":4,"Available Count":2,"Score":-0.0996679946,"is_accepted":false,"ViewCount":3104,"Q_Id":6165824,"Users Score":-2,"Answer":"I think that you need to start by making a separate file in Python and getting the -m option to work. Then, turn that Python file into a code object and incorporate it into your binary in such a way that it continues to work.\nLook up setuptools in PyPi, download the .egg and take a look at the file. You will see that the first few bytes contain a Python script and these are followed by a .ZIP file bytestream. Something similar may work for you.","Q_Score":15,"Tags":"python","A_Id":6196366,"CreationDate":"2011-05-29T03:43:00.000","Title":"Getting python -m module to work for a module implemented 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},{"Question":"I have a pure C module for Python and I'd like to be able to invoke it using the python -m modulename approach. This works fine with modules implemented in Python and one obvious workaround is to add an extra file for that purpose. However I really want to keep things to my one single distributed binary and not add a second file just for this workaround.\nI don't care how hacky the solution is.\nIf you do try to use a C module with -m then you get an error message No code object available for .","AnswerCount":4,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":3104,"Q_Id":6165824,"Users Score":0,"Answer":"Does your requirement of single distributed binary allow for the use of an egg? If so, you could package your module with a __main__.py with your calling code and the usual __init__.py...\nIf you're really adamant, maybe you could extend pkgutil.ImpLoader.get_code to return something for C modules (e.g., maybe a special __code__ function). To do that, I think you're going to have to actually change it in the Python source. Even then, pkgutil uses exec to execute the code block, so it would have to be Python code anyway.\nTL;DR: I think you're euchred. While Python modules have code at the global level that runs at import time, C modules don't; they're mostly just a dict namespace. Thus, running a C module doesn't really make sense from a conceptual standpoint. You need some real Python code to direct the action.","Q_Score":15,"Tags":"python","A_Id":7943332,"CreationDate":"2011-05-29T03:43:00.000","Title":"Getting python -m module to work for a module implemented 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},{"Question":"What interpreters have been made using the PyPy Translator Toolchain besides PyPy itself?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":205,"Q_Id":6169726,"Users Score":3,"Answer":"The two most complete (besides the Python one) are Javascript and Prolog, but there are also Squeak, Scheme, Brainfuck, and Haskell in various levels of completeness.","Q_Score":4,"Tags":"interpreter,pypy,rpython","A_Id":6170275,"CreationDate":"2011-05-29T18:54:00.000","Title":"What interpreters have been made using the PyPy Translator Toolchain?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to work with PIL in my project but the pydev can't seem to find it in my project. First of all I can see it when I enter the python shell, I can import it and I see it in the python sys.path. Second, I Added it to the PYTHONPATH in eclipse.\nI restarted eclipse, but still, when I try to do \"from PIL import Image\" I am getting: \"unresolved import\". \nCan any one please help me here, all other packages I used until now worked great the same way.... and i really need to use PIL","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":7037,"Q_Id":6171749,"Users Score":9,"Answer":"Had the same problem here.\nGot it resolved by adding \/usr\/share\/pyshared to the Libraries tab in window->preferences->pydev->Interpreter - Python.\nThere were a lot of \/usr\/lib\/python* paths with the compiled libraries (the C stuff with python bindings) where included already, but not \/usr\/share... parts with the source.","Q_Score":13,"Tags":"python,django,eclipse,python-imaging-library,pydev","A_Id":6486750,"CreationDate":"2011-05-30T02:20:00.000","Title":"How do I add PIL to PyDev in Eclipse, so i could import it and use it in my 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":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Does anyone know what the complexity of the os.path.exists function is in python with a ext4 filesystem?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":810,"Q_Id":6176547,"Users Score":0,"Answer":"Chances are good that the complexity is O(n) with n being the depth in the filesystem (e.g. \/ would have n=1, \/something n=2, ...)","Q_Score":4,"Tags":"python,linux,complexity-theory,ext4","A_Id":6176569,"CreationDate":"2011-05-30T12:55:00.000","Title":"python: complexity of os.path.exists with a ext4 filesystem?","Data Science and Machine Learning":0,"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},{"Question":"After uploading a binary distribution of my Python C extension with python setup.py bdist upload, easy_install [my-package-name] fails on \"error: Couldn't find a setup script in \/tmp\/easy_install\/package-name-etc-etc\".\nWhat am I doing wrong?","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":23071,"Q_Id":6178664,"Users Score":1,"Answer":"Sometimes you don't actually really intend to easy_install the 'directory', which will look for a setup.py file.\nIn simple words, you may be doing easy_install xyz\/\nwhile what you really want to do is easy_install xyz","Q_Score":11,"Tags":"python,binary,easy-install,python-c-extension","A_Id":39579939,"CreationDate":"2011-05-30T16:29:00.000","Title":"easy_install fails on error \"Couldn't find setup script\" after binary upload?","Data Science and Machine Learning":0,"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},{"Question":"In the Python unittest framework, is there a way to pass a unit test if an exception wasn't raised, and fail with an AssertRaise otherwise?","AnswerCount":3,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":31748,"Q_Id":6181555,"Users Score":3,"Answer":"Simply call your functionality, e.g. do_something(). If an unhandled exception gets raised, the test automatically fails! There is really no reason to do anything else. This is also the reason why assertDoesNotRaise() does not exist.\n\nCredit: comment by Sven","Q_Score":26,"Tags":"python,unit-testing","A_Id":45474275,"CreationDate":"2011-05-30T23:23:00.000","Title":"Pass a Python unittest if an exception isn't 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},{"Question":"I want to choose an embedded scripting language that i will use on C++. It should connect a database such as Oracle. My host application is a server application. That will pass raw data to script. The script will parse and do some specific logics. Also updates database. Then script will returns raw data as result.\nCan you help me to choose it?\nThanx","AnswerCount":6,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":10847,"Q_Id":6188798,"Users Score":2,"Answer":"TCL would be another option for an easy to embed scripting language. \npersonally I'd go with the scripting language you and\/or whoever will be using the scripting language is most familiar with already, especially if end users will be able to run custom scripts, you will need to know what, if any, languages they are familiar with in their business domain e.g. CAD\/CAM people may know TCL, gaming people may know Lua etc.","Q_Score":9,"Tags":"c++,python,ruby,scripting,lua","A_Id":6190078,"CreationDate":"2011-05-31T14:05:00.000","Title":"Choosing embedded scripting language for 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":0,"Web Development":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},{"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},{"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},{"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},{"Question":"The engine I've been wanting to remake is from a PlayStation 1 game called Final Fantasy Tactics, and the game is basically a 2.5D game I guess you could say. Low-resolution sprites and textures, and 3D maps for battlefields. The plan is to mainly load the graphics from a disc, or .iso (I already know the sectors the graphics need to be read from) and fill in the rest with game logic and graphics routines, and probably load other things from the disc like the map data.\nI want this to be a multiplatform project, because I use Linux and would like for more people to join in on the project once I have enough done (and it's easy to get more people through platforms like Windows). I'll be making a website to host the project. Also, none of the graphics will be distributed, they'll have to be loaded from your own disc. I'd rather not have to deal with any legal issues.. At least not soon after the project is hosted on my site. \nBut anyway, here's my dilemma- I know quite a bit of Java, and some Python, but I'm worried about performance\/feature issues if I make this engine using one of these two languages. I chose them due to familiarity and platform independence, but I haven't gotten too into graphics programming yet. I'm very much willing to learn, however, and I've done quite a bit of ASM work on the game- looking at graphics routines and whatnot. What would be the best route to take for a project like this? Oh, and keep in mind I'll eventually want to add higher-resolution textures in an .iso restructuring patch or something.\nI'm assuming based on my results on Google that I could go with something like Pygame + OpenGL, JOGL, Pyglet, etc. Any suggestions on an API? Which has plenty of documentation\/support for game or graphics programming? Do they have any serious performance hits?\nThank you for your time.","AnswerCount":3,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":213,"Q_Id":6195508,"Users Score":0,"Answer":"I'd recommend going with PySFML, and, of course, Python.\nIf you do your Python programming correctly , and if you really are willing to fiddle with C or ASM Python plugins for faster computations, you shouldn't really have too much performace hits.","Q_Score":1,"Tags":"java,python","A_Id":6195610,"CreationDate":"2011-06-01T02:04:00.000","Title":"Game Engine Remake - Trouble Choosing a Language \/API(Java or 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":0,"Web Development":1},{"Question":"The engine I've been wanting to remake is from a PlayStation 1 game called Final Fantasy Tactics, and the game is basically a 2.5D game I guess you could say. Low-resolution sprites and textures, and 3D maps for battlefields. The plan is to mainly load the graphics from a disc, or .iso (I already know the sectors the graphics need to be read from) and fill in the rest with game logic and graphics routines, and probably load other things from the disc like the map data.\nI want this to be a multiplatform project, because I use Linux and would like for more people to join in on the project once I have enough done (and it's easy to get more people through platforms like Windows). I'll be making a website to host the project. Also, none of the graphics will be distributed, they'll have to be loaded from your own disc. I'd rather not have to deal with any legal issues.. At least not soon after the project is hosted on my site. \nBut anyway, here's my dilemma- I know quite a bit of Java, and some Python, but I'm worried about performance\/feature issues if I make this engine using one of these two languages. I chose them due to familiarity and platform independence, but I haven't gotten too into graphics programming yet. I'm very much willing to learn, however, and I've done quite a bit of ASM work on the game- looking at graphics routines and whatnot. What would be the best route to take for a project like this? Oh, and keep in mind I'll eventually want to add higher-resolution textures in an .iso restructuring patch or something.\nI'm assuming based on my results on Google that I could go with something like Pygame + OpenGL, JOGL, Pyglet, etc. Any suggestions on an API? Which has plenty of documentation\/support for game or graphics programming? Do they have any serious performance hits?\nThank you for your time.","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":213,"Q_Id":6195508,"Users Score":0,"Answer":"At the end of the day if you're passionate about the project and committed to getting the most out of the language you choose, the performance difference between java and python will be minimal if non-existent.\nPersonally speaking, the biggest challenge is finishing the project once it loses novelty and initial momentum. I suggest you go with whichever language you're more passionate about and are interested in plumbing the depths of, or one that could boost your resume.\nSecondly, as you mention you're hoping to attract contributors, you may want to factor that into your decision. I can't comment much here, but have a look at similar projects with lots of activity.\nGood luck!","Q_Score":1,"Tags":"java,python","A_Id":6195870,"CreationDate":"2011-06-01T02:04:00.000","Title":"Game Engine Remake - Trouble Choosing a Language \/API(Java or 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":0,"Web Development":1},{"Question":"I will separate my business code into a script language. it would be Lua or Python. \nMy question is my business code written in script file is viewable by others.\nBecause of script file will not compiled that is open. Anyone can see it.\nHow can I hide it?\nI think if I use Python, it would be compiled (.pyo), but Lua looks like more suitable for me.","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":1177,"Q_Id":6197760,"Users Score":1,"Answer":"(For Lua)\nDepends on how safe it should be. For keeping out dumb edits you can just change the extension, and configure the path to recognize it anyhow.\nFor keeping out people who know how to change extensions, you can ship files compiled with luac. For deciphering that you already have to put considerable effort in it.\nBut to be really save I guess the only way is to encrypt\/sign the code, and perhaps modify the core such that it'll only run files who's signature checks out to be OK, or which can be decrypted.","Q_Score":3,"Tags":"python,lua,compilation,obfuscation","A_Id":6198605,"CreationDate":"2011-06-01T07:36:00.000","Title":"Compiling script files Lua 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},{"Question":"I will separate my business code into a script language. it would be Lua or Python. \nMy question is my business code written in script file is viewable by others.\nBecause of script file will not compiled that is open. Anyone can see it.\nHow can I hide it?\nI think if I use Python, it would be compiled (.pyo), but Lua looks like more suitable for me.","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":1177,"Q_Id":6197760,"Users Score":1,"Answer":"You will not be able to hide this easily. You can encrypt and decipher on the fly. The problem is that people will be able to look at you're process memory and see the code clear as day. If you want to prevent people from changing the lua you can create a hash which the text file is checked against on each run.","Q_Score":3,"Tags":"python,lua,compilation,obfuscation","A_Id":6197862,"CreationDate":"2011-06-01T07:36:00.000","Title":"Compiling script files Lua 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},{"Question":"I am doing various projects acroos diff computers , servers and diff languages like php python java etc.\nNow on every computer i have to install \/ download various supporting libraries like javascript libraries for PHP , Jar files for Java and many python modules.\nIs there way so that i can make online folder on server with only libraries and then automatically sync them across different computers. There may be some solution out there for this but i don't know it\nFor java and php there is no need to install them but i don't know whether python modules or libraraies work this way or not like south, PIL, matolib etc.\nIs there any thing which can help me with this","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":229,"Q_Id":6198941,"Users Score":0,"Answer":"For Java projects, you could give Maven a try, and configure you own repository on your server. Don't know if it can be used for the other languages, however.","Q_Score":1,"Tags":"java,php,python,linux,sync","A_Id":6199290,"CreationDate":"2011-06-01T09:23:00.000","Title":"How can keep my libraries , modules or jar files Synced across diff 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":1},{"Question":"Well, i do want to make a web app in php, where the user could create an account and log in, then download a desktop app made in python, log in there also with the username and the password from the web app and then run in tray. The purpose of this project is none, i want to do it for fun and practice, but i do have some problems. How i could link a web app to a desktop application? That desktop app should gather information about the user's system, harware memory used (like the windows rating) and then send it to the web app and display it in the user's panel. Any ideas ? thanks","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":227,"Q_Id":6200707,"Users Score":0,"Answer":"There are a million ways to do this. I suggest you write the local data gathering first, to know the amount and format of the data (and because getting Windows hardware information via Python seems to be the hardest part).\nThen write the web page login, to see if you can get HTTPS or have to take care of security yourself. With these constrains it is much easier to make a recommendation.","Q_Score":1,"Tags":"php,python","A_Id":6200853,"CreationDate":"2011-06-01T11:55:00.000","Title":"Python desktop app linked to PHP web 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":0,"Web Development":1},{"Question":"I have a package I am developing. This package is already installed as an egg file parked in the site-packages directory, egg path added to easy-install.pth. \nI now realized I have a bug in the package, so I invoked python setup.py develop to hook up the development dir. The path of the source dir is correctly added to easy-install.pth, but it's added latest, meaning that the already installed egg will be chosen and imported first with I issue import mypackage. \nHow can I have the development hook override the already installed package ? \nEventually, if I am doing it wrong, please explain what's the proper strategy to solve this use case.","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":6964,"Q_Id":6201503,"Users Score":1,"Answer":"I would use a virtual environment, that is, an isolated Python installation that is not affected by distributions installed system-wide. See virtualenv and virtualenvwrapper on PyPI.","Q_Score":16,"Tags":"python,distutils","A_Id":9918482,"CreationDate":"2011-06-01T12:57:00.000","Title":"python setup.py develop to override installed 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},{"Question":"If I schedule print \"Hello World!\"; to run every hour with crontab, where will Hello World! be printed? Is there a log file?\nIf I do it with Java or C instead of Python, will it make any difference?\nThanks!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":109,"Q_Id":6208274,"Users Score":2,"Answer":"They will be sent to the email address defined at the top of the crontab, or to the crontab's owner by default. See the crontab(5) man page for more details.","Q_Score":0,"Tags":"python,crontab","A_Id":6208294,"CreationDate":"2011-06-01T22:02:00.000","Title":"Where do scheduled python programs \"print\"?","Data Science and Machine Learning":0,"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},{"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},{"Question":"I have Jenkins running a python script that makes some SVN calls, my problem is that Jenkins tries to run this script as SYSTEM user which doesn't seem to have permission to access the SVN. It prompts me for a password for 'SYSTEM' upon my svn call.\nIf I run the python script by itself, I have no problems accessing the repository. Is there a way to have Jenkins run its Windows batch command as a non-SYSTEM user? I would rather not hardcode the SVN username and password in my script.\nEdit: I found a way to change the user Jenkins runs under, it is accessed through:\nStart > Control Panel > Administrative Tools > Services > Right Click, Properties for jenkins > Log On.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1833,"Q_Id":6208922,"Users Score":2,"Answer":"Create a new Jenkins job, and use Subversion as the revision control system. Put in the URL of the Subversion repository you want to manipulate in your Python script. Under the URL will appear a link to let you set the login. Click the link and log in.\nOnce you're done, you can delete the job. The whole purpose was to allow Jenkins to set up Subversion to allow that user to login in for that repository URL.","Q_Score":4,"Tags":"python,svn,windows-7,credentials,jenkins","A_Id":6209784,"CreationDate":"2011-06-01T23:34:00.000","Title":"SVN having credential problems with Jenkins running as 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},{"Question":"I want to develop an application targeting both android and iphone. I guess they use Java and Objective-C. Can I use single language like Python? Is it the best route? Will I lose performance, features, etc. by using Python. Are there any limitations that I will run into?","AnswerCount":4,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1256,"Q_Id":6216890,"Users Score":0,"Answer":"phonegap is one of the way that you can use to target the iphone & android.through the javascript,html.","Q_Score":3,"Tags":"python,android,iphone,beeware","A_Id":6217111,"CreationDate":"2011-06-02T15:47:00.000","Title":"target both android and iphone with 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":0,"Web Development":1},{"Question":"I have a ipy script that can be called either from an embedded console in a larger application or directly from the command line and I'm looking for a quick way to determine at run time which has occurred without having to pass an argument to differentiate the events. \nAdditionally the script has to run on both mono\/linux and .net\/windows.\nThanks in advance for any assistance.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":112,"Q_Id":6217545,"Users Score":1,"Answer":"You could use System.AppDomain.CurrentDomain.GetAssemblies() (assuming you don't use AppDomain isolation, of course) and see if that contains an assembly that would only be preset when your application is running.","Q_Score":0,"Tags":".net,mono,ironpython","A_Id":6218295,"CreationDate":"2011-06-02T16:49:00.000","Title":"How to detect in Iron Python what the script is being called from?","Data Science and Machine Learning":0,"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},{"Question":"I've setup an Amazon EC2 server. I have a Python script that is supposed to download large amounts of data from the web onto the server. I can run the script from the terminal through ssh, however very often I loose the ssh connection. When I loose the connection, the script stops.\nIs there a method where I tell the script to run from terminal and when I disconnect, the script is still running on the server?","AnswerCount":3,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":15157,"Q_Id":6232564,"Users Score":40,"Answer":"You have a few options.\n\nYou can add your script to cron to be run regularly.\nYou can run your script manually, and detach+background it using nohup.\nYou can run a tool such as GNU Screen, and detach your terminal and log out, only to continue where you left off later. I use this a lot.\n\nFor example:\n\nLog in to your machine, run: screen.\nStart your script and either just close your terminal or properly detach your session with: Ctrl+A, D, D.\nDisconnect from your terminal.\nReconnect at some later time, and run screen -rD. You should see your stuff just as you left it.\n\n\nYou can also add your script to \/etc\/rc.d\/ to be invoked on book and always be running.","Q_Score":23,"Tags":"python,amazon-ec2","A_Id":6232612,"CreationDate":"2011-06-03T20:53:00.000","Title":"How to continuously run a Python script on an EC2 server?","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},{"Question":"I tried using mechanize to see the URL of the image, but its a dynamic page generating a different image each time. I was wondering if there was any way to \"capture\" this image for viewing\/saving.\nThanks!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":540,"Q_Id":6232780,"Users Score":4,"Answer":"The only way to save the image would be to make a single call to the CATPCHA URL programatically, save the result, and then present that saved result to the user. The whole point of CAPTCHA is that each request generates a unique\/different reponse\/image.","Q_Score":0,"Tags":"python","A_Id":6232816,"CreationDate":"2011-06-03T21:17:00.000","Title":"Capturing CAPTCHA image 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":1},{"Question":"I have a list of objects in python that I would regularly check and destroy some of them - those which haven't been accessed lately (i.e. no method was called). \nI can maintain the last time accessed and update it in every method, but is there any more elegant way to achieve this?","AnswerCount":5,"Available Count":4,"Score":0.0,"is_accepted":false,"ViewCount":565,"Q_Id":6241448,"Users Score":0,"Answer":"What is the scope of your objects? Can you lock down where they are stored and accessed? If so, you should consider creating some kind of special container that will timestamp when the object was last used or accessed. Access to the objects would be tightly controlled by a function which could time-stamp last access time.","Q_Score":6,"Tags":"python,class,object,tracking","A_Id":6241493,"CreationDate":"2011-06-05T06:55:00.000","Title":"What's the most elegant way of keeping track of the last time a python object is accessed?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a list of objects in python that I would regularly check and destroy some of them - those which haven't been accessed lately (i.e. no method was called). \nI can maintain the last time accessed and update it in every method, but is there any more elegant way to achieve this?","AnswerCount":5,"Available Count":4,"Score":0.0798297691,"is_accepted":false,"ViewCount":565,"Q_Id":6241448,"Users Score":2,"Answer":"If you are using python 3.2 then have a look at functions.lru_cache() and see if that does what you want. It won't give you a last modified time, but it will do the cleanup of unused object.\nFor older versions it might provide the pattern you want to use but you'll have to provide the code.","Q_Score":6,"Tags":"python,class,object,tracking","A_Id":6241583,"CreationDate":"2011-06-05T06:55:00.000","Title":"What's the most elegant way of keeping track of the last time a python object is accessed?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a list of objects in python that I would regularly check and destroy some of them - those which haven't been accessed lately (i.e. no method was called). \nI can maintain the last time accessed and update it in every method, but is there any more elegant way to achieve this?","AnswerCount":5,"Available Count":4,"Score":0.0,"is_accepted":false,"ViewCount":565,"Q_Id":6241448,"Users Score":0,"Answer":"Keep a dict of the IMAP connections, keyed by the user ID. Write a function, that given a user ID, returns an IMAP connection. The function will look up the user ID in the dict, and if the user ID is there, get the corresponding IMAP connection, and check that it's still alive. If alive, the function returns that connection. If not alive, or if the user ID was not in the dict, it creates a new connection, adds it to the dict, and returns the new connection. No timestamps required.","Q_Score":6,"Tags":"python,class,object,tracking","A_Id":6243773,"CreationDate":"2011-06-05T06:55:00.000","Title":"What's the most elegant way of keeping track of the last time a python object is accessed?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a list of objects in python that I would regularly check and destroy some of them - those which haven't been accessed lately (i.e. no method was called). \nI can maintain the last time accessed and update it in every method, but is there any more elegant way to achieve this?","AnswerCount":5,"Available Count":4,"Score":0.0399786803,"is_accepted":false,"ViewCount":565,"Q_Id":6241448,"Users Score":1,"Answer":"Python's highly dynamic nature lets you write proxies that wrap objects in interesting ways. In this case, you could write a proxy that replaces the methods of an object (or an entire class) with wrapper methods that update a timestamp and then delegates the call to the original method.\nThis is somewhat involved. A simpler mechanism is to use Python decorators to augment specific methods. This also lets you exempt some functions that don't constitute an \"access\" when they are called (if you need this).","Q_Score":6,"Tags":"python,class,object,tracking","A_Id":6241480,"CreationDate":"2011-06-05T06:55:00.000","Title":"What's the most elegant way of keeping track of the last time a python object is accessed?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I need to use fabfile to remotely start some program in remote boxes from time to time, and get the results. Since the program takes a long while to finish, I wish to make it run in background and so I dont need to wait. So I tried os.fork() to make it work. The problem is that when I ssh to the remote box, and run the program with os.fork() there, the program can work in background fine, but when I tried to use fabfile's run, sudo to start the program remotely, os.fork() cannot work, the program just die silently. So I switched to Python-daemon to daemonalize the program. For a great while, it worked perfectly. But now when I started to make my program to read some Python shelve dicts, python-daemon cannot work any longer. Seems like if you use python-daemon, the shelve dicts cannot be loaded correctly, which I dont know why. Anyone has an idea besides os.fork() and Python-daemon, what else can I try to solve my problem?","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":2313,"Q_Id":6243933,"Users Score":2,"Answer":"For those who came across this post in the future. Python-daemon can still work. It is just that be sure to load the shelve dicts within the same process. So previously the shelve dicts is loaded in parent process, when python-daemon spawns a child process, the dict handler is not passed correctly. When we fix this, everything works again.\nThanks for those suggesting valuable comments on this thread!","Q_Score":3,"Tags":"python,fork,shelve,python-daemon","A_Id":6258988,"CreationDate":"2011-06-05T15:42:00.000","Title":"remotely start Python program in background","Data Science and Machine Learning":0,"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},{"Question":"I am using python struct module to create custom binary files.\nThe file itself has the following format:\n4 bytes (integer)\n1 byte (unsigned char)\n4 bytes (float) \n4 bytes (integer)\n1 byte (unsigned char)\n4 bytes (float) \n.......................... (100000 such lines)\n4 bytes (integer)\n1 byte (unsigned char)\n4 bytes (float) \n\nCurrently, I am using a 32bit machine to create these custom binary files. I am soon planning on switching to a 64bit machine.\nWill I be able to read\/write the same files using both {32bit \/ 64bit} machines? or should I expect compatibility issues?\n(I will be using Ubuntu Linux for both)","AnswerCount":3,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1348,"Q_Id":6244799,"Users Score":2,"Answer":"As long as your struct format string uses \"standard size and alignment\" (< or >) rather than \"native size and alignment\" (@), your files can be used cross-platform.","Q_Score":3,"Tags":"python,serialization,32bit-64bit","A_Id":6244838,"CreationDate":"2011-06-05T18:06:00.000","Title":"Binary Files on 32bit \/ 64bit systems?","Data Science and Machine Learning":0,"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},{"Question":"There's not really anything on my planned site that would require a whole lot of customization but I'm looking for something that has built in functionality for forums, comments, reviews, a blog, a database that can queried by users, and some social networking features.\nI have a decent amount of experience using python so I was thinking of using Django and also learning it in the process. I realize though that this would be much more time consuming than using a CMS.\nSo, part of me is inclined to use a PHP based CMS like worpress or drupal. I don't have any prior experience with PHP but since all the features I'm looking for are built in, do you think this would be my fastest route to get up and running?","AnswerCount":6,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":1735,"Q_Id":6244906,"Users Score":0,"Answer":"Drupal or Joomla are your best bet. Firstly, Joomla allows you to basically drop in these features you're asking for in an install an go manner. This is the easiest way to go.\nNow if you want a LOTS and LOTS customization and don't mind getting into a little code then drupal will be perfect.The great thing is that the customization possibilities are almost endless! The bad thing is that Drupal has a NOTORIOUSLY crazy templating system. It's not hard to understand but even simple things can become a real pain. But Like joomla you can avoid all this with install and go plugins. you'll have the choice.\nI don't know too much about wordpress, but having looked at the developer API, it seems to assume volumes about what you intend to build on top of it. Which makes it a lot less flexible than drupal and django.\nDjango, well according to your question... it's everything you don't want. Also if you have gone to any of the Django CMS sites you'll see how painful it is to get them up and running. That said I'm personally a Django fanatic but I'd rather you dint run into a bad experience with it and have a horrible impression of it. so given your question i'd say Drupal!","Q_Score":3,"Tags":"python,django,wordpress,content-management-system","A_Id":6245184,"CreationDate":"2011-06-05T18:25:00.000","Title":"CMS or web framework a simple 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":1},{"Question":"There's not really anything on my planned site that would require a whole lot of customization but I'm looking for something that has built in functionality for forums, comments, reviews, a blog, a database that can queried by users, and some social networking features.\nI have a decent amount of experience using python so I was thinking of using Django and also learning it in the process. I realize though that this would be much more time consuming than using a CMS.\nSo, part of me is inclined to use a PHP based CMS like worpress or drupal. I don't have any prior experience with PHP but since all the features I'm looking for are built in, do you think this would be my fastest route to get up and running?","AnswerCount":6,"Available Count":2,"Score":0.0333209931,"is_accepted":false,"ViewCount":1735,"Q_Id":6244906,"Users Score":1,"Answer":"Use a CMS, Drupal is very flexible and you can install another cms like vanilla for the forums options with a plugin.\nIt's al you need. But if you want a full control of your site, use a framwork like Django and you get all. \nRemenber, the CMS is the fastest way to build a site.\nSorry for my english mistakes.","Q_Score":3,"Tags":"python,django,wordpress,content-management-system","A_Id":6244936,"CreationDate":"2011-06-05T18:25:00.000","Title":"CMS or web framework a simple 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":1},{"Question":"I have a method in my script that pulls a Twitter RSS feed, parses it with FeedPharser, wraps it in TwiML (Twilio-flavored XML) using the twilio module, and returns the resulting response in a CherryPy method via str(). This works my fine in development environment (Kubuntu 10.10); I have had mixed results on my server (Ubuntu Server 10.10 on Linode).\nFor the first few months, all was well. Then, the method described above began to fail with something like:\n\nUnicodeEncodeError: 'ascii' codec\n can't encode character u'\\u2019' in\n position 259: ordinal not in\n range(128)\n\nBut, when I run the exact same code on the same feed, with the same python version, on the the same OS, on my development box, the code executes fine. However, I should note that even when it does work properly, some characters aren't outputted right. For example:\n\n\u00e2\u20ac\u2122 \n\nrather than \n\n'\n\nTo solve this anomaly, I simply rebuilt my VPS from scratch, which worked for a few more months, and then the error came back.\nThe server automatically installs updated Ubuntu packages, but so does my development box. I can't think of anything that could cause this. Any help is appreciated.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":238,"Q_Id":6246850,"Users Score":0,"Answer":"A few reboots later (for unrelated reasons) and it's working again. How odd....","Q_Score":2,"Tags":"python,cherrypy,feedparser","A_Id":6279095,"CreationDate":"2011-06-06T00:22:00.000","Title":"What could cause a UnicodeEncodeError exception to creep into a working Python 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},{"Question":"I'm copying files from the temporary internet files cache into a folder, in bulk using a python script. Using shutil to copy the full path to the os.cwd, it comes up with this error:\n\nbuiltins.IOError: [Errno 22] Invalid argument: \n'C:\\\\Users\\\\NICK\\\\AppData\\\\(no whitespace in path; only for readability)\nLocal\\\\Microsoft\\\\Windows\\\\(no whitespace in path; only for readability)\nTemporary Internet Files\\\\CONTENT.IE5\\\\04HT8Z5C\\\\024MS[1].png\\\\'\n\nIs it because these files are hidden or something?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":347,"Q_Id":6258064,"Users Score":1,"Answer":"There is a backslash at the end of your file name so it is maybe treated as a path.","Q_Score":0,"Tags":"python,shutil","A_Id":6258122,"CreationDate":"2011-06-06T21:10:00.000","Title":"Copying files from temporary internet cache 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},{"Question":"I'm fairly new to Python and was hoping I could get some advice before moving forward. I have a group of integers and I want to check whether or not a given element is contained within that group as fast as possible (speed does matter here).\nWith Python, should I be looking at custom data structures tailored for these operations (BST, etc), python trickery like wrapping with any(), or are there any well known Python\/C libraries that are standard for this sort of thing. I don't want to reinvent the wheel here, so I'm interested to hear the common way to approach this in Python.\nA little more background, elements are all inserted into the group up front, and none occur thereafter, so insertion time doesn't matter. This seems to imply that maintaining a sorted group and doing something like binary search will be the best approach, but I'm sure this has already been implemented much more efficiently than I could implement and is available in a Python\/C lib. Interested to hear what you guys think. \nThanks!","AnswerCount":2,"Available Count":2,"Score":1.0,"is_accepted":false,"ViewCount":116,"Q_Id":6266641,"Users Score":6,"Answer":"As DMS says in the comment, there's a built-in set (and the immutable variant, frozenset, which is very useful you don't need to mutate and can fit the generation of the values into a single generator expression). It's hash-based and therefore sacrifices order for amortized O(1) membership testing. It's written in C and more time went into making it fast than you could reasonably spend at all on it. If memory serves right, it's based on the dictionary implementation, which is propably among the fastet hash tables (for common usage) in existence.\nNote that the \"hash\" part will be O(1) too, as integers hash to themselves. The algorithms are tailored to handling \"non-random\" (e.g. somewhat consecutive) hashes very well.","Q_Score":2,"Tags":"python,c,performance,comparison,binary-search","A_Id":6266843,"CreationDate":"2011-06-07T14:20:00.000","Title":"Improving Python Comparison and Existence Operations","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm fairly new to Python and was hoping I could get some advice before moving forward. I have a group of integers and I want to check whether or not a given element is contained within that group as fast as possible (speed does matter here).\nWith Python, should I be looking at custom data structures tailored for these operations (BST, etc), python trickery like wrapping with any(), or are there any well known Python\/C libraries that are standard for this sort of thing. I don't want to reinvent the wheel here, so I'm interested to hear the common way to approach this in Python.\nA little more background, elements are all inserted into the group up front, and none occur thereafter, so insertion time doesn't matter. This seems to imply that maintaining a sorted group and doing something like binary search will be the best approach, but I'm sure this has already been implemented much more efficiently than I could implement and is available in a Python\/C lib. Interested to hear what you guys think. \nThanks!","AnswerCount":2,"Available Count":2,"Score":1.0,"is_accepted":false,"ViewCount":116,"Q_Id":6266641,"Users Score":6,"Answer":"The most Pythonic way would be to not store them in a sorted container, but to use a set (or the immutable variant frozenset). These are hash-based containers, so lookups are O(1). More importantly, the hashing algorithm is one of the core operations in Python (used for dictionaries, and attribute lookups), so it's written in C, and written to be fast.\nAnd that's usually the case with Python. Using the standard containers will be faster than rolling your own at the Python level, so try to use them as much as possible.\nIf you do want to store them in a sorted list, then look at the bisect module in the standard library. It has standard functions for binary searches. (Well, not actually. I actually returns the index of where the searched for item would be. You'll have to do the final comparison yourself.) And it may implement them in C (depending on your configuration), so it'll be faster than what you write on your own.","Q_Score":2,"Tags":"python,c,performance,comparison,binary-search","A_Id":6266828,"CreationDate":"2011-06-07T14:20:00.000","Title":"Improving Python Comparison and Existence Operations","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to work out a solution for detecting traceability between source code and documentation. The most important use case is that the user needs to see the a collection of source code tokens (sorted by relevance to the documentation) that can be traced back to the documentation. She is wont be bothered about the code format, but somehow needs to see an \"identifier- documentation\" mapping to get the idea of traceability. \nI take the tokens from source code files - somehow split the concatenated identifiers (SimpleMAXAnalyzer becomes \"simple max analyzer\"), which then act as search terms on the documentation. Search frameworks are best for doing this specific task - drilling down documents to locate stuff using powerful information retrieval algorithms. Whoosh looked really great python search... with a number of analyzer and filters. \nThough the problem is similar to search - it differs in that the user is not physically doing any search. So am I solving the problem the right way? Given that everything is static and needs to computed only once - am I using a wrong tool(a search framework) for the job?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":44,"Q_Id":6266899,"Users Score":0,"Answer":"I'm not sure, if I understand your use case. The user sees the source code and has some ways of jumping from a token to the appropriate part or a listing of the possible parts of the documentation, right?\nThen a search tool seems to be the right tool for the job, although you could precompile every possible search (there is only a limited number of identifiers in the source, so you can calculate all possible references to the docs in advance).\nOr are there any \"canonical\" parts of the documentation for every identifier? Then maybe some kind of index would be a better choice. \nMaybe you could clarify your use case a bit further.\nEdit: Maybe an alphabetical index of the documentation could be a step to the solution. Then you can look up the pages\/chapters\/sections for every token of the source, where all or most of its components are mentioned.","Q_Score":0,"Tags":"python","A_Id":6271510,"CreationDate":"2011-06-07T14:36:00.000","Title":"Design help for static content with fixed keywords search 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":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},{"Question":"I have a set of Python tests that run on TeamCity. I am able to get the test to run, however I cannot get TeamCity to produce a test report. How can I get TeamCity to produce a report of my tests?\nThanks","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":7336,"Q_Id":6269795,"Users Score":0,"Answer":"The test reports are to be generated by the test runner, not TeamCity. TeamCity will only look at the test report generated and use it for purposes like displaying info on the tests passed etc.","Q_Score":1,"Tags":"python,unit-testing,teamcity","A_Id":6269838,"CreationDate":"2011-06-07T18:16:00.000","Title":"Python Integration Testing on TeamCity","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"Now I use lxml to parse HTML in python. But I haven't found any API to get font information of a text node. Is there any librafy to do that?\nThanks very much!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":203,"Q_Id":6273635,"Users Score":0,"Answer":"You can't get this information from the text nodes in the HTML, because it isn't there.","Q_Score":0,"Tags":"python,html","A_Id":6274197,"CreationDate":"2011-06-08T02:38:00.000","Title":"How to get font of a HTML node 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},{"Question":"How do I get Tornado (or in general another server) to handle the .py files on my host, while Apache still handles the php files?","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":847,"Q_Id":6276805,"Users Score":0,"Answer":"So you have Apache as the web head and Tornado running behind it? Why not just use ProxyPass from port 80 to whatever port Tornado is running on. \nYou can't get Tornado to serve the .py files like PHP can do with .php files.","Q_Score":0,"Tags":"python,apache,webserver,tornado","A_Id":6289549,"CreationDate":"2011-06-08T09:39:00.000","Title":"Installed Tornado and Python but Apache is still handling .py 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":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have a CentOS 5.5 server running a local telnet daemon (which is only accessible from localhost) which prints out a list of active users on our accounting system when sent the correct commands through telnet. I need to make this information available on our intranet website which uses PHP. \nI've written a Python script using the telnetlib modules to run locally on the CentOS server which simply captures the output of the telnet command and prints them to stdout. I've setup key based ssh between the web server and the CentOS server to run the python script remotely from the web server. I can execute the script successfully from the web server using ssh and it prints the list of users to stdout on the webserver. I was hoping to be able to execute this SSH command and capture the results into a variable to display on the website. \nHowever, I can't get exec(), shell_exec(), passthru() or any other PHP exec function to display the data. I'm well aware that I may be approaching this from the totally wrong angle! What would be the best way to capture the output from ssh?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":899,"Q_Id":6282891,"Users Score":0,"Answer":"Why don't you redirect your stdout to a file. Then use your php website framework to read the file and display the results","Q_Score":0,"Tags":"php,python,ssh,telnet","A_Id":6283332,"CreationDate":"2011-06-08T17:37:00.000","Title":"Using PHP\/Python to access data from a remote telnet server 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},{"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},{"Question":"I have a libfoo.so library built from C++ code (compiled with gcc), and I would like to quickly test some of its exported classes (basically, instantiating a class then calling its methods to check the output).\nWhile I could do that in C\/C++ with a main file that links to the library in question and build my tests, but I think it would be much easier if it was possible to simply call Python from the command line and call the methods from there.\nI know I can use CDLL from ctypes to load C-style libraries, but is there a similar functionality for C++ libraries and objects?\nEDIT : Ideally, I do not want to modify the C++ code, I would need to use it as-is.","AnswerCount":2,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":2846,"Q_Id":6308649,"Users Score":10,"Answer":"Honestly C++ is a bit messy. You could do something like create a pure C function which wraps the C++ functionality (which you then call from python) but at that point you might as well write your tests in C++. Unfortunately the only tool out there for this (that I know of) is SWIG.\nIt's sad that it's called the \"simplified\" wrapper and interface generator, because there's nothing simple about it. If you have VERY primitive data types in your signatures (like, JUST ints or maybe char*) it'll be a pretty quick job. Otherwise you have to tell swig how to marshal your data types between languages, and that gets REALLY ugly very quickly. Furthermore, after short time you realize you have to learn the CPython API in order to write your marshalling code.\nAnd by that point you may as well write your own CPython wrapper without involving SWIG. You suddenly realize you've spent a good month learning a new API and feel horribly frustrated. If you're going to be doing this a lot, it's definitely worth your time. However if this is a one-time thing, just write your tests in C \/ C++.\n(I'm speaking from experience here)","Q_Score":4,"Tags":"c++,python,shared-libraries","A_Id":6308733,"CreationDate":"2011-06-10T15:33:00.000","Title":"Testing a C++ library 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},{"Question":"Im in the process of launching a Django app on ec2, but have hit a wall trying to install my code on my AMI instance. This is my situation: I have a bitnami AMI up and running that has Django, apache, Postgresql, and nearly all my dependancies pre installed, and I have my fully functional Django app running on my local machine that I have been testing thus far with the Django Dev server. After quite a bit of googling, the most common methods of installing an app to an ec2 instance seem either using ssh\/sftp\/scp to drop a tarball in the instance, or creating a repository and importing code from there. If anyone can tell me the method they prefer, and guide me through the process, or provide a link to a good tutorial, it would be hugely appreciated!","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":618,"Q_Id":6310624,"Users Score":0,"Answer":"I usually simply scp -R my whole site directory into \/home\/bitnami of my AMI. I'm using Apache\/NGINX\/Django with mod_wsgi. So the directory (for example \/home\/bitnami\/djangosites\/) gets referred to based on my mod_wsgi path in my apache cfg file.\nIn other words, why not just move the whole directory recursively (scp -R) instead of making a tarball etc?","Q_Score":1,"Tags":"python,django,amazon-ec2,amazon-web-services,cloud-hosting","A_Id":6311394,"CreationDate":"2011-06-10T18:34:00.000","Title":"Installing a my Django app on 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":0,"Web Development":1},{"Question":"In PHP, it was extremely easy to start hacking away and figuring out what was going on on a page. Just throw in a bunch of echos and print_r's and that was about it. It appears that this technique is not working for me in python. I am getting practice by hacking around in a python photo upload module, and when a photo is uploaded, it creates 3 different size photos. I found the code that does this, but I want to see the state at that particular moment. I tried doing a \"print\" on the size variable, but it did not show up in my browser.\nI guess a more straightforward question would be, is it \"pythonic\" do debug using the browser ( equivalent to echo's and print_r's in php ), or is this what the python console is for? Thanks!","AnswerCount":5,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":147,"Q_Id":6311322,"Users Score":4,"Answer":"Use the logging module rather than printing stuff to stdout. \nUsing the interpreter in interactive mode is a great way to try out code, and pdb is very useful for real debugging.","Q_Score":1,"Tags":"python,debugging","A_Id":6311351,"CreationDate":"2011-06-10T19:43:00.000","Title":"Experienced Python programmers (ESPECIALLY former php programmers) : How do I debug 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},{"Question":"I am in the process of building a system in python that centralizes the compilation of our code to a set of machines. I have all three programs written, running and working; however I'm still trying to weed out some of the more elusive bugs. I have been mostly testing over the localhost interface and therefore run all of the components on my machine. \nIs there a way to run all the components simultaneously in one Eclipse session so that I can flip between them and terminate if needed?\nI have been using multiple terminal windows, but since the code is still immature, it's not always possible to exit cleanly from the program.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":2548,"Q_Id":6311577,"Users Score":3,"Answer":"Yes - just run them as normal and use the Console menu to flip between them. If you run them under the debugger, you can also use the Debug view in the Debug perspective to terminate them - in either case, using the red square icon to do the terminating.","Q_Score":3,"Tags":"python,eclipse,pydev","A_Id":6317735,"CreationDate":"2011-06-10T20:11:00.000","Title":"Is there a way to run two or more python modules simultaneously from Eclipse(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":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"A bit of background:\nI have been developing apps for the past 2 years for Mac and iOS. I really like Objective-c and Cocoa\/Cocoa-Touch framework. I did java and c++ before I started programing for iOS and now when I look at these languages i literally get a headache (The syntax mainly but also lack of classes provided by Cocoa framework). I think I have become too used to Objective-c [] syntax and the rich Cocoa-Framework (Things like NSDictionary, NSPredicate, NSString....)\nNow:\nI need to do some server side programming. I was wondering what's my best option. I certainly don't want to go with Java, but is there a language that is closely like Objective-C that I can use which has a framework like Cocoa with classes similar to NSString, NSDictionary and such...? or better yet, can I even use Objective-C itself in server side programming?\nEdit: I took a look at python, and as far as syntax goes, i like it. But of course, that's just syntax, there's ALOT more to a language than just syntax...\nThanks.","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":3015,"Q_Id":6319507,"Users Score":0,"Answer":"I concur, try doing it in objective-c\nBut if you are looking for a similar language that also has rich wen development frameworks widely used, take a look at Ruby. \nThe syntax is quite different but the object model is fairly similar and won't actually feel that far away. The framework Ruby on Rails is also a very rich one with a nice MVC approach and good documentation. \nBut still, objective-c would be awesome.","Q_Score":6,"Tags":"python,objective-c,cocoa,server-side","A_Id":18298127,"CreationDate":"2011-06-12T01:09:00.000","Title":"Objective-c Server Side","Data Science and Machine Learning":0,"Database and SQL":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},{"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},{"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},{"Question":"We all know that working with S3 is a pain: deleting virtual directories requires to delete all the objects from within the path, etc. At least with RESTful API this is the case.\nI was wondering whether there would be any performance improvement if I would use PHP to call GSUtil rather than using my own PHP class. Is there anything special the way GSUtil handles requests or is it the same REST wrapper?\nThe main issues I am having:\n\ndeleting big folders\nuploading many small files\nreading hierarchical data steps (e.g. only files and folders under \/foo path, but not their children-children)","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":766,"Q_Id":6327592,"Users Score":2,"Answer":"Fundamentally, your PHP code and gsutil are both using the RESTful interface (gsutil is actually layered atop an open source Python library called boto which implements the bulk of the REST interface), however, there are several reasons to consider using gsutil:\n\nGsutil takes care of OAuth 2.0 authentication\/authorization for you.\nGsutil does wildcard expansion, which, for example would enable you to remove all objects in a bucket by specifying, simply, 'gsutil rm gs:\/\/bucket\/*'\nGsutil has lots of other features (get\/set ACLs and associated XML parse\/build, listing bucket contents, dump object contents, etc.) which you would have to implement yourself (or find in some other PHP library) if you bypass gsutil.\nGsutil has some nice performance capabilities for your \"uploading many small files\" use case. In particular, the -m option runs your uploads in parallel processes and threads, which provides a substantial performance boost.\n\nIn summary, you can roll your own PHP code but I think you'll get your job done faster and have access to more functionality if you leverage gsutil.","Q_Score":0,"Tags":"php,python,rest,google-cloud-storage","A_Id":9041894,"CreationDate":"2011-06-13T07:18:00.000","Title":"GSUtil vs PHP RESTful 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":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I need to call \"\/usr\/bin\/pdf2txt.py\" with few arguments from my Perl script. How should i do this ?","AnswerCount":4,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":31279,"Q_Id":6340479,"Users Score":0,"Answer":"IF you want to see output in \"real time\" and not when script has finished running , Add -u after python. example :\n\nmy $ret = system(\"python -u pdf2txt.py arg1 arg2\");","Q_Score":17,"Tags":"python,perl","A_Id":70644949,"CreationDate":"2011-06-14T07:37:00.000","Title":"How to call a python script from 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},{"Question":"I have a code written in C# I would like to use as the back-end of a site I'm building.\nI would prefer not to build the site front-end in ASP.NET (which integrates nicely with C#), and to use PHP or Python instead. \nIs that reasonable? Should I re-consider using ASP.NET?\nHow can I achieve that?","AnswerCount":4,"Available Count":3,"Score":0.049958375,"is_accepted":false,"ViewCount":3827,"Q_Id":6340972,"Users Score":1,"Answer":"You can do whatever you like. Personally i wouldnt use php because i dont know very much php.\nBut you can do it, you could expose a soap web service and there are libraries that will let php talk to it.\nNo one here will be able to tell you what you haven't already told us. Asp.Net will probably be easier because of how everything integrates and you can share classes etc - but that does not mean you HAVE to use it.\nBoth of them are fairly passive server side technologies that present html to browsers though. why do you need 2 servers?\nYou have to ask why you are doing it .. if you are playing and want to learn then of course you can do it just to see how it all works. But if you are on a commercial project then id suggest that you dont need both a php and a c# server ... or if you do perhaps you want to go asp.net for your web server and if you need another layer of services behind then use WCF if you want to go a microsoft route. Howver it is usually possible to host all services in the same IIs instance.","Q_Score":4,"Tags":"c#,php,asp.net,python,web-services","A_Id":6341033,"CreationDate":"2011-06-14T08:28:00.000","Title":"Connecting C# Back-end with PHP frontend","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I have a code written in C# I would like to use as the back-end of a site I'm building.\nI would prefer not to build the site front-end in ASP.NET (which integrates nicely with C#), and to use PHP or Python instead. \nIs that reasonable? Should I re-consider using ASP.NET?\nHow can I achieve that?","AnswerCount":4,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":3827,"Q_Id":6340972,"Users Score":0,"Answer":"Ugh, in normal instances, reading data with C# writing it to files and loading up with PHP sound slow, inefficient and down wright crazy. I believe these terms are being used wrongly.\nClient Server - user machine - database great for private networks where you connect to the DB without going over the internet\nvs n-Tier\nClient - Browser programming html, css, javascript connects to middleware over the internet\nMiddleware - inside your firewall, connects browser to database could be called part of backend - php and C# are middleware languages\nDatabase final (generally 3rd) tier\nWith php and c# you are creating multiple middleware layers\nwhy why why would you do this for a web app pick one\nnow if you have a web app with PHP and sneakerware in house client server apps that are controlled ie shipping, accounting that are not exposed - maybe but you have added complexity that you would not need (generally)\nGary","Q_Score":4,"Tags":"c#,php,asp.net,python,web-services","A_Id":43901958,"CreationDate":"2011-06-14T08:28:00.000","Title":"Connecting C# Back-end with PHP frontend","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I have a code written in C# I would like to use as the back-end of a site I'm building.\nI would prefer not to build the site front-end in ASP.NET (which integrates nicely with C#), and to use PHP or Python instead. \nIs that reasonable? Should I re-consider using ASP.NET?\nHow can I achieve that?","AnswerCount":4,"Available Count":3,"Score":0.1488850336,"is_accepted":false,"ViewCount":3827,"Q_Id":6340972,"Users Score":3,"Answer":"Just use asp.net mvc framework for the frontend instead of plain asp.net. It's easy to learn. And if you know php it will be easy to you undestand asp.net mvc.\nI don't see the reasons if you are using c# backend use php frontend. For sure you can create service layer on c# and communicate with php through it, but it does not make sence for me.","Q_Score":4,"Tags":"c#,php,asp.net,python,web-services","A_Id":6341059,"CreationDate":"2011-06-14T08:28:00.000","Title":"Connecting C# Back-end with PHP frontend","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I wrote a little testing framework that uses 'nm' to inspect shared libraries and look for test functions. I then use Python's ctypes library to dynamically load the shared object and execute the test functions. Is there a way to do this with an executable? When I tried the same trick on an executable module Python reported that it could not dynamically load an executable.","AnswerCount":2,"Available Count":1,"Score":0.2913126125,"is_accepted":false,"ViewCount":5178,"Q_Id":6346757,"Users Score":3,"Answer":"If this is your own application you could rearrange the build so your executable is only main() { real_main(); } and real_main() is in libapp.so. Then you could test libapp.so with your existing code.\nIf it's possible to load another executable it probably involves loading ld.so and getting it to do the work. If you run \/lib\/ld-linux.so (on Linux) it will print a stanza with information.","Q_Score":1,"Tags":"python,c,linux,dynamic-linking","A_Id":6346820,"CreationDate":"2011-06-14T16:22:00.000","Title":"Can I dynamically load an executable 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":0,"Web Development":0},{"Question":"I am trying to import a module from inside a function and have it be available to my whole file the same way it would be if I imported outside any functions and before all the other code. The reason it is in a function is because I don't have much control over the structure of the script. Is this possible without resorting to things like hacking __builtin__ or passing what I need all around my code?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":5294,"Q_Id":6347588,"Users Score":9,"Answer":"How about something like globals()[\"os\"] = __import__(\"os\")?\nI guess this could be wrapped in a generic function if you wanted since the module name is a string.","Q_Score":11,"Tags":"python,import,global","A_Id":6347667,"CreationDate":"2011-06-14T17:30:00.000","Title":"Is it possible to import to the global scope from inside a function (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},{"Question":"i wanna know if it is possible not to hard code my user name and password in a script that copy a file in the operation system and send it via smtp [gmail]\nThank you!","AnswerCount":3,"Available Count":3,"Score":0.0665680765,"is_accepted":false,"ViewCount":1677,"Q_Id":6348988,"Users Score":1,"Answer":"Store your data as environment variables or inside a configuration file...","Q_Score":2,"Tags":"python,passwords,smtp,hardcoded","A_Id":6349049,"CreationDate":"2011-06-14T19:31:00.000","Title":"There is a way not to hard code username & pass when sending mail [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},{"Question":"i wanna know if it is possible not to hard code my user name and password in a script that copy a file in the operation system and send it via smtp [gmail]\nThank you!","AnswerCount":3,"Available Count":3,"Score":1.2,"is_accepted":true,"ViewCount":1677,"Q_Id":6348988,"Users Score":1,"Answer":"I bet that best way will be to keep password encrypted, algo is your choice. Then when user give you credentials you check if it match stored encrypted data and then send it. This will take off the step you have to keep plaintext password in any file\/database. Anyway you didn't say if you realy need to keep password plain text (but it seems like a case because of remote use), if so then you should use 2-way encryption to avoid plain text passwords - it can be breaked easy but still needs one more step than just read the config file.","Q_Score":2,"Tags":"python,passwords,smtp,hardcoded","A_Id":6349407,"CreationDate":"2011-06-14T19:31:00.000","Title":"There is a way not to hard code username & pass when sending mail [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},{"Question":"i wanna know if it is possible not to hard code my user name and password in a script that copy a file in the operation system and send it via smtp [gmail]\nThank you!","AnswerCount":3,"Available Count":3,"Score":0.0665680765,"is_accepted":false,"ViewCount":1677,"Q_Id":6348988,"Users Score":1,"Answer":"make the script take the username as command line args.\nif you import sys, then sys.argv is the list of all command line args, where the first is the name of the python script itself.","Q_Score":2,"Tags":"python,passwords,smtp,hardcoded","A_Id":6349055,"CreationDate":"2011-06-14T19:31:00.000","Title":"There is a way not to hard code username & pass when sending mail [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},{"Question":"What template engines \/ template languages are turing complete? I heard about these so far:\n\nFreeMarker (implemented in java)\nMovableTypes template language (in perl)\nxslt :-(\nCheetah (in Python)\nSmarty (in PHP)\n\nAny others (especially implemented with perl)?\nPs: Don't waste time with clarifying me MVC, and why turing complete templates are bad, and why this is not a useful comparison point :)","AnswerCount":4,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":630,"Q_Id":6351765,"Users Score":0,"Answer":"Virtually anything that allows procedural code to compute the template result.","Q_Score":5,"Tags":"python,ruby,perl,templates,programming-languages","A_Id":6351798,"CreationDate":"2011-06-15T00:38:00.000","Title":"Turing complete template engines","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I wish to convert a bash script that's currently using \"curl -b 'cookie'\" into a Python script. I've looked at Pycurl, but I couldnt' find a -b equivalent. There are also urllib and urllib2, but I couldn't see an easy way to replicate the line.\nAny help would be great.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":262,"Q_Id":6352644,"Users Score":0,"Answer":"You can use CookieJar.add_cookie_header to add your cookie to a http request header.","Q_Score":0,"Tags":"python","A_Id":6353057,"CreationDate":"2011-06-15T03:15:00.000","Title":"Python equivalent for curl -b (--cookie)","Data Science and Machine Learning":0,"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},{"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},{"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},{"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},{"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},{"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},{"Question":"I have found most python modules in python source directory, under Python\/Lib or Python\/Modules ,but where is the sys (import sys) module ? I didn't find it .","AnswerCount":3,"Available Count":2,"Score":0.1325487884,"is_accepted":false,"ViewCount":18447,"Q_Id":6409935,"Users Score":2,"Answer":"It's in Python\/Python\/sysmodule.c.","Q_Score":9,"Tags":"python,module","A_Id":6409965,"CreationDate":"2011-06-20T10:39:00.000","Title":"where is the sys module in python source 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},{"Question":"I have found most python modules in python source directory, under Python\/Lib or Python\/Modules ,but where is the sys (import sys) module ? I didn't find it .","AnswerCount":3,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":18447,"Q_Id":6409935,"Users Score":11,"Answer":"The Answer\nI find it here: .\/Python\/sysmodule.c\nIf you're on Linux or Mac OS X, and in doubt, just try find . -name 'sysmodule.c' in the Python directory.\nOther Stuff\nThe way I found it was by searching for the string \"platform\" throughout the Python directory (using TextMate), as I've used e.g. sys.platform before from the sys module... something similar can be done with grep and xargs.\nAnother suggestion could be : for i in .\/**\/*.c ; do grep -H platform $i ; done\nThis will loop through all *.c files present in anywhere up the file tree you're currently located at, and search the file for \"platform\". The -H flag will ensure we get a filename path so we can trace the matches back to the files they are found in.","Q_Score":9,"Tags":"python,module","A_Id":6409975,"CreationDate":"2011-06-20T10:39:00.000","Title":"where is the sys module in python source 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},{"Question":"I have a background python script that gets ran several thousand times a day. I'm simply running it with python foo.py. The script itself does some imports (a parsing library and sqlalchemy) and then makes a database connection, makes the parsing and saves the data to db.\nI'm wondering if it adds a lot of overhead to load the python environment each time the script is run? \nI could make it so that the script is started once and it would have a polling loop to see if it should do something, but want to clarify that it's worth to do this.\nAny input?","AnswerCount":1,"Available Count":1,"Score":0.6640367703,"is_accepted":false,"ViewCount":112,"Q_Id":6432377,"Users Score":4,"Answer":"of course it adds a lot of overhead, and it would be (however negligibly) more eco-friendly to use a built-in poll or select(); but then you'd have to have a watchdog to see if it crashed, or use respawn from inittab. as long as the server load is fine, it might not be worth the effort.\n\nforgot to mention, memory leaks that would be unnoticeable in a cron job can become server-eating monsters when your script runs as a daemon. you'd want to watch it carefully the first hour or two, to see if it's growing.","Q_Score":3,"Tags":"python,environment,overhead","A_Id":6432467,"CreationDate":"2011-06-21T21:46:00.000","Title":"How expensive it is to load the environment to run 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":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm looking for an IDE that will allow me to edit remote Python projects and also has decent Django support, remote command execution, and maybe remote debugging. I've tried PyCharm and Aptana with PyDev but I'm not having much luck configuring them for remote editing. Thanks for your help!","AnswerCount":3,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":5204,"Q_Id":6435000,"Users Score":6,"Answer":"I have Pycharm setup on a Ubuntu 10.10. The key is to use \"sshfs\" - it maps to my web-host - via ssh. Those are the pre-reqs : ssh access, sshfs. (unless you can figure out a way to map ssh to a windows shared drive).\nSo once ssh, sshfs are setup, I create a linux mount locally - so my webhost's directory appears locally as \"\/webhostx\" .. From then on Pycharm (or WingIde or any editor) does not care that \"\/webhostx\" is really a remote folder mounted locally.\nIf all else fails there's always Emacs (everything included :-) ).\nPycharm also has a remote debugging feature - I am in the process of testing it with my host (webfaction).","Q_Score":8,"Tags":"python,django,ide","A_Id":6714141,"CreationDate":"2011-06-22T04:45:00.000","Title":"Python and Django IDE with remote editing?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I'm a Java web developer that knows a bit of Python (but haven't done any Python web development), and I am curious what exactly is meant by a LAMP stack.\nI understand this to be Linux-Apache-MySQL-(PHP, Perl, or Python), but I don't understand what unites these three languages other than the letter P.\nIs a LAMP stack fundamentally different if Ruby was used? Using Ruby would typically mean using Rails, but Python web apps usually use Django or Pylons. Or does LAMP signify that no framework is used? Is Java web development essentially different because of Tomcat in place of Apache?","AnswerCount":4,"Available Count":4,"Score":0.0996679946,"is_accepted":false,"ViewCount":6337,"Q_Id":6446385,"Users Score":2,"Answer":"I think you're trying to read too much into what it means. The acronym became popular because they were often used together and it was easy to pronounce. It doesn't have any meaning or implication beyond the literal one. There's also WAMP (Windows), LAPP (PostgreSql) and whatever else you want to make up.","Q_Score":3,"Tags":"java,python,ruby,lamp","A_Id":6446503,"CreationDate":"2011-06-22T20:50:00.000","Title":"What is the significance of the 'P' in LAMP? Why is it PHP, Perl, 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":0,"Web Development":1},{"Question":"I'm a Java web developer that knows a bit of Python (but haven't done any Python web development), and I am curious what exactly is meant by a LAMP stack.\nI understand this to be Linux-Apache-MySQL-(PHP, Perl, or Python), but I don't understand what unites these three languages other than the letter P.\nIs a LAMP stack fundamentally different if Ruby was used? Using Ruby would typically mean using Rails, but Python web apps usually use Django or Pylons. Or does LAMP signify that no framework is used? Is Java web development essentially different because of Tomcat in place of Apache?","AnswerCount":4,"Available Count":4,"Score":0.049958375,"is_accepted":false,"ViewCount":6337,"Q_Id":6446385,"Users Score":1,"Answer":"Besides being popular Web development languages, Perl, PHP, and Python share something else: They are all dynamically typed languages, and notoriously fast to develop in. I believe this is part of the \"spirit\" of LAMP.\nSo, while it's true you could substitute any other language in for the 'P', some languages fit the dynamic, agile spirit better than others. Ruby, for example, would fit very nicely. You could also use Scheme, if that's what you're good at. Java doesn't fit as nicely into LAMP because it is a statically typed language, and to many feels subjectively \"heavier\" than the so-called scripting languages.","Q_Score":3,"Tags":"java,python,ruby,lamp","A_Id":6447007,"CreationDate":"2011-06-22T20:50:00.000","Title":"What is the significance of the 'P' in LAMP? Why is it PHP, Perl, 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":0,"Web Development":1},{"Question":"I'm a Java web developer that knows a bit of Python (but haven't done any Python web development), and I am curious what exactly is meant by a LAMP stack.\nI understand this to be Linux-Apache-MySQL-(PHP, Perl, or Python), but I don't understand what unites these three languages other than the letter P.\nIs a LAMP stack fundamentally different if Ruby was used? Using Ruby would typically mean using Rails, but Python web apps usually use Django or Pylons. Or does LAMP signify that no framework is used? Is Java web development essentially different because of Tomcat in place of Apache?","AnswerCount":4,"Available Count":4,"Score":1.2,"is_accepted":true,"ViewCount":6337,"Q_Id":6446385,"Users Score":8,"Answer":"It's just so happens that the most commonly used components in that part of the stack all happened to begin with a P. It's nothing more than a coincidence. The LAMP acronym was coined before Ruby gained its current popularity levels and there's no reason why you couldn't stick Ruby in the P slot.","Q_Score":3,"Tags":"java,python,ruby,lamp","A_Id":6446413,"CreationDate":"2011-06-22T20:50:00.000","Title":"What is the significance of the 'P' in LAMP? Why is it PHP, Perl, 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":0,"Web Development":1},{"Question":"I'm a Java web developer that knows a bit of Python (but haven't done any Python web development), and I am curious what exactly is meant by a LAMP stack.\nI understand this to be Linux-Apache-MySQL-(PHP, Perl, or Python), but I don't understand what unites these three languages other than the letter P.\nIs a LAMP stack fundamentally different if Ruby was used? Using Ruby would typically mean using Rails, but Python web apps usually use Django or Pylons. Or does LAMP signify that no framework is used? Is Java web development essentially different because of Tomcat in place of Apache?","AnswerCount":4,"Available Count":4,"Score":1.0,"is_accepted":false,"ViewCount":6337,"Q_Id":6446385,"Users Score":7,"Answer":"I believe the P originally stood mainly for PHP, as that particular combination was extremely widely used. It got expanded to include Python and Perl as non-PHP languages became more popular for web development, and never expanded further because it would have broken the acronym.\nLAMP is a de facto standard way of doing things, but not a formal standard. Changing out the P for Ruby+Rails, or Apache\/PHP for Tomcat\/Java changes some things about your development process, but not other things.\nOne aspect of LAMP that's significant is that all the components are open-source.","Q_Score":3,"Tags":"java,python,ruby,lamp","A_Id":6446566,"CreationDate":"2011-06-22T20:50:00.000","Title":"What is the significance of the 'P' in LAMP? Why is it PHP, Perl, 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":0,"Web Development":1},{"Question":"OK, so we are developing an network related application where the user can upload their own python scripts to decide for an algorithm. Our code contains c and cython and python modules. \nSince avoiding latency, memory footprint and minimal processing is critical for us, we were wondering if it's a wise and effective (performance wise) to turn off garbage collection and handle memory deallocation ourselves.","AnswerCount":6,"Available Count":6,"Score":0.0333209931,"is_accepted":false,"ViewCount":2303,"Q_Id":6448742,"Users Score":1,"Answer":"CPython (the original and most used Python) uses a ref counting approach for garbage collection: objects which are no longer referenced are immediately freed. Therefore if you don't create any cycles then the garbage collector, which only exists to detect cycles, shouldn't be getting invoked much.","Q_Score":7,"Tags":"python,memory-management,memory-leaks,garbage-collection,cython","A_Id":6448987,"CreationDate":"2011-06-23T02:35:00.000","Title":"Does garbage collection make python slower?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"OK, so we are developing an network related application where the user can upload their own python scripts to decide for an algorithm. Our code contains c and cython and python modules. \nSince avoiding latency, memory footprint and minimal processing is critical for us, we were wondering if it's a wise and effective (performance wise) to turn off garbage collection and handle memory deallocation ourselves.","AnswerCount":6,"Available Count":6,"Score":1.0,"is_accepted":false,"ViewCount":2303,"Q_Id":6448742,"Users Score":18,"Answer":"Just let the language do what it wants to do, and if you find you have an actual problem, come on back and post about it. Otherwise it's premature optimization.","Q_Score":7,"Tags":"python,memory-management,memory-leaks,garbage-collection,cython","A_Id":6448754,"CreationDate":"2011-06-23T02:35:00.000","Title":"Does garbage collection make python slower?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"OK, so we are developing an network related application where the user can upload their own python scripts to decide for an algorithm. Our code contains c and cython and python modules. \nSince avoiding latency, memory footprint and minimal processing is critical for us, we were wondering if it's a wise and effective (performance wise) to turn off garbage collection and handle memory deallocation ourselves.","AnswerCount":6,"Available Count":6,"Score":1.2,"is_accepted":true,"ViewCount":2303,"Q_Id":6448742,"Users Score":11,"Answer":"gc.disable only turns off the cyclic garbage collector. Objects will still be collected when the refcount drops to zero anyway. So unless you have a lot of cyclic references, it will make no difference.\nAre you are talking about doing a customised Python build and disabling the ref counting GC?","Q_Score":7,"Tags":"python,memory-management,memory-leaks,garbage-collection,cython","A_Id":6448994,"CreationDate":"2011-06-23T02:35:00.000","Title":"Does garbage collection make python slower?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"OK, so we are developing an network related application where the user can upload their own python scripts to decide for an algorithm. Our code contains c and cython and python modules. \nSince avoiding latency, memory footprint and minimal processing is critical for us, we were wondering if it's a wise and effective (performance wise) to turn off garbage collection and handle memory deallocation ourselves.","AnswerCount":6,"Available Count":6,"Score":0.1651404129,"is_accepted":false,"ViewCount":2303,"Q_Id":6448742,"Users Score":5,"Answer":"Just develop the application so that it is functionally correct. Once you've got a correct application fire up the profiler and determine where the slow bits are. If you're worried about user script performance, you're probably focussing on the wrong thing.\nA shorter answer is that it is probably unwise and ineffective to try to optimize before initial development is complete.","Q_Score":7,"Tags":"python,memory-management,memory-leaks,garbage-collection,cython","A_Id":6448778,"CreationDate":"2011-06-23T02:35:00.000","Title":"Does garbage collection make python slower?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"OK, so we are developing an network related application where the user can upload their own python scripts to decide for an algorithm. Our code contains c and cython and python modules. \nSince avoiding latency, memory footprint and minimal processing is critical for us, we were wondering if it's a wise and effective (performance wise) to turn off garbage collection and handle memory deallocation ourselves.","AnswerCount":6,"Available Count":6,"Score":0.1325487884,"is_accepted":false,"ViewCount":2303,"Q_Id":6448742,"Users Score":4,"Answer":"Garbage collection makes everything slower. It also makes everything much less error-prone. Especially if the point is to run user-uploaded scripts, I have a hard time believing the trade-off will work out well; if you have any leaks or double frees, you now have a DoS vulnerability if someone can figure out how to trigger it.","Q_Score":7,"Tags":"python,memory-management,memory-leaks,garbage-collection,cython","A_Id":6448786,"CreationDate":"2011-06-23T02:35:00.000","Title":"Does garbage collection make python slower?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"OK, so we are developing an network related application where the user can upload their own python scripts to decide for an algorithm. Our code contains c and cython and python modules. \nSince avoiding latency, memory footprint and minimal processing is critical for us, we were wondering if it's a wise and effective (performance wise) to turn off garbage collection and handle memory deallocation ourselves.","AnswerCount":6,"Available Count":6,"Score":0.0665680765,"is_accepted":false,"ViewCount":2303,"Q_Id":6448742,"Users Score":2,"Answer":"I've spent quite a bit of time working in languages with automatic garbage collection and I can say almost unilaterally that trusting the native garbage collection will be faster and more reliable than a custom solution.","Q_Score":7,"Tags":"python,memory-management,memory-leaks,garbage-collection,cython","A_Id":6449666,"CreationDate":"2011-06-23T02:35:00.000","Title":"Does garbage collection make python slower?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm running fedora 32 bit on one machine and have installed several eggs using easy_install.\nI've installed the same eggs using easy_install on a 64-bit centos 5 machine. The site-packages directories are different - on my fedora machine, some of the eggs have been inflated so there are directories ending .egg-info as well as the main code directories. On Centos there are no .egg-info directories. Why is this?\nThanks","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":133,"Q_Id":6486598,"Users Score":0,"Answer":"A package can specify itself using the zip_safe flag inside its setup.py file if it should be unarchived or not. In addition most installers like 'easy_install' provide options to control the unpacking explicitly (e.g. easy_install --zip-ok ...)...so it may depend on how the packages are installed under Fedora oder CentOS.","Q_Score":1,"Tags":"python,egg","A_Id":6488633,"CreationDate":"2011-06-26T20:39:00.000","Title":"Python eggs - sometimes inflated, sometimes not","Data Science and Machine Learning":0,"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},{"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},{"Question":"What is the recommended library for python to do everything that is Amazon EC2 related?\nI came across boto and libcloud. Which one is easier to use? does libcloud offer the same functionality as boto?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":933,"Q_Id":6507708,"Users Score":10,"Answer":"The big advantage of libcloud is that it provides a unified interface to multiple providers, which is a big plus in my mind. You won't have to rewrite everything if you plan to migrate some instances to Rackspace later, or mix and match, etc. I haven't used it extensively but it looks fairly complete as far as EC2 goes. In boto's favor it has support for nearly all of Amazon's web services, so if you plan to be Amazon-centric and use other services you'll probably want to use boto. \nThat said, try both packages and see which you prefer.","Q_Score":9,"Tags":"python,amazon-ec2","A_Id":6508616,"CreationDate":"2011-06-28T14:04:00.000","Title":"Python & Amazon EC2 -- Recommended Library?","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},{"Question":"To use OAUTH with python-twitter I need to register a web app, website etc. The program I have is for personal use though. Since basic auth is now defunct and Oauth is not an option due to the requirements is there a work around to log in to twitter using a script?\nI can't imagine that Twitter would alienate everyone who does not have a website\/web app from logging in to twitter from a script that is for personal use.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":881,"Q_Id":6511633,"Users Score":0,"Answer":"If you want to access resources at Twitter, even if they are your own, and even if it is just for a \"personal script\" -> you have to use oAuth.","Q_Score":1,"Tags":"python,authentication,twitter,oauth","A_Id":6533687,"CreationDate":"2011-06-28T18:53:00.000","Title":"How to log in to twitter without Oauth for a 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},{"Question":"I've read through many of the related questions and am a bit unsure as to how to handle this situation.\nThe Basic Question: What is the best way to handle \"foreign\" (Hebrew, Greek, Aramaic?, etc.) characters in a website?\nI get that I need to use UTF-8 encoding but the mechanics behind it are lost on me.\nI am using tornado as my framework and am storing the data in redis. \nMy current implementation is to simply store the English keyboard equivalent in the data store and then rendering on a page with the appropriate Hebrew\/Greek font (e.g. Bwhebb.ttf). This has worked, for the most part, but I am bumping up against some characters which are being CGI encoded which, in turn, causes the font method to break.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":920,"Q_Id":6514971,"Users Score":3,"Answer":"Read the articles given in the comments.\nShort answer though, store unicode in Redis, and if you're using Python 2.x, use unicode strings (u\"\") throughout. You may have to convert to unicode (unicode()) after retrieval from Redis, depending on what it gives you.","Q_Score":1,"Tags":"python,redis,tornado,hebrew","A_Id":6518345,"CreationDate":"2011-06-29T01:53:00.000","Title":"Handling foreign characters in website running on python, tornado and redis","Data Science and Machine Learning":0,"Database and SQL":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},{"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},{"Question":"I have a test footest.py which runs with mysql database, and the same test runs on psql database, is there a way to distinguish this difference in an XML result file between the two tests.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":63,"Q_Id":6515166,"Users Score":0,"Answer":"Why not trying to create a base_test_class.py with a base test class class BaseSQLTest(unittest.TestCase) that contains all your tests, and 2 other files mysqltest.py and psqltest.py that contains 2 inherited classes (class MySQLTest(BaseSQLTest) and class PSQLTest(BaseSQLTest)) for your MySQL and PSQL tests. \nDoing this will split your tests in the resulting XML.","Q_Score":0,"Tags":"python,xml,nosetests","A_Id":6517155,"CreationDate":"2011-06-29T02:31:00.000","Title":"How can i distinguish the XML results of two python tests (using nosetests as test runner) with the same name but with different context","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I checked the documentation for Python-Twitter and I couldn't find any methods for OAuthentication. There is a methods for Basic Auth, but I obviously can't use that any more. \nIf I get a separate module for Oauth can I still use methods in Python-Twitter that require Oauth or does the Oauth only support methods from the same module I authenticated in.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":66,"Q_Id":6515477,"Users Score":0,"Answer":"OAuth is a generic protocol; any well-behaved library that implements it should work with any site's API (this is the whole point of having a standard...)","Q_Score":0,"Tags":"python,twitter,module","A_Id":6515489,"CreationDate":"2011-06-29T03:33:00.000","Title":"Do I need a specific Python module Oauthentication?","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},{"Question":"I have created a Python-based GUI application which has certain dependencies such as the \"request\" and \"psycopg2\" modules among others.\nI want to create a setup script that will install all such dependencies when run, so that a user can run the GUI application without having any missing package errors.\nI did try looking up the distutils module, but am not able to fully understand its usage.","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":1635,"Q_Id":6524104,"Users Score":1,"Answer":"You specify all dependent packages in the 'install_requires' option within your setup.py - that's it. \nIf this is not sufficient or good enough (for whatever reason): look into zc.buildout giving your more options installing and configuring external dependencies.","Q_Score":1,"Tags":"python,installation","A_Id":6524127,"CreationDate":"2011-06-29T16:33:00.000","Title":"Installing dependencies for 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":1,"Web Development":0},{"Question":"I'd like to mangle and demangle C++ function names in a Python program.\nIs there anything like that available? I searched for hours now, perhaps I'm lucky here...","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":5841,"Q_Id":6526500,"Users Score":3,"Answer":"You most likely don't want to be doing this in Python. As an aside you probably shouldn't be exporting mangled names from your DLLs since it makes it hard to use for anyone with a different compiler.\nIf you have to use mangled names then just hard code them in your Python code. If you were going to do mangling in Python code then you'd have to:\n\nKnow the implementation specific rules for the compiler in question.\nSpecify in Python the C++ function signature for each function.\n\nIt seems highly unlikely to me that coding all this up in Python would be better than simply hard coding the mangled names.","Q_Score":13,"Tags":"c++,python,name-mangling","A_Id":6526604,"CreationDate":"2011-06-29T19:59:00.000","Title":"C++ Name Mangling Library 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},{"Question":"I have a python project that takes in two Excel spreadsheets with various data as input, and depending on given parameters in a python 'run' type module, produces several spreadsheets which contain statistical information as outputs. I have several versions of this project released already to a few clients, but testing to make sure that the input spreadsheets, their parameters (in a python module), and their corresponding output spreadsheets are the same is very time consuming because I have a lot of possible parameters that can be used. Is there a tool or something I can do or use to automate testing for my project to ensure inputs, parameters and outputs of past versions of the project match the latest version?\nI know that there are many testing modules in python (in particular unittest, nose, Scons, doctest etc), but I was wondering if anyone knew of a simpler tool for testing inputs and outputs, or a way to create my own quickly. I do not want to test every single method due to time and cost constraints and complexity of the project.\nThanks in advance!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":202,"Q_Id":6528059,"Users Score":0,"Answer":"One of the unit testing frameworks you list is just what you need. Testing is hard and takes time. If you try to do it without putting in sufficient time and thought your testing won't be worth very much.\nIt sounds like you are wanting a list of inputs and outputs that your test loops through. That's easy. Just declare such a list in your test case and run a loop across it. That's the easy bit. The hard bit is working out the test data.","Q_Score":0,"Tags":"python,unit-testing,excel,testing","A_Id":6528157,"CreationDate":"2011-06-29T22:36:00.000","Title":"Simple test tool for 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":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"How can I access my php script from a Python script?\nI need my Python script to be able to access the variables within the php script. (By the way, I'm new to php and Python.)\nThanks in advance.","AnswerCount":2,"Available Count":1,"Score":-0.0996679946,"is_accepted":false,"ViewCount":1637,"Q_Id":6530663,"Users Score":-1,"Answer":"Elaborate. Is the PHP file local? On a webserver? Where's the python file?\nIf the php file is on a server with the python file, use an exec statement.\nIf the python file is local and the php file is on a server, then you need to use urllib.\nIf both are local, write an interpreter...","Q_Score":1,"Tags":"php,python,import","A_Id":6530718,"CreationDate":"2011-06-30T06:16:00.000","Title":"How to access variable values of a php script from 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":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Is there an equivalent to the POSIX sigaction available through Python? I realize python has traditional support for signals, but I need sigaction.\nI'm trying to identify the pid of a process that is the source of a signal being issued. From what I can see from the documentation, there isn't a way to do this.\nI'm only concerned with functionality on Linux.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":2124,"Q_Id":6532213,"Users Score":7,"Answer":"There is a standard module called, unsurprisingly, signal. This seems to carry out the functionality of sigaction(2). However I'm guessing that what you really need is the siginfo_t struct, which gives the PID of the source of the signal, which is not part of the module at the moment (possibly because it is not implemented on all UNIXs). \nThe only alternative I can suggest is to use ctypes.","Q_Score":4,"Tags":"python,linux,posix,signals","A_Id":6534882,"CreationDate":"2011-06-30T08:43:00.000","Title":"Python, sigaction(2) available?","Data Science and Machine Learning":0,"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},{"Question":"Currently Fabric's 'rsync_projecct' requires a user and a host parameter to be specified. I'having a lot of issues copying user@127.0.0.1 because it is still asking me for the password for rsync. I've spent hours on this and am wondering if there is just a way to use the rsync [src] [dest] without having to specify a [user] and [host]? Or do you guys recommend something better? \nThe reason I like rsync over anything else is because I already have the rsync files\/folders\/excludes setup for that specific command.\nThen again, I could just write my own rsync command right?\nThanks.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1806,"Q_Id":6536862,"Users Score":4,"Answer":"you can just local() out and use rsync any way you want to.","Q_Score":1,"Tags":"python,fabric","A_Id":6605088,"CreationDate":"2011-06-30T15:04:00.000","Title":"Python's Fabric to use rsync locally, is it possible?","Data Science and Machine Learning":0,"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},{"Question":"I started coding an RPG engine in python and I want it to be very scripted(buffs, events). I am experimenting with events and hooking. I would appreciate if you could tell me some matured opensource projects(so i can inspect the code) to learn from. Not necessarily python, but it would be ideal. \nThanks in advance.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":730,"Q_Id":6539267,"Users Score":0,"Answer":"You might have a look at pygame, it's pretty common for this sort of thing.","Q_Score":0,"Tags":"python","A_Id":6539682,"CreationDate":"2011-06-30T18:17:00.000","Title":"Python rpg adivce?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I want to my tests to fail if they take longer than a certain time to run (say 500ms) because it sucks when a load of slightly slow tests mount up and suddenly you have this big delay every time you run the test suite. Are there any plugins or anything for Nose that do this already?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1155,"Q_Id":6548496,"Users Score":6,"Answer":"I respectfully suggest that changing the meaning of \"broken\" is a bad idea. \nThe meaning of a failed\/\"red\" test should never be anything other than \"this functionality is broken\". To do anything else risks diluting the value of the tests. \nIf you implement this and then next week a handful of tests fail, would it be an indicator that\n\nYour tests are running slowly?\nThe code is broken?\nBoth of the above at the same time? \n\nI suggest it would be better to gather MI from your build process and monitor it in order to spot slow tests building up, but let red mean \"broken functionality\" rather then \"broken functionality and\/or slow test.\"","Q_Score":9,"Tags":"python,unit-testing,nose","A_Id":6548606,"CreationDate":"2011-07-01T13:20:00.000","Title":"Making Nose fail slow 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":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},{"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},{"Question":"Is it possible without any plugins?\nOr what's the best plugin for edit python file?","AnswerCount":8,"Available Count":5,"Score":1.0,"is_accepted":false,"ViewCount":5089,"Q_Id":6579723,"Users Score":7,"Answer":"The way I do it is not specific to functions. It will just select a continuous block of Python code:\nv]] if what you want to select is below the cursor\nv[[ if it is above the cursor.\nJust remove one bracket if the cursor is on the first line of the code block you want to select.","Q_Score":18,"Tags":"python,vim","A_Id":57220317,"CreationDate":"2011-07-05T08:20:00.000","Title":"what's the fastest way to select a function of Python via VIM?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Is it possible without any plugins?\nOr what's the best plugin for edit python file?","AnswerCount":8,"Available Count":5,"Score":0.0,"is_accepted":false,"ViewCount":5089,"Q_Id":6579723,"Users Score":0,"Answer":"I try to avoid visual, hence for actions like yank, I tend to go to the beginning of the paragraph [[, yank till the end y]] and come back ^o.\nAll in one, it is [[y]]^o (With ^ standing for control).\nFor visual you might use [[v]] or some variations like [[v][, [[v]m, or [[v]M.","Q_Score":18,"Tags":"python,vim","A_Id":64190015,"CreationDate":"2011-07-05T08:20:00.000","Title":"what's the fastest way to select a function of Python via VIM?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Is it possible without any plugins?\nOr what's the best plugin for edit python file?","AnswerCount":8,"Available Count":5,"Score":0.049958375,"is_accepted":false,"ViewCount":5089,"Q_Id":6579723,"Users Score":2,"Answer":"I normally use vip or any of the above depending on the need, do not forget that you can always select up (i.e., down =)) to the next occurrence using v\/match (followed by Enter to confirm, and possibly n for next). For python, you could look for the next def or for the return (ret is normally enough). \nThis isn't the fastest at the beginning, but it is very general, use it in any language and also outside coding (md, latex, etc.).","Q_Score":18,"Tags":"python,vim","A_Id":59506958,"CreationDate":"2011-07-05T08:20:00.000","Title":"what's the fastest way to select a function of Python via VIM?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Is it possible without any plugins?\nOr what's the best plugin for edit python file?","AnswerCount":8,"Available Count":5,"Score":0.0,"is_accepted":false,"ViewCount":5089,"Q_Id":6579723,"Users Score":0,"Answer":"If your function is long or has many blank lines, using v}}...}}d is pretty slow.\nThe quickest way I've found (without plug-ins) is zc2dd. The command zc closes the fold under the cursor, so if you are at the function declaration or any line at the outermost indent level, the whole function will fold. Then 2dd (or 3dd if you have two blank lines before\/after your function) will remove the whole thing.","Q_Score":18,"Tags":"python,vim","A_Id":68185960,"CreationDate":"2011-07-05T08:20:00.000","Title":"what's the fastest way to select a function of Python via VIM?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Is it possible without any plugins?\nOr what's the best plugin for edit python file?","AnswerCount":8,"Available Count":5,"Score":1.0,"is_accepted":false,"ViewCount":5089,"Q_Id":6579723,"Users Score":14,"Answer":"try vis to visualy select and o to jump edges","Q_Score":18,"Tags":"python,vim","A_Id":6597250,"CreationDate":"2011-07-05T08:20:00.000","Title":"what's the fastest way to select a function of Python via VIM?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Anyone knows how to build and run emesene - the chat client in Python - on OS X once you get the code from GitHub?\nI have searched online and I cannot find a source that is working. I did find some documents on sidhosting website. But that did not work for me completely. Hence I need help here.\nThanks\nSumod","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":73,"Q_Id":6586793,"Users Score":2,"Answer":"Have you tried running python setup.py install in the emesene directory?","Q_Score":0,"Tags":"python,git","A_Id":6587062,"CreationDate":"2011-07-05T17:53:00.000","Title":"How to build and run emesene on OS X using 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":1,"System Administration and DevOps":1,"Web Development":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},{"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},{"Question":"I am trying to use the mpdboot command to start 4 processors on which to run my MPI program. I created a mpd.hosts file with 4 nodes (75, 77, 79 and 80). Each of them run python 2.3.4. I also modified the bashrc and cshrc files to ensure that the variables contain the path to the directory of the compiler libraries. I also set up the mpd.conf file and checked that it has rw (600) permissions. \nI have copied below the output screen when I run mpdboot\n[n@heart]$ mpdboot -n 4 -r ssh\n:38: Deprecation Warning: The popen2 module is deprecated. Use the subprocess module.\nn@75's password:xxx\nn@77's password:xxx\nn@79's password:xxx\nn@80's password:xxx\nmpdboot_heart.int(err_exit 526): mpd failed to start correctly on heart.int\nreason: 0: invalid port from mpd \/opt\/intel\/mpi\/2.0\/bin\/mpd.py:85: DeprecationWarning: the md5 module is deprecated; use hashlib instead\nKilled\n\nPART 2:\nI also logged into one of the nodes and tried running mpdboot. Here is the output by doing that\n[n@79 ~]$ mpdboot -n 4 -r ssh\nn@75's password:xxx\nn@77's password:xxx\nn@79's password:xxx\nn@80's password:xxx\nmpdboot_79_0 (mpdboot 499): problem has been detected during mpd(boot) startup at 1 75; output:\nPermission denied, please try again.\nn@75's password: Permission denied, please try again.\nn@77's password: mpdboot_79_0 (mpdboot 515): problem has been detected during mpd(boot) startup at 2 77; output:\nPermission denied, please try again.\nPermission denied (publickey,gssapi-with-mic,password).\nn@77's password: Permission denied, please try again.\nPermission denied (publickey,gssapi-with-mic,password).\n\nHow should I proceed on this matter?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2152,"Q_Id":6590343,"Users Score":0,"Answer":"Is mpdboot compatible with such a version of python? That's downright ancient, I didn't know there was even any distribution left that still shipped 2.3. Have you tried with 2.7?","Q_Score":0,"Tags":"python,mpi,mpich,mpiexec","A_Id":6590376,"CreationDate":"2011-07-06T00:24:00.000","Title":"Mpdboot: Deprecation Warning","Data Science and Machine Learning":0,"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},{"Question":"Lets say for batch processing of over 10000 videos, is there any thing to be gained from using FFmpeg rather than the pyFFmpeg?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":774,"Q_Id":6603810,"Users Score":5,"Answer":"Considering that pyFFmpeg is just a wrapper over the libraries, I'd say you shouldn't have any negligible performance difference between the 2, since they use the same libraries at the core.","Q_Score":0,"Tags":"python,ffmpeg,video-encoding","A_Id":6603847,"CreationDate":"2011-07-06T22:28:00.000","Title":"FFmpeg VS PyFFmpeg performance wise?","Data Science and Machine Learning":0,"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},{"Question":"I know about gethostbyaddr in Python and that is somewhat useful for me. I would like to get even more info about an ip address like one can find at various websites such as who hosts that ip address, the country of origin, ..., etc. I need to accomplish this programmatically.\nAre there any built in commands for Python, or would I need access to some database which contains this type of information, or are there any Python APIs? Python is not my native language so I am not as familiar with how one would approach such a problem in Python.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":3195,"Q_Id":6611298,"Users Score":0,"Answer":"Ok, here is my answer. I am going to work on cleaning up for public consumption a Python 3.x version of pywhois that I have on my machine and hopefully in the next week I will submit my code to the subversion repository. From the IP addresses I am using, I have about a 78% success rate for retrieving info first by applying gethostbyaddr to the IP address as phihag suggested and then putting that through pywhois. I will let the reader decide for themselves whether that rate is high enough for their particular application.","Q_Score":3,"Tags":"python,reverse-dns,gethostbyaddr,pywhois","A_Id":6644900,"CreationDate":"2011-07-07T13:24:00.000","Title":"In Python, Getting More Info About An 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},{"Question":"I already did a search, but I just couldn't find what I searched for.\nI want to create a Python Module using C++ and Visual C++ Express 2010.\nNow, I need to include Python.h, but when I compile it says it couldn't find Python.h. How do I give my VC the Python header file ?","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":4649,"Q_Id":6613039,"Users Score":5,"Answer":"Tell IDE where header is located:\nProject -> Properties -> C\/C++ -> Additional Include Directories","Q_Score":0,"Tags":"c++,python,visual-c++-2010-express","A_Id":6613094,"CreationDate":"2011-07-07T15:24:00.000","Title":"How do I get Visual Express 2010 to find my python.h header 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},{"Question":"I already did a search, but I just couldn't find what I searched for.\nI want to create a Python Module using C++ and Visual C++ Express 2010.\nNow, I need to include Python.h, but when I compile it says it couldn't find Python.h. How do I give my VC the Python header file ?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":4649,"Q_Id":6613039,"Users Score":0,"Answer":"You either have to set the path to to the python include files in your IDE. Navigate to Tools | Options | Projects and Solutions | VC++ Directories and add the path under Include Directories.","Q_Score":0,"Tags":"c++,python,visual-c++-2010-express","A_Id":6613085,"CreationDate":"2011-07-07T15:24:00.000","Title":"How do I get Visual Express 2010 to find my python.h header 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},{"Question":"I came across a potential issue when migrating from a 32bit system to a 64bit system.\nthe system runs two 'one way' encryption algos on the string. \nHowever when I tried the same code on a 64 bit system the hashes were different, now thats fine but does anyone have any method on how to ensure the the hash can still be retreived and matched in the future when upgrading to 64bit and beyond?\nWithout risking the customers sensitive password? or ever storing the raw password or other sensitive data without encryption?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":309,"Q_Id":6615529,"Users Score":3,"Answer":"Basically, just make sure that you're using the same algorithm. If your hashes were different with the same inputs, you were using a different algorithm; there may be some unstated dependencies upon the underlying word size. Make sure you don't use those types of algorithms, or if you do, that they have very clear expectations of the word sizes and that those things can be overridden by you.","Q_Score":1,"Tags":"java,php,python,encryption","A_Id":6615599,"CreationDate":"2011-07-07T18:44:00.000","Title":"Password hashing on 32bit system then migrating to 64bit systems","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to use python in order to simulate social networks, this requires matplotlib.pyplot, networkx and xlrd. Everything works fine from terminal, IDLE or X11 but when I try to use TextMate import matplotlib.pyplot as plt and import xlrd throws up ImportError: No module named... however import networkx works fine! \nI downloaded python via EPD and so matplotlib came ready baked in however I got xlrd and networkx with easy_install. \nAnybody have an idea what might be going on?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1391,"Q_Id":6616005,"Users Score":5,"Answer":"You need to tell TextMate which Python to use. One way to do that is to define the shell variable TM_PYTHON with an absolute path to the Python interpreter you want to use. In the TextMate menu, select Preferences, then the Advanced tab, then the Shell Variables tab, and click + to add the new variable. If you don't know the absolute path to the EPD Python, type which python (or whatever you are using to start Python) in a Terminal shell window.","Q_Score":0,"Tags":"python,module,matplotlib,textmate","A_Id":6616093,"CreationDate":"2011-07-07T19:29:00.000","Title":"Just downloaded TextMate, can't import 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},{"Question":"Background\nThe group I work with has been using and developing a Python package, which for the purposes of this question I'll call foobuilder. We serve updates for Linux systems using private RPM and Deb repositories we provide for our users.\nRecently, a public package was added to PyPi with the same name. It also got packaged on the public Debian repository, among other places. Since we don't publicly advertise our package, it's understandable that a package with the same name has popped up.\nConcerns\nThis looks like a big problem for foobuilder because somewhere down the line, a user might try to install our foobuilder while the public foobuilder package is installed on the same system.\nBesides the obvious problem in Python, I would guess that adding our repository to a Debian package manager program could also cause some issues, though I haven't played around with this situation yet.\nProblem\nSince we've been using the proprietary foobuilder for years, there is a ton of code in existence which wants to import foobuilder and expects to get our package, so I don't think it's feasible to change the name.\nMy thoughts on possible solutions\nPython\nI've considered changing the name of the package to my_foobuilder, and having it include a meta-package called foobuilder which consists only of an __init__.py that imports everything from my_foobuilder. I could instruct new users to import my_foobuilder directly. Then I could begin to deprecate the foobuilder name. In the end this would result in the same amount of work as if I changed foobuilder to my_foobuilder now, since everyone needs to be served updates and the foobuilder name can't be in deprecation purgatory forever.\nDebian\nThe Debian problem shouldn't be too hard to solve; I can change the debian package name to my_foobuilder but have it still install the same (conflicting) Python package. I could then set the my_foobuilder package to Conflict with foobuilder. It might require users to fiddle around with their package manager to get things back on track during the transition but I don't think that's a big deal. Still, this prevents users from using the public foobuilder package at the same time.\nQuestion\nIs there an easier or better way to treat this situation than what I've considered above? Are there any problems with the solutions I'm considering? How would you deal with this?","AnswerCount":3,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":1217,"Q_Id":6617895,"Users Score":3,"Answer":"I'd email the new foobuilder package author to discuss the problem. Obviously one of you needs to change package name; due to proprietary nature of your program is may be undesirable to change its name... Asking this question to the new package author may come up with some new solutions. \nThere really is no sane way to have Python handle this in a way so 'import foobuilder' can mean 2 things.","Q_Score":13,"Tags":"python,debian,packages,naming","A_Id":6634222,"CreationDate":"2011-07-07T22:28:00.000","Title":"How to deal with a proprietary Python package name conflicting with a public 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":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am about to start into a daemon project with a friend, he will do the design and I will do the coding\nI am confused between Python and C++\nI know C++, but I need to learn Python if I will go with it\nThe daemon I am about to write will be more than 1 daemon actually, each one is responsible for a function, such as accepting SSL connections from network, stream audio and video, sending files and data and more network operations, I like going with C++ but I am afraid from the time I'll lose fixing the memory leaks that will occur (for sure), but also I am afraid from Python because I don't know it and I don't know if it can do the job for me or not\nAny suggestions?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":453,"Q_Id":6621501,"Users Score":1,"Answer":"Use the right tool for the right job. If you want a process that keeps on running for a long time you will want a proof of some of it's correctness (not a complete one, but at least something). This proof is given to you by the compiler or interpreter accepting the language. It depends a lot on the language, what kind of things are proven about your program. For python you get a proof of syntactic correctness, that is all. If you use C++ existence of all methods and some type soundness will also be proven. This is much better for long running processes, such as daemon. There are languages, where you can use the compiler to prove even more, but this is often not as simple.\nDon't worry too much about the memory leaks. As has been pointed out in the comments, if you use modern C++ memory leaks or memory corruption are not an issue anymore and speed will be much higher, than if a garbage collector is present. Use C++ or C++0x but not C\/C++, and all will be fine.","Q_Score":0,"Tags":"python,linux,daemon","A_Id":6622182,"CreationDate":"2011-07-08T07:48:00.000","Title":"Using python to write a daemon instead of 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},{"Question":"I'm trying to import pycassa library in a Python project in Aptana 3, but in the line \"import pycassa\" it show me the next error: \"Unresolved import: pycassa\". I installed pycassa with easy install and if I run \"import pycassa\" in a python shell it run with no errors. If I run the Aptana project run with no errors too, but the error mark continues. Why?\nSorry for my english.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":5859,"Q_Id":6621902,"Users Score":0,"Answer":"I had the same problem with Tastypie. I tried to add external library to project using Preferences-PyDev PUTHONPATH, but it didn't work for me...\nBut then I found solution: Window-Preferences-PyDev-Interpreter Python-Libraries-New folder (Button). Choose folder with needed library and Aptana should work fine then.","Q_Score":12,"Tags":"python,pydev,aptana,pycassa","A_Id":26035528,"CreationDate":"2011-07-08T08:31:00.000","Title":"Aptana 3 Unresolved import - 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},{"Question":"I'm trying to import pycassa library in a Python project in Aptana 3, but in the line \"import pycassa\" it show me the next error: \"Unresolved import: pycassa\". I installed pycassa with easy install and if I run \"import pycassa\" in a python shell it run with no errors. If I run the Aptana project run with no errors too, but the error mark continues. Why?\nSorry for my english.","AnswerCount":2,"Available Count":2,"Score":0.4621171573,"is_accepted":false,"ViewCount":5859,"Q_Id":6621902,"Users Score":5,"Answer":"The only working solution for me: open menu \u201cWindow\u201d \u2192 \u201cPreferences\u201d \u2192 \u201cInterpreter - Python\u201d, then click button \u201cApply\u201d, select your interpreter and then \u201cOK\u201d. Pydev will rescan all packages and in some seconds all unresolved imports disappear.\nUnfortunately I have to do these steps on every restart because Pydev always \u201cforget\u201d some packages after restart\u2026","Q_Score":12,"Tags":"python,pydev,aptana,pycassa","A_Id":6888449,"CreationDate":"2011-07-08T08:31:00.000","Title":"Aptana 3 Unresolved import - 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},{"Question":"I have some code available in some form of AST and I would like to execute it.\nI can think of several ways to do this, e.g.:\n\nJust straight-forwardly interpret it.\nTranslate it into a Python AST (the ast module) and\n\nPython-compile that or\nPython-eval that.\n\nTranslate it into Python source code (e.g. a pure string) and\n\nPython-compile that or\nPython-eval that.\n\nTranslate it in some form of low level code and write a simple VM in Python which runs that.\n\nI guess I would get the fasted execution by translating it into a Python AST, compile that and run that. Esp. when using PyPy, I might even get improvements by PyPys JIT compiling optimizations (I hope I do, do I?).\nCan you think of other possibilities? Can you give suggestions on what might be the best way?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":314,"Q_Id":6626901,"Users Score":0,"Answer":"Another possibility: translate the AST directly to Python byte code and execute that. This is like your last idea except using the existing Python VM.\nIt is not a great possibility because it could be a lot of work and Python compile would probably do a better job except in rather peculiar cases, but I'm just throwing it out there.","Q_Score":5,"Tags":"python,scripting,abstract-syntax-tree,jit,vm-implementation","A_Id":6627457,"CreationDate":"2011-07-08T15:42:00.000","Title":"possibilities for fast dynamic code execution 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},{"Question":"I have a Python project with the following directory structure:\n\nproject\/\nproject\/src\/\nproject\/src\/somecode.py\nproject\/src\/mypackage\/mymodule.py\nproject\/src\/resources\/\nproject\/src\/resources\/datafile1.txt\n\nIn mymodule.py, I have a class (lets call it \"MyClass\") which needs to load datafile1.txt. This sort of works when I do:\nopen (\"..\/resources\/datafile1.txt\")\nAssuming the code that creates the MyClass instance created is run from somecode.py.\nThe gotcha however is that I have unit tests for mymodule.py which are defined in that file, and if I leave the relative pathname as described above, the unittest code blows up as now the code is being run from project\/src\/mypackage instead of project\/src and the relative filepath doesn't resolve correctly.\nAny suggestions for a best practice type approach to resolve this problem? If I move my testcases into project\/src that clutters the main source folder with testcases.","AnswerCount":5,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":11129,"Q_Id":6629597,"Users Score":0,"Answer":"The filepath will be relative to the script that you initially invoked. I would suggest that you pass the relative path in as an argument to MyClass. This way, you can have different paths depending on which script is invoking MyClass.","Q_Score":11,"Tags":"python,unit-testing,resources","A_Id":6629638,"CreationDate":"2011-07-08T19:40:00.000","Title":"Accessing resource files in Python unit tests & main 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},{"Question":"I am running Ubuntu Natty and install Emacs and pymacs and ropemacs all from the repos. So when I add to my .emacs file the script to load ropemacs and pymacs I get the following error:\nFile mode specification error: (error \"Pymacs Lisp version is 0.23, Python is 0.24-beta2\"\nI've been reading the docs and readmes but I haven't found out what is happening here. So I turn to you. Any ideas? Thanks!","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":486,"Q_Id":6635759,"Users Score":0,"Answer":"I install pymacs manually the python part,and i use the pymacs package in the elpa's python-mode (it contains pymacs.el),then this two conflict,i remove the pymacs in python-mode,it works well.maybe you are the same error.Or you should check your python version.","Q_Score":1,"Tags":"python,emacs23,ropemacs,pymacs","A_Id":8797023,"CreationDate":"2011-07-09T15:42:00.000","Title":"Pymacs lisp version rarities","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"So I have a Superclass (which for simplicity I'll call), Mammal, from which classes Dog, Monkey, and Bear inherit methods. Some of the inherited methods return an object that needs to be of the same class it is called from. For example, Dog.find(...) should return Dog objects. But because the find() method is inherited from Mammal, the method can't be coded to explicitly return Dog(...). It would need to be able to return Dog, Monkey, Bear, or Mammal objects, depending on the value of self.__class__.__name__.\nI've achieved this with return eval(self.__class__.__name__)(...), but I'd prefer to avoid using eval. Is there a better way?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1943,"Q_Id":6639536,"Users Score":3,"Answer":"Just try return self.__class__()","Q_Score":0,"Tags":"python","A_Id":6639553,"CreationDate":"2011-07-10T06:06:00.000","Title":"Returning an object based on __class__.__name__ 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},{"Question":"I am looking to set up a continuous integration server for a python project. Normally this would build the project however as python is not built as such, what should be done instead? Just unit tests? Or are there additional steps that anyone can recommend?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2281,"Q_Id":6640385,"Users Score":0,"Answer":"Using Jenkins\/Hudson for continuous integration is the standard approach.","Q_Score":8,"Tags":"python,continuous-integration","A_Id":6640410,"CreationDate":"2011-07-10T09:50:00.000","Title":"python continuous integration","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"This is my python script which creates a \"test.txt\" file when executed. when I execute using terminal (Ubuntu 11.04) root@gml-VirtualBox:\/var\/www\/HMS# python test.py. It creates the \"test.txt\" in the \/var\/www\/HMS directory as I expected.\n\ntest.py:\n\n#!\/usr\/bin\/env python\n\ndef init():\n filename = \"test.txt\"\n file = open(filename, 'w')\n file.write(\"This is the new content of test.txt :-)\")\n file.close()\n print \"done\"\n\ndef main():\n init()\n\nif __name__ == '__main__':\n main()\n\nBut when I try to call this test.py using PHP, It's not creating the 'test.txt' output file. \n\nindex.php:\n\n$tmp = exec(\"python test.py\");\necho \"temp: $tmp\";\n\n\nBoth test.py & index.php are in the same directory(\/var\/www\/HMS\/). But when I modified the test.py like this:\n\n#!\/usr\/bin\/env python\n\ndef init():\n print \"done\"\n\ndef main():\n init()\n\nif __name__ == '__main__':\n main()\n\n\nIt prints temp: done in the browser, which is what I expected. \nI don't know why my previous python code didn't work as expected.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":584,"Q_Id":6645801,"Users Score":1,"Answer":"When you test the python script on the command line, you're running as root. Chances are you're not running the webserver as root (which is a good thing), and the webserver's user does not have appropriate permissions to create and\/or write to that file.","Q_Score":1,"Tags":"php,python","A_Id":6645831,"CreationDate":"2011-07-11T04:37:00.000","Title":"Problem in calling Python script from 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":1,"Web Development":0},{"Question":"I'm a self-taught programmer who jumped into Python as my first language about 7-8 months ago. I'm fairly solid at making things work, though my foundational knowledge is limited thanks to my questionable choice in college to not study computer science. \nBeyond Python, I'm not really familiar with C or other lower level languages. \nI would like to teach myself Objective C as a foray into programming iPhone apps (as a hobby initially). I initially want to create relatively simple utility apps (I think they are relatively simple, at least). \nCould any one give me a guess as to how long it might take me to pick up Objective C and actually produce a semi-decent app? If time is of the essence, should I just scrap it and go with HTML5? \nI pick things up fairly fast but, again, my background in Comp Sci is really limited. \nSorry if this question is a bit too general and thanks for any insight!","AnswerCount":5,"Available Count":2,"Score":0.0399786803,"is_accepted":false,"ViewCount":5620,"Q_Id":6666499,"Users Score":1,"Answer":"You should learn both, Objective-C and HTML5. HTML5 isn't very difficult to grasp even if you don't have any experience.","Q_Score":8,"Tags":"iphone,python,objective-c,c","A_Id":6666567,"CreationDate":"2011-07-12T15:11:00.000","Title":"Python to Objective C (Expected Learning Curve)","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},{"Question":"I'm a self-taught programmer who jumped into Python as my first language about 7-8 months ago. I'm fairly solid at making things work, though my foundational knowledge is limited thanks to my questionable choice in college to not study computer science. \nBeyond Python, I'm not really familiar with C or other lower level languages. \nI would like to teach myself Objective C as a foray into programming iPhone apps (as a hobby initially). I initially want to create relatively simple utility apps (I think they are relatively simple, at least). \nCould any one give me a guess as to how long it might take me to pick up Objective C and actually produce a semi-decent app? If time is of the essence, should I just scrap it and go with HTML5? \nI pick things up fairly fast but, again, my background in Comp Sci is really limited. \nSorry if this question is a bit too general and thanks for any insight!","AnswerCount":5,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":5620,"Q_Id":6666499,"Users Score":0,"Answer":"Well when i started progamming for Objective-c i was well known in Java, but nothing close to C\/Objective-c. It took me around 1 month to learn the basics (using tutorials etc).\nThere are some really good tutorials on iTunes (search for Objective-c seminar). I also used a couple of pdf's to use them as backup while making my first app. That helped alot!","Q_Score":8,"Tags":"iphone,python,objective-c,c","A_Id":6666588,"CreationDate":"2011-07-12T15:11:00.000","Title":"Python to Objective C (Expected Learning Curve)","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},{"Question":"I am using to twill to do integration testing for an AppEngine (using tipfy micro framework) application but unfortunately twill is not maintained and I cannot test PUT and DELETE requests.\nIs there any similar solution?\nI am thinking of using PhantomJS, there are some python bindings and it can execute JS (as it is a headless webkit but I have not found much).","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1072,"Q_Id":6678523,"Users Score":2,"Answer":"There are not many alternatives for headless JS testing, you could try selenium 2 web driver. Good luck :)","Q_Score":3,"Tags":"python,google-app-engine,integration-testing,tipfy,twill","A_Id":6681186,"CreationDate":"2011-07-13T12:02:00.000","Title":"Twill alternative for integration 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":1},{"Question":"Im having some import problems with an application I developed in python with Eclipse\/PyDev.\nRunning the app from within Eclipse is no problem but when I try running it through the linux terminal the imports (which are imported from other folders (packages in Eclipse)) are broken and I get an ImportError: No module named xxx..\nFrom previous experiences developing Java-apps in Eclipse I always solved this through exporting the project to a runnable jar-file but this isn't an option with Python.\nIs there a way of circumventing this? I'd rather not put all my .py-files in a single folder since I very much like the package-system (guess Java has damaged me). Can I change the import statement to make it work in both Eclipse and the terminal or do I have to abandon PyDev if I want this to work in the terminal?\nThanks for any help!\nSlim","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":408,"Q_Id":6681690,"Users Score":2,"Answer":"The key here is that PyDev and Eclipse manage a custom Python Path when you're launching within Eclipse. You can modify your environment variables to contain a more complete PYTHONPATH value that contains the locations where you're importing from, or you can use sys.path.append() to add directories to the path at run time so that the imports can be resolved.","Q_Score":2,"Tags":"python,eclipse,terminal,pydev","A_Id":6681756,"CreationDate":"2011-07-13T15:45:00.000","Title":"Problem running PyDev-developed apps in 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":1},{"Question":"Currently I have a \"main\" folder where all of the modules I write eventually go, but I usually place the modules I'm currently working on in a 'dev' folder just so I don't clutter up the other folder with stuff that aren't ready.\nThe structure looks like this\n\nMyProg\n|-run.py\n|-\\lib\n| |-someLibrary.py\n| ...\n|\n|-\\main\n| |-readyScripts.py\n| ...\n|\n|-\\dev\n |-inProgress.py\n\nRun.py will import scripts from the main folder.\nScripts in the main folder use relative imports to import someLibrary from the lib folder, and it works fine.\nHowever, it doesn't work when I'm still writing my program in the dev folder and running it directly from there (ie: python inProgress.py), saying that I \"attempted relative import in non-package\"\nIs there a way to be able to import modules from the lib folder while I am working on scripts in dev?\nEDIT: this is my import statement in inProgress.py:\n\nfrom .lib import someLibrary\n\nIdeally, I would like to keep it this way so that when I move it to the main folder, I won't have to do anything to the import statement.","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2770,"Q_Id":6683165,"Users Score":0,"Answer":"Set your PYTHONPATH to one level up, and then run it with the package syntax?","Q_Score":4,"Tags":"python,import","A_Id":6683207,"CreationDate":"2011-07-13T17:40:00.000","Title":"Relative import from current 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},{"Question":"Here is my scenario.\nI have a ajax call in my web site to find the elevation at particular point. Once this point comes into an action of a controller in Ruby on rails, I have to use python on command line to find the elevation.\nThe following sequence of commands in DOS does that for me.\n\npython (starts a python session)\nimport arcpy (takes a lot of time)\nfunction call (very fast).\n\nNow if I put this into a script and run it, I do get the result, but its very slow, because the 'import' step takes a lot of time. But the actual function takes less than a second. \nAs all this is suppose to happen behind an Ajax call on ror web site, such a large delay is unacceptable.\nQuestion:\nIs it possible for me in Ror to open a 'command line session' when the application loads and issue the first two commands, and then use this session every time a request comes in a controller's action, and issue the third command, and return its output?\nIf yes can someone please post some samples?\nThanks\nShaunak","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":95,"Q_Id":6685530,"Users Score":1,"Answer":"What you are proposing could be possible if Rails was friendlier about forked processes. A cleaner and better solution would be to write a python daemon that you could query so that you don't incur the startup penalty. (This could be a web-service or a daemon you communicate with standard network sockets or whatever).","Q_Score":0,"Tags":"python,ruby-on-rails,session,command-line,dos","A_Id":6685611,"CreationDate":"2011-07-13T20:54:00.000","Title":"issuing dos commands from inside ruby on rails controller in the same dos 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":1},{"Question":"Is there a way in a huge python file , you just see the function def you are interested in ? I remember Eclipse has an option to do this in Java and it was pretty helpful.How about for Python in PyDev\/Aptana Studio 3?","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":1098,"Q_Id":6700416,"Users Score":2,"Answer":"Look in Window > Preferences > PyDev > Editor > Code Folding. Enable Folding for Function Definitions. Then hit Ctrl-9 and Ctrl-0 to fold and unfold your code.\nEdit: You can also use Ctrl-- (minus) and Ctrl-= to fold and unfold single levels.","Q_Score":0,"Tags":"python,eclipse,pydev,aptana,outline-view","A_Id":6700834,"CreationDate":"2011-07-14T21:56:00.000","Title":"Show only python function def in PyDev Eclipse\/Aptana","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I have an application made in Django which finally uses Reportlab to generate the pdf file by accessing the data from some tables.\nThere are some imports like: \nfrom rlextra.graphics.guiedit.datacharts import DataAwareDrawing, ODBCDataSource, DataAssociation\nfrom reportlab.graphics.charts.barcharts import VerticalBarChart3D\nfrom reportlab.graphics.shapes import _DrawingEditorMixin \nin my reportlab file. I am using Eclipse for generating the Django application. When I included the reportlab py file in the application, its showing errors that these imports can not be resolved.\nI included the rlextra and reportlab folders in the application by which the last 2 imports can be resolved by first one couldnt be. \nI went inside diving through the rlextra folder to find that,folder guidedit does not contain any folder datacharts by has a pyc file of that name. My eclipse is not understanding what does DataAwareDrawing, ODBCDataSource, DataAssociation mean. \nWhen I run the same reportlab py from outside eclipse separately as a python file it does the work properly. But Eclipse is not understanding what is required and from where to get it.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":318,"Q_Id":6701114,"Users Score":0,"Answer":"rlextra is a proprietary addition on top of ReportLab. You only get the .pyc files but not the source .py files when you receive the package. I do remember a packaging issue with datacharts.pyc on version 2.4 that was reported by a client and fixed on the day. If you contact ReportLab they will be more than happy to help you.","Q_Score":0,"Tags":"python,django,eclipse,eclipse-plugin,reportlab","A_Id":8851849,"CreationDate":"2011-07-14T23:20:00.000","Title":"eclipse with reportlab","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I retrieve a unix timestamp from a web service in a Python program. This timestamp is in a USA timezone. In order to insert it in a MySQL database with other objects, localized in France, I would like to convert this timestamp to the French timezone.\nI could do it with mathematical functions, but there is the issue of daylight savings time. I would prefer to use Python time and date specific functions which should deal with these concepts.\nDo you have a hint, I am lost in the Python documentation?","AnswerCount":3,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":8568,"Q_Id":6706808,"Users Score":8,"Answer":"If it's really a unix timestamp, then it's UTC based. Just interpret it correctly for your use case. Apply the timezone translation only when you have to print this date as text.\nIf you're storing it as timestamp on your side too, keep it exactly as it is.","Q_Score":8,"Tags":"python,datetime,date,timezone","A_Id":6706828,"CreationDate":"2011-07-15T12:16:00.000","Title":"Changing a unix timestamp to a different timezone","Data Science and Machine Learning":0,"Database and SQL":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},{"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},{"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},{"Question":"I'm using Pydev with Eclipse on Mac. My python interpeter is macports python 2.6. \nRight now the python package i'm working on is in my eclipse workspace, but the only way I can get my scripts to run is if I first install it into the macports 2.6 python site_packages folder. This means each time I make a code change I have to uninstall it, and then re-install it for my python interpreter to pick up the change. \nHow to I tell eclipse to tell python that {workspace}\/mypythonporject should be part of the python path environment?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":932,"Q_Id":6712824,"Users Score":2,"Answer":"Go to Window > Preferences > PyDev > Interpreter - Python. You should have an interpreter set up. If not, click New and browse to it.\nUnder Libraries, click New Folder and browse to the directory you want to include. Click Apply, let it build, and try again.\nEdit: That is if you want to run the scripts THROUGH Eclipse.\nIf you want to run them from, say, the command line, you'll need to add the path to your PYTHONPATH environment variable.","Q_Score":1,"Tags":"python,eclipse,macos","A_Id":6712886,"CreationDate":"2011-07-15T20:31:00.000","Title":"Eclipse pydev project PYTHONPATH with macports python 2.6","Data Science and Machine Learning":0,"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},{"Question":"I want to add a feature to search documents stored in a directory. The back end is developed in Python to additionally manipulate the search results. The documents are stored in a dedicated web server.\nThe established technologies (Lucene, Xapian, Whoosh) have mature python bindings. My colleagues have set up Apache, Lucene and PHP for their clients. I would choose Whoosh for being written in Python, but I am scared by reviews of its slow performance and lack of \"feature X\". \nMy specific requirements are:\nSupport (makes me bite my nails)\n\nwell supported in Python\ntech support of major hosts can easily set it up\nscales well for upto 100000 documents\nupdating the index for 4 new files shouldnt slow down our dedicated server\n\nFeatures (I am a newb here)\n\nreturns data in a format which I can manipulate by myself \ncan return highlighted text snippets\nhigher priority for certain files and words in title or bold","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":174,"Q_Id":6716125,"Users Score":1,"Answer":"Solr, even though written in Java is an amazingly powerful search engine.\nIt has everything you need like highlighting, weight, ability to insert new items in the index relatively fast, and also a whole slew of other features like ability to provide autocomplete-like features.\nIt has json \/ xml \/ other response methonds, and a fairly good way in python to the search engine.","Q_Score":0,"Tags":"python,full-text-search","A_Id":6720127,"CreationDate":"2011-07-16T07:48:00.000","Title":"Best-suited text indexer for handling 10000s of (formatted) documents 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},{"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},{"Question":"I'm looking for a way to write a XMPP bot that would listen to a RabbitMQ queue and send messages to the XMPP channel notifying users of any new issues ( already got Nagios sending notifications to RabbitMQ).\nI've tried using xmppy and it stopped working and I stumbled across SleekXMPP which looks fairly better. \nI'm just wondering if I define a AMQP listener to automatically call the XMPP \"send\" method in the bot. So it would be listening both on AMQP and XMPP at the same time. \nThank you for your help!\nEdit: Would BOSH be much better solution here ?","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":571,"Q_Id":6723588,"Users Score":1,"Answer":"This is really quite simple. I suggest that you start by writing an AMQP listener that simply prints out received messages. Once you get that working it should be obvious how to integrate that into an XMPP bot.","Q_Score":0,"Tags":"python,xmpp,amqp","A_Id":6724730,"CreationDate":"2011-07-17T11:40:00.000","Title":"Interconnecting AMQP and XMPP","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},{"Question":"I am a newb coder in a startup and I am implementing search of documents in a directory in a web host.\nI am comparing Lucene\/Solr, Whoosh, Sphinx and Xapian. Whoosh is natively python. But I want your opinions on it too. Which of these have \n\nmature and easy to use and install interfaces with python? (Whoosh is a no-brainer)\nno chance for crashes, bottlenecks and other failures\nbest documented interface (Im not reading PHP docs because python docs were sparse)\neasiest to get up and running (only one has a quick-start tutorial)","AnswerCount":3,"Available Count":1,"Score":0.1325487884,"is_accepted":false,"ViewCount":2946,"Q_Id":6724672,"Users Score":2,"Answer":"Use Whoosh if you don't need the speed, extra features of the alternatives. It's great, has a nice API, good documentation. My second choice would probably be Xapian, which is fast and has a fairly decent API. They are all fairly mature products. If you don't know what you really need, I'd just go with Whoosh for now.","Q_Score":8,"Tags":"python,solr,full-text-search,sphinx,whoosh","A_Id":6724817,"CreationDate":"2011-07-17T15:04:00.000","Title":"Among Lucene\/Solr, Whoosh, Sphinx, Xapian which integrates best 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},{"Question":"I'm trying to get an xml report of the results of my behavior tests running in the lettuce framework. According the --help for lettuce, you should use the switch --with-xunit. I've done that (and also used --xunit-file) but no report is generated. I tried reinstalling lettuce but still no luck. How can I get it to generate this report?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":2043,"Q_Id":6739856,"Users Score":1,"Answer":"This was actually something simple: the folder the tests were running in were owned by root so I needed to run the tests with sudo in order for it to generate the report.","Q_Score":1,"Tags":"python,lettuce","A_Id":6884086,"CreationDate":"2011-07-18T21:49:00.000","Title":"Python lettuce test results in XML","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},{"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},{"Question":"My hard drive is full.\nWhat is the easiest way to find out the TOP 5 FOLDERS that consume the most disk space?\nA python solution would be greatly appreciated. I use Ubuntu Linux.","AnswerCount":4,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":475,"Q_Id":6748791,"Users Score":0,"Answer":"You could just check the properties of each folder and look for the total size of the files in it. In Ubuntu, just right click on the folder, click properties and check the contents size. Not a python solution, but much easier (not everything needs a script to find the answer). The biggest folders will likely be the ones at the top of the tree.","Q_Score":1,"Tags":"python","A_Id":6748862,"CreationDate":"2011-07-19T14:26:00.000","Title":"Top 5 Folders Consuming The Most Space?","Data Science and Machine Learning":0,"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},{"Question":"Suppose that one is interested to write a python app where there should be communication between different processes. The communications will be done by sending strings and\/or numpy arrays.\nWhat are the considerations to prefer OpenMPI vs. a tool like RabbitMQ?","AnswerCount":2,"Available Count":2,"Score":0.3799489623,"is_accepted":false,"ViewCount":4063,"Q_Id":6756630,"Users Score":4,"Answer":"This is exactly the scenario I was in a few months ago and I decided to use AMQP with RabbitMQ using topic exchanges, in addition to memcache for large objects.\nThe AMQP messages are all strings, in JSON object format so that it is easy to add attributes to a message (like number of retries) and republish it. JSON objects are a subset of JSON that correspond to Python dicts. For instance {\"recordid\": \"272727\"} is a JSON object with one attribute. I could have just pickled a Python dict but that would have locked us into only using Python with the message queues.\nThe large objects don't get routed by AMQP, instead they go into a memcache where they are available for another process to retrieve them. You could just as well use Redis or Tokyo Tyrant for this job. The idea is that we did not want short messages to get queued behind large objects. \nIn the end, my Python processes ended up using both AMQP and ZeroMQ for two different aspects of the architecture. You may find that it makes sense to use both OpenMPI and AMQP but for different types of jobs.\nIn my case, a supervisor process runs forever, starts a whole flock of worker who also run forever unless they die or hang, in which case the supervisor restarts them. The work constantly flows in as messages via AMQP, and each process handles just one step of the work, so that when we identify a bottleneck we can have multiple instances of the process, possibly on separate machines, to remove the bottleneck. In my case, I have 15 instances of one process, 4 of two others, and about 8 other single instances.","Q_Score":7,"Tags":"python,messaging,mpi,rabbitmq,amqp","A_Id":6757194,"CreationDate":"2011-07-20T03:18:00.000","Title":"Python: OpenMPI Vs. 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},{"Question":"Suppose that one is interested to write a python app where there should be communication between different processes. The communications will be done by sending strings and\/or numpy arrays.\nWhat are the considerations to prefer OpenMPI vs. a tool like RabbitMQ?","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":4063,"Q_Id":6756630,"Users Score":13,"Answer":"There is no single correct answer to such question. It all depends on a big number of different factors. For example:\n\nWhat kind of communications do you have? Are you sending large packets or small packets, do you need good bandwidth or low latency?\nWhat kind of delivery guarantees do you need?\nOpenMPI can instantly deliver messages only to a running process, while different MQ solutions can queue messages and allow fancy producer-consumer configurations.\nWhat kind of network do you have? If you are running on the localhost, something like ZeroMQ would probably be the fastest. If you are running on the set of hosts, depends on the interconnections available. E.g. OpenMPI can utilize infiniband\/mirynet links.\nWhat kind of processing are you doing? With MPI all processes are usually started at the same time, do the processing and terminate all at once.","Q_Score":7,"Tags":"python,messaging,mpi,rabbitmq,amqp","A_Id":6756939,"CreationDate":"2011-07-20T03:18:00.000","Title":"Python: OpenMPI Vs. 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},{"Question":"I have ported python3 csv module to C# what license could I use for my module? \nShould I distribute my module? \nShould I put PSF copyright in every header of my module?\nthanks","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":122,"Q_Id":6761201,"Users Score":0,"Answer":"You need to pay a copyright lawyer to tell you that. But my guess is that you need to use the PSF license. Note that PSF does not have the copyright to Python source code. They coders do how that copyright translates into you making a C# port is something only a copyright expert can say. Also note that it is likely to vary from country to country.\nCopyright sucks.","Q_Score":1,"Tags":"python,module,licensing","A_Id":6761407,"CreationDate":"2011-07-20T11:33:00.000","Title":"Ported python3 csv module to C# what license should I use for my module?","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},{"Question":"How do I generate a unique ID value that can be easily passed on via phone or email, that can be easily remembered while still not being easily guessable.\nI am using database. But as I am giving away the ID to people I do not want it to be bound to a database. I could do something with the unique ID I already have in database, but cannot use it directly, to avoid it being guessable.\nI am using Python and have tried using uuid, but uuid is too long to be human readable. \nIs there any way to create a human friendly pronounceable ID?","AnswerCount":5,"Available Count":1,"Score":0.0798297691,"is_accepted":false,"ViewCount":14441,"Q_Id":6761898,"Users Score":2,"Answer":"How about something like Amazon's payphrases? Convert the binary ID to a sequence of english words.\nIf you want something with the same range as a UUID, you need to represent 16 bytes.\nTo keep it reasonable, restrict the phrase to 4 words, so each word represents 4 bytes, or 65536 possibilities, so you'll need a dictionary of 262,144 words.\nEDIT:\nActually on reflection what might be better is a sort of mad lib sentence - it will restrict the number of needed words and may make it easier to remember since it has a grammatical structure. It will need to be longer, of course, perhaps something like this:\n(a\/an\/the\/#) (adj) (noun) (verb)(tense) (adverb) while (a\/an\/the\/#) (adj) (noun) (verb) (adverb).","Q_Score":17,"Tags":"python,random,unique,uniqueidentifier","A_Id":6762089,"CreationDate":"2011-07-20T12:30:00.000","Title":"How to generate a human friendly unique ID 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},{"Question":"I'm writing an application that connects to twitter and uses the OAuth API, my issue is with storing the consumer_key and the consumer_key_secret\nHow can I safely store these values so they're difficult for the user to get to but still have ability to use them within my application?\nI've had storing them within a pyc and encrypting them as suggestions so far, but I'm open to any other ideas.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":167,"Q_Id":6770610,"Users Score":1,"Answer":"An alternative to DRM (which is what you are describing) is to proxy the secured interaction through a server application on your own, controlled machine. Since you're using OAuth, you can use the same authentication credentials against your own server as you would connecting directly to twitter.\nThe advantage to this approach is that there is no private key disclosure; you don't share your private key with your consumers, since that's stored on a remote server that they cannot read, and your consumers don't share their passwords with you (instead, they get an OAuth token which ties that particular login to your specific service).","Q_Score":0,"Tags":"python,encryption,credentials","A_Id":6770811,"CreationDate":"2011-07-21T02:12:00.000","Title":"A way to store sensitive data to disk, without (serious) fear of user tampering?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"Wanted to get some feedback on this implementation.\nI'm developing an application on the PC to send and receive data to the serial port.\nSome of the data received by the application will be solicited, while other data unsolicited.\nControlling the serial port and processing messages would be handled by a Python application that would reside between the serial port and the MySQL database. This would be a threaded application with one thread handling sending\/receiving using the Queue library and other threads handling logic and the database chores.\nThey MySQL database would contain tables for storing data received from the serial port, as well as tables of outgoing commands that need to be sent to the serial port. A command sent out may or not be received, so some means of handling retries would be required.\nThe webapp using HTML, PHP, and javascript would provide the UI. Users can query data and send commands to change parameters, etc. All commands sent out would be written into an outgoing table in the database and picked up by the python app.\nMy question: Is this a reasonable implementation? Any ideas or thoughts would be appreciated. Thanks.","AnswerCount":2,"Available Count":2,"Score":0.1973753202,"is_accepted":false,"ViewCount":743,"Q_Id":6791799,"Users Score":2,"Answer":"It seems there's a lot of places for things to go wrong.\nWhy not just cut out PHP all together and use python?\ne.g. Use a python web framework & let your JavaScript communicate with that and while also reading the serial port and logging to MySQL.\nThat's just me though. I'd try and cut out as many points where it could fail as possible and keep it super simple.","Q_Score":1,"Tags":"javascript,php,python,mysql,serial-port","A_Id":9482670,"CreationDate":"2011-07-22T14:50:00.000","Title":"Controlling serial port through a webapp(PHP, javascript) using MySQL 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":1},{"Question":"Wanted to get some feedback on this implementation.\nI'm developing an application on the PC to send and receive data to the serial port.\nSome of the data received by the application will be solicited, while other data unsolicited.\nControlling the serial port and processing messages would be handled by a Python application that would reside between the serial port and the MySQL database. This would be a threaded application with one thread handling sending\/receiving using the Queue library and other threads handling logic and the database chores.\nThey MySQL database would contain tables for storing data received from the serial port, as well as tables of outgoing commands that need to be sent to the serial port. A command sent out may or not be received, so some means of handling retries would be required.\nThe webapp using HTML, PHP, and javascript would provide the UI. Users can query data and send commands to change parameters, etc. All commands sent out would be written into an outgoing table in the database and picked up by the python app.\nMy question: Is this a reasonable implementation? Any ideas or thoughts would be appreciated. Thanks.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":743,"Q_Id":6791799,"Users Score":0,"Answer":"You might also want to check out pySerial (http:\/\/pyserial.sourceforge.net\/). You might also want to think about you sampling rates, i.e. how much data are you going to be generating and at what frequency. in other words how much data are you planning to store. Will give you some idea of system sizing.","Q_Score":1,"Tags":"javascript,php,python,mysql,serial-port","A_Id":10899487,"CreationDate":"2011-07-22T14:50:00.000","Title":"Controlling serial port through a webapp(PHP, javascript) using MySQL 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":1},{"Question":"Any ideas on connecting GitHub with a locally hosted Trac 0.12 instance? We were thinking of using GitHub's email service hook to shoot off an email anytime GitHub is pushed to, which would fire off a script to have our local repo pull from GitHub, and also tell Trac to re-sync the repo. Any ideas to improve on what we were thinking? If you need any more background info, let me know. Thanks!","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":161,"Q_Id":6794100,"Users Score":0,"Answer":"We were trying to avoid opening a port on on our firewall, so we thought an email might be easier than using the post-receive url service hook. If we had a publicly hosted Trac instance, we would definitely go the rout of the post-receive url, but since we are hosted internally, this is not an option.","Q_Score":1,"Tags":"python,git,github,trac","A_Id":6808464,"CreationDate":"2011-07-22T17:56:00.000","Title":"Trying to connect Trac 0.12 (privately hosted) with 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":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to figure out the best way to upload a file to a NodeJS(any server I guess, but just being specific) every 30 mins.\nI was thinking about using perl or python to acheive this, or even NodeJS or a CGI script?\nWould it be best to just create a multi-part form?\nTrying to figure out the best practice.\nThanks.","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":598,"Q_Id":6798305,"Users Score":2,"Answer":"If this isn't part of other program logic, a simple curl --upload-file would do the job. If not, like Dan Grossman commented, any language capable of opening a socket and write HTTP headers and body would work (all assuming your node.js server is speaking http).","Q_Score":0,"Tags":"python,perl,file-upload,node.js","A_Id":6798369,"CreationDate":"2011-07-23T04:50:00.000","Title":"Upload file to NodeJS server every 30 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":1},{"Question":"I'm trying to figure out the best way to upload a file to a NodeJS(any server I guess, but just being specific) every 30 mins.\nI was thinking about using perl or python to acheive this, or even NodeJS or a CGI script?\nWould it be best to just create a multi-part form?\nTrying to figure out the best practice.\nThanks.","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":598,"Q_Id":6798305,"Users Score":1,"Answer":"I might recommend crontab for a job like this. It's a sort of job-scheduler for the operating system, and is designed for 'do this job every so often' tasks.","Q_Score":0,"Tags":"python,perl,file-upload,node.js","A_Id":6798370,"CreationDate":"2011-07-23T04:50:00.000","Title":"Upload file to NodeJS server every 30 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":1},{"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},{"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},{"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},{"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},{"Question":"I am quoting a part of Python documentation:\n\"A program doesn\u2019t run any faster when it is read from a .pyc or .pyo file than when it is read from a .py file; the only thing that\u2019s faster about .pyc or .pyo files is the speed with which they are loaded.\"\nI don't understand what does it mean when it says it doesn't affect the running time but the loading time? Could someone please explain it a little deep that I can understand completely?","AnswerCount":2,"Available Count":1,"Score":0.2913126125,"is_accepted":false,"ViewCount":365,"Q_Id":6803126,"Users Score":3,"Answer":"When you import a module test.py, Python must read the source and convert it into the bytecode Python can execute. This takes time, but Python will store this in test.pyc. This Bytecode is the result of breaking your code down into simpler terms able to run directly on the CPython Virtual Machine.\nIf you load test.pyc, Python doesn't need to compile your source into bytecode before running, so it takes slightly less time to start.\nIf you import the module test.py twice without modifying it or deleting the generated test.pyc, Python checks for the existence of test.pyc and loads it instead - so the performance benefit is automatic.","Q_Score":3,"Tags":"python,time,module,loading","A_Id":6803141,"CreationDate":"2011-07-23T20:31:00.000","Title":"Difference between loading time and running time 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},{"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},{"Question":"When it comes to the frontend code you always minify it (remove white spaces, comments etc) in production.\nShould one do the same with server code? I usually have a lot of comments in my server files. But I have never heard about people doing so.\nWouldn't the server run faster if the code was optimized in the same way?","AnswerCount":4,"Available Count":3,"Score":1.2,"is_accepted":true,"ViewCount":3747,"Q_Id":6810977,"Users Score":74,"Answer":"You're not going to have any improvement as the whitespaces and all formatting are lost when your server side code is translated to machine code (or interpreted). It's also not sent over the wire, it's read from the local filesystem, so while having less characters would lead to a faster startup, it would not make any difference on the long run and the startup speed gain would be marginal (or even unnoticeable).\nSo, no, minifying your server side code is basically useless, worse, it's probably going to make stack traces completely useless, as there's going to be a lot of code in the same line (and not necessarily with the same formatting you used).","Q_Score":36,"Tags":"php,python,ruby,perl,node.js","A_Id":6811003,"CreationDate":"2011-07-25T01:24:00.000","Title":"Should one minify server code when it's in 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},{"Question":"When it comes to the frontend code you always minify it (remove white spaces, comments etc) in production.\nShould one do the same with server code? I usually have a lot of comments in my server files. But I have never heard about people doing so.\nWouldn't the server run faster if the code was optimized in the same way?","AnswerCount":4,"Available Count":3,"Score":1.0,"is_accepted":false,"ViewCount":3747,"Q_Id":6810977,"Users Score":18,"Answer":"I think that minification has more to do with reducing bytes on the wire than it does runtime efficiency.","Q_Score":36,"Tags":"php,python,ruby,perl,node.js","A_Id":6811008,"CreationDate":"2011-07-25T01:24:00.000","Title":"Should one minify server code when it's in 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},{"Question":"When it comes to the frontend code you always minify it (remove white spaces, comments etc) in production.\nShould one do the same with server code? I usually have a lot of comments in my server files. But I have never heard about people doing so.\nWouldn't the server run faster if the code was optimized in the same way?","AnswerCount":4,"Available Count":3,"Score":1.0,"is_accepted":false,"ViewCount":3747,"Q_Id":6810977,"Users Score":6,"Answer":"i do not believe this offers any benefit to server side code since the server evaluates the code and doesn't actually send it down. If you are looking to optimize production code you can look into setting up a compiler cache such as APC for PHP","Q_Score":36,"Tags":"php,python,ruby,perl,node.js","A_Id":6811024,"CreationDate":"2011-07-25T01:24:00.000","Title":"Should one minify server code when it's in 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},{"Question":"What I have is a bunch of PDFs (few 100s). They don't have a proper structure nor do they have particular fields. All they have is lot of text. \nWhat I am trying to do : \nIndex the PDFs and search for some keywords against the index. \nI am interested in finding if that particular keyword is in the PDF doc and if it is, I want the line where the keyword is found. \nIf I searched for 'Google' in a PDF doc that has that term, I would like to see 'Google is a great search engine' which is the line in the PDF. \nHow I decided to do :\nEither use SOLR or Whoosh but SOLR is looking good for inbuilt PDF support. I prefer to code in Python and Sunburst is a wrapper on SOLR which I like. \nSOLR's sample\/example project has some price comparision based schema file. Now I am not sure if I can use SOLR to answer my problem.\nWhat do you guys suggest? Any input is much appreciated.","AnswerCount":3,"Available Count":1,"Score":0.1325487884,"is_accepted":false,"ViewCount":13288,"Q_Id":6822884,"Users Score":2,"Answer":"I once solved this by converting the PDF files to text with utilities as pdftotext (pdftohtml would also work I guess), generating a 'cache' of some sorts. Then using some grep I searched the text file cache for keywords.\nThis is slightly different from your proposed solution, but I can imagine you can call this from Python as well.","Q_Score":8,"Tags":"python,pdf,indexing,solr","A_Id":6827387,"CreationDate":"2011-07-25T22:00:00.000","Title":"How do I Index PDF files and search for keywords?","Data Science and Machine Learning":0,"Database and SQL":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},{"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},{"Question":"At work we are using Trac on several internal wiki's and an external wiki. REcently we found the need for a new plugin. After we going through a few tutorials we went to install a plugin to make sure it would work. It didn't. We've been going through trying to figure out. Below I will list the steps and various things I did while trying to get it to work.\n1) I went to trac-hacks website and downloaded their hellow world plugin, figured I couldn't make a mistake using their code.\n2) I compiled and made an egg using python setup.py bdist_egg on the machine where trac is installed, to make sure it's the same Python version being used.\n3) I then copied it over to \/directory\/where\/trac\/is\/plugins\/ folder and chmod 755 the file egg file.\n4) I then restarted http, unable to find a better way of restaring trac so this may be where my problem is. It didn't work. So I deleted the egg folder in plugins\n5) Uploaded it via trac->administration->plugins and restarted httpd again. Nothing. \n6) I realized I had to edit the trac.ini file and added helloworld.* = enabled under component and restarted the web server. \nIt's quite possible it's me but any help would be greatly appreciated!\nIts the helloworld plugin from trachack, essentially displays hello world and theres a button. There are no error messages provided, hence why googling was hard.\nI'm assuming that it's using root and that's the user I built it with. I will look into seeing if it's anybody else, just taking a quick look though I don't see anything else that could be using it. I only copied the egg file to the plugins folder, I set up another folder elsewhere and built it and cp to the plugins folder. I'm glad to know I was doing that right because looking up documentation on how to restart trac turns up practically nothing, they just say restart trac or restart apache. I will look into the logs later on tomorrow. Thanks for the replies! Also we are using trac .12.1.\nSo after looking at the log files it seems that it doesn't even load the plugin, can't find anywhere that says it's loading or any errors with it. Now we have a few trac sites for various projects and one of the sites already has plugins installed so I went there and and put the test plugin there and checked logs and it didn't work either. So I'm just going to conclude it's the plugin or something we already have in place and it's not me. I believe I'm going to try and make one and test it. Thanks for the help!","AnswerCount":3,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":1484,"Q_Id":6835274,"Users Score":0,"Answer":"Quite an old thread, but since I ran into the same problem at one point:\nMake sure you build the .egg with the same Python version that you use to run Trac with!Backwards compatibility between Python versions does not matter here, because Trac reads information about the Python version out of the .egg file before it even loads it, to make sure it is compatible.\n(Small version numbers should not matter, so you should be able to run a .egg with Python 2.7.10 when it was built with 2.7.3, but not when it was built with 2.6.x. Look at the Version number that is written into the .egg file name.)","Q_Score":1,"Tags":"python,plugins,webserver,trac","A_Id":33694758,"CreationDate":"2011-07-26T19:14:00.000","Title":"Trac Plugin Not working","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"At work we are using Trac on several internal wiki's and an external wiki. REcently we found the need for a new plugin. After we going through a few tutorials we went to install a plugin to make sure it would work. It didn't. We've been going through trying to figure out. Below I will list the steps and various things I did while trying to get it to work.\n1) I went to trac-hacks website and downloaded their hellow world plugin, figured I couldn't make a mistake using their code.\n2) I compiled and made an egg using python setup.py bdist_egg on the machine where trac is installed, to make sure it's the same Python version being used.\n3) I then copied it over to \/directory\/where\/trac\/is\/plugins\/ folder and chmod 755 the file egg file.\n4) I then restarted http, unable to find a better way of restaring trac so this may be where my problem is. It didn't work. So I deleted the egg folder in plugins\n5) Uploaded it via trac->administration->plugins and restarted httpd again. Nothing. \n6) I realized I had to edit the trac.ini file and added helloworld.* = enabled under component and restarted the web server. \nIt's quite possible it's me but any help would be greatly appreciated!\nIts the helloworld plugin from trachack, essentially displays hello world and theres a button. There are no error messages provided, hence why googling was hard.\nI'm assuming that it's using root and that's the user I built it with. I will look into seeing if it's anybody else, just taking a quick look though I don't see anything else that could be using it. I only copied the egg file to the plugins folder, I set up another folder elsewhere and built it and cp to the plugins folder. I'm glad to know I was doing that right because looking up documentation on how to restart trac turns up practically nothing, they just say restart trac or restart apache. I will look into the logs later on tomorrow. Thanks for the replies! Also we are using trac .12.1.\nSo after looking at the log files it seems that it doesn't even load the plugin, can't find anywhere that says it's loading or any errors with it. Now we have a few trac sites for various projects and one of the sites already has plugins installed so I went there and and put the test plugin there and checked logs and it didn't work either. So I'm just going to conclude it's the plugin or something we already have in place and it's not me. I believe I'm going to try and make one and test it. Thanks for the help!","AnswerCount":3,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":1484,"Q_Id":6835274,"Users Score":0,"Answer":"Check the Trac version and downloaded plugin\ninstead python setup.py bdist_egg try python setup.py install","Q_Score":1,"Tags":"python,plugins,webserver,trac","A_Id":27168395,"CreationDate":"2011-07-26T19:14:00.000","Title":"Trac Plugin Not working","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"At work we are using Trac on several internal wiki's and an external wiki. REcently we found the need for a new plugin. After we going through a few tutorials we went to install a plugin to make sure it would work. It didn't. We've been going through trying to figure out. Below I will list the steps and various things I did while trying to get it to work.\n1) I went to trac-hacks website and downloaded their hellow world plugin, figured I couldn't make a mistake using their code.\n2) I compiled and made an egg using python setup.py bdist_egg on the machine where trac is installed, to make sure it's the same Python version being used.\n3) I then copied it over to \/directory\/where\/trac\/is\/plugins\/ folder and chmod 755 the file egg file.\n4) I then restarted http, unable to find a better way of restaring trac so this may be where my problem is. It didn't work. So I deleted the egg folder in plugins\n5) Uploaded it via trac->administration->plugins and restarted httpd again. Nothing. \n6) I realized I had to edit the trac.ini file and added helloworld.* = enabled under component and restarted the web server. \nIt's quite possible it's me but any help would be greatly appreciated!\nIts the helloworld plugin from trachack, essentially displays hello world and theres a button. There are no error messages provided, hence why googling was hard.\nI'm assuming that it's using root and that's the user I built it with. I will look into seeing if it's anybody else, just taking a quick look though I don't see anything else that could be using it. I only copied the egg file to the plugins folder, I set up another folder elsewhere and built it and cp to the plugins folder. I'm glad to know I was doing that right because looking up documentation on how to restart trac turns up practically nothing, they just say restart trac or restart apache. I will look into the logs later on tomorrow. Thanks for the replies! Also we are using trac .12.1.\nSo after looking at the log files it seems that it doesn't even load the plugin, can't find anywhere that says it's loading or any errors with it. Now we have a few trac sites for various projects and one of the sites already has plugins installed so I went there and and put the test plugin there and checked logs and it didn't work either. So I'm just going to conclude it's the plugin or something we already have in place and it's not me. I believe I'm going to try and make one and test it. Thanks for the help!","AnswerCount":3,"Available Count":3,"Score":0.0665680765,"is_accepted":false,"ViewCount":1484,"Q_Id":6835274,"Users Score":1,"Answer":"It sounds like you built the egg correctly. After you copy it into your plugins folder, change the file's owner and group (I'm assuming you're on Linux since you mentioned chmod) to match the account that your webserver uses. I'm not sure if that's strictly necessary, but it's what's always worked for me.\nI may be misreading your #4, but it sounds like you copied the whole egg folder to your plugins directory. Only the .egg file needs to be copied over, it's a self-contained package. I don't think Trac looks for .egg files in subdirectories.\nRestarting your webserver is the easiest way to restart Trac. Actually, I'm not aware of any other way to do it.\nWhen it comes to plugin problems, Trac's log is usually a very good source of information. I recommend setting Trac's log level to DEBUG, then shut down the web server. Clear out the contents of Trac's log file, then start the web server and make a copy of Trac's log file after the server has completely come back online. Do this process twice: once with the plugin installed and once without it installed. The difference in the logfiles should give you a good indication of what the problem is. Once you get accustomed to what your logs normally look like, you'll be able to read the log in place without clearing it out and generating two versions of it.\nBy the way, what Trac version are you using?","Q_Score":1,"Tags":"python,plugins,webserver,trac","A_Id":6848819,"CreationDate":"2011-07-26T19:14:00.000","Title":"Trac Plugin Not working","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I am using a proprietary Matlab MEX file to import some simulation results in Matlab (no source code available of course!). The interface with Matlab is actually really simple, as there is a single function, returning a Matlab struct. I would like to know if there is any way to call this function in the MEX file directly from Python, without having to use Matlab?\nWhat I have in mind is for example using something like SWIG to import the C function into Python by providing a custom Matlab-wrapper around it...\nBy the way, I know that with scipy.io.loadmat it is already possible to read Matlab binary *.mat data files, but I don't know if the data representation in a mat file is the same as the internal representation in Matlab (in which case it might be useful for the MEX wrapper).\nThe idea would be of course to be able to use the function provided in the MEX with no Matlab installation present on the system.\nThanks.","AnswerCount":4,"Available Count":1,"Score":0.049958375,"is_accepted":false,"ViewCount":7858,"Q_Id":6848790,"Users Score":1,"Answer":"A mex function is an api that allows Matlab (i.e. a matlab program) to call a function written in c\/c++. This function, in turn, can call Matlab own internal functions. As such, the mex function will be linked against Matlab libraries. Thus, to call a mex function directly from a Python program w\/o Matlab libraries doesn't look possible (and doesn't makes sense for that matter). \nOf consideration is why was the mex function created in the first place? Was it to make some non-matlab c libraries (or c code) available to matlab users, or was it to hide some proprietery matlab-code while still making it available to matlab users? If its the first case, then you could request the owners of the mex function to provide it in a non-mex dynamic lib form that you can include in another c or python program. This should be easy if the mex function doesnt depend on Matlab internal functions. \nOthers above have mentioned the matlab compiler... yes, you can include a mex function in a stand alone binary callable from unix (thus from python but as a unix call) if you use the Matlab Compiler to produce such binary. This would require the binary to be deployed along with Matlab's runtime environment. This is not quite the same as calling a function directly from python-- there are no return values for example.","Q_Score":7,"Tags":"python,matlab,mex","A_Id":11173545,"CreationDate":"2011-07-27T17:42:00.000","Title":"Embed a function from a Matlab MEX file directly in 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},{"Question":"I have of late been learning Python, and am amazed by its superb runtime metaprogramming capabilities. Previously I came across the term 'runtime metaprogramming' was when I was reading about Smalltalk, which as far as I know boasts of best runtime metaprogramming capabilities. How well does Python stack up against Smalltalk w.r.t. metaprogramming? What are the notable differences between the approaches taken by two languages?","AnswerCount":2,"Available Count":2,"Score":1.0,"is_accepted":false,"ViewCount":1442,"Q_Id":6852189,"Users Score":10,"Answer":"Posted as an answer at questioner's request.\nOne of the big ideas of Smalltalk is orthogonality. Frankly Python suffers in this respect. Not everything works on everything. Examples:\n\ninspect.getargspec() does not work on built-in functions or the results of calls to functools.partial (in the C interpreter anyway).\neval only works for expression strings, and exec only works for statement strings.\nLambda expressions cannot be pickled.\nmyclass = type('x', (object,), {'__init__': partial(foo, value)}) produces a class that can't be instantiated, whereas passing an equivalent lambda expression instead of a partial works fine. (Though this may just be a bug not a feature.)\n\nMaybe PyPy doesn't have these problems, I'm not sure. But I do love Python very much and find it very convenient to use metaclasses, currying and the occasional descriptor in real applications.","Q_Score":10,"Tags":"python,oop,programming-languages,metaprogramming,smalltalk","A_Id":6864488,"CreationDate":"2011-07-27T22:52:00.000","Title":"Python and Smalltalk - Metaprogramming capabilities comparison","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have of late been learning Python, and am amazed by its superb runtime metaprogramming capabilities. Previously I came across the term 'runtime metaprogramming' was when I was reading about Smalltalk, which as far as I know boasts of best runtime metaprogramming capabilities. How well does Python stack up against Smalltalk w.r.t. metaprogramming? What are the notable differences between the approaches taken by two languages?","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":1442,"Q_Id":6852189,"Users Score":12,"Answer":"Python actually holds up fairly well here. Smalltalk usually doesn't make explicit distinction between program and metaprogramm, but Python is more explicit - eg, the special syntax for decorators or the __foo__() naming convention for metaprogramming hooks. This is a good thing. \nOn the other hand, it's a bit of an apples-to-oranges comparison. Smalltalk is a smaller, tighter language than Python, and so there's just less material to manipulate with metaprograms. For example, consider __getattr__(). This is a hook that lets Python objects provide a custom implementation of attribute access. Smalltalk doesn't have anything like this. But! Smalltalk enforces tighter encapsulation of an object's internal state, and there's no equivalent of the object.attribute syntax that's used in Python. So reading an object's state requires going through a method... which is exactly what __getattr__() provides. So for a lot of cases where you'd use __getattr__() in Python, you'd just write a normal method in Smalltalk - no metaprogramming needed.\nAnd it's like that all over the place: Python's __getitem__() and friends make it possible to write classes that mimic lists or dictionaries. Smalltalk doesn't need that because Array and Dictionary are just regular Smalltalk classes and there's no special syntax for using them. Python __eq__() and so on enable operator overloading. Smalltalk doesn't have operators, so you can implement + without doing anything special. Python's contextlib provides some nifty tools for implementing your own context managers. Smalltalk doesn't have a with construct, but it does have really lightweight syntax for lambdas, which lets you do the same sort of thing in a straightforward way.\nSmalltalk's metaprogramming facilities tend to be pretty low-level. You can, for example, create your own CompiledMethod instances, and stick them into a class's method dictionary. You can also write your own compiler and specify that all the methods of a particular class be compiled with it. That enables all sorts of things - I've seen projects that experiment with alternate syntaxes, instrument bytecode for profiling, trap reads and writes to instance variables for transparent persistence, and so on. \nSmalltalk's metaprogramming facilities are powerful, but they're not as neatly organized as Python's, and don't get used as often.","Q_Score":10,"Tags":"python,oop,programming-languages,metaprogramming,smalltalk","A_Id":6853978,"CreationDate":"2011-07-27T22:52:00.000","Title":"Python and Smalltalk - Metaprogramming capabilities comparison","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I was reading through Facebook's hiring now job listings and I saw this...\n* Competency in Shell, PHP, Perl or Python. C is a plus\nThis sparked a question in my mind, is it possible to use (for example) python and PHP together?\nAs in... I write a function in PHP to read a MySQL database and cut the data read into raw string form.\nI then use python to use this PHP function to perform operations on this data.\nThe part where I say \"use python to use this PHP function\" is this possible?\nIf so, how? (a small code example would be awesome)","AnswerCount":3,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":406,"Q_Id":6852990,"Users Score":3,"Answer":"First, Facebook is a large company. They have many different software projects, apart from the site itself, and some of them are probably written in languages different from the company's mainstream. \nSecond, teaching a good $lang1 programmer $lang2's syntax takes two weeks, while teaching a bad $lang2 programmer how to program takes life.","Q_Score":0,"Tags":"php,python,perl","A_Id":6854713,"CreationDate":"2011-07-28T00:49:00.000","Title":"Python PHP and Perl being used together?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"Can anyone explain the use of Python's setUp and tearDown methods while writing test cases apart from that setUp is called immediately before calling the test method and tearDown is called immediately after it has been called?","AnswerCount":3,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":128148,"Q_Id":6854658,"Users Score":9,"Answer":"Suppose you have a suite with 10 tests. 8 of the tests share the same setup\/teardown code. The other 2 don't.\nsetup and teardown give you a nice way to refactor those 8 tests. Now what do you do with the other 2 tests? You'd move them to another testcase\/suite. So using setup and teardown also helps give a natural way to break the tests into cases\/suites","Q_Score":116,"Tags":"python,unit-testing,python-unittest","A_Id":6854720,"CreationDate":"2011-07-28T05:59:00.000","Title":"Explain the \"setUp\" and \"tearDown\" Python methods used in test cases","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a USB camera (uEye) which has a C++ interface allowing you to configure some features of the camera. The C++ program can read the image data from the camera and store it somewhere in pre-allocated memory. All of this runs under Windows.\nPython with numpy gives me a simple environment to manipulate images and spend some quality time working on my processing algorithms.\nWhat I would like to do is:\n\nUse the c++ program to configure the camera and obtain images (at video rate),\nPass the data to Python\nProcess the data in Python\n\nI am under the impression that I do not want to embed C++ in Python or Python in C++, as I prefer to have two stand-alone systems (so I can use the camera without the Python stuff, or use the Python stuff without the camera).\nWhat I can find so far are methods to share some data using pipes, sockets, or mapped memory, though it appears to be restricted to small amounts of data or strings. What I can not find, however, is an indication if this is fast enough and something that I should attempt to implement. Should I want to do this?\nIf this is a bad idea, what would be a better alternative? Embed the Python code in C++ or vice versa? Or ditch Python all together because the savings in development time there do not offset the additional effort in getting the interprocess communication to work?","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":1214,"Q_Id":6871537,"Users Score":2,"Answer":"Since you say the device has a \"C++ interface\", I assume it provides a header file + DLL which you can link to and control the device via an API. In such a case, the fastest approach would be to wrap this API in Python (using Swig or other C++-to-Python API tools). This will provide a very low overhead of just a couple of procedure calls, passing the data directly as pointers to memory.\nIf you don't want to \"marry\" Python, write yourself a controlling app in C++ too, but I think the fastest and most convenient way of connecting the API to Python is the above.","Q_Score":1,"Tags":"c++,python,windows,ipc","A_Id":6872320,"CreationDate":"2011-07-29T10:08:00.000","Title":"Share video data between C++ and 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":0,"Web Development":0},{"Question":"I am wondering what modules or methods I should use to control a File Upload box from Python. I want Python to take control of this box when it pops up, and automatically navigate to a specific folder\/file and select this file.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":175,"Q_Id":6878273,"Users Score":0,"Answer":"I used the SendKeys module, which allows you to send keystrokes to Windows. Not perfect, but it works in the meantime.","Q_Score":0,"Tags":"python","A_Id":6892524,"CreationDate":"2011-07-29T19:48:00.000","Title":"Controlling a File Upload Box 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},{"Question":"I am getting a 500 : Internal error, the payload of the POST is definately right, one thing I noticed is the Content-Type is not \"sticking\" using b.addheaders = [('Content-Type',\"text-x-gwt-rpc\")] -- and I'm not sure why.\nDoes anyone have quick\/dirty code used to access a GWT RPC (i.e. emulate the GWT client) in Python using mechanize. Browser?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":425,"Q_Id":6880142,"Users Score":0,"Answer":"The answer to the question is GWT requires the content-type to be x-gwt-rpc; rather than 'application\/x-www-form-urlencoded'; which is hard coded in _http.py in the mechanize library.\nQuick and dirty hack is to change this to text\/x-gwt-rpc; charset=UTF-8 -- I'm sure this could be done better by subclassing AbstractHTTPHandler; maybe someone else could contribute a quick way to do that.","Q_Score":0,"Tags":"python,gwt,gwt-rpc","A_Id":6883832,"CreationDate":"2011-07-29T23:59:00.000","Title":"Calling a GWT RPC function from 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},{"Question":"I am getting a 500 : Internal error, the payload of the POST is definately right, one thing I noticed is the Content-Type is not \"sticking\" using b.addheaders = [('Content-Type',\"text-x-gwt-rpc\")] -- and I'm not sure why.\nDoes anyone have quick\/dirty code used to access a GWT RPC (i.e. emulate the GWT client) in Python using mechanize. Browser?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":425,"Q_Id":6880142,"Users Score":0,"Answer":"Do not use GWT-RPC from non-GWT solutions, the format is internal and subject to change without notice. Consider RESTifying the app (or use SOAP and reuse the existing code of the methods, but care needs to be given to the interface definitions).","Q_Score":0,"Tags":"python,gwt,gwt-rpc","A_Id":6880354,"CreationDate":"2011-07-29T23:59:00.000","Title":"Calling a GWT RPC function from 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},{"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},{"Question":"I was thinking of rewriting my custom PHP app on a framework... mainly for the solidity and more ease of growth going forward. Right now its a pseudo MVC setup with lots of hacks in between.\nI already have the db built out and the app uses a lot of AJAX too.\nI am not concerned with the amount of work involved as the solidity of the platform I move things to. Server configurations are no worries. I am also looking to increase performance all around. \nMy friend (and Python enthusiast) told me things of python rendering tabular type data at almost 40% increase over PHP and speed is definitely a decision maker in this.\nTaking out the fact that there would be significantly less work moving to a PHP based framework since the app is PHP already which would be the best fit?\nI know there are a lot of PHP vs Python stories out there. Python seems to be the clear winner, but how easy is it to use with standard web stuff like AJAX?\nI just want to know who would use which and why vs the other.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":259,"Q_Id":6886699,"Users Score":0,"Answer":"Which language do you prefer? That's all that really matters. Both have solid frameworks and similar performance. If you want to increase performance, writing more efficient code is going to make a way bigger difference.\nPersonally, I like python. Django is great, but you might also consider Flask or Pyramid\/Pylons. Ajax is just as easy with python as it is with PHP--it's only a request. The server configuration is definitely harder--it doesn't get any easier than PHP--but it's not that hard, and you said you didn't mind it. If you like both languages equally, give python a shot.","Q_Score":0,"Tags":"php,python,django","A_Id":6886763,"CreationDate":"2011-07-31T00:05:00.000","Title":"Rewriting A Custom PHP App on a framework. Torn between Python (Django) and PHP (CodeIgniter)","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I am curious about the complexity of Python and JS 's looking up: \nPython supports multi-inheritance, which affects the member lookup. Specifically, when referencing a member from an instance of a class, the process will start from the instance's dict, then to the class of the instance, then up to the super classes of the class of the instance, which for each super class, it has its own super class list..... which seems to end up with the complexity to be exponential (theoretically). \nWhile it seems that the JS's member lookup time is linear -- which just has to trace back to the prototype chain.\nAm I reasoning the right way? or I am missing something?","AnswerCount":1,"Available Count":1,"Score":0.537049567,"is_accepted":false,"ViewCount":121,"Q_Id":6888332,"Users Score":3,"Answer":"You're missing the fact that MI is very, very rarely used in Python, usually only for mixins where the inheritance chain tends to be very short anyways.","Q_Score":1,"Tags":"javascript,python","A_Id":6888348,"CreationDate":"2011-07-31T08:22:00.000","Title":"The complexity of member looking up: Python Vs. Javascript","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm looking for solutions that make it possible to create AJAX-enabled web applications without need to write JavaScript code manually. The requirements are:\n\nPerformance doesn't matter. It can be slow, JavaScript may be unoptimized, amount of code it generates may be large.\nPlatform doesn't matter as long as I can work with it on either Linux or Windows.\nLanguage doesn't matter as long as it's Python, Java or C#.\nI want to be able to create composite 'widgets' that can be updated dynamically using AJAX. For instance, I want to be able to load data dynamically and replace existing controls with the other ones when user clicks the button on that page.\nAs long as this solution provides concepts like 'Panel' (composite widget), 'EditBox' and 'Label', I don't care if it's hard to create my own controls.\n\nWhat do you think?","AnswerCount":4,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":217,"Q_Id":6888856,"Users Score":2,"Answer":"I'd recommend you GWT from Google. It is great, well done framework that allows creating Web 2.0 applications without dealing with HTML\/JavaScript at all.","Q_Score":0,"Tags":"c#,java,javascript,python","A_Id":6888882,"CreationDate":"2011-07-31T10:20:00.000","Title":"AJAX web applications with no hand-written JavaScript","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},{"Question":"I work for a webhost and my job is to find and cleanup hacked accounts. The way I find a good 90% of shells\\malware\\injections is to look for files that are \"out of place.\" For example, eval(base64_decode(.......)), where \".....\" is a whole bunch of base64'ed text that is usually never good. Odd looking files jump out at me as I grep through files for key strings.\nIf these files jump out at me as a human I'm sure I can build some kind of profiler in python to look for things that are \"out of place\" statistically and flag them for manual review. To start off I thought I can compare the length of lines in php files containing key strings (eval, base64_decode, exec, gunzip, gzinflate, fwrite, preg_replace, etc.) and look for lines that deviate from the average by 2 standard deviations.\nThe line length varies widely and I'm not sure if this would be a good statistic to use. Another approach would be to assign weighted rules to cretin things (line length over or under threshold = X points, contains the word upload = Y points) but I'm not sure what I can actually do with the scores or how to score the each attribute. My statistics is a little rusty.\nCould anyone point me in the right direction (guides, tutorials, libraries) for statistical profiling?","AnswerCount":1,"Available Count":1,"Score":0.761594156,"is_accepted":false,"ViewCount":3832,"Q_Id":6892449,"Users Score":5,"Answer":"Here's a simple machine learning approach to the problem, and is what I'd do to get started on this problem and develop a baseline classifier:\nBuild up a corpus of scripts and attach a label either 'good' (label= 0) or 'bad' (label = 1) the more the better. Try to ensure that the 'bad' scripts are a reasonable fraction of the total corpus,50-50 good\/bad is ideal.\nDevelop binary features that indicate suspicious or bad scripts. For example, the presence of 'eval', the presence of 'base64_decode'.Be as comprehensive as you can be and don't be afraid of including afeature that might capture some 'good' scripts too. One way to help to do this might be to calculate the frequency counts of words in the two classes of script and select as features words that appear prominently in 'bad' but less prominently in 'good'.\nRun the feature generator over the corpus and build up a binary matrix of features with labels.\nSplit the corpus into train (80% of examples) and test sets (20%). Using the scikit learn library, train a few different classification algorithms (random forests, support vector machines, naive bayes etc) with the training set and test their performance on the unseen test set.\nHopefully I have a reasonable classification accuracy to benchmark against. I'd then look at improving the features, some unsupervised methods (without labels) and more specialised algorithms to get better performance.\nFor resources, Andrew Ng's Coursera course on Machine Learning (which includes example spam classification, I believe) is a good start.","Q_Score":15,"Tags":"python,machine-learning,statistics,intrusion-detection","A_Id":17491843,"CreationDate":"2011-07-31T21:32:00.000","Title":"Anomaly detection 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},{"Question":"i want to create a django project using ssh, my host give me some options when i enable ssh, i'm allowed to use bash, zsh, ksh, csh,fish and tcsh, I'm familiar with bash but not with the rest so which is better for django? which is the closest to python? or are they all the same when it comes to application development?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":342,"Q_Id":6892686,"Users Score":2,"Answer":"The chosen UNIX shell does not matter for the Python development. AFAIK the only shell specific part in Python development, which is currently being widely used, is virtualenv and it should work with sh compatible shells.","Q_Score":0,"Tags":"python,django,bash,ssh","A_Id":6898424,"CreationDate":"2011-07-31T22:16:00.000","Title":"run django from 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":1},{"Question":"I know that this question will recieve some fairly strong comments but I'm going to post it anyway. \nI'm working on a project in Python. My simple reasons for choosing Python are the available librtaries and it is cross platform and open source. My problem is that I really enjoy coding with the very verbose, descriptive method names of Objective C. The type of functions that I have to write can have fairly complex arguments and I find that with the Objective C approach I'm not having to constantly refer back to other pieces of dicumentation to make sure I'm using the right arguments with the right functions. \nIs there any way of using the Objective C style for calling functions with Python? I am aware this probably doesn't suit recommended coding styles for Python, but it does suit what I am doing right now so I'd like to try and find a way of doing it if possible.","AnswerCount":1,"Available Count":1,"Score":0.6640367703,"is_accepted":false,"ViewCount":142,"Q_Id":6896565,"Users Score":4,"Answer":"If you mean, \"can I write the call with square brackets instead of round ones and put them around the object and method names instead of after and omit the commas\", then no.\nIf you mean \"can I make verbose, descriptive method names\", then of course you can; you can do that in any language worth mentioning.\nI think what you really mean is \"can I use keyword arguments as in [myObject frobnicateWithHax:42 Foo:23 Bar:69]?\". Yes; in Python, this is spelled myObject.frobnicateWith(hax=42, foo=23, bar=69). On the function-definition side, there are a number of ways to make it work, depending on exactly what you want; see the documentation (or a good reference or tutorial) for default arguments and kwargs.\nHonestly, Google answers this kind of question better than SO, once you know a little bit about what these kinds of language features are called.","Q_Score":2,"Tags":"python,objective-c,coding-style","A_Id":6896630,"CreationDate":"2011-08-01T09:36:00.000","Title":"Using Objective C function call styles 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},{"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},{"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},{"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},{"Question":"I want to Search for an Object name.\nIf i have this Structure:\n\/de\/myspace\/media\/justAnotherPdf.pdf\nThen i want to Search for the name \"justAnotherPdf\" to find it or something like \"justAnot\"\nI have Indexed the pdf files.\nBut i cant search it with TextIndexNG2 or PathIndex.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":171,"Q_Id":6912241,"Users Score":3,"Answer":"Currently this is not supported out-of-the-box. Object identifiers (getId) are only indexed as field values and thus can only be looked up as whole strings.\nYou'd need to add separate index to the catalog to support your use-case. You could add a new TextIndexNG2 index with a new name indexing just the getId method. In the ZMI, find the portal_catalog, then it's 'Indexes' tab, then on the right-hand-side you'll find a drop-down menu for adding a new index. Pick a memorable name ('fullTextId' for example) and use getId as the indexed attribute.\nYou'll need to do a reindex, but only for that index. Once added, select it in on the Indexes tab (tick the check-box) and select 'Reindex' at the bottom of that page. Now you can use this index in your custom searches with a wildcard search.","Q_Score":3,"Tags":"python,dhtml,zope","A_Id":6913162,"CreationDate":"2011-08-02T12:42:00.000","Title":"How to search for ZCatalog object names","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I have a C++ process running in the background that will be generating 'events' infrequently that a Python process running on the same box will need to pick up.\n\nThe code on the C side needs to be as lightweight as possible. \nThe Python side is read-only.\nThe implementation must be cross-platform.\nThe data being sent is very simple.\n\nWhat are my options?\nThanks","AnswerCount":7,"Available Count":2,"Score":0.0285636566,"is_accepted":false,"ViewCount":40430,"Q_Id":6915191,"Users Score":1,"Answer":"How complex is your data? If it is simple I would serialize it as a string. If it was moderately complex I would use JSON. TCP is a good cross-platform IPC transport. Since you say that this IPC is rare the performance isn't very important, and TCP+JSON will be fine.","Q_Score":43,"Tags":"c++,python,cross-platform,ipc","A_Id":6915320,"CreationDate":"2011-08-02T16:17:00.000","Title":"Simple IPC between C++ and Python (cross platform)","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},{"Question":"I have a C++ process running in the background that will be generating 'events' infrequently that a Python process running on the same box will need to pick up.\n\nThe code on the C side needs to be as lightweight as possible. \nThe Python side is read-only.\nThe implementation must be cross-platform.\nThe data being sent is very simple.\n\nWhat are my options?\nThanks","AnswerCount":7,"Available Count":2,"Score":-0.0855049882,"is_accepted":false,"ViewCount":40430,"Q_Id":6915191,"Users Score":-3,"Answer":"I will say you create a DLL that will manage the communication between the two. The python will load DLL and call method like getData() and the DLL will in turn communicate with process and get the data.\nThat should not be hard.\nAlso you can use XML file or SQLite database or any database to query data. The daemon will update DB and Python will keep querying. There might be a filed for indicating if the data in DB is already updated by daemon and then Python will query.\nOf course it depends on performance and accuracy factors!","Q_Score":43,"Tags":"c++,python,cross-platform,ipc","A_Id":6915884,"CreationDate":"2011-08-02T16:17:00.000","Title":"Simple IPC between C++ and Python (cross platform)","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},{"Question":"Does anyone know, what is the actual reason behind \"dollar variable notation\" in some of the scripting languages, i.e. PHP or Perl? Python creators did not find $variable useful, neither do I. Why does PHP and Perl force me to press shift-4 so often?\n(OK, in Perl you can somehow explain it with distinguishing $scalar, @array and %hash but still it could be successfully avoided there, type does not need to be explicit)","AnswerCount":4,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":656,"Q_Id":6922245,"Users Score":2,"Answer":"They use it when parsing so that variables can easily be distinguished from other stuffs.","Q_Score":6,"Tags":"php,javascript,python,perl","A_Id":6922286,"CreationDate":"2011-08-03T05:55:00.000","Title":"Dollar notation in script languages - why?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":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},{"Question":"I'd like some advice on how to check for the correctness of the parameters I receive.\nThe checking is going to be done in C++, so if there's a good solution using Boost.Python (preferably) or the C API, please tell me about that. Otherwise, tell me what attributes the object should have to ensure that it meets the criteria.\nSo...\n\nHow do you check that an object is a function?\nHow do you check that an object is a bound method?\nHow do you check that an object is a class object?\nHow do you check that a class object is a child of another class?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":400,"Q_Id":6933058,"Users Score":0,"Answer":"I have two unconventional recommendations for you:\n1) Don't check. The Python culture is to simply use objects as you need to, and if it doesn't work, then an exception will occur. Checking ahead of time adds overhead, and potentially limits how people can use your code because you're checking more strictly than you need to.\n2) Don't check in C++. When combining Python and C (or C++), I recommend only doing things in C++ that need to be done there. Everything else should be done in Python. So check your parameters in a Python wrapper function, and then call an unchecked C++ entry point.","Q_Score":2,"Tags":"c++,python,boost,boost-python","A_Id":6933233,"CreationDate":"2011-08-03T20:44:00.000","Title":"Python: How to check 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":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'd like some advice on how to check for the correctness of the parameters I receive.\nThe checking is going to be done in C++, so if there's a good solution using Boost.Python (preferably) or the C API, please tell me about that. Otherwise, tell me what attributes the object should have to ensure that it meets the criteria.\nSo...\n\nHow do you check that an object is a function?\nHow do you check that an object is a bound method?\nHow do you check that an object is a class object?\nHow do you check that a class object is a child of another class?","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":400,"Q_Id":6933058,"Users Score":3,"Answer":"When in doubt just work out how you would get the required effect by calling the usual Python builtins and translate it to C\/C++. I'll just answer for Python, for C you would look up the global such as 'callable' and then call it like any other Python function.\n\nWhy would you care about it being a function rather than any other sort of callable? If you want you can find out if it is callable by using the builtin callable(f) but of course that won't tell you which arguments you need to pass when calling it. The best thing here is usually just to call it and see what happens.\nisinstance(f, types.MethodType) but that won't help if it's a method of a builtin. Since there's no difference in how you call a function or a bound method you probably just want to check if it is callable as above.\nisinstance(someclass, type) Note that this will include builtin types.\nissubclass(someclass, baseclass)","Q_Score":2,"Tags":"c++,python,boost,boost-python","A_Id":6933216,"CreationDate":"2011-08-03T20:44:00.000","Title":"Python: How to check 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":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm deciding on a web framework for an upcoming project, and I'd appreciate any advice. We've decided to use jQuery for the JavaScript, and are heavily leaning toward Python or PHP (more Python) for our server-side logic. I'm especially interested in web2py because of its jQuery integration.\nAbout our project\n\nOur project is to develop a security console for a complex\ncybersecurity system operating within an organization's internal\nnetwork.\nThis console will be largely server-driven, as messages come in from the network and must be pushed by the server to the user.\nThe user will also be able to initiate security actions, the implementation for which will likely be in C++.\nThe interface we've planned will be relatively rich, and I want to leverage jQuery's power as much as possible.\nWe have some control over the browser environment we'll be running in (e.g., we don't have to worry about clients with JavaScript disabled).\nOur site is likely to have only a few, long-lived client connections.\nWe are looking for software components with permissive licenses, though we're using some copyleft components (I see that web2py is LGPL while Django is BSD, so +1 to Django)\nWe have about a month to create a functional demo of our system, of which this interface is a small (but visible) part.\n\nAbout us\nWe are two developers with about 5 years of programming experience, but little web development experience. I have several years of Python experience and a summers' worth of experience messing around with PHP. My coworker has some Python experience and has never touched PHP.\nI used Django once back in 2008, and was frustrated by the file and code structure, which I found highly unintuitive. Perhaps this structure is inherent to the MVC model (I've had similar experiences with Django and CakePHP since), and I just need to bite the bullet and memorize it.\nMy Question\nGiven the information above, what are the relative advantages of the various Python\/PHP web frameworks for our project? As mentioned above, I'm especially interested in web2py because of its jQuery integration, though Django's dominance is (once again) hard to ignore.\nThank you very much for your time!","AnswerCount":5,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":1845,"Q_Id":6935094,"Users Score":0,"Answer":"I've been using Django as part of my work for a couple years now and truly enjoy it when I can make it work. Unfortunately, and maybe it's just me, but I end up spending hours working on configuration every time I start a new server, or try to make it work in a development IDE.\nIt's relatively simple to start a new project and start coding. But there are all sorts of little catches that keep things from working if you deviate from the norm. Things like if you want your django project to serve from a subdirectory like example.com\/django. The information is out there to make it work. But it's hard to find. \nI can't tell you if web2py has those same problems or not. I only just learned about it from your question. It does look slick and simple though. I can tell you that after the hassles of getting the applications to serve properly from whatever server configuration I'm using, django is way more fun to program with than plain php. PHP frameworks may differ.","Q_Score":4,"Tags":"php,python,django,web-frameworks,web2py","A_Id":6935676,"CreationDate":"2011-08-04T01:05:00.000","Title":"What are the relative advantages of various Python\/PHP web frameworks (particularly for my 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":1},{"Question":"I'm deciding on a web framework for an upcoming project, and I'd appreciate any advice. We've decided to use jQuery for the JavaScript, and are heavily leaning toward Python or PHP (more Python) for our server-side logic. I'm especially interested in web2py because of its jQuery integration.\nAbout our project\n\nOur project is to develop a security console for a complex\ncybersecurity system operating within an organization's internal\nnetwork.\nThis console will be largely server-driven, as messages come in from the network and must be pushed by the server to the user.\nThe user will also be able to initiate security actions, the implementation for which will likely be in C++.\nThe interface we've planned will be relatively rich, and I want to leverage jQuery's power as much as possible.\nWe have some control over the browser environment we'll be running in (e.g., we don't have to worry about clients with JavaScript disabled).\nOur site is likely to have only a few, long-lived client connections.\nWe are looking for software components with permissive licenses, though we're using some copyleft components (I see that web2py is LGPL while Django is BSD, so +1 to Django)\nWe have about a month to create a functional demo of our system, of which this interface is a small (but visible) part.\n\nAbout us\nWe are two developers with about 5 years of programming experience, but little web development experience. I have several years of Python experience and a summers' worth of experience messing around with PHP. My coworker has some Python experience and has never touched PHP.\nI used Django once back in 2008, and was frustrated by the file and code structure, which I found highly unintuitive. Perhaps this structure is inherent to the MVC model (I've had similar experiences with Django and CakePHP since), and I just need to bite the bullet and memorize it.\nMy Question\nGiven the information above, what are the relative advantages of the various Python\/PHP web frameworks for our project? As mentioned above, I'm especially interested in web2py because of its jQuery integration, though Django's dominance is (once again) hard to ignore.\nThank you very much for your time!","AnswerCount":5,"Available Count":3,"Score":0.0399786803,"is_accepted":false,"ViewCount":1845,"Q_Id":6935094,"Users Score":1,"Answer":"Python vs PHP: Python\nWith python, you can always write wrappers for C code so you won't have to mess with starting other processes and passing args to them. That might be useful for your security functions. \nWeb2py will allow you to easily write a webservice for this too, to more easily integrate the C portions with the web-site infrastructure. \nIf you already prefer python, I would go with that. If you need to bring on web-developers later that are trained in PHP, teach them Python. It won't take long, and I'm sure they'll appreciate it in the long run. Plus, moving from a PHP MVC framework to web2py or even django would make things easier. I've used CodeIgniter for PHP and find that web2py was so much simpler and easy to understand. \nAlso as for the directory structure, django is not actually true MVC -- it's MTV (model, template, view). \nI find web2py's organization a little more straight-forward. But yes, either way it can seem strange at first. I would say YES, you should bite the bullet and use MVC.\nIn web2py, the \"view\" is html markup with the ability to write raw python code. The controller extracts data from the model (database), attaches any needed files (css\/js etc) and the model of course simply defines the structure of the data and allows you to access it in an OO way. \nLastly, I wouldn't tip my hat in favor of web2py just because of jQuery integration. It does use it, and a some of the built-in framework stuff (like response.flash\/session.flash, the LOAD function that loads a page or data from another controller) rely on jQuery, but using it in another framework only means you have to write an include statement (e.g. ). \nBut, the way it allows\/forces you to focus on development is what takes the cake for me.","Q_Score":4,"Tags":"php,python,django,web-frameworks,web2py","A_Id":6961688,"CreationDate":"2011-08-04T01:05:00.000","Title":"What are the relative advantages of various Python\/PHP web frameworks (particularly for my 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":1},{"Question":"I'm deciding on a web framework for an upcoming project, and I'd appreciate any advice. We've decided to use jQuery for the JavaScript, and are heavily leaning toward Python or PHP (more Python) for our server-side logic. I'm especially interested in web2py because of its jQuery integration.\nAbout our project\n\nOur project is to develop a security console for a complex\ncybersecurity system operating within an organization's internal\nnetwork.\nThis console will be largely server-driven, as messages come in from the network and must be pushed by the server to the user.\nThe user will also be able to initiate security actions, the implementation for which will likely be in C++.\nThe interface we've planned will be relatively rich, and I want to leverage jQuery's power as much as possible.\nWe have some control over the browser environment we'll be running in (e.g., we don't have to worry about clients with JavaScript disabled).\nOur site is likely to have only a few, long-lived client connections.\nWe are looking for software components with permissive licenses, though we're using some copyleft components (I see that web2py is LGPL while Django is BSD, so +1 to Django)\nWe have about a month to create a functional demo of our system, of which this interface is a small (but visible) part.\n\nAbout us\nWe are two developers with about 5 years of programming experience, but little web development experience. I have several years of Python experience and a summers' worth of experience messing around with PHP. My coworker has some Python experience and has never touched PHP.\nI used Django once back in 2008, and was frustrated by the file and code structure, which I found highly unintuitive. Perhaps this structure is inherent to the MVC model (I've had similar experiences with Django and CakePHP since), and I just need to bite the bullet and memorize it.\nMy Question\nGiven the information above, what are the relative advantages of the various Python\/PHP web frameworks for our project? As mentioned above, I'm especially interested in web2py because of its jQuery integration, though Django's dominance is (once again) hard to ignore.\nThank you very much for your time!","AnswerCount":5,"Available Count":3,"Score":1.2,"is_accepted":true,"ViewCount":1845,"Q_Id":6935094,"Users Score":2,"Answer":"Before deciding on a framework, you should first decide if you want to commit to a language you are unfamiliar with.\nYou said you've both got minimal PHP experience, so you have to weigh up the advantages here; Will the pros for going PHP (if any) out weigh the amount of time the developers will need to spend to retrain? \n(Although depending on your background experience, PHP should be very easy to pick up.)\nIf you frame it like that, PHP would have to have a pretty convincing offering to give you. From what I'm seeing, specifically Django vs web2py, they both seem very close in functionality - which is good, but doesn't provide the \"you must use x!\" scenario you may be after.\nHowever, If you will be bringing more people in later and feel finding people to work with web2py will be difficult, it may tip it to PHP. You said your self, Django's popularity (and BSD license) is hard to ignore, and it should make it easier to find people for later expansion.\nIf it were me, in your shoes, I would go with web2py. Assuming the development team will continue to be Python focused for the foreseeable future.","Q_Score":4,"Tags":"php,python,django,web-frameworks,web2py","A_Id":6935412,"CreationDate":"2011-08-04T01:05:00.000","Title":"What are the relative advantages of various Python\/PHP web frameworks (particularly for my 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":1},{"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},{"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},{"Question":"I'm currently researching deployment techniques for our Python products. We manage our code with multiple git repositories already but want to improve the process of setting up and updating our servers. It seems that easy_install, .egg files and virtualenv are the best tools for doing this nowadays.\nHere's the catch: We don't really do versioning; all our products have a master branch which is supposed to provide stable code all the time. If we want to update, we have to git pull the master branch on every server, for each product and all its dependencies.\nThis solution is very time-consuming and we want to improve it.\nMy idea was to create a virtualenv instance on all servers\/installations and use easy_install to install and update our own packages, but I couldn't find a way to specify a git repository as a source for the source code.\nIs there a way to achieve that? Did I miss something? Am I going in the wrong direction and this is a bad idea overall?\nThanks in advance,\nFabian","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1234,"Q_Id":6939351,"Users Score":5,"Answer":"You can use pip instead of easy_install, it supports a number of possible ways to specify where to get the package from, one being git, you could then install your package like this:\n\npip install git:\/\/my.git-repo.com\/my_project.git","Q_Score":1,"Tags":"python,virtualenv,setuptools","A_Id":6939437,"CreationDate":"2011-08-04T09:54:00.000","Title":"Create Python .egg that installs from git 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},{"Question":"I have several scripts written in perl, python, and java (wrapped under java GUI with system calls to perl & python). And I have many not-tech-savy users that need to use this in their windows machines (xp & 7).\nTo avoid users from installing perl,python,and java and to avoid potential incompatibility between various versions of these interpreters, I'd like to make a local copy of these interpreters in a folder and then calling them. I'd zip the whole folder (which would also contain my code) and send it away.\nI'd have to worry about environment variables and make calls to the correct interpreter (especially when other versions of python,java,perl may exists in their current system), but not sure what other problems I may face. Any better ideas?\nI never used jython and do not know the overhead of moving to it. I also suspect a complex python system, with many files and 3rd party modules will have problems. Same with perl scripts and I don't know a robust perl interpreter callable from java.\nThank you, in advance.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":168,"Q_Id":6949915,"Users Score":1,"Answer":"Why don't you try migrating your perl\/python code into java and then packagin everything into a nice webstart application? What do perl\/python offer that java doesn't support?\nFor perl you can use something like perl2exe and for python py2exe so you can have 2 exes (which would include all the necessary interpreter bits) and invoke them as resources from within java? Or unzip them inside user's home directory and call them again as normal external programs (ProcessBuilder ?) ?","Q_Score":1,"Tags":"java,python,windows,perl,installation","A_Id":6950147,"CreationDate":"2011-08-04T23:44:00.000","Title":"Package them all! Perl, python, java for naive users (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":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I'm trying to get certain strings in a .py file translated, using the i18n machinery. Translating .pt files is not a problem, but whenever I try to translate using _('Something') in Python code on the filesystem, it always gives English text (which is the default) instead of the Norwegian text that should be there. So I can see output from python code in English, while other Page Templates bits are correctly translated.\nIs there a how-to or something similar for this?","AnswerCount":3,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":190,"Q_Id":6953370,"Users Score":3,"Answer":"be aware that _() does not translate the text at call, but returns a Message object which will be translated when rendered in a template.\nThat means:\n\ndo not concat Message objects. \"text %s\" % _('translation') will not work, as well as \"text\" + _('translation')\nif you do not send the text to the browser through a template, it may not be translated. for example if you generate a email you need to translate the Message object manually","Q_Score":2,"Tags":"python,internationalization,plone,zope","A_Id":6956931,"CreationDate":"2011-08-05T08:18:00.000","Title":"Translating content in filesystem for a Plone product","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm newbie to python and it's philosophy. I'm trying to develop a module on github. Is there any Ruby's gem generator like tool for developing module? How to develop a module? Thank you for any advise.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":445,"Q_Id":6959310,"Users Score":2,"Answer":"You don't need a tool to create a python module, any filename ending in .py is sufficient. A package, which is a collection of modules, is similarly created by the presence of a file named __init__.py in the same folder as other modules (and possibly other packages). The __init__.py file can be empty or not, your choice.\nBest practices dictate that importing a module should have no side effects; It should define classes and functions, but take no action. python modules should start with a docstring explaining the purpose of the module and how it should be used.","Q_Score":0,"Tags":"python,python-module","A_Id":6959402,"CreationDate":"2011-08-05T16:10:00.000","Title":"Python module generator 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},{"Question":"Ok, as Google search isn't helping me in a while (even when using the correct keywords).\nI have a class extending from TestCase in which I want to have some auxiliary methods that are not going to be executed as part of the test, they'll be used to generate some mocked objects, etc, auxiliary things for almost any test.\nI know I could use the @skip decorator so unittest doesn't run a particular test method, but I think that's an ugly hack to use for my purpose, any tips?\nThanks in advance, community :D","AnswerCount":3,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":18227,"Q_Id":6961099,"Users Score":91,"Answer":"I believe that you don't have to do anything. Your helper methods should just not start with test_.","Q_Score":62,"Tags":"python,unit-testing","A_Id":6961157,"CreationDate":"2011-08-05T18:39:00.000","Title":"Non-test methods in a Python TestCase","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Ok, as Google search isn't helping me in a while (even when using the correct keywords).\nI have a class extending from TestCase in which I want to have some auxiliary methods that are not going to be executed as part of the test, they'll be used to generate some mocked objects, etc, auxiliary things for almost any test.\nI know I could use the @skip decorator so unittest doesn't run a particular test method, but I think that's an ugly hack to use for my purpose, any tips?\nThanks in advance, community :D","AnswerCount":3,"Available Count":2,"Score":0.1973753202,"is_accepted":false,"ViewCount":18227,"Q_Id":6961099,"Users Score":3,"Answer":"The test runner will only directly execute methods beginning with test, so just make sure your helper methods' names don't begin with test.","Q_Score":62,"Tags":"python,unit-testing","A_Id":6961191,"CreationDate":"2011-08-05T18:39:00.000","Title":"Non-test methods in a Python TestCase","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Well, this query struck my mind when someone pointed out to me that importing a package using import package gives more code readability. Is this actually true? I mean when using this statement as compared to from package import x, y, z, isn't there any overhead of importing the entire package?","AnswerCount":4,"Available Count":1,"Score":0.1488850336,"is_accepted":false,"ViewCount":557,"Q_Id":6967166,"Users Score":3,"Answer":"The performance will be same either way. The entire module is compiled, if needed, and the code executed, the first time you import a module, no matter how you import it.","Q_Score":1,"Tags":"python,import","A_Id":6967383,"CreationDate":"2011-08-06T13:37:00.000","Title":"Python \"import\" performance query","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am having a python .so file which works fine with python v2.4.3 , but I dont have the source code of that library file. Now It fails to work in python 2.6.5. Is it possible to open the .so file and recompile it in python 2.6.5 ?? I dont know whether it is possible, I am just curious . Thanks ! \nThe error I get \n\nTraceback (most recent call last):\nFile \"run.py\", line 1, in \nimport MarkovPrediction\nFile \"\/home\/ssubbiah\/markov_prediction\/vmresource\/MarkovPrediction.py\", line 7, in \nimport libmarkov\nImportError: \/home\/ssubbiah\/markov_prediction\/vmresource\/libmarkov.so: undefined symbol: _ZN5boost6python9converter8registry6insertEPFPvP7_objectEPFvS5_PNS1_30rvalue_from_python_stage1_dataEENS0_9type_infoE\n\n\nSethu","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":152,"Q_Id":6969951,"Users Score":0,"Answer":"A .so file (.pyd on Windows) is a module which was written in C. It's compiled for, and tied to, a specific version of Python, in this case Python 2.4.x.\nIf you want it to work with a different version of Python, you'll need to re-compile the original source code for that version.","Q_Score":0,"Tags":"python,linux","A_Id":6969990,"CreationDate":"2011-08-07T00:39:00.000","Title":"Finding out what is inside a python library 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},{"Question":"I am having a python .so file which works fine with python v2.4.3 , but I dont have the source code of that library file. Now It fails to work in python 2.6.5. Is it possible to open the .so file and recompile it in python 2.6.5 ?? I dont know whether it is possible, I am just curious . Thanks ! \nThe error I get \n\nTraceback (most recent call last):\nFile \"run.py\", line 1, in \nimport MarkovPrediction\nFile \"\/home\/ssubbiah\/markov_prediction\/vmresource\/MarkovPrediction.py\", line 7, in \nimport libmarkov\nImportError: \/home\/ssubbiah\/markov_prediction\/vmresource\/libmarkov.so: undefined symbol: _ZN5boost6python9converter8registry6insertEPFPvP7_objectEPFvS5_PNS1_30rvalue_from_python_stage1_dataEENS0_9type_infoE\n\n\nSethu","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":152,"Q_Id":6969951,"Users Score":0,"Answer":"Extension modules need to be compiled for a specific version of Python. Without the source code, no, you can't use it for a different version.","Q_Score":0,"Tags":"python,linux","A_Id":6969991,"CreationDate":"2011-08-07T00:39:00.000","Title":"Finding out what is inside a python library 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},{"Question":"I am about to get involved in a NLP-related project and I need to use various libraries. Some are in java, others in C\/C++ (for tasks that require more speed) and finally some are in Python. I was thinking of using Python as the \"glue\" and create wrapper-classes for every task that I want to do that relies on a different language. In order to do that, the wrapper class, for example, would execute the java program and communicate with it using pipes. \nMy questions are:\n\nDo you think that would work for cpu-demanding and highly repetitive tasks? Or would the overhead added by the pipe-communication be too heavy?\nIs there any other (preferably simple) architecture that you would suggest?","AnswerCount":5,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":360,"Q_Id":6970359,"Users Score":5,"Answer":"I would simply advise not doing this.\nDon't implement stuff in C\/C++ \"for speed\". The performance benefit is not likely to be as great as you expect; e.g. compared with implementing in Java using \"best practice\" design and performance techniques.\nDon't try and glue lots of languages together. You are setting yourself up for lots of portability issues, difficulties in debugging, and reliability issues; e.g. due to C \/ C++ bugs crashing the JVM. In addition, there are performance overheads in bridging between languages, and there can be unexpected bottlenecks. (For instance, you may find that your C\/C++ has to be run single-threaded due to threading issues, and that you therefore can't get the benefit of Java multi-threading on a typically multi-core system.)\nInstead, I advise you to look for libraries that allow you to implement the entire application in one language. If that is not possible, design it so that the different language components are different executables \/ processes, communicating via some kind of RPC, messaging, or whatever.","Q_Score":7,"Tags":"java,c++,python,nlp,wrapper","A_Id":6970615,"CreationDate":"2011-08-07T02:35:00.000","Title":"Find an efficient way to integrate different language libraries into one project using Python as the \"glue\"","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"This is simply a personal exercise\/project, I don't intend to inflict this on the world. My goal is to further my understanding of both languages, and it would be a nice having a nice Python code base in the end. \nBut basically there is a program I like with a large (about 100ksloc) C++ code base, what I'd like to do is gradually rewrite modules in Python while having the existing C++ code use the new Python. The reason I'd like to do it this way instead of starting from scratch is because the application would\/should be fully functional from the beginning. \nPrime question is: Is this realistic? I'm pretty sure it'd work in theory, but in practice is it just not worth the effort?\nHas anyone done it before?","AnswerCount":1,"Available Count":1,"Score":0.6640367703,"is_accepted":false,"ViewCount":215,"Q_Id":6970557,"Users Score":4,"Answer":"having the existing C++ code use the new Python\n\nI think you'll find that python makes a better glue language for C++ than C++ does for python. So you probably will have an easier time converting the main function to python first (in fact, the first step could be just renaming the main function, compiling the C++ app as a python library, and having one line of python which calls the renamed main). Then start moving functionality from C++ to python one line at a time.\nAs @freedompeace suggested, you may want to leave significant chunks in C++, with python providing the glue. Depends on whether portability or speed\/memory efficiency is more important to you.","Q_Score":2,"Tags":"c++,python,translation,boost-python","A_Id":6970611,"CreationDate":"2011-08-07T03:33:00.000","Title":"Is gradually translating a program written in C++ to Python feasible?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I usually unit test per class and this is no problem. However after messing around with python I have hit a problem that I have not encountered before in other languages, meta classes and inner classes.\nSay I have a class that contains an inner class and also has a meta class, what is the best way to structure unit tests for this situation?\nOne way could be to test all three in a single test module as they are so tightly coupled anyway. But this seems wrong to me. But how would I unit test the meta class on it's own, create a dummy class within the test that uses said meta class??\nYour thoughts please stackoverflow!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1309,"Q_Id":6971335,"Users Score":3,"Answer":"You test a class by instantiating it. The \"dummy class\" you mentioned would be an instance of the metaclass, so that's exactly how you should test it.\nWhen it comes to testing the inner class \/ outer class -- yes, I would include testing the inner class in the test for the outer class. If it makes sense to test the inner class independently from the outer class, why is it an inner class at all? Any inner class should only make sense in the scope of the outer class. If you are going to test it independently, you'll have to imitate the environment of the outer class anyway.","Q_Score":3,"Tags":"python,unit-testing,inner-classes,metaclass,python-unittest","A_Id":6971546,"CreationDate":"2011-08-07T07:19:00.000","Title":"Unit testing metaclasses and inner classes 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},{"Question":"I'm in the process of setting up a webserver from scratch, mainly for writing webapps with Python. On looking at alternatives to Apache+mod_wsgi, it appears that pypy plays very nicely indeed with pretty much everything I intend to use for my own apps. Not really having had a chance to play with PyPy properly, I feel this is a great opportunity to get to use it, since I don't need the server to be bulletproof. \nHowever, there are some PHP apps that I would like to run on the webserver for administrative purposes (PHPPgAdmin, for example). Is there an elegant solution that allows me to use PyPy within a PHP-compatible webserver like Apache? Or am I going to have to run CherryPy\/Paste or one of the other WSGI servers, with Apache and mod_wsgi on a separate port to provide administrative services?","AnswerCount":2,"Available Count":1,"Score":-0.0996679946,"is_accepted":false,"ViewCount":815,"Q_Id":6976578,"Users Score":-1,"Answer":"I know that mod_wsgi doesn't work with mod_php\nI heavily advise you, running PHP and Python applications on CGI level. \nPHP 5.x runs on CGI, for python there exists flup, that makes it possible to run WSGI Applications on CGI. \nTamer","Q_Score":5,"Tags":"php,python,apache,wsgi,pypy","A_Id":8920308,"CreationDate":"2011-08-07T23:41:00.000","Title":"PyPy + PHP on a single webserver","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},{"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},{"Question":"I'd like to:\n\nSend request from the browser to a python CGI script\nThis request will start some very long operation\nThe browser should check progress of that operation every 3 seconds\n\nHow can I do that?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":345,"Q_Id":6983622,"Users Score":1,"Answer":"You could do this -\n\nUse Javascript to check progress every 3 seconds.\nYour Python script hit at anytime should give the progress at that instance. It should essentially act as state-machine. You need a server here or maybe the progress is stored on some file. \n\nBut having a server is the way to go... \nMaybe the long running process stores the progress in a MySQL table.\nHope this helps...","Q_Score":0,"Tags":"python,ajax,cgi","A_Id":6983929,"CreationDate":"2011-08-08T14:25:00.000","Title":"Python with CGI - handle ajax","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},{"Question":"I have a local git repository which has some Python modules and I would like to create a new project which includes these files (I installed egit egit).\nMy repository does not include a .project file.","AnswerCount":3,"Available Count":2,"Score":0.3215127375,"is_accepted":false,"ViewCount":6040,"Q_Id":6996167,"Users Score":5,"Answer":"It happened to me not so long ago. \nI could not find a nice way to solve it, but found a simple way though :). \nWhat I did was simple :\nCreate a brand new project, and let it empty. \nGet the .project file wihch was created together with the project and add it in the git repository.\nNow you can directly import your repo as a project. \nQuite straightforward and simple.","Q_Score":4,"Tags":"python,eclipse,git,pydev,egit","A_Id":9559566,"CreationDate":"2011-08-09T12:26:00.000","Title":"How to add an existing git repository (without an eclipse project) into 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},{"Question":"I have a local git repository which has some Python modules and I would like to create a new project which includes these files (I installed egit egit).\nMy repository does not include a .project file.","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":6040,"Q_Id":6996167,"Users Score":1,"Answer":"File > New PyDev Project\nUnclick \"Use default\" and browse to your git repo.\nEnter project name. Name must be the same as the git repo. You'll get a \"Source Folder Not Found\" error if it's not.\nClick Finish.","Q_Score":4,"Tags":"python,eclipse,git,pydev,egit","A_Id":34880409,"CreationDate":"2011-08-09T12:26:00.000","Title":"How to add an existing git repository (without an eclipse project) into 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},{"Question":"I have written an application which using twitter authentication.\nAuthentication process:\n\nGet the request token\nAuthorize the token\nGet the access key\n\nNow I have access key, I can use the twitter API. I stored the access_key pair in the database for further use. But when next time user logged in via twitter, since already i have access_key pair I dont want to authorize. How can I do that?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":151,"Q_Id":6998046,"Users Score":1,"Answer":"You mean you're using the \"log in via twitter\" hack?\nWell, if you want a \"remember me\" option you can build one just like normal (store some session info in a cookie... all security caveats apply).\nIf the actually are logged out and there's no cookie then you have to go through the whole process again anyway. The authorize step will just redirect them right back, likely, since they have already authorized your app.","Q_Score":1,"Tags":"python,api,twitter","A_Id":6998115,"CreationDate":"2011-08-09T14:44:00.000","Title":"twitter authentication issue using oauth?","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},{"Question":"I've noticed how easy it is to debug a Python script from Eclipse. Simply set breakpoints and run a Python script from the debug menu. But is it possible to start a Python Interactive Interpreter instead of running a particular Python script, whilst still having Eclipse breaking on breakpoints? This would make it so much easier to test functions.\nThanks for any help\n\nStill looking for a simple\/ish way to start the debugger in Eclipse->PyDev that lets me use the interactive debugger. None of the answers as of yet is acceptable","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1331,"Q_Id":7000138,"Users Score":0,"Answer":"what about this, in the script, you can write a function, say onlyForTest, then each time you write a new function and want to test it, you can just put it in the onlyForTest function, then specify some arguments required by the new function you just write, then open the interactive python shell, import the script, call the onlyForTest function, check out the result.","Q_Score":3,"Tags":"python,eclipse,debugging,aptana","A_Id":7008430,"CreationDate":"2011-08-09T17:17:00.000","Title":"How can I debug Python code without running a script (using 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},{"Question":"I'm primarily using Drupal and am considering moving away from CMS. If I were to build my own platform could I integrate modules like commenting systems, user login, etc. through a PHP\/Python API? What would be the proper steps\/good places to look\/good tutorial on this? Would I have to build all of my own tables manually to suit the needs of such custom modules? I'm wondering if this would even be possible with out having to hard code all of this by hand? Thank you.","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":152,"Q_Id":7006013,"Users Score":0,"Answer":"First of all if you are considering moving away from CMS than you should consider using some sort of framework but with time you will come to idea that you need your own shit in order to be satisfied.\nSecond, subject you are trying to decipher is a little bit more complex than just writing it down here. \nI would suggest you to first think what do you need. What is your main goal with it or what are you trying to accomplish? For example in meaning of commenting, if you want the truth nor PHP nor Python are masterpieces. Why not to consider Node.JS for that?\nI mean, web is becoming real-time more and more. Now days we have scripts or to be more precise, pieces of art such as Socket.IO who can with help of Node.JS handle large amount of traffic without any problem. Something nor Python nor PHP can do.\nSome stuff you will need to code by yourself but most of the time you just need to code \"architecture link\" between one versus many features. Eg. take some code and adjust it to be able use it from your own framework or whatever.\nAs far I see it. I like to do all crucial parts by myself but for example there is Zend Framework and you can use ACL + Auth library and start from there.\nHope this makes some sense. Cheers!","Q_Score":1,"Tags":"php,python","A_Id":7006100,"CreationDate":"2011-08-10T04:46:00.000","Title":"Are there comment system\/user loggin type modules through PHP API\/Python API outside of CMS?","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},{"Question":"I'm unit-testing a python c module in Eclipse using PyDev unit-testing.\nThe development steps are: \nI first write the python tests in Eclipse and then the c code that passes\nthe tests for the module in Codeblocks. Here is where a script is called\nto create a dll and ctypes bindings for it. After that the \u201cdll\u201d and the\n\u201cpy\u201d code is copied to a directory where the module can be easily imported.\nBut sometimes I get the error:\nIOError: [Errno 13] Permission denied: 'C:\\...\\pyCModule.dll'\nI\u2019ve haven\u2019t found the reason for that (deactivating code analysis and code\ncompletion haven\u2019t helped). I\u2019ve checked with the Process Explorer (from\nsysinternals) and it shows that the eclipse process has python.exe as child\n(I suppose that\u2019s from PyDev) and that one is using my pyCModule.dll (and\nnot always releasing it). \nDoes someone have and idea of want could be done here? or what is wrong?\nThanks in advance !\nFrancis","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":260,"Q_Id":7007635,"Users Score":2,"Answer":"This happens because PyDev launches a shell that imports that dll (to do code-completion). You can do Ctrl+2 kill (with focus in a PyDev editor), to kill all the shells that PyDev may have spawned (that way you can update it).\nCheers,\nFabio","Q_Score":1,"Tags":"python,unit-testing,dll,pydev","A_Id":7011545,"CreationDate":"2011-08-10T08:05:00.000","Title":"Dll from python module is not released in Eclipse \/ PyDev","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},{"Question":"When I put in Python interpreter a ** b % c with large a (20 figures) b (4 figures) c (20 figures) I saw that Python calculates it pretty fast, almost like pow (a,b,c). I expect another behavior that Python first calculate a ** b then get the modulo (%) of result and such calculation will take significantly more time.\nWhere is the magic behind the scene?","AnswerCount":4,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":2476,"Q_Id":7014512,"Users Score":0,"Answer":"Today's computers are amazingly fast, very complicated calculations can occur in what seems like no time at all. You need to repeat such calculations very many times to see the delay; I'd start with a million.","Q_Score":1,"Tags":"python,math,modulo","A_Id":7014615,"CreationDate":"2011-08-10T16:40:00.000","Title":"Behavior of Python ** and % operators with big numbers","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"When I put in Python interpreter a ** b % c with large a (20 figures) b (4 figures) c (20 figures) I saw that Python calculates it pretty fast, almost like pow (a,b,c). I expect another behavior that Python first calculate a ** b then get the modulo (%) of result and such calculation will take significantly more time.\nWhere is the magic behind the scene?","AnswerCount":4,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":2476,"Q_Id":7014512,"Users Score":2,"Answer":"There is no magic behind the scenes, other than Python supports arbitrary-precision integers, and is well-implemented. It really did calculate a**b, then %c.","Q_Score":1,"Tags":"python,math,modulo","A_Id":7014538,"CreationDate":"2011-08-10T16:40:00.000","Title":"Behavior of Python ** and % operators with big numbers","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm developing an application in Python which needs to send a one-way message to all threads (threading module in Python2) in an array, except the current thread. I have tried variables, but that would result in all threads responding to it instead of all but the sender.\nWhat is the best way to send messages that way?","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":263,"Q_Id":7015171,"Users Score":1,"Answer":"This is what Queue's are for. Give each thread a Queue, and write into all but your own.","Q_Score":2,"Tags":"python,multithreading","A_Id":7015281,"CreationDate":"2011-08-10T17:31:00.000","Title":"Sending a one-way message with Python on all threads except the sender","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm developing an application in Python which needs to send a one-way message to all threads (threading module in Python2) in an array, except the current thread. I have tried variables, but that would result in all threads responding to it instead of all but the sender.\nWhat is the best way to send messages that way?","AnswerCount":2,"Available Count":2,"Score":0.1973753202,"is_accepted":false,"ViewCount":263,"Q_Id":7015171,"Users Score":2,"Answer":"Why not make the \"message\" be a tuple of (thread_id, 'message'), and then send it to all threads - the thread that sent it can just ignore messages with its own thread_id.","Q_Score":2,"Tags":"python,multithreading","A_Id":7015194,"CreationDate":"2011-08-10T17:31:00.000","Title":"Sending a one-way message with Python on all threads except the sender","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm running a new mac with osx lion and it came with the latest Python 2.7. My \/Library\/Frameworks\/Python.framework\/Versions directory has 2.3, 2.5, 2.6, 2.7, and Current. \nNow 2.5 and 2.6 have Python.h and many other header files in \/include. \nMy problem is I can't find any header files except pyconfig.h in the 2.7\/include or Current\/include directories.\nCan anyone shed light on this? \nEDIT:\nas Foo Bah pointed out, I should be looking for my header files in \/usr\/include. So in \/usr\/include I do not even have a folder python2.7. I have folders for previous version, python2.5 and python2.6.\nIs there a reason that python2.7 include folder is not there even though the mac came with 2.7?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1543,"Q_Id":7015910,"Users Score":2,"Answer":"OK found the answer.\nYou need to install a newer version of Xcode. \nI had installed an older Xcode 3.2 on Lion. After upgrading, my \/usr\/include\/python2.7 directory was populated with the header files.","Q_Score":3,"Tags":"python","A_Id":7016498,"CreationDate":"2011-08-10T18:32:00.000","Title":"why is Python.h in my \/usr\/local\/python2.6 folder when my Mac is using 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":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I'm automating a configuration process for an embedded board. To enter the setup screen I need to send \"Ctrl-C\" command.\nThis is NOT to interrupt a process I'm running locally, KeyboardInterrupt will not work. I need to send a value that will be interpreted by the bootloader as Ctrl-C.\nWhat is the value I need to send?\nThank you","AnswerCount":4,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":44697,"Q_Id":7018139,"Users Score":24,"Answer":"IIRC, Ctrl-C is etx. Thus send \\x03.","Q_Score":17,"Tags":"python,serial-port,copy-paste,pyserial","A_Id":7018187,"CreationDate":"2011-08-10T21:34:00.000","Title":"PySerial: How to send Ctrl-C command on the serial 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},{"Question":"I'm having a lot of trouble getting Eclipse to recognise PyDev when using the PyDev zip file. (I need to use the zip file as the Dev machine does not have internet access).\nI have Eclipse installed and have downloaded the PyDev zip. I've Googled a fair bit and tried the following based on suggestions I found:-\n\nUnzipped the .zip into ECLIPSE\/helios\/dropins and restarted eclipse.\nUnzipped the .zip into ECLIPSE\/helios\/plugins and restarted eclipse.\n\nNeither makes Python appear as a selection in the Eclipse, Window, Preferences.\nHelios contains the executable eclipse file I use to load eclipse.\nI'm using eclipse in Redhat linux.\nOne suggestion was to extract the zip over the eclipse plugins and features folders, but I don't see how that would work as the zip just produces a heap of files and no folders.\nAny help to get this working would be great.","AnswerCount":5,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":11417,"Q_Id":7019933,"Users Score":0,"Answer":"For whatever it's worth, I was having the same problem running eclipse 3.6 on RHEL 6. When I ran eclipse as myself, I didn't get any PyDev options; however, when I ran eclipse as root, everything showed up. So permissions could be an issue fyi.","Q_Score":6,"Tags":"python,eclipse,pydev","A_Id":18454032,"CreationDate":"2011-08-11T01:42:00.000","Title":"Adding PyDev to Eclipse using the PyDev zip","Data Science and Machine Learning":0,"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},{"Question":"I'm having a lot of trouble getting Eclipse to recognise PyDev when using the PyDev zip file. (I need to use the zip file as the Dev machine does not have internet access).\nI have Eclipse installed and have downloaded the PyDev zip. I've Googled a fair bit and tried the following based on suggestions I found:-\n\nUnzipped the .zip into ECLIPSE\/helios\/dropins and restarted eclipse.\nUnzipped the .zip into ECLIPSE\/helios\/plugins and restarted eclipse.\n\nNeither makes Python appear as a selection in the Eclipse, Window, Preferences.\nHelios contains the executable eclipse file I use to load eclipse.\nI'm using eclipse in Redhat linux.\nOne suggestion was to extract the zip over the eclipse plugins and features folders, but I don't see how that would work as the zip just produces a heap of files and no folders.\nAny help to get this working would be great.","AnswerCount":5,"Available Count":3,"Score":0.0399786803,"is_accepted":false,"ViewCount":11417,"Q_Id":7019933,"Users Score":1,"Answer":"I just did this today and a far easier way to do it is to use the built-in installer. Go to Help -> Install New Software and then type pydev in the software filter. Since you already have the zip, if you extract it in the dropins folder, you'll skip the download portion and go straight to installing it.\nI have been able to use the zip to install it manually before. I would extract its contents in the eclipse folder overwriting the features and plugins folder. I suggested this to a coworker earlier today and it didn't work for her. She had to download the newest version of eclipse for this method to work. She downloaded the classic version.","Q_Score":6,"Tags":"python,eclipse,pydev","A_Id":7020096,"CreationDate":"2011-08-11T01:42:00.000","Title":"Adding PyDev to Eclipse using the PyDev zip","Data Science and Machine Learning":0,"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},{"Question":"I'm having a lot of trouble getting Eclipse to recognise PyDev when using the PyDev zip file. (I need to use the zip file as the Dev machine does not have internet access).\nI have Eclipse installed and have downloaded the PyDev zip. I've Googled a fair bit and tried the following based on suggestions I found:-\n\nUnzipped the .zip into ECLIPSE\/helios\/dropins and restarted eclipse.\nUnzipped the .zip into ECLIPSE\/helios\/plugins and restarted eclipse.\n\nNeither makes Python appear as a selection in the Eclipse, Window, Preferences.\nHelios contains the executable eclipse file I use to load eclipse.\nI'm using eclipse in Redhat linux.\nOne suggestion was to extract the zip over the eclipse plugins and features folders, but I don't see how that would work as the zip just produces a heap of files and no folders.\nAny help to get this working would be great.","AnswerCount":5,"Available Count":3,"Score":0.0399786803,"is_accepted":false,"ViewCount":11417,"Q_Id":7019933,"Users Score":1,"Answer":"I've been playing with PyDev and Eclipse. Reinstalled Eclipse on a fresh machine and unzipped the standard PyDev over it (not the source version) and it worked fine. Did the same thing on the same machine having the problems but in a different location (\/home) also worked fine. So it looks like a configuration problem on the machine not a PyDev\/Eclipse issue. Sorry for the run around and thanks for the help. Dog.","Q_Score":6,"Tags":"python,eclipse,pydev","A_Id":7033285,"CreationDate":"2011-08-11T01:42:00.000","Title":"Adding PyDev to Eclipse using the PyDev zip","Data Science and Machine Learning":0,"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},{"Question":"When trying to to import and execute a function within a Python module from a C++ executable, how can I pass in the directory where the module is located as a command line argument?","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":52,"Q_Id":7031077,"Users Score":2,"Answer":"Python honors PYTHONPATH environmental variable. It is a PATH like environmental variable specifying paths where Python loads modules.\nInside .py script PYTHONPATH can be accessed and updated through the sys.path variable.\nIf you can show more source code how you create Python interpreter more helpful answer can be given.","Q_Score":4,"Tags":"c++,python","A_Id":7031182,"CreationDate":"2011-08-11T18:38:00.000","Title":"specifiying directory of Python module when calling it from 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},{"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},{"Question":"I am trying to import the OpenGL.GL module.\nGiven the py file with that line, I can perform \"python file.py\" just fine, but I cannot run that same file when used in Aptana or Eclipse. Both IDEs have PyDev installed.\nI do have PyOpenGL installed.\nI wish to point out that I can still import other modules (PIL, numpy), which were installed the same way as the PyOpenGL. I am confident that there is only 1 python running on my MacOS.","AnswerCount":3,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":1045,"Q_Id":7036584,"Users Score":0,"Answer":"Are you sure you don't have multiple versions of python? Seems to me like the interpreter that aptana uses is not the same as the one used from command line. You can look in:\nRun -> Run configurations -> Python run -- then you have Interpreter tab\nThere you can click : See resulting command line. Than will get you the python that is used as well as the python path","Q_Score":1,"Tags":"python,eclipse,opengl,aptana,pydev","A_Id":7036672,"CreationDate":"2011-08-12T06:54:00.000","Title":"Python OpenGL in Eclipse\/Aptana","Data Science and Machine Learning":0,"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},{"Question":"I am trying to import the OpenGL.GL module.\nGiven the py file with that line, I can perform \"python file.py\" just fine, but I cannot run that same file when used in Aptana or Eclipse. Both IDEs have PyDev installed.\nI do have PyOpenGL installed.\nI wish to point out that I can still import other modules (PIL, numpy), which were installed the same way as the PyOpenGL. I am confident that there is only 1 python running on my MacOS.","AnswerCount":3,"Available Count":3,"Score":0.0665680765,"is_accepted":false,"ViewCount":1045,"Q_Id":7036584,"Users Score":1,"Answer":"Maybe you need to reconfigure your interpreter.\nIf you installed PyOpenGL as an egg after pydev was set up your PYTHONPATH might be out of date.\nCheck out Preferences->PyDev->Interpreter - Python","Q_Score":1,"Tags":"python,eclipse,opengl,aptana,pydev","A_Id":7041218,"CreationDate":"2011-08-12T06:54:00.000","Title":"Python OpenGL in Eclipse\/Aptana","Data Science and Machine Learning":0,"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},{"Question":"I am trying to import the OpenGL.GL module.\nGiven the py file with that line, I can perform \"python file.py\" just fine, but I cannot run that same file when used in Aptana or Eclipse. Both IDEs have PyDev installed.\nI do have PyOpenGL installed.\nI wish to point out that I can still import other modules (PIL, numpy), which were installed the same way as the PyOpenGL. I am confident that there is only 1 python running on my MacOS.","AnswerCount":3,"Available Count":3,"Score":0.1325487884,"is_accepted":false,"ViewCount":1045,"Q_Id":7036584,"Users Score":2,"Answer":"I had the same problem after installing a different version of PyOpen and my Eclipse PyDev path is messed up. What I did was remove the interpreter link and re-added the old one which made PyDev to re-scan my libs. This seems to fix the problem. Don't forget for all your projects, you need to go to the property (Right click project->properties) and re-select the interpreter.","Q_Score":1,"Tags":"python,eclipse,opengl,aptana,pydev","A_Id":10692265,"CreationDate":"2011-08-12T06:54:00.000","Title":"Python OpenGL in Eclipse\/Aptana","Data Science and Machine Learning":0,"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},{"Question":"Is it possible to retrieve messages from an SQS queue during their visibility timeout if you don't have the message id? I.e. something along the lines of \"get invisible messages\" or \"get messages currently being processed\".\nI'm working with large timeouts and sometimes I'd like to be able to inspect the queue to see what's left. I'd rather not have to wait for a 5 hour timeout to expire.\nI'm working with boto in python.\nThanks.","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":1141,"Q_Id":7044319,"Users Score":2,"Answer":"As far as I know there is no way of doing this. Seeing as your processing code should only take what it needs off the queue and nothing more it doesn't seem like you would ever need to do this. Do your jobs actually take 5hrs to complete? I assume based on \"I'm working with large timeouts\" they do but if not you can set the expiration to make it a shorter period.","Q_Score":3,"Tags":"python,amazon-web-services,parallel-processing,boto,amazon-sqs","A_Id":7045553,"CreationDate":"2011-08-12T17:58:00.000","Title":"Is it possible to retrieve messages from SQS while they're invisible?","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},{"Question":"First, props to whoever did node.js. I've been using it for less than a day and I'm already thinking about using it for stuff I use Python for now. \nIn fact, whoever did node.js should think about using it for stuff they use Python for now. There is apparently a tool called node-waf that is in Python and is necessary for npm to work and npm of course is necessary for anything else useful.\nI think that my original install went bad because node-waf (which is in \/mnt\/michael\/bin\/node-waf) couldn't find Scripting.py (which is in \/mnt\/michael\/node\/tools\/wafadmin\/; it was looking in non-existent \/mnt\/michael\/node\/tools\/..\/lib\/node\/wafadmin\/). So I hacked node-waf to point to the right director and kept going and found a much more serious problem.\nTurns out node-waf isn't written in \"Python\", but in Python2.6, which is a perfectly good language, it's the language I use myself, but it isn't the language that the default on the system I use. The system is CentOS, which requires Python2.4 be the Python that the command \"python\" invokes. Yes, that's foolish on the part of the CentOS people but less foolish than the same mistake on the part of the node-waf people, since they are necessarily subject to the rules of the OS.\nSo, please tell me there's some switch I haven't found yet that say \"Use Python2.6\". Also, any hints about a proper install would be appreciated.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":5062,"Q_Id":7051276,"Users Score":3,"Answer":"To solve the path problem, I backed up and re-installed Node. To solve the version problem, at the suggestion of some bright soul on the #nodejs channel, I created a symbolic link at ~\/bin\/python that pointed to the right version (that solved a lot of my own problems too, starting up the wrong version from the command line...) An obvious hack, but when you're frustrated, you overlook the obvious.","Q_Score":4,"Tags":"python,node.js,npm,waf","A_Id":7057283,"CreationDate":"2011-08-13T15:12:00.000","Title":"How do I get node-waf to 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":1},{"Question":"I used to use netbeans for a while and really liked it.\nBut now, I wan't to expand my toolbox with Python, and Netbeans dropped support for Django, also Python support seems to suck in NB 7.0.\nSo I am looking for recommendations on IDE or Text Editor for Windows with support: \n\nPython (possibly with Django)\nPHP\nHTML, CSS, JavaScript\nFTP\nGIT & SVN\n\nI know Aptana 3 can do this, is there anything else? \nI don't know Vim a lot, but would that be an option?","AnswerCount":5,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":3567,"Q_Id":7051282,"Users Score":0,"Answer":"Eclipse and Visual Studio have plugins for just about everything. Eclipse is free, I think for Visual Studio though you'd have to get the professional version to run plugins...","Q_Score":6,"Tags":"php,python,ide","A_Id":7051285,"CreationDate":"2011-08-13T12:46:00.000","Title":"IDE for PHP and Python 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},{"Question":"I used to use netbeans for a while and really liked it.\nBut now, I wan't to expand my toolbox with Python, and Netbeans dropped support for Django, also Python support seems to suck in NB 7.0.\nSo I am looking for recommendations on IDE or Text Editor for Windows with support: \n\nPython (possibly with Django)\nPHP\nHTML, CSS, JavaScript\nFTP\nGIT & SVN\n\nI know Aptana 3 can do this, is there anything else? \nI don't know Vim a lot, but would that be an option?","AnswerCount":5,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":3567,"Q_Id":7051282,"Users Score":0,"Answer":"Well Aptana is built upon eclipse, so you could just use the basic eclipse with all your necessary add ons.\nObviously you'll need Pydev for the python stuff and that has Django integration.\nFor some reason though I actually prefer netbeans for my php ide.\nTbh just try out a few and see which one you like best.","Q_Score":6,"Tags":"php,python,ide","A_Id":7051283,"CreationDate":"2011-08-13T12:46:00.000","Title":"IDE for PHP and Python 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},{"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},{"Question":"In matlab, it is possible to execute a script (ie an m-file) and then manipulate the variables created by the script on the command line.\nIs it possible to run a .py file on PyDev and consequently, manipulate its variables inside eclipse as is possible in the case of matlab?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":7173,"Q_Id":7067279,"Users Score":2,"Answer":"Yes, check the run configurations. You can add the script as a \"Python Run\".","Q_Score":5,"Tags":"python,eclipse,pydev","A_Id":7067352,"CreationDate":"2011-08-15T15:55:00.000","Title":"Running python command line interpreter inside 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":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am looking for feasible solutions for my Application to be backed with MongoDB. I am looking to host the MongoDB on the cloud with a python based server to interact with the DB and my app (either mobile\/web). I am trying to understand how the architecture should look like.\n\nEither i can host a mongoDB on the AWS cloud and have the server running there only. \nI also tried using MongoLab and seemed to be simple accessing it using HTTP requests. but i am not sure if it exposes all the essential features of MongoDB (what ever i can do using a pymongo driver)? Also, should i go for accessing the MongoLab service directly from my application or still i should build a server in-between? \n\nI would prefer to building an server in either case as i want to do some processing before sending the data back to application. but i am not sure in that case how my DB-server-app interaction design should be\nAny suggestions?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":501,"Q_Id":7067909,"Users Score":0,"Answer":"One thing to consider is that you don't need to use MongoLab's REST API. You can connect directly via a driver as well. \nSo, if you need to implement business logic (which it sounds like you do), it makes sense to have a three tier architecture with an app server connecting to your MongoLab database via one of the drivers. In your case it sounds like this would be pymongo. \n-will","Q_Score":0,"Tags":"python,mongodb,amazon-web-services,cloud-hosting,mlab","A_Id":7068152,"CreationDate":"2011-08-15T16:47:00.000","Title":"Using MongoLab Database service vs Custom web service with MongoDB running on AWS","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I have a php video hosting site, not a typical video hosting site, but i think you put it in that category.\nI'm almost done with it, I'll launch it maybe next week, i created it in php because my partner wanted to get it done so fast, and the fastest way for me to do it was php, because i know it could be done with php mysql, ffmpeg and ffmpeg-php and some other multimedia packages. I don't know what it takes to do it in other languages.\nnow I want to launch the site, and re-write another better version, because i don't like the current version, my partner likes it but he's on the business side and I'm on the development side lol, so i decide :D\nI don't know much about the php frameworks, I've seen them all, but I don't think they are that good for such websites\nI was thinking maybe Django, but Django is created mainly for CMS websites, I don't know if i can use it for my site\nI've never used plone but i think it's good for my site, I don't have experience with it so I would like to know what you think\nRuby on rails seems to be another option but I've never seen any video hosting site using ROR\nSo what is the best language to re-write my site? or should i stick with php?\nedit\ni already know python, so it's not hard for me to switch to python framwork if it's better for such project...I have some ROR knowledge...and I'm gonna use php for now as you said guys but I'm talking about the future\nI don't want to make this question an argumentative question, because it will be closed, so let ask another question, can i do such website with django because i know django, but i have never used it for such thing, i used it for cms, i don't know if it supports ffmpeg, multimedia and such things\nsorry for posting an argumentative topic, i hope my question is now better :D","AnswerCount":2,"Available Count":2,"Score":0.2913126125,"is_accepted":false,"ViewCount":588,"Q_Id":7070097,"Users Score":3,"Answer":"It does not really matter in which language you would make it. If you are good programmer, the application will work fine in any of those environment. If you are not good programmer, it will sux always :) you can do it for example in Ruby on Rails, but what is the purpose if you will not be able to follow MVC structure? it's a little bit risky to use technology that you do not know. There are many issues you can run into. Just for example N+1 queries. I wouldn't recommend you switching the language, unless you really would like to learn other technology - but be aware that your application most probably will not be \"pretty\" :)","Q_Score":0,"Tags":"php,python,ruby-on-rails,django,plone","A_Id":7070188,"CreationDate":"2011-08-15T20:02:00.000","Title":"which is better for my project: Django, Plone, php, or ruby on rails","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I have a php video hosting site, not a typical video hosting site, but i think you put it in that category.\nI'm almost done with it, I'll launch it maybe next week, i created it in php because my partner wanted to get it done so fast, and the fastest way for me to do it was php, because i know it could be done with php mysql, ffmpeg and ffmpeg-php and some other multimedia packages. I don't know what it takes to do it in other languages.\nnow I want to launch the site, and re-write another better version, because i don't like the current version, my partner likes it but he's on the business side and I'm on the development side lol, so i decide :D\nI don't know much about the php frameworks, I've seen them all, but I don't think they are that good for such websites\nI was thinking maybe Django, but Django is created mainly for CMS websites, I don't know if i can use it for my site\nI've never used plone but i think it's good for my site, I don't have experience with it so I would like to know what you think\nRuby on rails seems to be another option but I've never seen any video hosting site using ROR\nSo what is the best language to re-write my site? or should i stick with php?\nedit\ni already know python, so it's not hard for me to switch to python framwork if it's better for such project...I have some ROR knowledge...and I'm gonna use php for now as you said guys but I'm talking about the future\nI don't want to make this question an argumentative question, because it will be closed, so let ask another question, can i do such website with django because i know django, but i have never used it for such thing, i used it for cms, i don't know if it supports ffmpeg, multimedia and such things\nsorry for posting an argumentative topic, i hope my question is now better :D","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":588,"Q_Id":7070097,"Users Score":2,"Answer":"I think you should stick with PHP : \n\nyou already know the language\nyou already have the tools for development\nyou already have a code base\n\nI think you should see how your site behaves in production and see what are the most wanted user needs before spending time rewriting everything, and during this time not beeing able to answer correctly to their needs.\nAnd while your site sends its first bits, it will give you a lot more info on what to expect from the version 2, from a technical point of view.\nEdit : I am not pro-php, I just think you should stick whit the language you already know, until your business gives you time to learn something else.","Q_Score":0,"Tags":"php,python,ruby-on-rails,django,plone","A_Id":7070199,"CreationDate":"2011-08-15T20:02:00.000","Title":"which is better for my project: Django, Plone, php, or ruby on rails","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I was wondering if there are any settings I need to do to enable Satchmo sending me an email (to the store config email address) each time an order is placed? I have set up the template:\ntemplates\/shop\/email\/order_placed_notice.html and enabled Send HTML Email in the settings.\nThe site is sending the order placed and order shipped emails to the customer no problems, but is not sending an email to the store email. I have searched through the Satchmo docs around the settings and couldn't find anything. Should I be changing something to the signals? I have gone through the signals.py, listeners.py and mail.py files and done reading on Django & Satchmo Signals but was reluctant to play around as my programming knowledge isn't too great.\nAny help is appreciated.\nThanks!","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":283,"Q_Id":7071829,"Users Score":1,"Answer":"I managed to find the solution for this. It was a setting under the Satchmo \/settings\/ page, under the Payment section:\nEmail Owner? Needs to be ticked.\nFeel like a bit of an idiot for missing this, but the reason I skipped over the payment section is that I'm using a custom payment module so didn't think it would apply. I am now using this setting alongside my custom payment module and all is working fine.","Q_Score":1,"Tags":"python,django,satchmo","A_Id":7085400,"CreationDate":"2011-08-15T23:06:00.000","Title":"Not receiving order placed notice 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":1},{"Question":"I am writing a game engine and I'd like it to have Python scripting as well as support for mods using PhysFS.\nMy game data is stored something like this:\n\n\/\n\nnative\n\nscripts\nsprites\n...\n\nmods\n\nmymodname\n\nscripts\n\n\n\n\nWhat I want is for the mod scripts to be able to 'import' the native scripts as if they were in the same directory. Is something like that possible using PhysFS?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":298,"Q_Id":7088196,"Users Score":0,"Answer":"[I am the same person who asked the question.]\nThe solution I used eventually was to modify Python's sys.path when my program starts. This does not pollute the game's data directories with symbolic links and is overall much cleaner.","Q_Score":0,"Tags":"c++,python,physfs","A_Id":7299183,"CreationDate":"2011-08-17T05:05:00.000","Title":"PhysFS and Python embedding","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I have a launchd entry that worked with OSX 10.6 but that fails with 10.7. It uses python, and it produces an error whilst trying to import serial. I don't quite understand this, because I've re-downloaded pyserial-2.5 and re-installed it with sudo. (In desperation, I re-installed it for each of the many flavours of python on my machine.) As a test, I can enter python and do import serial without difficulties. Maybe there is a system path that is set up well for an interactive user, that is not set up for launched??\nCan anyone suggest how I might diagnose the problem?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":1631,"Q_Id":7093689,"Users Score":1,"Answer":"The path you are appending:\n\/Library\/Frameworks\/Python.framework\/Versions\/2.7\/lib\/python2.7\/site-packages\nis the site-packages directory for a third-party, non-system Python, possibly installed using a python.org installer, and not that of the Apple-supplied system Python 2.7, which would be:\n\/Library\/Python\/2.7\/site-packages\nSo most likely you are using the python.org Python to install pyserial but are launching the system Python under launchd. Check your shell PATH (echo $PATH), it probably has:\n\/Library\/Frameworks\/Python.framework\/Versions\/2.7\/bin\nin it. And try which python. If you want to use the python.org Python with your launchd plist, modify it to use an absolute path to the right Python, for instance:\n\/Library\/Frameworks\/Python.framework\/Versions\/2.7\/bin\/python\nIf you want to install pyserial with the system supplied Python, you can use an absolute path to it when doing the install:\n\/usr\/bin\/python2.7","Q_Score":0,"Tags":"python,macos,osx-lion,launchd,pyserial","A_Id":7096933,"CreationDate":"2011-08-17T13:30:00.000","Title":"python\/serial broken in OSX lion \/ launchd","Data Science and Machine Learning":0,"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},{"Question":"Is there an equivalent of Python properties in C++? Or would it just be better to do this using getters and setters?","AnswerCount":3,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":2093,"Q_Id":7105202,"Users Score":12,"Answer":"Yes, explicit getter and setters would be the closest construct in C++.","Q_Score":7,"Tags":"c++,python,properties","A_Id":7105239,"CreationDate":"2011-08-18T09:27:00.000","Title":"C++ equivalent of Python properties","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I am working with a pressure-sensing mattress having a USB interface. The maker provides USB device drivers for Windows, and an API written in C++ which has functions to request data and set some parameters.\nCurrently, I cannot use this sensor for testing some Python data-visualization scripts directly, having had to ask my coworkers to write a text-logger for me, and then I read this information offline with Python.\nAlso, I cannot use Linux at all with the sensor, because there are not drivers for Linux, and I do not know where to start to \"hack\" the sensor, and that is why I am asking:\n\"If I were to try to read data from this sensor directly with Python and perhaps in Linux, what should I do first, or read first?\"\nEDIT: the device has an FTDI driver (FTD2XX.dll) if it helps.\nAny help would be very welcome","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":1493,"Q_Id":7112063,"Users Score":1,"Answer":"The FTDI chips have a linux driver. Just go to the FTDI website and download it. The driver creates a virtual serial port. You can use PySerial to interface with it.\nToo bad I didn't see the post sooner!","Q_Score":2,"Tags":"c++,python,usb,sensors,hardware-interface","A_Id":16451772,"CreationDate":"2011-08-18T18:12:00.000","Title":"Access USB hardware (pressure sensor matrix with native C++ API) using 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":0,"Web Development":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},{"Question":"I wanna build a simple social network use python. Just like twitter but smaller than twitter.I just wanna make a few features like follow,BE followed,view others profile,etc.\nMy question is that i should use web.py or Tornado?\nBTW, is there any tutorial about Tornado? I feel it hard to understand when i read the documenations on the offical.\n(Oops,my english is week. :P )","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":2321,"Q_Id":7130303,"Users Score":0,"Answer":"You might consider using Pinax. When I used it, it had the self-concept of 'django with an opinion.' I'm not sure where it's at now, but my experience was that it was best suited for exactly what you want to do. One of the base projects is actually a fully functional social network site. You could then customize from there.","Q_Score":0,"Tags":"python,tornado","A_Id":7131286,"CreationDate":"2011-08-20T07:00:00.000","Title":"Choose web.py or Tornado","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I wanna build a simple social network use python. Just like twitter but smaller than twitter.I just wanna make a few features like follow,BE followed,view others profile,etc.\nMy question is that i should use web.py or Tornado?\nBTW, is there any tutorial about Tornado? I feel it hard to understand when i read the documenations on the offical.\n(Oops,my english is week. :P )","AnswerCount":3,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":2321,"Q_Id":7130303,"Users Score":3,"Answer":"these two are different things.\nTornado is web server while web.py is a framework.\ntherefore you can use both of them.","Q_Score":0,"Tags":"python,tornado","A_Id":7130351,"CreationDate":"2011-08-20T07:00:00.000","Title":"Choose web.py or Tornado","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I have a concept I'd like to work on that requires the use of low-level sockets (i.e.: no frameworks or wrappers, just the standard send\/recv pattern included in most standard libraries. \nI'm familiar with both Ruby and Python, and from my (limited) experience they seem to have similar socket libraries. What I'd like to know is if either language has any advantage, whether it be with performance, stability, ease-of-use or otherwise.\nThanks.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":903,"Q_Id":7156837,"Users Score":0,"Answer":"What a language you know better, that'll fit your needs.","Q_Score":1,"Tags":"python,ruby,sockets,tcp,udp","A_Id":7157569,"CreationDate":"2011-08-23T05:56:00.000","Title":"Ruby Vs Python - Socket Libraries","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I have a concept I'd like to work on that requires the use of low-level sockets (i.e.: no frameworks or wrappers, just the standard send\/recv pattern included in most standard libraries. \nI'm familiar with both Ruby and Python, and from my (limited) experience they seem to have similar socket libraries. What I'd like to know is if either language has any advantage, whether it be with performance, stability, ease-of-use or otherwise.\nThanks.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":903,"Q_Id":7156837,"Users Score":0,"Answer":"Both language offer a very thin wrapper above the underlying OS socket library. You won't get much difference.","Q_Score":1,"Tags":"python,ruby,sockets,tcp,udp","A_Id":7158166,"CreationDate":"2011-08-23T05:56:00.000","Title":"Ruby Vs Python - Socket Libraries","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I'd like to test the speed of a bash script and a Python script. How would I get the time it took to run them?","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":327,"Q_Id":7162812,"Users Score":0,"Answer":"At the beginning of each script output the start time and at the end of each script output the end time. Subtract the times and compare. Or use the time command if it is available as others have answered.","Q_Score":1,"Tags":"python,performance,bash,testing","A_Id":7162876,"CreationDate":"2011-08-23T14:39:00.000","Title":"Test speed of two 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},{"Question":"I'm trying to create a python shell script to create a number of directories in Ubuntu Linux. The main directory I'm trying to create directories in is protected from write access. Is there a way to allow the Python script to be allowed to create directories in there as if it's the root user but not have to run the script through su, since other users might need to run the script but should not have su access?","AnswerCount":5,"Available Count":4,"Score":0.0,"is_accepted":false,"ViewCount":2415,"Q_Id":7166528,"Users Score":0,"Answer":"You could create a separate command that creates the directory and make it setuid root (or, more safely, setuid or setgid to the owner of the parent directory). Make sure the command can't do anything other than what you want to allow it to do (e.g., don't let it pass its argument to system()). Then invoke that command from your Python script.\nOf course this will also enable any other process with execute permission on the new command to create subdirectories.","Q_Score":2,"Tags":"python,linux,shell,filesystems","A_Id":7166842,"CreationDate":"2011-08-23T19:34:00.000","Title":"How do you allow a Python script access to mkdir in a protected directory without su access 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},{"Question":"I'm trying to create a python shell script to create a number of directories in Ubuntu Linux. The main directory I'm trying to create directories in is protected from write access. Is there a way to allow the Python script to be allowed to create directories in there as if it's the root user but not have to run the script through su, since other users might need to run the script but should not have su access?","AnswerCount":5,"Available Count":4,"Score":1.2,"is_accepted":true,"ViewCount":2415,"Q_Id":7166528,"Users Score":6,"Answer":"This question is not really related to Python. The Python script is just a process like any other process and needs to have to right permissions to do things. The usual method is to create a group, and make the parent directory g+ws for that group. Then add the appropriate users to that group as a supplemental group.","Q_Score":2,"Tags":"python,linux,shell,filesystems","A_Id":7166747,"CreationDate":"2011-08-23T19:34:00.000","Title":"How do you allow a Python script access to mkdir in a protected directory without su access 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},{"Question":"I'm trying to create a python shell script to create a number of directories in Ubuntu Linux. The main directory I'm trying to create directories in is protected from write access. Is there a way to allow the Python script to be allowed to create directories in there as if it's the root user but not have to run the script through su, since other users might need to run the script but should not have su access?","AnswerCount":5,"Available Count":4,"Score":0.0798297691,"is_accepted":false,"ViewCount":2415,"Q_Id":7166528,"Users Score":2,"Answer":"Unfortunately no. A process's permissions in a *nix environment are always less than or equal to the permissions of the person who fires it. This actually makes sense though -- it is a huge security risk to allow processes exceed the user's own abilities. \nThis will require someone who has access to that directory -- either through one of their groups or through sudo. Either way, it will require human interaction on every machine that the script is run on.\nAs far as what is easiest, well, you'll need someone who has that authority to grant it to another user, or simply use sudo directly.","Q_Score":2,"Tags":"python,linux,shell,filesystems","A_Id":7166771,"CreationDate":"2011-08-23T19:34:00.000","Title":"How do you allow a Python script access to mkdir in a protected directory without su access 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},{"Question":"I'm trying to create a python shell script to create a number of directories in Ubuntu Linux. The main directory I'm trying to create directories in is protected from write access. Is there a way to allow the Python script to be allowed to create directories in there as if it's the root user but not have to run the script through su, since other users might need to run the script but should not have su access?","AnswerCount":5,"Available Count":4,"Score":0.0,"is_accepted":false,"ViewCount":2415,"Q_Id":7166528,"Users Score":0,"Answer":"You could add a user just for this task, then give the said user permissions for the directory you want the subdirectories created in and execute the script as the said user.\nThere might be easier solutions but that's what comes to my mind at first glance.","Q_Score":2,"Tags":"python,linux,shell,filesystems","A_Id":7166564,"CreationDate":"2011-08-23T19:34:00.000","Title":"How do you allow a Python script access to mkdir in a protected directory without su access 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},{"Question":"Quickie here that needs more domain expertise on pymongo than I have right now: \nAre the \"right\" parts of the pymongo driver written in python for me to call gevent monkey_patch() and successfully alter pymongo's blocking behavior on r\/w within gevent \"asynchronous\" greenlets? \nIf this will require a little more leg work on gevent and pymongo -- but it is feasible -- I would be more than willing to put in the time as long as i can get a little guidance over irc. \nThanks! \nNote: At small scale mongo writes are not a big problem because we are just queuing a write \"request\" before unblocking. BUT talking to fiorix about his twisted async mongo driver (https:\/\/github.com\/fiorix\/mongo-async-python-driver), even mongo's quick write (requests) can cause problems in asyncronous applications at scale. (And of course, non-blocking reads could cause problems from the start!)","AnswerCount":2,"Available Count":2,"Score":0.1973753202,"is_accepted":false,"ViewCount":4465,"Q_Id":7166998,"Users Score":2,"Answer":"On initial inspection it doesn't appear to do any socket operations in the c code so it should be fine (blocking ops should just block the green thread).","Q_Score":13,"Tags":"python,mongodb,pymongo,monkeypatching,gevent","A_Id":7168735,"CreationDate":"2011-08-23T20:15:00.000","Title":"pymongo + gevent: throw me a banana and just monkey_patch?","Data Science and Machine Learning":0,"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},{"Question":"Quickie here that needs more domain expertise on pymongo than I have right now: \nAre the \"right\" parts of the pymongo driver written in python for me to call gevent monkey_patch() and successfully alter pymongo's blocking behavior on r\/w within gevent \"asynchronous\" greenlets? \nIf this will require a little more leg work on gevent and pymongo -- but it is feasible -- I would be more than willing to put in the time as long as i can get a little guidance over irc. \nThanks! \nNote: At small scale mongo writes are not a big problem because we are just queuing a write \"request\" before unblocking. BUT talking to fiorix about his twisted async mongo driver (https:\/\/github.com\/fiorix\/mongo-async-python-driver), even mongo's quick write (requests) can cause problems in asyncronous applications at scale. (And of course, non-blocking reads could cause problems from the start!)","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":4465,"Q_Id":7166998,"Users Score":19,"Answer":"I have used PyMongo with Gevent and here are a few things you need to watch out for:\n\nInstantiate only one pymongo.Connection object, preferrably as a global or module-level variable. This is important because Connection has within itself a pool!\nMonkey patch everything, or at least BOTH socket and threading. Due to the use of thread locals in Connection, patching socket alone is not enough.\nRemember to call end_request to return the connection to the pool.\n\nThe answer to your question is go ahead, PyMongo works just fine with Gevent.","Q_Score":13,"Tags":"python,mongodb,pymongo,monkeypatching,gevent","A_Id":7169174,"CreationDate":"2011-08-23T20:15:00.000","Title":"pymongo + gevent: throw me a banana and just monkey_patch?","Data Science and Machine Learning":0,"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},{"Question":"I need to know, When i run My python over terminal by default how many module are loaded with it which i do not have to import to use, which modules i can directly use ??\nMy System Env is Ubuntu 11.04\nRegards","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":237,"Q_Id":7175909,"Users Score":0,"Answer":"Any modules you wish to use from the standard library must be imported before you can use them.","Q_Score":2,"Tags":"python,linux,module","A_Id":7176030,"CreationDate":"2011-08-24T13:06:00.000","Title":"Python - How many Default Modules loaded","Data Science and Machine Learning":0,"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},{"Question":"installing python2.6 after running .\/configure it runs with no errors but after running gmake i get this error * WARNING: renaming \"_curses\" since importing it failed: ld.so.1: python: fatal: relocation error: file build\/lib.solaris-2.10-i86pc-2.6\/_curses.so: symbol newscr: referenced symbol not found\nbuilding '_curses_panel' extension\ngcc -fPIC -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I. -I\/export\/home\/joseph\/Python-2.6.6\/.\/Include -I. -IInclude -I.\/Include -I\/usr\/local\/include -I\/export\/home\/joseph\/Python-2.6.6\/Include -I\/export\/home\/joseph\/Python-2.6.6 -c \/export\/home\/joseph\/Python-2.6.6\/Modules\/_curses_panel.c -o build\/temp.solaris-2.10-i86pc-2.6\/export\/home\/joseph\/Python-2.6.6\/Modules\/_curses_panel.o\ngcc -shared build\/temp.solaris-2.10-i86pc-2.6\/export\/home\/joseph\/Python-2.6.6\/Modules\/_curses_panel.o -L\/usr\/local\/lib -lpanel -lcurses -ltermcap -o build\/lib.solaris-2.10-i86pc-2.6\/_curses_panel.so\n* WARNING: renaming \"_curses_panel\" since importing it failed: No module named _curses\nFailed to find the necessary bits to build these modules:\n_bsddb _sqlite3 _tkinter\nbsddb185 gdbm linuxaudiodev\nossaudiodev readline\nTo find the necessary bits, look in setup.py in detect_modules() for the module's name.\nFailed to build these modules:\n_curses _curses_panel \nand when i try installing a python module reportlab with python2.6 setup.py install returns an error copying src\/reportlab\/lib\/hyphen.mashed -> build\/lib.solaris-2.10-i86pc-2.6\/reportlab\/lib\nrunning build_ext\nbuilding '_renderPM' extension\ngcc -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -DRENDERPM_FT -DLIBART_COMPILATION -DLIBART_VERSION=\"2.3.12\" -I\/export\/home\/joseph\/reportlab-2.5\/src\/rl_addons\/renderPM -I\/export\/home\/joseph\/reportlab-2.5\/src\/rl_addons\/renderPM\/libart_lgpl -I\/export\/home\/joseph\/reportlab-2.5\/src\/rl_addons\/renderPM\/gt1 -I\/usr\/local\/include -I\/usr\/local\/include\/freetype2 -I\/usr\/local\/include\/python2.6 -c \/export\/home\/joseph\/reportlab-2.5\/src\/rl_addons\/renderPM\/_renderPM.c -o build\/temp.solaris-2.10-i86pc-2.6\/export\/home\/joseph\/reportlab-2.5\/src\/rl_addons\/renderPM\/_renderPM.o\n\/export\/home\/joseph\/reportlab-2.5\/src\/rl_addons\/renderPM\/_renderPM.c: In function 'parse_utf8':\n\/export\/home\/joseph\/reportlab-2.5\/src\/rl_addons\/renderPM\/_renderPM.c:81:9: error: expected identifier or '*' before numeric constant\n\/export\/home\/joseph\/reportlab-2.5\/src\/rl_addons\/renderPM\/_renderPM.c:96:9: error: expected identifier or '*' before numeric constant\n\/export\/home\/joseph\/reportlab-2.5\/src\/rl_addons\/renderPM\/_renderPM.c:100:1: warning: statement with no effect\n\/export\/home\/joseph\/reportlab-2.5\/src\/rl_addons\/renderPM\/_renderPM.c:100:4: error: expected ';' before ':' token\n\/export\/home\/joseph\/reportlab-2.5\/src\/rl_addons\/renderPM\/_renderPM.c:101:5: error: 'else' without a previous 'if'\n\/export\/home\/joseph\/reportlab-2.5\/src\/rl_addons\/renderPM\/_renderPM.c: In function '_get_ft_face':\n\/export\/home\/joseph\/reportlab-2.5\/src\/rl_addons\/renderPM\/_renderPM.c:162:2: warning: pointer targets in passing argument 2 of 'FT_New_Memory_Face' differ in signedness\n\/usr\/local\/include\/freetype2\/freetype\/freetype.h:1904:3: note: expected 'const FT_Byte *' but argument is of type 'char *'\n\/export\/home\/joseph\/reportlab-2.5\/src\/rl_addons\/renderPM\/_renderPM.c: In function '_get_gstatePath':\n\/export\/home\/joseph\/reportlab-2.5\/src\/rl_addons\/renderPM\/_renderPM.c:936:3: warning: enumeration value 'ART_END' not handled in switch\n\/export\/home\/joseph\/reportlab-2.5\/src\/rl_addons\/renderPM\/_renderPM.c: In function '_get_gstateVPath':\n\/export\/home\/joseph\/reportlab-2.5\/src\/rl_addons\/renderPM\/_renderPM.c:968:3: warning: enumeration value 'ART_CURVETO' not handled in switch\n\/export\/home\/joseph\/reportlab-2.5\/src\/rl_addons\/renderPM\/_renderPM.c:968:3: warning: enumeration value 'ART_END' not handled in switch\n\/export\/home\/joseph\/reportlab-2.5\/src\/rl_addons\/renderPM\/_renderPM.c: In function 'gstate_setFont':\n\/export\/home\/joseph\/reportlab-2.5\/src\/rl_addons\/renderPM\/_renderPM.c:1108:5: warning: suggest explicit braces to avoid ambiguous 'else'\n\/export\/home\/joseph\/reportlab-2.5\/src\/rl_addons\/renderPM\/_renderPM.c: In function 'gstateFree':\n\/export\/home\/joseph\/reportlab-2.5\/src\/rl_addons\/renderPM\/_renderPM.c:1492:4: warning: suggest explicit braces to avoid ambiguous 'else'\n\/export\/home\/joseph\/reportlab-2.5\/src\/rl_addons\/renderPM\/_renderPM.c: At top level:\n\/export\/home\/joseph\/reportlab-2.5\/src\/rl_addons\/renderPM\/_renderPM.c:332:12: warning: 'notdefPathLen' defined but not used\nerror: command 'gcc' failed with exit status 1","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":715,"Q_Id":7176218,"Users Score":0,"Answer":"First and foremost, make sure you have the newest version of gmake\/make. I had a nasty problem using an older version. It was similar to this, which is why I am suggesting it. \nIf you don't have it, install gmake and redo the python installation (.\/configure, make, make install). Hope that helps!","Q_Score":0,"Tags":"python,unix","A_Id":7176623,"CreationDate":"2011-08-24T13:28:00.000","Title":"python2.6.6 installation problem","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I wonder if is there any reliable and consistant way to get a Python package's \"import name\" \/ namespace. For example;\nPackage; django-haystack\nImport name; haystack\nor\nPackage; ipython\nImport name; IPython\nSo far I know, PyPi doesn't store that information that I've checked with PyPiXmlRpc.\nI also tried to automate to download the package, extract it and dig the .egg-info but some packages doesn't have that folder at all.\nAny help will be appreciated and will be used for a good-manner gadget :)","AnswerCount":3,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":8641,"Q_Id":7184375,"Users Score":8,"Answer":"Note that what you call a package here is not a package but a distribution. A distribution can contain zero or more modules or packages. That means there is no one-to-one mapping of distributions to packages.\nI'm not sure there is a way to detect what modules and packages will be installed by a distribution, other than actually installing it and introspect filesystem changes for newly added packages, modules and pth files.","Q_Score":28,"Tags":"python,namespaces,pypi,cheeseshop","A_Id":7461581,"CreationDate":"2011-08-25T02:10:00.000","Title":"How to find \"import name\" of any package 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},{"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},{"Question":"I assume it is because of the interpreter's implementation. \nCan anyone give me a more in-depth answer please? Thanks. \nAlso, I wonder if bash has a garbage collector?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":635,"Q_Id":7200700,"Users Score":4,"Answer":"bash loads a large number of commands from disk. Most other scripting languages have many more instructions that they run internally.\nFor example, to do a simple computation in bash, you'd use a=`expr 1 + 2` and bash will first load \/usr\/bin\/expr, run that command which writes the result in the output, bash collects the output (the ` quotes) and saves the result in the variable 'a'. That's definitively slow.\nThe advantage of bash is the incredible flexibility though. Each person may have a different set of powerful \"instructions\". For example, I have a small tool called hex to print out numbers in octal, hexadecimal and decimal all at once. Other languages would not integrate in the way bash does...","Q_Score":3,"Tags":"python,ruby,bash,interpreter","A_Id":7200742,"CreationDate":"2011-08-26T06:16:00.000","Title":"Why is bash language often slower than python or 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":1,"System Administration and DevOps":1,"Web Development":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},{"Question":"I'm using Fabric for my build script. I just cloned one of my VMs and created a new server. The Fabric script (which uses paramiko underneath) works fine one server but not the other. Since it's a clone I don't know what could be different but everytime I run my Fabric script I get the error Error reading SSH protocol banner. This script is connecting with the same user on both servers. The script works fine on all other servers except this new one that I just clones. The only thing that is radically different is the IP address which is totally different range.\nAny ideas on what could be causing this?","AnswerCount":2,"Available Count":2,"Score":0.2913126125,"is_accepted":false,"ViewCount":29345,"Q_Id":7206272,"Users Score":3,"Answer":"Try changing the banner timeout from 15 seconds to 30 secs in the transport.py file. Also, it could be that the sshd daemon on the server is hung. Can you SSH into it manually?","Q_Score":6,"Tags":"python,linux,ssh,fabric,paramiko","A_Id":7207845,"CreationDate":"2011-08-26T14:33:00.000","Title":"Paramiko Error: Error reading SSH protocol banner","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},{"Question":"I'm using Fabric for my build script. I just cloned one of my VMs and created a new server. The Fabric script (which uses paramiko underneath) works fine one server but not the other. Since it's a clone I don't know what could be different but everytime I run my Fabric script I get the error Error reading SSH protocol banner. This script is connecting with the same user on both servers. The script works fine on all other servers except this new one that I just clones. The only thing that is radically different is the IP address which is totally different range.\nAny ideas on what could be causing this?","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":29345,"Q_Id":7206272,"Users Score":8,"Answer":"This issue didn't lie with Paramiko, Fabric or the SSH daemon. It was simply a firewall configuration in ISPs internal network. For some reason, they don't allow communication between different subnets of theirs.\nWe couldn't really fix the firewall configuration so instead we switched all our IPs to be on the same subnet.","Q_Score":6,"Tags":"python,linux,ssh,fabric,paramiko","A_Id":7252752,"CreationDate":"2011-08-26T14:33:00.000","Title":"Paramiko Error: Error reading SSH protocol banner","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},{"Question":"I'm trying to build an exception class that I can use both in a C extension and the Python modules that import the extension. I'm using the PyErr_NewException to create the class as a superclass of the Exception class, but I can't figure out how to create an __init__ constructor for the class. I assume that is the best way to populate the class with the attributes I need.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":242,"Q_Id":7216925,"Users Score":0,"Answer":"You should pass a dict as the third argument to PyErr_NewException. The dict should have an __init__ key bound to your initializer function.","Q_Score":0,"Tags":"python","A_Id":7217257,"CreationDate":"2011-08-27T19:40:00.000","Title":"Trying to build a Python class in a C extension that can be instantiated from a 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},{"Question":"I'm on Ubuntu. I'd like to be able to retrieve images saved in my temp folder, and clear it, at will (or does mechanize not actually read images but rather just html?).","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":341,"Q_Id":7230327,"Users Score":0,"Answer":"Mechanize doesn't retrieve images unless you specifically tell it to (on a one by one basis).","Q_Score":0,"Tags":"python,mechanize","A_Id":7236208,"CreationDate":"2011-08-29T12:52:00.000","Title":"Where is the python mechanize cache\/temp folder? How can I clear it? How can I retrieve files from 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":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"We're running a pylons app with multiple ini files (production, staging, development, etc). When a new setting is added that can be the same in all environments, it would be great to be able to set it once in some sort of master configuration that gets included with all .ini files. Or included via some other way to load centralized config as well as deploy-specific config.\nIt doesn't look like there's an \"import\" syntax for pylons ini files. What's the best way to achieve this type of config compositing for pylons, if any?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":539,"Q_Id":7233546,"Users Score":0,"Answer":"You can use the ConfigParser module.","Q_Score":2,"Tags":"python,configuration,pylons,ini,paster","A_Id":7233653,"CreationDate":"2011-08-29T17:26:00.000","Title":"any way to composite configuration\/.ini files in pylons?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"How do you redirect the stdin of a csh script to the stdin of a python script? \nI have a cgi script I'm writing in csh that runs on a Solaris machine. This csh script is a wrapper to a python script that reads from the stdin (I know, scripting in csh is bad but I'm forced to in this case). \nThanks for help! (And sorry for the n00b question!)","AnswerCount":2,"Available Count":1,"Score":0.2913126125,"is_accepted":false,"ViewCount":299,"Q_Id":7234640,"Users Score":3,"Answer":"You don't need to do anything.\nCommands (such that a Python script) that you start from a shell (such as csh) will inherit the shell's stdin (and stdout, stderr) by default unless you actively do something to prevent it.","Q_Score":2,"Tags":"python,stdin,csh","A_Id":7234676,"CreationDate":"2011-08-29T19:07:00.000","Title":"csh stdin to Python 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":0,"Web Development":0},{"Question":"I want to rename all files in a folder and add a .xml extension. I am using Unix. How can I do that?","AnswerCount":4,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":13442,"Q_Id":7253198,"Users Score":2,"Answer":"In Python:\nUse os.listdir to find names of all files in a directory. If you need to recursively find all files in sub-directories as well, use os.walk instead. Its API is more complex than os.listdir but it provides powerful ways to recursively walk directories.\nThen use os.rename to rename the files.","Q_Score":11,"Tags":"php,python,linux,shell,unix","A_Id":7253246,"CreationDate":"2011-08-31T06:11:00.000","Title":"How to add .xml extension to all files in a folder in Unix\/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":1,"Web Development":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},{"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},{"Question":"Which sites are the best for posting Python code that actually works? To show\/share, and get input? I would like to post my code.","AnswerCount":4,"Available Count":1,"Score":0.049958375,"is_accepted":false,"ViewCount":1231,"Q_Id":7265548,"Users Score":1,"Answer":"I think Github (Git) or Bitbucket\/Kiln (Mercurial) would be the best places to host any code. That way you can keep it in version control + get comments, suggestions, and even features or additional code for free via the pull requests.","Q_Score":3,"Tags":"python","A_Id":7265575,"CreationDate":"2011-09-01T02:26:00.000","Title":"Best site for posting 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},{"Question":"We're building a commercial (closed\/proprietary) intranet application which makes used of hosted IronPython (2.7), targeting .NET 4.0. \nWhat approach would you recommend for ensuring the DLR runtimes (Microsoft.Scripting.dll & Microsoft.Dynamic.dll - both included in the IronPython 2.7 binary distribution) are available at runtime? \nThey're both licensed under Apache license so including with our software wouldn't be a problem. Potentially an alternative would be ensuring they're available in the GAC. \nIt seems the intention of the DLR developers is that more and more of the DLR will eventually end up in the .NET framework\/CLR (presumably under System.Core). \nAny thoughts or considerations are appreciated.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":309,"Q_Id":7266270,"Users Score":2,"Answer":"The best thing to do is include the DLR DLLs in your application next to the IronPython DLLs. Putting them in the GAC will affect every other application on the system that uses the DLR, which is probably not what you want unless you have complete control of the systems involved.\nWhat's in .NET 4 is probably the extent of the DLR that's going to go in; Microsoft is not involved in the development of the DLR anymore.","Q_Score":2,"Tags":"c#,runtime,ironpython,distribution,dynamic-language-runtime","A_Id":7272791,"CreationDate":"2011-09-01T04:57:00.000","Title":"Distrubuting DLR runtime for C# Application with embedded (hosted) 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":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"In perl debugger I can use DB::get_fork_TTY() to debug both parent and child process in different terminals. Is there anything similar in python debugger?\nOr, is there any good way to debug fork in python?","AnswerCount":5,"Available Count":4,"Score":-1.0,"is_accepted":false,"ViewCount":2992,"Q_Id":7268563,"Users Score":-17,"Answer":"But I'm still curious if there's any similar feature in python debugger. I happen to find this feature in perldb and I find it's very handy\n\nNo.\nYou don't need it.\nNo matter how handy it may appear in other environments, you just don't need it.\nYou don't need fork() in Python; therefore you don't need fancy debugging to work with fork().\nIf you think you need fork() you should either use subprocess, multiprocessing or C.","Q_Score":5,"Tags":"python,debugging,fork","A_Id":7272926,"CreationDate":"2011-09-01T09:39:00.000","Title":"How to debug python scripts that fork","Data Science and Machine Learning":0,"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},{"Question":"In perl debugger I can use DB::get_fork_TTY() to debug both parent and child process in different terminals. Is there anything similar in python debugger?\nOr, is there any good way to debug fork in python?","AnswerCount":5,"Available Count":4,"Score":0.0399786803,"is_accepted":false,"ViewCount":2992,"Q_Id":7268563,"Users Score":1,"Answer":"The debugger in pyCharm does this nicely. It seems to use gdb with python support to accomplish that, however all the tutorials on how to do this with gdb by Hand which I've found so far didn't work for me. In pyCharm it just works.","Q_Score":5,"Tags":"python,debugging,fork","A_Id":45673792,"CreationDate":"2011-09-01T09:39:00.000","Title":"How to debug python scripts that fork","Data Science and Machine Learning":0,"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},{"Question":"In perl debugger I can use DB::get_fork_TTY() to debug both parent and child process in different terminals. Is there anything similar in python debugger?\nOr, is there any good way to debug fork in python?","AnswerCount":5,"Available Count":4,"Score":0.0,"is_accepted":false,"ViewCount":2992,"Q_Id":7268563,"Users Score":0,"Answer":"One possible way to debug a fork is to use pdb on the main process and winpdb on the fork. You put a software break early in the fork process and attach the winpdb app once the break has been hit.\nIt might be possible to run the program under winpdb and attach another instance after the fork - I haven't tried this. You certainly can't attach two winpdb instances at the same time, I've tried and it fails. If it works, this would be preferable - pdb really sucks.","Q_Score":5,"Tags":"python,debugging,fork","A_Id":23942909,"CreationDate":"2011-09-01T09:39:00.000","Title":"How to debug python scripts that fork","Data Science and Machine Learning":0,"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},{"Question":"In perl debugger I can use DB::get_fork_TTY() to debug both parent and child process in different terminals. Is there anything similar in python debugger?\nOr, is there any good way to debug fork in python?","AnswerCount":5,"Available Count":4,"Score":1.2,"is_accepted":true,"ViewCount":2992,"Q_Id":7268563,"Users Score":3,"Answer":"You can emulate forked process if you will set instead of fork and its condition (pid == 0) always True. For debugging main process debugger will work.\nFor debugging multi-processing interaction better to use detailed logs as for me","Q_Score":5,"Tags":"python,debugging,fork","A_Id":7268624,"CreationDate":"2011-09-01T09:39:00.000","Title":"How to debug python scripts that fork","Data Science and Machine Learning":0,"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},{"Question":"We are running a very large framework of python scripts for test automation and I do really miss the opportunity to kill a running python script with ctrl + c in some situations on Windows.\nWhen the script might be doing some socket communications with long time-outs the only options sometimes is to kill the DOS window.. Is there any options I have missed?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":200,"Q_Id":7285874,"Users Score":2,"Answer":"Rather than using blocking calls with long timeouts, use event-driven networking. This will allow you never to have long periods of time doing uninterruptable operations.","Q_Score":1,"Tags":"python","A_Id":7285945,"CreationDate":"2011-09-02T15:39:00.000","Title":"Make running python script more responsive to ctrl 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},{"Question":"Since Pyramid does not have any form dependencies, I need recommendations for form handling.\nThis covers form generation, validation, etc.\nI only know wtforms, but I dont mind to use some other thing more advanced.","AnswerCount":3,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":3636,"Q_Id":7288143,"Users Score":7,"Answer":"I'd recommend deform. Beyond supporting form generation and validation it has great documentation, a running demo app and it supports localization and ajax. I don't believe formalchemy directly support ajax.","Q_Score":9,"Tags":"python,forms,pyramid,wtforms","A_Id":8394921,"CreationDate":"2011-09-02T19:06:00.000","Title":"Form handling 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":0},{"Question":"I recently implemented password reset on AD using python ldap module.\nThis involved passing modified attributes in this manner:\nadd_pass = [(ldap.MOD_REPLACE, \"unicodePwd\", )]\nThis worked since the passwords on AD are stored in attribute \"unicodePwd\".\nNow I want to unlock a locked user account but I cannot find the attribute that must be changed to achieve the same.\nCould you guys please tell me which attribute I have to change?","AnswerCount":3,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":6179,"Q_Id":7294218,"Users Score":5,"Answer":"To unlock a user, you need to set the lockoutTime attribute to 0.","Q_Score":0,"Tags":"python,active-directory","A_Id":7365734,"CreationDate":"2011-09-03T16:06:00.000","Title":"unlocking Locked user accounts on Active Directory using Python ldap 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":0},{"Question":"When you write some scripts that are self sufficient, is it a bad idea to use the if __name__ == '__main__' as a place to write tests?","AnswerCount":4,"Available Count":3,"Score":1.2,"is_accepted":true,"ViewCount":2066,"Q_Id":7297719,"Users Score":5,"Answer":"Test logic and tests should never be part of \"production\" (production can mean in use by you, released to client, etc.) code. So, it is a bad idea to have them anywhere within your script.\nIdeally, have them in separate files.","Q_Score":10,"Tags":"python,unit-testing","A_Id":7297727,"CreationDate":"2011-09-04T06:22:00.000","Title":"Use if __name__ == '__main__': for 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},{"Question":"When you write some scripts that are self sufficient, is it a bad idea to use the if __name__ == '__main__' as a place to write tests?","AnswerCount":4,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":2066,"Q_Id":7297719,"Users Score":0,"Answer":"I guess not, in fact, I saw a lot of python scripts (mostly plugins of another application) written that way.","Q_Score":10,"Tags":"python,unit-testing","A_Id":7297726,"CreationDate":"2011-09-04T06:22:00.000","Title":"Use if __name__ == '__main__': for 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},{"Question":"When you write some scripts that are self sufficient, is it a bad idea to use the if __name__ == '__main__' as a place to write tests?","AnswerCount":4,"Available Count":3,"Score":0.1488850336,"is_accepted":false,"ViewCount":2066,"Q_Id":7297719,"Users Score":3,"Answer":"Best practice is to put the tests in separate units that use the unittest module. This separation allows you to keep the main code clean (no need for lots of testing helper functions) and encourages you to write good comprehensive tests since you are not inhibited by cluttering the main code.","Q_Score":10,"Tags":"python,unit-testing","A_Id":7297763,"CreationDate":"2011-09-04T06:22:00.000","Title":"Use if __name__ == '__main__': for 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},{"Question":"I am writing a scientific program in Python and C with some complex physical simulation algorithms. After implementing algorithm, I found that there are a lot of possible optimizations to improve performance. Common ones are precalculating values, getting calculations out of cycle, replacing simple matrix algorithms with more complex and other. But there arises a problem. Unoptimized algorithm is much slower, but its logic and connection with theory look much clearer and readable. Also, it's harder to extend and modify optimized algorithm. \nSo, the question is - what techniques should I use to keep readability while improving performance? Now I am trying to keep both fast and clear branches and develop them in parallel, but maybe there are better methods?","AnswerCount":4,"Available Count":1,"Score":0.1488850336,"is_accepted":false,"ViewCount":434,"Q_Id":7300903,"Users Score":3,"Answer":"Yours is a very good question that arises in almost every piece of code, however simple or complex, that's written by any programmer who wants to call himself a pro. \nI try to remember and keep in mind that a reader newly come to my code has pretty much the same crude view of the problem and the same straightforward (maybe brute force) approach that I originally had. Then, as I get a deeper understanding of the problem and paths to the solution become clearer, I try to write comments that reflect that better understanding. I sometimes succeed and those comments help readers and, especially, they help me when I come back to the code six weeks later. My style is to write plenty of comments anyway and, when I don't (because: a sudden insight gets me excited; I want to see it run; my brain is fried), I almost always greatly regret it later.\nIt would be great if I could maintain two parallel code streams: the na\u00efve way and the more sophisticated optimized way. But I have never succeeded in that.\nTo me, the bottom line is that if I can write clear, complete, succinct, accurate and up-to-date comments, that's about the best I can do. \nJust one more thing that you know already: optimization usually doesn't mean shoehorning a ton of code onto one source line, perhaps by calling a function whose argument is another function whose argument is another function whose argument is yet another function. I know that some do this to avoid storing a function's value temporarily. But it does very little (usually nothing) to speed up the code and it's a bitch to follow. No news to you, I know.","Q_Score":18,"Tags":"python,performance,algorithm,optimization,code-readability","A_Id":7301095,"CreationDate":"2011-09-04T17:25:00.000","Title":"Preserve code readability while optimising","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},{"Question":"Let's says I have a Djano app. Users can sign up, get a activation mail, activate their accounts and log in. After logging in, users can can create, update and delete objects rhough a custom Form which uses the Manager to handle the Model.\nWhat should I be testing here \u2014 should I use the request framework to make requests and test the whole chain via the Views and Forms or should I be writing unit tests to test the Manager and the Model?\nWhen testing the whole chain, I get to see that the URLs are configured properly, the Views work as expecvted, the Form cleans the data properly and it would also test the Models and Managers. It seems that the Django test framework is more geared toward unit-testing than this kind of test. (Is this something that should be tested with Twill and Selenium?)\nWhen writing unit tests, I would get to test the Manger and the Models but the URLs and the Forms don't really come into play, do they?! \nA really basic question but I'd like to get some of the fundamentals correct.\nThank you everyone.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":288,"Q_Id":7301681,"Users Score":2,"Answer":"Yes, Django unit tests, using the Client feature, are capable of testing whether or not your routes and forms are correct. \nIf you want full-blown behavior-driven testing from the outside, you can used a BDD framework like Zombie. \nAs for which tests you need, Django author Jacob Kaplan-Moss answered the question succinctly: \"All of them.\"\nMy general testing philosophy is to work until something stupid happens, then write a test to make sure that stupid thing never happens again.","Q_Score":4,"Tags":"python,django,unit-testing,testing,django-testing","A_Id":7301849,"CreationDate":"2011-09-04T19:41:00.000","Title":"What kind of tests should one write 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},{"Question":"I am using MonkeyRunner to automate some UI test cases.\nI need to collect logs from the device using tool like QXDM.\nI see that win32com python module can be used to launch QXDM and collecting logs.\nBut when i use from win32com.client import Dispatch in python script which is passed as argument to MonkeyRunner, MonkeyRunner throws:\n\n\"Import Error: No Module named win32com\".\n\nI have installed win32com on my machine, and when i use win32com in a python script which ran using \"python test.py\" its working fine.\nDo we need to install win32com python module on Android device also? or what need to be done to make this work?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":2667,"Q_Id":7311676,"Users Score":1,"Answer":"Monkeyrunner use Jython as its Python interface (jython.jar under tools\\lib folder).\nIt uses 2.5.0 version. Now the latest Jython version is 2.5.2. \nEither one does not support pywin32 or any other modules. It only supports standard Python modules in version 2.5.","Q_Score":4,"Tags":"python,monkeyrunner","A_Id":8291126,"CreationDate":"2011-09-05T18:40:00.000","Title":"MonkeyRunner::How to install python modules?","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},{"Question":"I don't know why, but I cant find it anywhere. All i need is the command to disable javascript in python's mechanize.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":663,"Q_Id":7327182,"Users Score":0,"Answer":"Mechanize doesn't deal with Javascript. It only take care of HTML. So you can't stop Javascript running using Mechanize. You need to find some other solution.","Q_Score":5,"Tags":"javascript,python,html,mechanize","A_Id":9391655,"CreationDate":"2011-09-06T23:07:00.000","Title":"How do you disable javascript in 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":1},{"Question":"I am writing a python interface to a c++ library and am wondering about the correct design of the library.\nI have found out (the hard way) that all methods passed to python must be declared static. If I understand correctly, this means that all functions basically must be defined in the same .cpp file. My interface has many functions, so this gets ugly very quickly.\nWhat is the standard way to deal with this problem? Possibilities I could think of:\n\ndon't worry about it and use one looong .cpp file\ncompile into more than one library (.so file)\nwrite a .cpp for each group of functions and #include that .cpp into the body of the main defining cpp file (the one with the PyMethodDef)\n\nboth of them seem very ugly","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":61,"Q_Id":7330279,"Users Score":0,"Answer":"Why do you say that all functions called by Python have to be\nstatic? It's usual for that to be the case, in order to avoid\nname conflicts (since any namespace, etc. will be ignored\nbecause of the extern \"C\"), but whether the function is static\nor not is of no consequence. \nWhen interfacing a library in C++, in my experience, it's\ngenerally not a big problem to make it static, and to put all of\nthe functions in a single translation unit, because the\nfunctions will be just small wrappers which call the actual C++,\nand normally, will be automatically generated from some sort of\ndescripter file; you surely aren't going to write all of the\nnecessary boilerplate by hand.","Q_Score":0,"Tags":"c++,python,interface","A_Id":7330536,"CreationDate":"2011-09-07T07:30:00.000","Title":"What is the pythonic structure of the code of a python-c++ interface with many functions?","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},{"Question":"Many people say developing in Python, Ruby, PHP ...etc is much faster than Java. \nQuestion is, why? In terms of coding, IDEs, available libraries... etc. Or is the speed in making the first prototype only?\nI'm interested in answers from people who worked long time on Java and long time on other languages.\nNote: I have developed for .Net before Java and yes it was faster to make some apps, but on the long run (large web projects) it will become like Java.","AnswerCount":4,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":970,"Q_Id":7332758,"Users Score":0,"Answer":"For rapid prototyping the more dynamic the language the better. Something like excel is a good for rapid prototyping. You can have a formula and a graph with a dozen clicks.\nHowever in the long run you may need to migrate your system to something more enterprise friendly. This doesn't always mean you should start this way.\nEven if you start in Java you may find you want to migrate some of your code to C for performance reasons.","Q_Score":0,"Tags":"java,php,.net,python,ruby","A_Id":7332862,"CreationDate":"2011-09-07T11:01:00.000","Title":"What makes other languages faster than Java in terms of Rapid 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":1},{"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},{"Question":"In search of a Python debugger I stumbled upon Aptana, which is based on eclipse.\nOften, I want to debug a single python script. However, Aptana won't let me run\/debug the currently opened file directly.\nInstead, it requires me to create a debug\/run configuration for each file I would like to run\/debug. Alternatively I could create a Python project in Aptana.\nBut: I don't want to. I just want to be able to run or debug the currently opened file. This way I would like to debug my scripts without being forced to create a project first (for each single script!).\nCan it be that hard?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":2990,"Q_Id":7335185,"Users Score":4,"Answer":"This is because Aptana\/Eclipse doesn't \"realize\" that the file you opened should be debugged using the Python debugger as it's not associated with a Python project\/perspective (there's a lot of environment setup when a project is created in Aptana\/Eclipse). \nThe simplest solution, IMO, would be to create a simple sandbox Python project and just stick your files in there to run\/debug. Aptana should then realize you're dealing with Python and start running the Python debugger without setup (that's my experience w\/ PyDev in Eclipse, at any rate).","Q_Score":3,"Tags":"python,eclipse,debugging,aptana","A_Id":7522349,"CreationDate":"2011-09-07T14:02:00.000","Title":"eclipse: Run\/Debug current 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},{"Question":"I want to know the best\/different ways to test a REST API which uses a database backend. I've developed my API with Flask in Python and want to use unittest or nose.\nBut my problem, is that some resources require another resource to create them in the first place. Is there a way to say that to test the creation of a blog post requires that another test involving the creation of the author was successful?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":7898,"Q_Id":7336101,"Users Score":8,"Answer":"There are 2 standard ways of approaching a test that depends on something else (object, function call, etc).\n\nYou can use mocks in place of the objects the code you are testing depends on.\nYou can load a fixture or do the creation\/call in the test setup.\n\nSome people like \"classical\" unit tests where only the \"unit\" of code is tested. In these cases you typically use mocks and stubs to replace the dependencies.\nOther like more integrative tests where most or all of the call stack is tested. In these cases you use a fixture, or possibly even do calls\/creations in a setup function.\nGenerally you would not make one test depend on another. All tests should:\n\nclean up after themselves\nbe runnable in isolation\nbe runnable as part of a suite\nbe consistent and repeatable\n\nIf you make one test dependent on another they cannot be run in isolation and you are also forcing an order to the tests run. Enforcing order in tests isn't good, in fact many people feel you should randomize the order in which your tests are run.","Q_Score":11,"Tags":"python,unit-testing,testing,rest,flask","A_Id":7355552,"CreationDate":"2011-09-07T15:03:00.000","Title":"Testing REST API with database backend","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I'm attempting to automate scp commands with pexpect on Ubuntu. However, I keep getting a password GUI prompt with title \"OpenSSH\". How can I disable this behavior and use command line prompts instead?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":905,"Q_Id":7352021,"Users Score":1,"Answer":"See the DISPLAY and SSH_ASKPASS section of man ssh-add.","Q_Score":1,"Tags":"python,pexpect","A_Id":7353518,"CreationDate":"2011-09-08T17:19:00.000","Title":"Python: how to launch scp with pexpect without OpenSSH GUI Password Prompt 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":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have many projects that I'm programatically running:\nnosetest --with-coverage --cover-html-dir=happy-sauce\/\nThe problem is that for each project, the coverage module overwrites the index.html file, instead of appending to it. Is there a way to generate a combined super-index.html file, that contains the results for all my projects?\nThanks.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":3218,"Q_Id":7352319,"Users Score":1,"Answer":"nosetests --with-coverage -i project1\/*.py -i project2\/*.py","Q_Score":11,"Tags":"python,unit-testing,nose","A_Id":24001681,"CreationDate":"2011-09-08T17:45:00.000","Title":"Nosetests & Combined Coverage","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I am running Aptana Studio 3, build: 3.0.4.201108101506.\nWhen I run \"Check for updates\" I get the following error\n\"A Problem occurred\" \n No repository found at file:\/C:\/Users\/Keith\/AppData\/Local\/Aptana%20Studio%203\/plugins\/com.python.pydev_2.2.1.2011073123\/.\nAny help would be appreciated","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":93,"Q_Id":7368288,"Users Score":0,"Answer":"Looks like that filepath is set up as an update site in your preferences. I'd just remove it, since it looks invalid (maybe you installed a pydev zip from here?). Go to Preferences > Install\/Update > Available Software Sites and then remove the entry for it.","Q_Score":0,"Tags":"python,aptana","A_Id":7419393,"CreationDate":"2011-09-09T22:56:00.000","Title":"error when running \"Check for updates\"","Data Science and Machine Learning":0,"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},{"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},{"Question":"I am building a Music file organizer(in python2) in which I read the metadata of all files & then put those file in the required folder.\nNow, I am already ready with the command line interface but this script shows feedback in a way that it shows \"Which file is it working on right now?\".\nIf the directory contains say 5000 mp3 files, there should be some kind of feedback.\n\nSo, I would like to know the most efficient way to find the total\n number of mp3s available in a directory (scanning recursively in all\n subsequent directories too). \n\nMy idea is to keep track of the total files processed and show a progress bar according to that. Is there a better way (performance wise), please feel free to guide. \nI want my app to not have any kind of platform dependent code. If there is serious performance penalty sticking to this idea, please suggest for linux.","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":362,"Q_Id":7371878,"Users Score":1,"Answer":"@shadyabhi: if you have many subdirectories maybe you can speedup the process by using os.listdir and multiprocessing.Process to recurse into each folder.","Q_Score":3,"Tags":"python,linux,algorithm,archlinux","A_Id":7372533,"CreationDate":"2011-09-10T13:05:00.000","Title":"Effective way to find total number of files in a 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},{"Question":"I am building a Music file organizer(in python2) in which I read the metadata of all files & then put those file in the required folder.\nNow, I am already ready with the command line interface but this script shows feedback in a way that it shows \"Which file is it working on right now?\".\nIf the directory contains say 5000 mp3 files, there should be some kind of feedback.\n\nSo, I would like to know the most efficient way to find the total\n number of mp3s available in a directory (scanning recursively in all\n subsequent directories too). \n\nMy idea is to keep track of the total files processed and show a progress bar according to that. Is there a better way (performance wise), please feel free to guide. \nI want my app to not have any kind of platform dependent code. If there is serious performance penalty sticking to this idea, please suggest for linux.","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":362,"Q_Id":7371878,"Users Score":2,"Answer":"I'm sorry to say this but no there isn't any way to do it more efficiently than recursively finding the files (at least that is platform (or filesystem) independent).\nIf the filesystem can help you it will, and you can't do anything to help it.\nThe reason it's not possible to do it without recursive scanning is how the filesystem is designed.\nA directory can be seen as a file, and it contains a list of all files it contains. To find something in a subdirectory you have to first open the directory, then open the subdirectory and search that.","Q_Score":3,"Tags":"python,linux,algorithm,archlinux","A_Id":7371922,"CreationDate":"2011-09-10T13:05:00.000","Title":"Effective way to find total number of files in a 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},{"Question":"I'm currently working on a social web application using python\/django. Recently I heard about the PHP's weakness on large scale projects, and how hippo-php helped Facebook to overcome this barrier. Considering a python social web application with lot of utilization, could you please tell me if a similar custom tool could help this python application? In what way? I mean which portion (or layer) of application need to be written for example in c++? I know that it's a general question but someone with relevant experience I think that could help me.\nThank you in advance.","AnswerCount":3,"Available Count":3,"Score":0.0665680765,"is_accepted":false,"ViewCount":1518,"Q_Id":7373299,"Users Score":1,"Answer":"You can think about PostgreSQL as Oracle, so from what I've found on the internet (because I am also a beginner) here is the order of DBs from smaller projects, to biggest:\n\nSQLite\nMySql\nPostgreSQL\nOracle","Q_Score":0,"Tags":"php,python,django,performance","A_Id":7374796,"CreationDate":"2011-09-10T17:18:00.000","Title":"Python\/Django - Web Application 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},{"Question":"I'm currently working on a social web application using python\/django. Recently I heard about the PHP's weakness on large scale projects, and how hippo-php helped Facebook to overcome this barrier. Considering a python social web application with lot of utilization, could you please tell me if a similar custom tool could help this python application? In what way? I mean which portion (or layer) of application need to be written for example in c++? I know that it's a general question but someone with relevant experience I think that could help me.\nThank you in advance.","AnswerCount":3,"Available Count":3,"Score":0.0665680765,"is_accepted":false,"ViewCount":1518,"Q_Id":7373299,"Users Score":1,"Answer":"Don't try to scale too early! Of course you can try to be prepared but most times you can not really know where you need to scale and therefore spend a lot of time and money in wrong direction before you recognize it.\nStart your webapp and see how it goes (agreeing with Spacedman here).\nThough from my experience the language of your web app is less likely going to be the bottleneck. Most of the time it starts with the database. Many times it simply a wrong line of code (be it just a for loop) and many other times its something like forgetting to use sth. like memcached or task management. As said, find out where it is. In most cases its better to check something else before blaming the language speed for it (since its most likely not the problem!).","Q_Score":0,"Tags":"php,python,django,performance","A_Id":7376098,"CreationDate":"2011-09-10T17:18:00.000","Title":"Python\/Django - Web Application 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},{"Question":"I'm currently working on a social web application using python\/django. Recently I heard about the PHP's weakness on large scale projects, and how hippo-php helped Facebook to overcome this barrier. Considering a python social web application with lot of utilization, could you please tell me if a similar custom tool could help this python application? In what way? I mean which portion (or layer) of application need to be written for example in c++? I know that it's a general question but someone with relevant experience I think that could help me.\nThank you in advance.","AnswerCount":3,"Available Count":3,"Score":1.2,"is_accepted":true,"ViewCount":1518,"Q_Id":7373299,"Users Score":3,"Answer":"The portion to rewrite in C++ is the portion that is too slow in Python. You need to figure out where your bottleneck is, which you can do by load testing or just waiting until users complain.\nOf course, even rewriting in C++ might not help. Your bottleneck might be the database (move to a separate, faster DB server or use sharding) or disk, or memory, or anything. Find bottleneck, work out how to eliminate bottleneck, implement. With 'test' inbetween all those phases. General advice.\nThere's normally no magic bullet, and I imagine Facebook did a LOT of testing and analysis of their bottlenecks before they tried anything.","Q_Score":0,"Tags":"php,python,django,performance","A_Id":7373467,"CreationDate":"2011-09-10T17:18:00.000","Title":"Python\/Django - Web Application 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},{"Question":"First Note: Sorry this is long. Wanted to be thorough.\nI really hate to ask a question when there's so much out there online but its been a week of searching and I have nothing to show for it. I'd really appreciate some help. I am a noob but I learn very fast and am more than willing to try alternate languages or whatever else it might take.\nThe goal:\nWhat I'm trying to do is build a Netflix remote (personal use only) that controls Netflix on the server (Windows 7 PC 32-bit) via keyboard shortcuts (example: spacebar to pause) after a button is pressed in a php page on my ipod touch or android phone. Currently the remote uses USBUIRT to control the TV and IR devices without issue. If you have any alternate methods (that I can build, not buy) to suggest or other languages I could learn that can achieve this, I'm happy to learn.\nThe issue:\nPHP's exec() and system() commands will not launch the python script (nor an exe compiled with py2exe) that simply presses the Windows key (intended to press the key on the server, not the machine loading the php page). I can use USBUIRT's UUTX.exe passing arguments with exec() to control IR devices without issue. But my exe, py, nor pyw files work. I've even tried calling a batch file that then launches the python script and that batch will not launch. The page refreshes and no errors are displayed. \nAttempted:\nHere's a code that works \n$exec = exec(\"c:\\\\USBUIRT\\\\UUTX.exe -r3 -fC:\\\\USBUIRT\\\\Pronto.txt LED_Off\", $results);\nHere's a few attempts that don't work\n$exec = exec(\"c:\\\\USBUIRT\\\\test.py\", $results);\n$exec = exec(\"python c:\\\\USBUIRT\\\\test.py\", $results);\n$exec = exec(\"C:\\\\python25\\\\python.exe c:\\\\USBUIRT\\\\test.py\", $results);\nAll of those I've tried without the dual backslashes and with forward slashes and dual forward slashes. I've left off passing it to variable $exec and that makes no difference. $result outputs\nArraystring(9) \"\nCopying everything in the exec() into command line works correctly. I've tried moving the file to the htdocs folder, changed folder permissions, and made sure I'm not in safemode in php. Var_dump returns: Array\" Using a foreach loop gives no info from the array. \nMy logs for Apache show only \n[Sat Sep 10 19:54:09 2011] [error] [client 127.0.0.1] File does not exist: C:\/Program Files\/Apache Software Foundation\/Apache2.2\/htdocs\/announce\nSetup: Apache 2.2, python 2.5, and php 5.3. Running this on Windows 7 and only connect on the local network, no vpn or the like. Given every associated folder (python, htdocs, the cmd.exe file, usbuirt folder) IUSR, admins, users, and everyone with full control just for initial testing (later I'll of course tighten security up). Safe mode is off on php as well. \nNotes: This code I saw on another similar issue doesn't work:\nexec(\"ping google.com -n 1\");\nNo errors in error.log nor event viewer. Putting it inside ob_start(); and getting the results with ob_get_clean(); gives me absolutely nothing. No text or anything at all. I've tried a lot more but I've already written a novel on here so I'll just have to answer the rest as we go. I'll post the full php source or the python script if that is needed but all it does is import sendkeys and press the windows key to pop open the start menu as a basic visual test. I don't know if its permissions, the way I have my setup running, my coding... I just don't know anymore. And again I apologize this is so long and if you do answer, I really appreciate you taking the time to read all this to help out a total stranger.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1377,"Q_Id":7375924,"Users Score":0,"Answer":"Figured it out thanks to the excellent help from Winston Ewert and Gringo Suave. \nI set Apache's service to the Local System Account and gave it access to interact with the desktop. This should help if you have Windows XP or Server 2003, but Vista and newer there's an Interactive Services Detection that pops up when you try to launch GUI applications from php. Every command was executing correctly, but were doing so in Session 0. This is because Apache was installed as a service. For most people I would think that reinstalling without setting up Apache as a service would work, but I was considering moving to XAMPP anyway, so having to uninstall Apache helped push my decision. \nUltimately all of the codes I wrote in my original post now work as a result, and my project can move forward. I hope someone else stumbles across this and gets as much help from Winston Ewert and Gringo Suave as I did! Thank you both very much!","Q_Score":2,"Tags":"php,python,windows,apache,exec","A_Id":7380933,"CreationDate":"2011-09-11T02:20:00.000","Title":"PHP exec() command wont launch python script using sendkeys","Data Science and Machine Learning":0,"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},{"Question":"I'm making a simple text adventure with Python and thought that background MIDI music would make it a little less boring.\nIs there a simple, light-weight, MIDI player \/ API for Python? Or do I need to use a full game library like Pygame? (Because if so, I'd rather pass, as I want to make it as lightweight as possible.)","AnswerCount":4,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":392,"Q_Id":7377983,"Users Score":2,"Answer":"As @Jakob Bowyer noted, pygame is really the way to go. I just wanted to add that if you are concerned about pygame because of its size, then you can selectively enable which modules you want at runtime. In this case, just using the MIDI playback features of pygame won't consume too much system resources.","Q_Score":3,"Tags":"python,console,midi,adventure","A_Id":7538486,"CreationDate":"2011-09-11T11:48:00.000","Title":"Light-weight MIDI playback for a Text Adventure?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I'm making a simple text adventure with Python and thought that background MIDI music would make it a little less boring.\nIs there a simple, light-weight, MIDI player \/ API for Python? Or do I need to use a full game library like Pygame? (Because if so, I'd rather pass, as I want to make it as lightweight as possible.)","AnswerCount":4,"Available Count":2,"Score":0.1973753202,"is_accepted":false,"ViewCount":392,"Q_Id":7377983,"Users Score":4,"Answer":"Yes, you will be wanting pygame for this. It's a nice idea to keep something light, but on the other hand, why re-invent the wheel? If someone has already written the code for you to play .midi files, then use their code! The only other option I can think of is searching for a MIDI playing library for Python (I can't find any right now) and then spawning that inside a subprocess and feeding it commands and jazz.","Q_Score":3,"Tags":"python,console,midi,adventure","A_Id":7378115,"CreationDate":"2011-09-11T11:48:00.000","Title":"Light-weight MIDI playback for a Text Adventure?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"Using Python and PyAudio, I can't seem to record sound to a wav file from an external audio interface (RME Fireface), but i am able to do so with the in built mic on my iMac. I set the default device to Fireface in System preferences, and when i run the code, the wav file is created but no sound comes out when i play it. The code is as given on the PyAudio webpage. Is there any way to rectify this?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":629,"Q_Id":7379439,"Users Score":1,"Answer":"A couple shots in the dark - Verify if you're opening the device correctly - looks like the Fireface can be both half or full duplex (pref pane configurable?), and pyaudio apparently cares (i.e. you can't specify an output if you specify an input or vise versa.)\nAnother thing to check out is the audio routing - under \/Applications\/Utilities\/Audio Midi Setup.app, depending on how you have the signals coming in you might be connecting to the wrong one and not realizing it.","Q_Score":3,"Tags":"macos,audio,python","A_Id":8441627,"CreationDate":"2011-09-06T09:50:00.000","Title":"Pyaudio for external interfaces (Mac OSX)","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"What problems can I have if I will use python 2.7 instead python 2.6 for my pylons\/pyramid projects? Before I use python 2.6 on my ubuntu 10.04 but now I have ubuntu 11.04 on my laptop with python 2.7.","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":3369,"Q_Id":7384150,"Users Score":0,"Answer":"Take a look at http:\/\/docs.python.org\/dev\/whatsnew\/2.7.html\nYou'll find what all you'll ever need to know.","Q_Score":2,"Tags":"python,pylons,pyramid","A_Id":7384274,"CreationDate":"2011-09-12T06:41:00.000","Title":"python 2.6 vs 2.7, for pylons\/pyramid 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},{"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},{"Question":"There is a library for Python that enables the calling ability (can call functions in C++ format without extern \"C\". Please, could you remind me the name of the library? I forgot it's name and can't find it.\nIt's not Boost.Python.\nThank you very much. Your answer will be rewarded.","AnswerCount":4,"Available Count":1,"Score":0.049958375,"is_accepted":false,"ViewCount":496,"Q_Id":7393672,"Users Score":1,"Answer":"SWIG, Boost.Python, SIP, Shiboken, PyBindgen, ...\nSWIG and Boost.Python are most popular, i.e. they have the largest user base and the most active development teams. Which of these two to use is largely a matter of taste. So if you don't want to use Boost.Python, then SWIG is the obvious choice.","Q_Score":1,"Tags":"c++,python,dll,shared-libraries","A_Id":7400723,"CreationDate":"2011-09-12T20:34:00.000","Title":"Library for Python: How to call C++ functions from 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":0,"System Administration and DevOps":0,"Web Development":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},{"Question":"I am creating rpm's for my project which is in pure python. I am running the command\n\npython setup.py bdist_rpm\n\nto build the rpm. This is creating architechture specific rpm's (x86 or x86-64). What I would like is to have a no-arch rpm. Can any of python guru's help me with creating a no-arch rpm. Any help would be appriciated. Thanks in advance.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":116,"Q_Id":7400099,"Users Score":1,"Answer":"If your software does not contain extension modules (modules written in C\/C++), distutils will make the RPM noarch. I don\u2019t think there\u2019s a way to explicitly control it.","Q_Score":0,"Tags":"python,rpm,distutils","A_Id":7531272,"CreationDate":"2011-09-13T10:08:00.000","Title":"Python command to create no-arch rpm's","Data Science and Machine Learning":0,"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},{"Question":"I am using buildbot (system for CI) and have one problem. How can I send parameters of Change to all builders? I want to use the properties comments and who of Changes object.\nThx","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":587,"Q_Id":7417518,"Users Score":0,"Answer":"I'm find answer: inheritance from BuildStep and use \nself.build.allChanges() and for set property: self.setProperty()","Q_Score":1,"Tags":"python,continuous-integration,buildbot","A_Id":7442406,"CreationDate":"2011-09-14T13:56:00.000","Title":"Buildbot properties from changes to all build","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},{"Question":"I want to generate a list of the hex values of all 256 byte-combinations.\nBasically, I want for example 'A' => '\\x41'. I've only found modules capable of converting 'A' => '41', and this is not what I want.\nHow am I to solve this problem? Does anybody know an appropriate module or algorithm (as I'd like to avoid hardcoding 256 hexvalues...)?","AnswerCount":5,"Available Count":1,"Score":0.0399786803,"is_accepted":false,"ViewCount":6934,"Q_Id":7422099,"Users Score":1,"Answer":"ord('A') returns the ASCII value as an integer (65 in the case of 'A'). You can think of an integer in any base you want. hex(ord('A')) gives you a nice string (\"0x41\" in this case), as does print \"%x\" % ord('A').","Q_Score":0,"Tags":"python,hex,byte,ascii","A_Id":7422175,"CreationDate":"2011-09-14T19:45:00.000","Title":"Generate a list of hex bytes 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},{"Question":"I just wrote a function on Python. Then, I wanted to make it module and install on my Ubuntu 11.04. Here is what I did.\n\nCreated setup.py along with function.py file.\nBuilt distribution file using $Python2.7 setup.py sdist\nThen installed it $Python2.7 setup.py install\n\nAll was going fine. But, later I wanted to use the module importing it on my code.\nI got import error: ImportError: No module named '-------'\nPS. I searched over google and didn't find particular answer. Detailed answer will be much appreciated.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":44972,"Q_Id":7426677,"Users Score":24,"Answer":"Most installation requires:\nsudo python setup.py install\nOtherwise, you won't be able to write to the installation directories.\nI'm pretty sure that (unless you were root), you got an error when you did\npython2.7 setup.py install","Q_Score":14,"Tags":"python,python-module","A_Id":7429157,"CreationDate":"2011-09-15T06:23:00.000","Title":"How to install Python module 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},{"Question":"I'm developing a content type for Plone 4, and I'd like to block all user, group, and context portlets it may inherit from its parent object. I'm thoroughly confused by the documentation at this point\u2013in portlets.xml, only seems to address path-specific blocking. seems like what I want, but it seems too specific\u2013I don't want to manage the assignment for all possible portlets on my content type.\nThere are hints that I've found that customizing an ILeftColumn and IRightColumn portlet manager specific to the content type, but I can't find any good examples. Does anyone have any hints or suggestions? I feel like I'm missing something dead simple.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":911,"Q_Id":7432317,"Users Score":1,"Answer":"Do the assignment to your portaltype live on a site via Sitesetup (controlpanel) -> Types -> \"Manage portlets assigned to this content type\". \nThen export the configuration via ZMI -> portal_setup -> Export-Tab -> select 'Portlets' -> click 'export' on bottom. \nExtract the types\/YourType.xml-file and copy the relevant parts in your package's profiles\/default\/types\/YourType.xml.","Q_Score":5,"Tags":"python,plone,portlet","A_Id":7435407,"CreationDate":"2011-09-15T14:15:00.000","Title":"Plone Content Type-Specific Portlet Assignment","Data Science and Machine Learning":0,"Database and SQL":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},{"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},{"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},{"Question":"I have some .txt files which included Turkish characters. I prepared a HTML code and wanna include texts which are in my txt files. The processes are successful but the html files which are made by python have character problems(special characters seems like this: \ufffd)\nI have tried add u before strings in python code but it did not work.\ntxt files are made by python. actually they are my blog entries I got them using urrlib. Moreover, they have not character problems\nthank you for your answers.","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":171,"Q_Id":7455371,"Users Score":1,"Answer":"When you serve the content to a web browser, you need to tell it what encoding the file is in. Ideally, you should send a Content-type: HTTP header in the response with something like text\/plain; charset=utf-8, where \"utf-8\" is replaced by whatever encoding you're actually using if it's not utf-8.\nYour browser may also need to be set to use a unicode-aware font for displaying text files; if it uses a font that doesn't have the necessary glyphs, obviously it can't display them.","Q_Score":0,"Tags":"python,encoding,character","A_Id":7455417,"CreationDate":"2011-09-17T14:12:00.000","Title":"Special characters in output are like \ufffd","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I'm trying to calculate the percentage of CPU% used for a particular process using Python\/Shell, but so far nothing.\nI have looked at a lot of questions here, but none could help me. \nAny suggestions?","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":541,"Q_Id":7470045,"Users Score":0,"Answer":"well, you can try to use the top command with \"-b -n 1\" and grab it's contents and than you can use cut or other tools to get what you need\nNOTE: you can add the -p option to limit to a particular process id","Q_Score":1,"Tags":"python,shell,unix,cpu","A_Id":7470125,"CreationDate":"2011-09-19T11:13:00.000","Title":"CPU Utilization on 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},{"Question":"I am trying to run a python script from the Linux SSH Secure Shell command line environment, and I am trying to import the argparse library, but it gives the error: \"ImportError: No module named argparse\".\nI think that this is because the Python environment that the Linux shell is using does not have the argparse library in it, and I think I can fix it fix it if I can find the directories for the libraries being used by the Python environment, and copy the argparse library into it, but I can not find where that directory is located.\nI would appreciate any help on finding this directory (I suppose I could include the argparse library in the same directory as my python script for now, but I would much rather have the argparse library in the place where the other Python libraries are, as it should be).","AnswerCount":5,"Available Count":2,"Score":0.0798297691,"is_accepted":false,"ViewCount":15510,"Q_Id":7473609,"Users Score":2,"Answer":"If you're on CentOS and don't have an easy RPM to get to Python 2.7, JF's suggestion of pip install argparse is the way to go. Calling out this solution in a new answer. Thanks, JF.","Q_Score":12,"Tags":"python,linux,command-line,argparse","A_Id":10015728,"CreationDate":"2011-09-19T15:45:00.000","Title":"argparse Python modules in cli","Data Science and Machine Learning":0,"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},{"Question":"I am trying to run a python script from the Linux SSH Secure Shell command line environment, and I am trying to import the argparse library, but it gives the error: \"ImportError: No module named argparse\".\nI think that this is because the Python environment that the Linux shell is using does not have the argparse library in it, and I think I can fix it fix it if I can find the directories for the libraries being used by the Python environment, and copy the argparse library into it, but I can not find where that directory is located.\nI would appreciate any help on finding this directory (I suppose I could include the argparse library in the same directory as my python script for now, but I would much rather have the argparse library in the place where the other Python libraries are, as it should be).","AnswerCount":5,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":15510,"Q_Id":7473609,"Users Score":0,"Answer":"You're probably using an older version of Python.\nThe argparse module has been added pretty recently, in Python 2.7.","Q_Score":12,"Tags":"python,linux,command-line,argparse","A_Id":7474038,"CreationDate":"2011-09-19T15:45:00.000","Title":"argparse Python modules in cli","Data Science and Machine Learning":0,"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},{"Question":"Is anyone aware of any issues with Django's caching framework when deployed to Apache\/Mod_WSGI?\nWhen testing with the caching framework locally with the dev server, using the profiling middleware and either the FileBasedCache or LocMemCache, Django's very fast. My request time goes from ~0.125 sec to ~0.001 sec. Fantastic.\nI deploy the identical code to a remote machine running Apache\/Mod_WSGI and my request time goes from ~0.155 sec (before I deployed the change) to ~.400 sec (post deployment). That's right, caching slowed everything down.\nI've spent hours digging through everything, looking for something I'm missing. I've tried using FileBasedCache with a location on tmpfs, but that also failed to improve performance.\nI've monitored the remote machine with top, and it shows no other processes and it has 6GB available memory, so basically Django should have full rein. I love Django, but it's incredibly slow, and so far I've never been able to get the caching framework to make any noticeable impact in a production environment. Is there anything I'm missing?\nEDIT: I've also tried memcached, with the same result. I confirmed memcached was running by telneting into it.","AnswerCount":3,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":707,"Q_Id":7477211,"Users Score":0,"Answer":"I had a similar problem with an app using memcached. The solution was running mod_wsgi in daemon mode instead of embeded mode, and Apache in mpm_worker mode. After that, application is working much faster.","Q_Score":1,"Tags":"python,django,performance","A_Id":7482454,"CreationDate":"2011-09-19T20:57:00.000","Title":"Using Django Caching with 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},{"Question":"Is anyone aware of any issues with Django's caching framework when deployed to Apache\/Mod_WSGI?\nWhen testing with the caching framework locally with the dev server, using the profiling middleware and either the FileBasedCache or LocMemCache, Django's very fast. My request time goes from ~0.125 sec to ~0.001 sec. Fantastic.\nI deploy the identical code to a remote machine running Apache\/Mod_WSGI and my request time goes from ~0.155 sec (before I deployed the change) to ~.400 sec (post deployment). That's right, caching slowed everything down.\nI've spent hours digging through everything, looking for something I'm missing. I've tried using FileBasedCache with a location on tmpfs, but that also failed to improve performance.\nI've monitored the remote machine with top, and it shows no other processes and it has 6GB available memory, so basically Django should have full rein. I love Django, but it's incredibly slow, and so far I've never been able to get the caching framework to make any noticeable impact in a production environment. Is there anything I'm missing?\nEDIT: I've also tried memcached, with the same result. I confirmed memcached was running by telneting into it.","AnswerCount":3,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":707,"Q_Id":7477211,"Users Score":0,"Answer":"Same thing happened to me and was wondering what is that is taking so much time. \neach cache get was taking around 100 millisecond.\nSo I debugged the code django locmem code and found out that pickle was taking a lot of time (I was caching a whole table in locmemcache).\nI wrapped the locmem as I didn't wanted anything advanced, so even if you remove the pickle and unpickle and put it. You will see a major improvement.\nHope it helps someone.","Q_Score":1,"Tags":"python,django,performance","A_Id":18531552,"CreationDate":"2011-09-19T20:57:00.000","Title":"Using Django Caching with 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},{"Question":"Is anyone aware of any issues with Django's caching framework when deployed to Apache\/Mod_WSGI?\nWhen testing with the caching framework locally with the dev server, using the profiling middleware and either the FileBasedCache or LocMemCache, Django's very fast. My request time goes from ~0.125 sec to ~0.001 sec. Fantastic.\nI deploy the identical code to a remote machine running Apache\/Mod_WSGI and my request time goes from ~0.155 sec (before I deployed the change) to ~.400 sec (post deployment). That's right, caching slowed everything down.\nI've spent hours digging through everything, looking for something I'm missing. I've tried using FileBasedCache with a location on tmpfs, but that also failed to improve performance.\nI've monitored the remote machine with top, and it shows no other processes and it has 6GB available memory, so basically Django should have full rein. I love Django, but it's incredibly slow, and so far I've never been able to get the caching framework to make any noticeable impact in a production environment. Is there anything I'm missing?\nEDIT: I've also tried memcached, with the same result. I confirmed memcached was running by telneting into it.","AnswerCount":3,"Available Count":3,"Score":1.2,"is_accepted":true,"ViewCount":707,"Q_Id":7477211,"Users Score":0,"Answer":"Indeed django is slow. But I must say most of the slowness goes from app itself.. django just forces you (bu providing bad examples in docs) to do lazy thing that are slow in production.\nFirst of: try nginx + uwsgi. it is just the best.\nTo optimize you app: you need to find you what is causing slowness, it can be:\n\nslow database queries (a lot of queries or just slow queries)\nslow database itself\nslow filesystem (nfs for example)\n\nTry logging request queries and watch iostat or iotop or something like that.\nI had this scenario with apache+mod_wsgi: first request from browser was very slow... then a few request from same browser were fast.. then if sat doing nothing for 2 minutes - wgain very slow. I don`t know if that was improperly configured apache if it was shutting down wsgi app and starting for each keepalive request. It just posted me off - I installed nging and with nginx+fgxi all was a lot faster than apache+mod_wsgi.","Q_Score":1,"Tags":"python,django,performance","A_Id":7477678,"CreationDate":"2011-09-19T20:57:00.000","Title":"Using Django Caching with 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},{"Question":"I'm working on running a Memory\/CPU intensive project on a cloud service, from my Googling and research it looks like I should use Amazon EC2 as there are guides it using MPI - however, reading up on stackoverflow about people's comparison of EC2 with rackspace, joyent, etc, I was wondering if this is really the best cloud option I should go with or is there an alternative better route I should take? Any insight would be appreciated.\nThanks,","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":384,"Q_Id":7478803,"Users Score":1,"Answer":"Your requirements are too vague for a specific response. It is unlikely you are going to be able to elaborate them sufficiently for anybody to provide an authoritative answer.\nFortunately for you, many Infrastructure as a Service platforms like AWS and Rackspace let you test things out extremely inexpensively (literal pocket change), so give them a try and see what works for your application.","Q_Score":0,"Tags":"python,multithreading,amazon-ec2,cloud,parallel-processing","A_Id":7478918,"CreationDate":"2011-09-20T00:21:00.000","Title":"Python Parallel Processing Amazon EC2 or Alternatives?","Data Science and Machine Learning":0,"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},{"Question":"I use R for data analysis and am very happy with it. Cleaning data could be a bit easier, however. I am thinking about learning another language suited to this task. Specifically, I am looking for a tool to use to take raw data, remove unnecessary variables or observations, and format it for easy loading in R. Contents would be mostly numeric and string data, as opposed to multi-line text.\nI am considering the awk\/sed combination versus Python. (I recognize that Perl would be another option, but, if I was going to learn another full language, Python seems to be a better, more extensible choice.)\nThe advantage of sed\/awk is that it would be quicker to learn. The disadvantage is that this combination isn't as extensible as Python. Indeed, I might imagine some \"mission creep\" if I learned Python, which would be fine, but not my goal.\nThe other consideration that I had is applications to large data sets. As I understand it, awk\/sed operate line-by-line, while Python would typically pull all the data into memory. This could be another advantage for sed\/awk.\nAre there other issues that I'm missing? Any advice that you can offer would be appreciated. (I included the R tag for R users to offer their cleaning recommendations.)","AnswerCount":6,"Available Count":5,"Score":1.0,"is_accepted":false,"ViewCount":4795,"Q_Id":7479686,"Users Score":15,"Answer":"Not to spoil your adventure, but I'd say no and here is why:\n\nR is vectorised where sed\/awk are not\nR already has both Perl regular expression and extended regular expressions\nR can more easily make recourse to statistical routines (say, imputation) if you need it\nR can visualize, summarize, ...\n\nand most importantly: you already know R.\nThat said, of course sed\/awk are great for small programs or even one-liners and Python is a fine language. But I would consider to also stick with R.","Q_Score":26,"Tags":"python,r,awk,sed,data-cleaning","A_Id":7479812,"CreationDate":"2011-09-20T03:13:00.000","Title":"Python or awk\/sed for cleaning data","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I use R for data analysis and am very happy with it. Cleaning data could be a bit easier, however. I am thinking about learning another language suited to this task. Specifically, I am looking for a tool to use to take raw data, remove unnecessary variables or observations, and format it for easy loading in R. Contents would be mostly numeric and string data, as opposed to multi-line text.\nI am considering the awk\/sed combination versus Python. (I recognize that Perl would be another option, but, if I was going to learn another full language, Python seems to be a better, more extensible choice.)\nThe advantage of sed\/awk is that it would be quicker to learn. The disadvantage is that this combination isn't as extensible as Python. Indeed, I might imagine some \"mission creep\" if I learned Python, which would be fine, but not my goal.\nThe other consideration that I had is applications to large data sets. As I understand it, awk\/sed operate line-by-line, while Python would typically pull all the data into memory. This could be another advantage for sed\/awk.\nAre there other issues that I'm missing? Any advice that you can offer would be appreciated. (I included the R tag for R users to offer their cleaning recommendations.)","AnswerCount":6,"Available Count":5,"Score":1.0,"is_accepted":false,"ViewCount":4795,"Q_Id":7479686,"Users Score":6,"Answer":"I would recommend sed\/awk along with the wealth of other command line tools available on UNIX-alike platforms: comm, tr, sort, cut, join, grep, and built in shell capabilities like looping and whatnot. You really don't need to learn another programming language as R can handle data manipulation as well as if not better than the other popular scripting languages.","Q_Score":26,"Tags":"python,r,awk,sed,data-cleaning","A_Id":7488114,"CreationDate":"2011-09-20T03:13:00.000","Title":"Python or awk\/sed for cleaning data","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I use R for data analysis and am very happy with it. Cleaning data could be a bit easier, however. I am thinking about learning another language suited to this task. Specifically, I am looking for a tool to use to take raw data, remove unnecessary variables or observations, and format it for easy loading in R. Contents would be mostly numeric and string data, as opposed to multi-line text.\nI am considering the awk\/sed combination versus Python. (I recognize that Perl would be another option, but, if I was going to learn another full language, Python seems to be a better, more extensible choice.)\nThe advantage of sed\/awk is that it would be quicker to learn. The disadvantage is that this combination isn't as extensible as Python. Indeed, I might imagine some \"mission creep\" if I learned Python, which would be fine, but not my goal.\nThe other consideration that I had is applications to large data sets. As I understand it, awk\/sed operate line-by-line, while Python would typically pull all the data into memory. This could be another advantage for sed\/awk.\nAre there other issues that I'm missing? Any advice that you can offer would be appreciated. (I included the R tag for R users to offer their cleaning recommendations.)","AnswerCount":6,"Available Count":5,"Score":0.0333209931,"is_accepted":false,"ViewCount":4795,"Q_Id":7479686,"Users Score":1,"Answer":"I would recommend 'awk' for this type of processing.\nPresumably you are just searching\/rejecting invalid observations in simple text files.\nawk is lightning fast at this task and is very simple to program.\nIf you need to do anything more complex then you can.\nPython is also a possibility if you don't mind the performance hit. The \"rpy\" library can be used to closely integrate the python and R components.","Q_Score":26,"Tags":"python,r,awk,sed,data-cleaning","A_Id":7479937,"CreationDate":"2011-09-20T03:13:00.000","Title":"Python or awk\/sed for cleaning data","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I use R for data analysis and am very happy with it. Cleaning data could be a bit easier, however. I am thinking about learning another language suited to this task. Specifically, I am looking for a tool to use to take raw data, remove unnecessary variables or observations, and format it for easy loading in R. Contents would be mostly numeric and string data, as opposed to multi-line text.\nI am considering the awk\/sed combination versus Python. (I recognize that Perl would be another option, but, if I was going to learn another full language, Python seems to be a better, more extensible choice.)\nThe advantage of sed\/awk is that it would be quicker to learn. The disadvantage is that this combination isn't as extensible as Python. Indeed, I might imagine some \"mission creep\" if I learned Python, which would be fine, but not my goal.\nThe other consideration that I had is applications to large data sets. As I understand it, awk\/sed operate line-by-line, while Python would typically pull all the data into memory. This could be another advantage for sed\/awk.\nAre there other issues that I'm missing? Any advice that you can offer would be appreciated. (I included the R tag for R users to offer their cleaning recommendations.)","AnswerCount":6,"Available Count":5,"Score":0.0333209931,"is_accepted":false,"ViewCount":4795,"Q_Id":7479686,"Users Score":1,"Answer":"I agree with Dirk. I thought about the same thing and used other languages a bit, too. But in the end I was surprised again again what more experienced users do with R. Packages like ddply or plyrmight be very interesting to you. That being said SQL helped me with data juggling often","Q_Score":26,"Tags":"python,r,awk,sed,data-cleaning","A_Id":7484242,"CreationDate":"2011-09-20T03:13:00.000","Title":"Python or awk\/sed for cleaning data","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I use R for data analysis and am very happy with it. Cleaning data could be a bit easier, however. I am thinking about learning another language suited to this task. Specifically, I am looking for a tool to use to take raw data, remove unnecessary variables or observations, and format it for easy loading in R. Contents would be mostly numeric and string data, as opposed to multi-line text.\nI am considering the awk\/sed combination versus Python. (I recognize that Perl would be another option, but, if I was going to learn another full language, Python seems to be a better, more extensible choice.)\nThe advantage of sed\/awk is that it would be quicker to learn. The disadvantage is that this combination isn't as extensible as Python. Indeed, I might imagine some \"mission creep\" if I learned Python, which would be fine, but not my goal.\nThe other consideration that I had is applications to large data sets. As I understand it, awk\/sed operate line-by-line, while Python would typically pull all the data into memory. This could be another advantage for sed\/awk.\nAre there other issues that I'm missing? Any advice that you can offer would be appreciated. (I included the R tag for R users to offer their cleaning recommendations.)","AnswerCount":6,"Available Count":5,"Score":0.0996679946,"is_accepted":false,"ViewCount":4795,"Q_Id":7479686,"Users Score":3,"Answer":"I would recommend investing for the long term with a proper language for processing data files, like python or perl or ruby, vs the short term sed\/awk solution. I think that all data analysts need at least three languages; I use C for hefty computations, perl for processing data files, and R for interactive analysis and graphics.\nI learned perl before python had become popular. I've heard great things about ruby so you might want to try that instead.\nFor any of these you can work with files line-by-line; python doesn't need to read the full file in advance.","Q_Score":26,"Tags":"python,r,awk,sed,data-cleaning","A_Id":7479874,"CreationDate":"2011-09-20T03:13:00.000","Title":"Python or awk\/sed for cleaning data","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I've just started using Jenkins today, so it's entirely possible that I've missed something in the docs.\nI currently have Jenkins set up to run unit tests from a local Git repo (via plugin). I have set up the environment correctly (at least, in a seemingly working condition), but have run into a small snag.\nI have a single settings.py file that I have excluded from my git repo (it contains a few keys that I'm using in my app). I don't want to include that file into my git repo as I'm planning on OS'ing the project when I'm done (anyone using the project would need their own keys). I realize that this may not be the best way of doing this, but it's what's done (and it's a small personal project), so I'm not concerned about it. \nThe problem is that because it's not under git management, Jenkins doesn't pick it up. \nI'd like to be able to copy this single file from my source directory to the Jenkins build directory prior to running tests.\nIs there a way to do this? I've tried using the copy to slave plugin, but it seems like any file that I want would first (manually) need to be copied or created in workspace\/userContent. Am I missing something?","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":350,"Q_Id":7479757,"Users Score":0,"Answer":"I am using the Copy Data To Workspace Plugin for this, Copy to Slave plugin should also work, but I found Copy Data To Workspace Plugin to be easier to work with for this use-case.","Q_Score":1,"Tags":"python,git,build,jenkins","A_Id":7481245,"CreationDate":"2011-09-20T03:24:00.000","Title":"Using un-managed file in Jenkins build step","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I've just started using Jenkins today, so it's entirely possible that I've missed something in the docs.\nI currently have Jenkins set up to run unit tests from a local Git repo (via plugin). I have set up the environment correctly (at least, in a seemingly working condition), but have run into a small snag.\nI have a single settings.py file that I have excluded from my git repo (it contains a few keys that I'm using in my app). I don't want to include that file into my git repo as I'm planning on OS'ing the project when I'm done (anyone using the project would need their own keys). I realize that this may not be the best way of doing this, but it's what's done (and it's a small personal project), so I'm not concerned about it. \nThe problem is that because it's not under git management, Jenkins doesn't pick it up. \nI'd like to be able to copy this single file from my source directory to the Jenkins build directory prior to running tests.\nIs there a way to do this? I've tried using the copy to slave plugin, but it seems like any file that I want would first (manually) need to be copied or created in workspace\/userContent. Am I missing something?","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":350,"Q_Id":7479757,"Users Score":0,"Answer":"Why just not use \"echo my-secret-keys > settings.txt\" in jenkins and adjust your script to read this file so you can add it to report?","Q_Score":1,"Tags":"python,git,build,jenkins","A_Id":7489440,"CreationDate":"2011-09-20T03:24:00.000","Title":"Using un-managed file in Jenkins build step","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I have a WordPress self hosted blog which was down until last week. After updating WordPress, now the site is working fine. But I would like to check it frequently for next couple of days. Is it possible to write a program to do this so that I can schedule it? \nPlease give some suggestions. I am thinking of Python as the language for the program, but I am open to any language.","AnswerCount":7,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":3127,"Q_Id":7481974,"Users Score":0,"Answer":"Your program should send a get request to the website, receive the html (verify you get \"200 OK\"), and compare the beginning of the string to what you know it should be (compare everything until the first thing that depends on content). If the comparison fails, then you should suspect that your site may be down, and check it yourself.","Q_Score":1,"Tags":"python","A_Id":7482087,"CreationDate":"2011-09-20T08:08:00.000","Title":"Programmatically checking whether a website is working or not?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I'm using Philip Semanchunk's posix_ipc python module to read from a posix message queue. A C++ program I've written populates the queue with a struct containing the data. My python program successfully reads the message off the queue but I'm not sure what to do with the resulting message.\ndoing a print msg just prints out an empty string but I know msg has something in it.\nI want to be able to read the members of the struct but I'm assuming I need to do something maybe with the struct module to marshal this message into something readable? Has anyone done anything like this?\nI've read through his documentation and demos, but he is using simple types and I haven't found any examples where the source is a C struct. Google hasn't been any help either.\nAlso, I'm restricted to using Python 2.3. Thanks!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":817,"Q_Id":7485830,"Users Score":1,"Answer":"Use the Python struct module.\nstruct::unpack() will translate the hex string from MessageQueue::receive() into a tuple of strings","Q_Score":1,"Tags":"python,posix,message-queue","A_Id":7500416,"CreationDate":"2011-09-20T13:20:00.000","Title":"How do I interpret the return from posix_ipc::MessageQueue::receive()?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"Full question\n\nWhy did Google choose Java for the Android Operating System and not the X language?\n\nWhere X would be one of the below:\n\nPython version 2.7 or version 3\n\nwhich is equally as powerful as Java\nhas a lot of useful third party libraries\nis faster to develop in thanks to it's dynamic nature\n\nC\/C++ or ObjC\n\nwhich are harder to develop in but\nrun faster thanks to less overhead\nwould require less beefy hardware, especially RAM\nare equally as robust as Java but are more prone to app-wide crashes when just one module fails\n\n\nAnd so on. My main concern when I asked this question was why Java and not Python. I can add other elements (languages) of comparison later if anyone else is also interested.\nInfo: I'm not a full-blown developer.\nEDIT I was very much aware that my question was going to be met with some opposition and bashing, that's why I said that I'm not a full-blown developer. I have my personal opinions to support me and just that but even thus, I still got great answers. I understand now, yes, Dalvik VM runs Java bytecodes on ARM devices, but how different is that Java from any other Oracle\/Sun Java spec, I don't know. I've been playing with both Java and Python and wrote at least one useful program in both + GUIs (Swing and PySide) and at least one third party library used. The order I did this was Java, then Python which made me realize how much faster it was for me to write everything from scratch in Python than it was in Java. Even packages seemed much easier to manager than Java's way of importing packages (thank God for Eclipse and a few intuitive clicks)... and then how complex would embedded apps be that you'd need to take extra care for type checking and unit tests (and afaik, unit tests are supposed to be a must nowadays for any serious developer)... but anyway, thanks for the answers so far. It's a learning process. ;)","AnswerCount":2,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":9975,"Q_Id":7497199,"Users Score":10,"Answer":"Google, as a company, uses Java a lot. The search features are written in Java. As far as I can tell from the outside, Google likes Java.\nFor most tasks, Java is faster than Python. I would rather work in Python, and I know how to write reasonably efficient Python, and yes PyPy is really shaking things up, but Google needed to provide a snappy experience on relatively underpowered phone processors so they likely didn't consider Python a contender.\nJava, like Python, provides a great deal of isolation from details of the underlying hardware. I think all Android phones are ARM-based, but in theory you could make an Android phone based on an x86 chip or something completely different, and as long as you do a good job of porting the Dalvik VM, your code will run. (Aside from apps that have native ARM code compiled in, of course.)\n\nGoogle likes the Java language, but they chose to write their own VM (\"Dalvik\") rather than license the Java VM. Compiled Java can be directly translated into Dalvik bytecodes. (Oracle sued Google over this. Oracle lost the lawsuit.)","Q_Score":19,"Tags":"java,android,python","A_Id":7497322,"CreationDate":"2011-09-21T09:02:00.000","Title":"Why did Google choose Java for the Android Operating 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":1},{"Question":"I am a newbie and I need your help!!\nI have installed scipy on my Ubuntu.\nWhen I ran the code from scipy import optimize, special\nI get the following in terminal:\n can't read \/var\/mail\/scipy.optimize\nand if I type python, and get >>> then type in from scipy import optimize\nthen I ran code including scipy, optimize, I get the following:\nname 'scipy' is not defined","AnswerCount":1,"Available Count":1,"Score":0.537049567,"is_accepted":false,"ViewCount":4965,"Q_Id":7501785,"Users Score":3,"Answer":"from scipy import optimize, special on the shell prompt starts the from command, which is an email program.\nfrom scipy import optimize, special in Python will put the modules optimize and special in your namespace, but not scipy. Either use them unqualified or do import scipy instead.","Q_Score":1,"Tags":"python,scipy","A_Id":7501841,"CreationDate":"2011-09-21T14:44:00.000","Title":"Question with scipy.optimize","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"Hello I have python script that takes apart an email from a string. I am using the get_payload(decode=True) function from the email class and it works great for pdf's and jpg's but it does not decode bmp files. The file is still encoded base64 when I write it to disk.\nHas anyone come across this issue themselves?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":310,"Q_Id":7505410,"Users Score":0,"Answer":"OK so I finally found the problem and it was not related to the python mail class at all. I was reading from a named pipe using the .read() function and it was not reading the entire email from the pipe. I had to pass the read function a size argument and then it was able to read the entire email. So ultimately the reason why my bmp file was not decoded is because I had invalid base64 data causing the get_payload() function to not be able to decode the attatchment.","Q_Score":0,"Tags":"python,email,mime","A_Id":7517921,"CreationDate":"2011-09-21T19:20:00.000","Title":"How to decode bitmap images using python's email 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":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have python 2.7 installed on my windows computer. I'm trying to email a puzzle answer to Spotify, which is running Python 2.6.6. When I submit my *.py source code, I'm getting the following error:\nRun Time Error\nExited, exit status: 1\nI only have \"import sys\". I've run tons of stress tests - possible inputs are 1 \u2264 m \u2264 10 000 lines, I've tested with 1 million+ values with zero problems. I've tried printing with print & sys.stdout.write. \nWhen I send in dummie test code (I run my full algorithm but only print garbage instead of my answer - ie, print \"test!\"), I get the expected \"Wrong Answer\" back. \nI have no idea where to start debugging - any tips\/help at all? \nThanks!\n-Sam","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":1602,"Q_Id":7512180,"Users Score":1,"Answer":"I got the same error. As I see it's not python output but just an answer from spotify bot that your program threw an exception in some tests. Maybe the real output isn't shown to prevent debugging using the bot.\nWhen you print dummy data fist test fails and you get 'Wrong Answer'.\nWhen you print real output first test may pass but next throw an exception and you get 'Run Time Error'.\nI fixed one defect with possible exception in my script and Run Time Error went away.","Q_Score":0,"Tags":"python,runtime,exitstatus","A_Id":8352031,"CreationDate":"2011-09-22T08:59:00.000","Title":"Run Time Error (exit status 1) when submitting puzzle 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},{"Question":"local_import function randomly does not import my modules from modules\ndirectory. The Error is:\n\nImportError: No module named testapp.modules.mymodule\n\nI have this problem when i use web2py with apache (with wsgi). I have no problem when i run locally with \"python web2py.py\" command.\nAny suggestion?","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":642,"Q_Id":7525761,"Users Score":0,"Answer":"Add testapp to your PYTHONPATH.","Q_Score":2,"Tags":"python,apache,wsgi,web2py,web2py-modules","A_Id":7525938,"CreationDate":"2011-09-23T07:40:00.000","Title":"local_import function does not 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":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"local_import function randomly does not import my modules from modules\ndirectory. The Error is:\n\nImportError: No module named testapp.modules.mymodule\n\nI have this problem when i use web2py with apache (with wsgi). I have no problem when i run locally with \"python web2py.py\" command.\nAny suggestion?","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":642,"Q_Id":7525761,"Users Score":1,"Answer":"I will answer my own question :)\nI started using mod_proxy and everything is ok.","Q_Score":2,"Tags":"python,apache,wsgi,web2py,web2py-modules","A_Id":7582872,"CreationDate":"2011-09-23T07:40:00.000","Title":"local_import function does not 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":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'd like to set the optimize flag (python -O myscript.py) at runtime within a python script based on a command line argument to the script like myscript.py --optimize or myscript --no-debug. I'd like to skip assert statements without iffing all of them away. Or is there a better way to efficiently ignore sections of python code. Are there python equivalents for #if and #ifdef in C++?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":2416,"Q_Id":7527055,"Users Score":12,"Answer":"-O is a compiler flag, you can't set it at runtime because the script already has been compiled by then.\nPython has nothing comparable to compiler macros like #if.\nSimply write a start_my_project.sh script that sets these flags.","Q_Score":11,"Tags":"python,optimization,runtime,assert,conditional-compilation","A_Id":7527449,"CreationDate":"2011-09-23T09:42:00.000","Title":"Is it possible to set the python -O (optimize) flag within a 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},{"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},{"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},{"Question":"For very simple, internal web-apps using ASP I was able to just switch IIS 'on' and then write some ASP scripts in the www directory that would start working immediately.\nIs there an equivalent webserver app for Python scripts that I can run that will automatically start serving dynamic pages (python scripts) in a certain folder (with virtually no configuration)?\nSolutions I've already found are either too limited (e.g. SimpleHTTPRequestHandler doesn't serve dynamic content) or require configuring the script that does the serving.","AnswerCount":4,"Available Count":4,"Score":0.0,"is_accepted":false,"ViewCount":394,"Q_Id":7534244,"Users Score":0,"Answer":"WSGI setups are fairly easy to get started, but in no anyway turn key. django MVC has a simple built in development server if you plan on using a more comprehensive framework.","Q_Score":0,"Tags":"python,webserver","A_Id":7534361,"CreationDate":"2011-09-23T20:07:00.000","Title":"What is a pythonic webserver equivalent to IIS and ASP?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"For very simple, internal web-apps using ASP I was able to just switch IIS 'on' and then write some ASP scripts in the www directory that would start working immediately.\nIs there an equivalent webserver app for Python scripts that I can run that will automatically start serving dynamic pages (python scripts) in a certain folder (with virtually no configuration)?\nSolutions I've already found are either too limited (e.g. SimpleHTTPRequestHandler doesn't serve dynamic content) or require configuring the script that does the serving.","AnswerCount":4,"Available Count":4,"Score":0.1973753202,"is_accepted":false,"ViewCount":394,"Q_Id":7534244,"Users Score":4,"Answer":"There's always CGI. Add a script mapping of .py to \"C:\\Python27\\python.exe\" -u \"%s\" then drop .py files in a folder and IIS will execute them.\nI'd not generally recommend it for real work\u2014in the longer term you would definitely want to write apps to WSGI, and then deploy them through any number of interfaces including CGI\u2014but it can be handy for quick prototyping.","Q_Score":0,"Tags":"python,webserver","A_Id":7534379,"CreationDate":"2011-09-23T20:07:00.000","Title":"What is a pythonic webserver equivalent to IIS and ASP?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"For very simple, internal web-apps using ASP I was able to just switch IIS 'on' and then write some ASP scripts in the www directory that would start working immediately.\nIs there an equivalent webserver app for Python scripts that I can run that will automatically start serving dynamic pages (python scripts) in a certain folder (with virtually no configuration)?\nSolutions I've already found are either too limited (e.g. SimpleHTTPRequestHandler doesn't serve dynamic content) or require configuring the script that does the serving.","AnswerCount":4,"Available Count":4,"Score":0.0,"is_accepted":false,"ViewCount":394,"Q_Id":7534244,"Users Score":0,"Answer":"My limited experience with Python web frameworks has taught me that most go to one extreme or the other: Django on one end is a full-stack MVC framework, that will do pretty much everything for you. On the other end, there are Flask, web.py, CherryPy, etc., which do much less, but stay out of your way.\nCherryPy, for example, not only comes with no ORM, and doesn't require MVC, but it doesn't even have a templating engine. So unless you use it with something like Cheetah, you can't write what would look like .asp at all.","Q_Score":0,"Tags":"python,webserver","A_Id":7534417,"CreationDate":"2011-09-23T20:07:00.000","Title":"What is a pythonic webserver equivalent to IIS and ASP?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"For very simple, internal web-apps using ASP I was able to just switch IIS 'on' and then write some ASP scripts in the www directory that would start working immediately.\nIs there an equivalent webserver app for Python scripts that I can run that will automatically start serving dynamic pages (python scripts) in a certain folder (with virtually no configuration)?\nSolutions I've already found are either too limited (e.g. SimpleHTTPRequestHandler doesn't serve dynamic content) or require configuring the script that does the serving.","AnswerCount":4,"Available Count":4,"Score":0.049958375,"is_accepted":false,"ViewCount":394,"Q_Id":7534244,"Users Score":1,"Answer":"For development or just to play around, here's an example using the standard Python library that I have used to help friend who wanted to get a basic CGI server up and running. It will serve python scripts from cgi-bin and files from the root folder. I'm not near a Windows computer at the moment to make sure that this still works. This also assumes Python2.x. Python 3.x has this, it's just not named the same.\n\nMake a directory on your harddrive with a cgi-bin folder in it (Ex. \"C:\\server\\cgi-bin\")\nIn a command window, navigate to \"C:\\server\" directory\nType the following assuming you've installed python 2.7 in C:\\Python27:\n\"c:\\python27\\python.exe -m CGIHTTPServer\"\nYou should get a message like \"Serving HTTP on 0.0.0.0 port 8000\"\n\nLinux is the same - \"python -m CGIHTTPServer\" in a directory with a cgi-bin\/ in it.","Q_Score":0,"Tags":"python,webserver","A_Id":7534970,"CreationDate":"2011-09-23T20:07:00.000","Title":"What is a pythonic webserver equivalent to IIS and ASP?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"What is the best way to set up a system that checks for events daily and sends messages via email, Twitter, SMS, and possibly Facebook? Keep in mind, that I do not have access to a web server with root access (Using Rackspace Cloud). Would PHP have a solution for this? Would there be any drawbacks to using Google App Engine and Python?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":150,"Q_Id":7535544,"Users Score":1,"Answer":"If you are using Google App Engine with Python you could use \"Cron\" to schedule a task to automatically run each day.\nGAE also allows you to send emails, just a little tip: make sure that you 'invite' the email address used to send mail to the application as an administrator so that you can programatically send emails etc.","Q_Score":0,"Tags":"php,python,google-app-engine","A_Id":8426091,"CreationDate":"2011-09-23T22:41:00.000","Title":"Check for Event Daily, and Send Notification Messages","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},{"Question":"I am writing an IRC bot in Python using the Twisted library. To test my bot I need to connect several times to an IRC network as my bot requires a restart each time a change is made. Therefore I am often \"banned\" from these networks for a couple of minutes because I have made a lot of connections.\nThis makes it annoying testing and writing the bot. Does anyone know of a better way to test the bot or any network which isn't as restrict with the amount of connections as QuakeNet is?","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":3842,"Q_Id":7546026,"Users Score":0,"Answer":"freenode is good.. You can create channels for yourself to test. Also check out this project called supybot, which is good for Python bots.","Q_Score":2,"Tags":"python,testing,connection,irc,bots","A_Id":7546076,"CreationDate":"2011-09-25T14:09:00.000","Title":"Testing an IRC 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},{"Question":"My Django application sends out quite a bit of emails and I've tried testing it thoroughly. However, for the first few months, I'd like to log all outgoing emails to ensure that everything is working smoothly. Is there a Django module that allows me to do this and makes the outgoing emails visible through the administration panel\nThanks.","AnswerCount":4,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":7599,"Q_Id":7552283,"Users Score":2,"Answer":"I do not know if there exists a module that works this way, but writing a custom one is a piece of cake. Just create a separate model and every time you send an email, create a new instance ( use a custom method for email sending ). Then, link this model with the admin and bingo..","Q_Score":13,"Tags":"python,django,logging,django-email","A_Id":7552429,"CreationDate":"2011-09-26T08:11:00.000","Title":"How can I log all outgoing 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},{"Question":"I'm trying to write a pop3 and imap clients in python using available libs, which will download email headers (and subsequently entire email bodies) from various servers and save them in a mongodb database. The problem I'm facing is that this client downloads emails in addition to a user's regular email client. So with the assumption that a user might or might not leave emails on the server when downloading using his mail client, I'd like to fetch the headers but only collect them from a certain date, to avoid grabbing entire mailboxes every time I fetch the headers. \nAs far as I can see the POP3 list call will get me all messages on the server, even those I probably already downloaded. IMAP doesn't have this problem.\nHow do email clients handle this situation when dealing with POP3 servers?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1501,"Q_Id":7553606,"Users Score":3,"Answer":"Outlook logs in to a POP3 server and issues the STAT, LIST and UIDL commands; then if it decides the user has no new messages it logs out. I have observed Outlook doing this when tracing network traffic between a client and my DBMail POP3 server. I have seen Outlook fail to detect new messages on a POP3 server using this method. Thunderbird behaves similarly but I have never seen it fail to detect new messages.\nIssue the LIST and UIDL commands to the server after logging in. LIST gives you an index number (the message's linear position in the mailbox) and the size of each message. UIDL gives you the same index number and a computed hash value for each message.\nFor each user you can store the size and hash value given by LIST and UIDL. If you see the same size and hash value, assume it is the same message. When a given message no longer appears in this list, assume it has been deleted and clear it from your local memory.\nFor complete purity, remember the relative positions of the size\/hash pairs in the message list, so that you can support the possibility that they may repeat. (My guess on Outlook's new message detection failure is that sometimes these values do repeat, at least for DBMail, but Outlook remembers them even after they are deleted, and forever considers them not new. If it were me, I would try to avoid this behavior.)\nFootnote: Remember that the headers are part of the message. Do not trust anything in the header for this reason: dates, senders, even server hand-off information can be easily faked and cannot be assumed unique.","Q_Score":3,"Tags":"python,email,pop3","A_Id":7556750,"CreationDate":"2011-09-26T10:14:00.000","Title":"Download POP3 headers from a certain date (Python)","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},{"Question":"I want to setup Jenkins to \n1) pull our source code from our repository, \n2) compile and build it\n3) run the tests on an embedded device\nstep 1 & 2 are quite easy and straight forward with Jenkins\nas for step 3, \nwe have hundreds of those devices in various versions of them, and I'm looking for a utility (preferable in python) that can handle the availability of hardware devices\/resources.\nin such manner that one of the steps will be able to receive which of the device is available and run the tests on it.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1059,"Q_Id":7559224,"Users Score":1,"Answer":"What I have found, is that the best thing to do, is have something like jenkins, or if you're using enterprise, electric commander, manage a resource 'pool' the pool is essentially virtual devices, but they have a property, such that you can call into a python script w\/ either an ip-address or serial port and communicate w\/ your devices.\nI used it for automated embedded testing on radios. The python script managed a whole host of tests, and commander would go ahead and choose a single-step resource from the pool, that resource had an ip, and would pass it into the python script. test would then perform all the tests and the stdout would get stored up into commander\/jenkins ... Also set properties to track pass\/fail count as test was executing\n\/\/main resource gets single step item from pool, in the main resource wrote a tiny script that asked if the item pulled from the pool had the resource name == \"Bench1\" .. \"BenchX\" etc.\nbasically:\nif resource.name==\"BENCH1\":\n python myscript.py --com COM3 --baud 9600\n...\netc.\nthe really great feature about doing it this way, is if you have to disconnect a device, you don't need to deliver up script changes, you simply mark the commander\/jenkins resource as disabled, and the main 'project' can still pull from what remains in your resource pool","Q_Score":3,"Tags":"python,embedded,jenkins","A_Id":7560987,"CreationDate":"2011-09-26T18:01:00.000","Title":"Handling hardware resources when testing with 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":0},{"Question":"Are there any benchmark on this???\n(I tried googling for some results but found none...\nand I couldn't test gmpy because gmplib wouldn't be installed on my laptop)\nthank you!","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":1269,"Q_Id":7560850,"Users Score":2,"Answer":"First of all, I'm probably biased since I'm the maintainer of gmpy.\ngmpy uses the GMP multiple-precision library and GMP is usually considered the fastest general purpose multiple-precision library. But when it's \"fastest\" depends on on the operation and the size of the values. When I compare the performance between Python longs and gmpy's mpz type, the crossover point is roughly between 20 and 50 digits. You'll probably get different results on your machine.\nWhat exactly are you trying to do?","Q_Score":0,"Tags":"java,python,performance,cython,bignum","A_Id":7561424,"CreationDate":"2011-09-26T20:21:00.000","Title":"What's the fastest implementation for bignum? (Java's bigInteger \/ Cython's int \/ gmpy \/ etc...)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Right now I have a script which uses numpy that I want to run automatically on a server. When I ssh in and run it manually, it works fine. However, when I set it to run as a cron job, it can't find numpy. Apparently due to the shared server environment, the cron demon for whatever reason can't find numpy. I contacted the server host's tech support and they told me to set up a vps or get my own damn server. Is there any way to hack a workaround for this? Perhaps, by moving certain numpy files into the same directory as the script?","AnswerCount":4,"Available Count":1,"Score":0.049958375,"is_accepted":false,"ViewCount":681,"Q_Id":7561969,"Users Score":1,"Answer":"Your cron job is probably executing with a different python interpreter. \nLog in as you (via ssh), and say which python. That will tell you where your python is. Then have your cron job execute that python interpreter to run your script, or chmod +x your script and put the path in a #! line at the top of the script.","Q_Score":2,"Tags":"python,numpy,cron,installation","A_Id":7562061,"CreationDate":"2011-09-26T22:11:00.000","Title":"Workaround Way To Install Numpy?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I am an experienced PHP developer (10 years) who has built 3 different custom frameworks for extreme high traffic sites. I have recently started to get into programming a lot of python, usually just for fun (algorithms). I am starting to develop a new site as my side project and wanted to know if I should use a pre-existing python web framework (Django, Pyramids, ect...) or develop my own.\nI know things might go a lot faster using a pre-existing framework, but from my experience with PHP frameworks and knowing the amount of traffic my side project could generate, whould it be better to develop an extremely light weight framework myself just like I have been doing for a while with PHP? It also might be a good way for me to learn python web development because most of my experience with the language has been for coding algorithms.\nIf I do use a pre-existing framework I was going to try out Pyramid or Django.\nAlso do other companies that use Python for web development and expect high traffic use their own web frameworks or a pre-existing one?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":481,"Q_Id":7562454,"Users Score":1,"Answer":"Learn from existing frameworks, I think. The Python web stack (wsgi, sqlalchemy, template engines, full stack frameworks, microframeworks) has spent a lot of time maturing. You'll have the opportunity to develop fast and learn from existing design.","Q_Score":0,"Tags":"python,frameworks","A_Id":7562586,"CreationDate":"2011-09-26T23:18:00.000","Title":"Use Python Framework or Build Own","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I need to fetch twitter historical data for a given set of keywords. Twitter Search API returns tweets that are not more than 9 days old, so that will not do. I'm currently using Tweepy Library (http:\/\/code.google.com\/p\/tweepy\/) to call Streaming API and it is working fine except the fact that it is too slow. For example, when I run a search for \"$GOOG\" sometimes it takes more than an hour between two results. There are definitely tweets containing that keyword but it isn't returning result fast enough. \nWhat can be the problem? Is Streaming API slow or there is some problem in my method of accessing it? Is there any better way to get that data free of cost?","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":1072,"Q_Id":7564100,"Users Score":1,"Answer":"How far back do you need? To fetch historical data, you might want to keep the stream on indefinitely (the stream API allows for this) and store the stream locally, then retrieve historical data from your db.\nI also use Tweepy for live Stream\/Filtering and it works well. The latency is typically < 1s and Tweepy is able to handle large volume streams.","Q_Score":0,"Tags":"python,api,twitter,streaming,tweepy","A_Id":7640150,"CreationDate":"2011-09-27T04:06:00.000","Title":"Is there any better way to access twitter streaming api through 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},{"Question":"I need to fetch twitter historical data for a given set of keywords. Twitter Search API returns tweets that are not more than 9 days old, so that will not do. I'm currently using Tweepy Library (http:\/\/code.google.com\/p\/tweepy\/) to call Streaming API and it is working fine except the fact that it is too slow. For example, when I run a search for \"$GOOG\" sometimes it takes more than an hour between two results. There are definitely tweets containing that keyword but it isn't returning result fast enough. \nWhat can be the problem? Is Streaming API slow or there is some problem in my method of accessing it? Is there any better way to get that data free of cost?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":1072,"Q_Id":7564100,"Users Score":0,"Answer":"streaming API too fast you get message as soon as you post it, we use twitter4j. But streamer streams only current messages, so if you not listening on streamer the moment you send tweet then message is lost.","Q_Score":0,"Tags":"python,api,twitter,streaming,tweepy","A_Id":7569606,"CreationDate":"2011-09-27T04:06:00.000","Title":"Is there any better way to access twitter streaming api through 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},{"Question":"pycassa has pycassa.util.convert_time_to_uuid(time_arg, lowest_val=True, randomize=False)\nphpcassa has static string uuid1 ([string $node = null], [int $time = null])\nCan phpcassa's uuid1 be used to get lowest\/highest uuids like in pycassa?\nIf not, what's the best approach to ensure you get everything between two given timestamps?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":411,"Q_Id":7573938,"Users Score":1,"Answer":"I believe that if you have a column with a type of UUID version 1, Cassandra will ignore the 'unique' component of the UUID and just use the time part for the range.","Q_Score":4,"Tags":"php,python,cassandra","A_Id":7575278,"CreationDate":"2011-09-27T18:27:00.000","Title":"lowest possible timeuuid in php (phpcassa)","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"As a long time Python programmer, I wonder, if a central aspect of Python culture eluded me a long time: What do we do instead of Makefiles?\nMost ruby-projects I've seen (not just rails) use Rake, shortly after node.js became popular, there was cake. In many other (compiled and non-compiled) languages there are classic Make files.\nBut in Python, no one seems to need such infrastructure. I randomly picked Python projects on GitHub, and they had no automation, besides the installation, provided by setup.py.\nWhat's the reason behind this?\nIs there nothing to automate? Do most programmers prefer to run style checks, tests, etc. manually?\nSome examples:\n\ndependencies sets up a virtualenv and installs the dependencies\ncheck calls the pep8 and pylint commandlinetools.\nthe test task depends on dependencies enables the virtualenv, starts selenium-server for the integration tests, and calls nosetest\nthe coffeescript task compiles all coffeescripts to minified javascript\nthe runserver task depends on dependencies and coffeescript\nthe deploy task depends on check and test and deploys the project.\nthe docs task calls sphinx with the appropiate arguments\n\nSome of them are just one or two-liners, but IMHO, they add up. Due to the Makefile, I don't have to remember them.\nTo clarify: I'm not looking for a Python equivalent for Rake. I'm glad with paver. I'm looking for the reasons.","AnswerCount":8,"Available Count":3,"Score":0.049958375,"is_accepted":false,"ViewCount":12445,"Q_Id":7580939,"Users Score":2,"Answer":"Any decent test tool has a way of running the entire suite in a single command, and nothing is stopping you from using rake, make, or anything else, really.\nThere is little reason to invent a new way of doing things when existing methods work perfectly well - why re-invent something just because YOU didn't invent it? (NIH).","Q_Score":34,"Tags":"python,automation,makefile,rake","A_Id":7581531,"CreationDate":"2011-09-28T09:16:00.000","Title":"Why are there no Makefiles for automation in 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":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"As a long time Python programmer, I wonder, if a central aspect of Python culture eluded me a long time: What do we do instead of Makefiles?\nMost ruby-projects I've seen (not just rails) use Rake, shortly after node.js became popular, there was cake. In many other (compiled and non-compiled) languages there are classic Make files.\nBut in Python, no one seems to need such infrastructure. I randomly picked Python projects on GitHub, and they had no automation, besides the installation, provided by setup.py.\nWhat's the reason behind this?\nIs there nothing to automate? Do most programmers prefer to run style checks, tests, etc. manually?\nSome examples:\n\ndependencies sets up a virtualenv and installs the dependencies\ncheck calls the pep8 and pylint commandlinetools.\nthe test task depends on dependencies enables the virtualenv, starts selenium-server for the integration tests, and calls nosetest\nthe coffeescript task compiles all coffeescripts to minified javascript\nthe runserver task depends on dependencies and coffeescript\nthe deploy task depends on check and test and deploys the project.\nthe docs task calls sphinx with the appropiate arguments\n\nSome of them are just one or two-liners, but IMHO, they add up. Due to the Makefile, I don't have to remember them.\nTo clarify: I'm not looking for a Python equivalent for Rake. I'm glad with paver. I'm looking for the reasons.","AnswerCount":8,"Available Count":3,"Score":1.2,"is_accepted":true,"ViewCount":12445,"Q_Id":7580939,"Users Score":-3,"Answer":"Is there nothing to automate? \n\nNot really. All but two of the examples are one-line commands. \ntl;dr Very little of this is really interesting or complex. Very little of this seems to benefit from \"automation\". \nDue to documentation, I don't have to remember the commands to do this.\n\nDo most programmers prefer to run stylechecks, tests, etc. manually?\n\nYes.\n\ngeneration documentation, \n the docs task calls sphinx with the appropiate arguments\n\nIt's one line of code. Automation doesn't help much.\nsphinx-build -b html source build\/html. That's a script. Written in Python.\nWe do this rarely. A few times a week. After \"significant\" changes.\n\nrunning stylechecks (Pylint, Pyflakes and the pep8-cmdtool).\n check calls the pep8 and pylint commandlinetools\n\nWe don't do this. We use unit testing instead of pylint.\nYou could automate that three-step process. \nBut I can see how SCons or make might help someone here.\n\ntests\n\nThere might be space for \"automation\" here. It's two lines: the non-Django unit tests (python test\/main.py) and the Django tests. (manage.py test). Automation could be applied to run both lines. \nWe do this dozens of times each day. We never knew we needed \"automation\".\n\ndependecies sets up a virtualenv and installs the dependencies\n\nDone so rarely that a simple list of steps is all that we've ever needed. We track our dependencies very, very carefully, so there are never any surprises. \nWe don't do this.\n\nthe test task depends on dependencies enables the virtualenv, starts selenium-server for the integration tests, and calls nosetest\n\nThe start server & run nosetest as a two-step \"automation\" makes some sense. It saves you from entering the two shell commands to run both steps.\n\nthe coffeescript task compiles all coffeescripts to minified javascript\n\nThis is something that's very rare for us. I suppose it's a good example of something to be automated. Automating the one-line script could be helpful.\nI can see how SCons or make might help someone here.\n\nthe runserver task depends on dependencies and coffeescript\n\nExcept. The dependencies change so rarely, that this seems like overkill. I supposed it can be a good idea of you're not tracking dependencies well in the first place.\n\nthe deploy task depends on check and test and deploys the project.\n\nIt's an svn co and python setup.py install on the server, followed by a bunch of customer-specific copies from the subversion area to the customer \/www area. That's a script. Written in Python. \nIt's not a general make or SCons kind of thing. It has only one actor (a sysadmin) and one use case. We wouldn't ever mingle deployment with other development, QA or test tasks.","Q_Score":34,"Tags":"python,automation,makefile,rake","A_Id":7581523,"CreationDate":"2011-09-28T09:16:00.000","Title":"Why are there no Makefiles for automation in 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":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"As a long time Python programmer, I wonder, if a central aspect of Python culture eluded me a long time: What do we do instead of Makefiles?\nMost ruby-projects I've seen (not just rails) use Rake, shortly after node.js became popular, there was cake. In many other (compiled and non-compiled) languages there are classic Make files.\nBut in Python, no one seems to need such infrastructure. I randomly picked Python projects on GitHub, and they had no automation, besides the installation, provided by setup.py.\nWhat's the reason behind this?\nIs there nothing to automate? Do most programmers prefer to run style checks, tests, etc. manually?\nSome examples:\n\ndependencies sets up a virtualenv and installs the dependencies\ncheck calls the pep8 and pylint commandlinetools.\nthe test task depends on dependencies enables the virtualenv, starts selenium-server for the integration tests, and calls nosetest\nthe coffeescript task compiles all coffeescripts to minified javascript\nthe runserver task depends on dependencies and coffeescript\nthe deploy task depends on check and test and deploys the project.\nthe docs task calls sphinx with the appropiate arguments\n\nSome of them are just one or two-liners, but IMHO, they add up. Due to the Makefile, I don't have to remember them.\nTo clarify: I'm not looking for a Python equivalent for Rake. I'm glad with paver. I'm looking for the reasons.","AnswerCount":8,"Available Count":3,"Score":0.049958375,"is_accepted":false,"ViewCount":12445,"Q_Id":7580939,"Users Score":2,"Answer":"The make utility is an optimization tool which reduces the time spent building a software image. The reduction in time is obtained when all of the intermediate materials from a previous build are still available, and only a small change has been made to the inputs (such as source code). In this situation, make is able to perform an \"incremental build\": rebuild only a subset of the intermediate pieces that are impacted by the change to the inputs.\nWhen a complete build takes place, all that make effectively does is to execute a set of scripting steps. These same steps could just be deposited into a flat script. The -n option of make will in fact print these steps, which makes this possible.\nA Makefile isn't \"automation\"; it's \"automation with a view toward optimized incremental rebuilds.\" Anything scripted with any scripting tool is automation.\nSo, why would Python project eschew tools like make? Probably because Python projects don't struggle with long build times that they are eager to optimize. And, also, the compilation of a .py to a .pyc file does not have the same web of dependencies like a .c to a .o.\nA C source file can #include hundreds of dependent files; a one-character change in any one of these files can mean that the source file must be recompiled. A properly written Makefile will detect when that is or is not the case.\nA big C or C++ project without an incremental build system would mean that a developer has to wait hours for an executable image to pop out for testing. Fast, incremental builds are essential.\nIn the case of Python, probably all you have to worry about is when a .py file is newer than its corresponding .pyc, which can be handled by simple scripting: loop over all the files, and recompile anything newer than its byte code. Moreover, compilation is optional in the first place!\nSo the reason Python projects tend not to use make is that their need to perform incremental rebuild optimization is low, and they use other tools for automation; tools that are more familiar to Python programmers, like Python itself.","Q_Score":34,"Tags":"python,automation,makefile,rake","A_Id":53604587,"CreationDate":"2011-09-28T09:16:00.000","Title":"Why are there no Makefiles for automation in 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":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm currently working on a project that has been relatively easy, up until now. The underlying project is to transmit data\/messages over lasers using audio transformation.\nIn a nutshell the process is currently like this\n\nThe user enters a message\nMessage is turned into binary\nFor each 1 and 0 in the binary message, it plays a corresponding tone to signal which is which, in my case 250hz for a 1 and 450 hz for a 0.\nThe outgoing tone is sent over a stereo cable to an audio transformer rigged to a laser\nA solar panel acts as a microphone and records the incoming \"sound\" as a file\nIt them plays the file back and reads off the tones and tries to match each 250 and 450 hz to a 1 or 0 (which is where my issue lies).\n\nUp until the actual processing of the sound is fine, my current issue is the following. \nI play the tones each for x time, on the receiving end it is recorded for y time, y time is cut sampled many times and then analyzed sample by sample which then logs each frequency. This is inefficient and inaccurate. I have had many issues regardless of the time I play the tones for it often hears a tone twice or doesn't hear it at all, which completely throws off whole messages.\nI have tried to match the rate at which it samples with the time each tone plays, but unless aligned accordingly it does not work. I've only had a few successful tests for messages like 'test' and 'hi'. I have already looked into bpsk and fsk, but I feel as if I'm already doing something like it but that I have a bad receiving end to decipher it all.\nThis is all written in Python and I'd be very grateful for any tips, suggestions, or possible implementations that you can provide. Also for tone emission I'm using pyaudiere and for recording I'm using pyaudio.\nThanks!\n-Steve","AnswerCount":4,"Available Count":2,"Score":0.049958375,"is_accepted":false,"ViewCount":1017,"Q_Id":7606111,"Users Score":1,"Answer":"I would tackle the receiving end using two FIR filters, one for each frequency that you are trying to detect. The coefficients of the filters are just a copy of the signal you are looking for (i.e. 250Hz in one case and 450Hz in the other). You would have to look at the output of your solar panel to decide whether that is a square wave, sine wave, or something in between. The length of the filter corresponds to the duration of the tone (i.e. 'x' in your question). The samples are fed into both filters in parallel.\nThe output of each filter needs to be rectified (i.e. take the absolute value) and smoothed. The smoothing can be done using a simple moving average over a period of about half x (you can experiment to find the best value). Then if you compare the smoothed values (i.e. is a>b, or b>a) you should get a stream of 0's and 1's.\nThings to be aware of: This assumes the channel behaves the same for both frequencies (i.e. you get similar snr and attenuation). You might need to tweak your frequencies a bit because 450Hz is quite close to 500Hz which is a harmonic of 250Hz.","Q_Score":5,"Tags":"python,audio,signal-processing,frequency","A_Id":7632584,"CreationDate":"2011-09-30T04:57:00.000","Title":"Python Audio Transfer Through Lasers","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I'm currently working on a project that has been relatively easy, up until now. The underlying project is to transmit data\/messages over lasers using audio transformation.\nIn a nutshell the process is currently like this\n\nThe user enters a message\nMessage is turned into binary\nFor each 1 and 0 in the binary message, it plays a corresponding tone to signal which is which, in my case 250hz for a 1 and 450 hz for a 0.\nThe outgoing tone is sent over a stereo cable to an audio transformer rigged to a laser\nA solar panel acts as a microphone and records the incoming \"sound\" as a file\nIt them plays the file back and reads off the tones and tries to match each 250 and 450 hz to a 1 or 0 (which is where my issue lies).\n\nUp until the actual processing of the sound is fine, my current issue is the following. \nI play the tones each for x time, on the receiving end it is recorded for y time, y time is cut sampled many times and then analyzed sample by sample which then logs each frequency. This is inefficient and inaccurate. I have had many issues regardless of the time I play the tones for it often hears a tone twice or doesn't hear it at all, which completely throws off whole messages.\nI have tried to match the rate at which it samples with the time each tone plays, but unless aligned accordingly it does not work. I've only had a few successful tests for messages like 'test' and 'hi'. I have already looked into bpsk and fsk, but I feel as if I'm already doing something like it but that I have a bad receiving end to decipher it all.\nThis is all written in Python and I'd be very grateful for any tips, suggestions, or possible implementations that you can provide. Also for tone emission I'm using pyaudiere and for recording I'm using pyaudio.\nThanks!\n-Steve","AnswerCount":4,"Available Count":2,"Score":0.049958375,"is_accepted":false,"ViewCount":1017,"Q_Id":7606111,"Users Score":1,"Answer":"Did you do a sanity check by listening to the sound files (both transmit and receive), or viewing the waveforms with an audio editor, to see if they roughly sound or look the same? That way you can narrow down the problem to channel induced errors versus your software analysis.\nYour decoding\/demodulation software will need a synchronization method that can determine and track the times that the audio signal changes from one frequency of modulation to another, then you will need to separately test this synchronization method for offset errors.","Q_Score":5,"Tags":"python,audio,signal-processing,frequency","A_Id":7614995,"CreationDate":"2011-09-30T04:57:00.000","Title":"Python Audio Transfer Through Lasers","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"In Eclipse PyDev plugin, all document of default library of python will be load, but document of pygtk doesn't load in Eclipse.\nAny way to load them to eclipse?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":887,"Q_Id":7621477,"Users Score":0,"Answer":"Make sure that your PYTHONPATH includes pygtk.","Q_Score":3,"Tags":"python,eclipse,pygtk,pydev,documentation-generation","A_Id":7651572,"CreationDate":"2011-10-01T16:26:00.000","Title":"How to load PyGTK documentation in Eclipse PyDev Plugin in auto-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},{"Question":"I have an infrared camera\/tracker with which I am communicating via the serial port. I'm using the pyserial module to do this at the moment. The camera updates the position of a tracked object at the rate of 60 Hz. In order to get the position of the tracked object I execute one pyserial.write() and then listen for an incoming reply with pyserial.read(serialObj.inWaiting()). Once the reply\/position has been received the while loop is reentered and so on. My question has to do with the reliability and speed of this approach. I need the position to be gotten by the computer at the rate of at least 60Hz (and the position will then be sent via UDP to a real-time OS). Is this something that Pyserial\/Python are capable of or should I look into alternative C-based approaches? \nThanks,\nLuke","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":4369,"Q_Id":7629403,"Users Score":1,"Answer":"This is more a matter of latency than speed.\nPython always performs memory allocation and release, but if the data is reused, the same memory will be reused by the C library.\nSo the OS (C library \/ UDP\/IP stack) will have more impact than Python itself.\nI really think you should use a serial port on your RTOS machine and use C code and pre-allocated buffers.","Q_Score":5,"Tags":"python,real-time,pyserial","A_Id":7629435,"CreationDate":"2011-10-02T21:38:00.000","Title":"pyserial\/python and real time data acquisition","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I have an infrared camera\/tracker with which I am communicating via the serial port. I'm using the pyserial module to do this at the moment. The camera updates the position of a tracked object at the rate of 60 Hz. In order to get the position of the tracked object I execute one pyserial.write() and then listen for an incoming reply with pyserial.read(serialObj.inWaiting()). Once the reply\/position has been received the while loop is reentered and so on. My question has to do with the reliability and speed of this approach. I need the position to be gotten by the computer at the rate of at least 60Hz (and the position will then be sent via UDP to a real-time OS). Is this something that Pyserial\/Python are capable of or should I look into alternative C-based approaches? \nThanks,\nLuke","AnswerCount":3,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":4369,"Q_Id":7629403,"Users Score":0,"Answer":"Python should keep up fine, but the best thing to do is make sure you monitor how many reads per second you are getting. Count how many times the read completed each second, and if this number is too low, write to a performance log or similar. You should also consider decoupling the I\/O part from the rest of your python program (if there is one) as pyserial read calls are blocking.","Q_Score":5,"Tags":"python,real-time,pyserial","A_Id":7630217,"CreationDate":"2011-10-02T21:38:00.000","Title":"pyserial\/python and real time data acquisition","Data Science and Machine Learning":0,"Database and SQL":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},{"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},{"Question":"In my script I read messages from socket and change the state of some objects in memory depending on the content in message. Everything works fine.\nBut I want to implement deletion of non-active objects: for example, if there's no message for specified object during some time, it should be deleted. What is the best way to do it ?","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":204,"Q_Id":7635456,"Users Score":1,"Answer":"Store a timestamp in each object - update the timestamp to the current time whenever you modify it.\nThen have something that runs every so often, looks at all of the objects, and removes any with a timestamp earlier than a certain amount before the current time.","Q_Score":4,"Tags":"python","A_Id":7635473,"CreationDate":"2011-10-03T13:12:00.000","Title":"How to track an objects state in 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},{"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},{"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},{"Question":"I have a quick one off task in a python script that I'd like to call from Django (www user), that's going to need to root privileges. \nAt first I thought I would could use Python's os.seteuid() and set the setuid bit on the script, but then I realized that I would have to set the setuid bit on Python itself, which I assume is big no no. From what I can tell, this would also be the case if using sudo, which I really would like to avoid.\nAt this point, I'm considering just writing a C wrapper the uses seteuid and calls my python script as root, passing the necessary arguments to it.\nIs this the correct thing to do or should I be looking at something else?","AnswerCount":3,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":4966,"Q_Id":7639141,"Users Score":3,"Answer":"The correct thing is called privilege separation: clearly identify minimal set of tasks which have to be done on elevated privileges. Write a separate daemon and an as much limited as possible way of communicating the task to do. Run this daemon as another user with elevated privileges. A bit more work, but also more secure.\nEDIT: using a setuid-able wrapper will also satisfy the concept of privilege separation, although I recommend having the web server chrooted and mounting the chrooted file system nosuid (which would defeat that).","Q_Score":13,"Tags":"python,c,django,freebsd","A_Id":7639481,"CreationDate":"2011-10-03T18:33:00.000","Title":"Execute Python Script as Root (seteuid vs c-wrapper)","Data Science and Machine Learning":0,"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},{"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},{"Question":"I have a test that runs a python script, which calls into C++ code, where it segfaults and dumps core. I've tried to load the core file in GDB using \/usr\/bin\/python2.6, but this just gives me ?? for all the items in the stack trace. How do I debug this core file?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":473,"Q_Id":7668850,"Users Score":1,"Answer":"You need to compile a version of Python with debugging symbols. You can do this by building Python with .\/configure --with-pydebug. Hopefully you will be able to find the error that way.\nThat will change the behavior of Python internally in some ways. If you don't still get the segfault that way, you might try running .\/configure CFLAGS=\"-O0 -ggdb3\" or even just .\/configure CFLAGS=-ggdb3.","Q_Score":3,"Tags":"c++,python,gdb,core-file","A_Id":7669126,"CreationDate":"2011-10-05T23:15:00.000","Title":"Debugging a segmentation fault in C++ code called 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":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have noticed this in a couple of scripting languages, but in this example, I am using python. In many tutorials, they would start with #!\/usr\/bin\/python3 on the first line. I don't understand why we have this.\n\nShouldn't the operating system know it's a python script (obviously it's installed since you are making a reference to it)\nWhat if the user is using a operating system that isn't unix based\nThe language is installed in a different folder for whatever reason\nThe user has a different version. Especially when it's not a full version number(Like Python3 vs Python32)\n\nIf anything, I could see this breaking the python script because of the listed reasons above.","AnswerCount":7,"Available Count":4,"Score":1.0,"is_accepted":false,"ViewCount":273899,"Q_Id":7670303,"Users Score":13,"Answer":"This line helps find the program executable that will run the script. This shebang notation is fairly standard across most scripting languages (at least as used on grown-up operating systems).\nAn important aspect of this line is specifying which interpreter will be used. On many development-centered Linux distributions, for example, it is normal to have several versions of python installed at the same time.\nPython 2.x and Python 3 are not 100% compatible, so this difference can be very important. So #! \/usr\/bin\/python and #! \/usr\/bin\/python3 are not the same (and neither are quite the same as #! \/usr\/bin\/env python3 as noted elsewhere on this page.","Q_Score":221,"Tags":"python,scripting","A_Id":7720640,"CreationDate":"2011-10-06T04:29:00.000","Title":"Purpose of #!\/usr\/bin\/python3 shebang","Data Science and Machine Learning":0,"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},{"Question":"I have noticed this in a couple of scripting languages, but in this example, I am using python. In many tutorials, they would start with #!\/usr\/bin\/python3 on the first line. I don't understand why we have this.\n\nShouldn't the operating system know it's a python script (obviously it's installed since you are making a reference to it)\nWhat if the user is using a operating system that isn't unix based\nThe language is installed in a different folder for whatever reason\nThe user has a different version. Especially when it's not a full version number(Like Python3 vs Python32)\n\nIf anything, I could see this breaking the python script because of the listed reasons above.","AnswerCount":7,"Available Count":4,"Score":1.0,"is_accepted":false,"ViewCount":273899,"Q_Id":7670303,"Users Score":7,"Answer":"And this line is how.\nIt is ignored.\nIt will fail to run, and should be changed to point to the proper location. Or env should be used.\nIt will fail to run, and probably fail to run under a different version regardless.","Q_Score":221,"Tags":"python,scripting","A_Id":7670323,"CreationDate":"2011-10-06T04:29:00.000","Title":"Purpose of #!\/usr\/bin\/python3 shebang","Data Science and Machine Learning":0,"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},{"Question":"I have noticed this in a couple of scripting languages, but in this example, I am using python. In many tutorials, they would start with #!\/usr\/bin\/python3 on the first line. I don't understand why we have this.\n\nShouldn't the operating system know it's a python script (obviously it's installed since you are making a reference to it)\nWhat if the user is using a operating system that isn't unix based\nThe language is installed in a different folder for whatever reason\nThe user has a different version. Especially when it's not a full version number(Like Python3 vs Python32)\n\nIf anything, I could see this breaking the python script because of the listed reasons above.","AnswerCount":7,"Available Count":4,"Score":0.0855049882,"is_accepted":false,"ViewCount":273899,"Q_Id":7670303,"Users Score":3,"Answer":"Actually the determination of what type of file a file is very complicated, so now the operating system can't just know. It can make lots of guesses based on -\n\nextension\nUTI\nMIME\n\nBut the command line doesn't bother with all that, because it runs on a limited backwards compatible layer, from when that fancy nonsense didn't mean anything. If you double click it sure, a modern OS can figure that out- but if you run it from a terminal then no, because the terminal doesn't care about your fancy OS specific file typing APIs.\nRegarding the other points. It's a convenience, it's similarly possible to run \npython3 path\/to\/your\/script\nIf your python isn't in the path specified, then it won't work, but we tend to install things to make stuff like this work, not the other way around. It doesn't actually matter if you're under *nix, it's up to your shell whether to consider this line because it's a shellcode. So for example you can run bash under Windows.\nYou can actually ommit this line entirely, it just mean the caller will have to specify an interpreter. Also don't put your interpreters in nonstandard locations and then try to call scripts without providing an interpreter.","Q_Score":221,"Tags":"python,scripting","A_Id":52982676,"CreationDate":"2011-10-06T04:29:00.000","Title":"Purpose of #!\/usr\/bin\/python3 shebang","Data Science and Machine Learning":0,"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},{"Question":"I have noticed this in a couple of scripting languages, but in this example, I am using python. In many tutorials, they would start with #!\/usr\/bin\/python3 on the first line. I don't understand why we have this.\n\nShouldn't the operating system know it's a python script (obviously it's installed since you are making a reference to it)\nWhat if the user is using a operating system that isn't unix based\nThe language is installed in a different folder for whatever reason\nThe user has a different version. Especially when it's not a full version number(Like Python3 vs Python32)\n\nIf anything, I could see this breaking the python script because of the listed reasons above.","AnswerCount":7,"Available Count":4,"Score":1.0,"is_accepted":false,"ViewCount":273899,"Q_Id":7670303,"Users Score":28,"Answer":"That's called a hash-bang. If you run the script from the shell, it will inspect the first line to figure out what program should be started to interpret the script.\nA non Unix based OS will use its own rules for figuring out how to run the script. Windows for example will use the filename extension and the # will cause the first line to be treated as a comment.\nIf the path to the Python executable is wrong, then naturally the script will fail. It is easy to create links to the actual executable from whatever location is specified by standard convention.","Q_Score":221,"Tags":"python,scripting","A_Id":7670334,"CreationDate":"2011-10-06T04:29:00.000","Title":"Purpose of #!\/usr\/bin\/python3 shebang","Data Science and Machine Learning":0,"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},{"Question":"I have an apache server that I am using for cgi. I am writing my cgis in Python.\nAs long as my responses are of the form \"Content-Type: text\/html\\n #\" it works.\nBut if I send anything else, I get a 500 error and my logs say \"malformed header from script. Bad header\" Can I change my configurations to make it work? Is there anything else I can do?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":1336,"Q_Id":7683597,"Users Score":1,"Answer":"You need to send a Content-Type header to tell the browser what type of data you're sending it. Without that you'll get the 500 error you're experiencing.","Q_Score":1,"Tags":"python,ajax,apache,cgi","A_Id":7683660,"CreationDate":"2011-10-07T06:05:00.000","Title":"Getting Apache cgi to send json 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},{"Question":"I'm using a shell execute action in rsyslog to a python script on a CentOS machine. How can I ensure that it runs in a specified virtualenv?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":321,"Q_Id":7687332,"Users Score":2,"Answer":"Have you ever asked a question while researching something, then learned what you needed to do and then wished you hadn't asked the question?\nAll you need to do is modify your python path and add the path to the site-packages directory of the virtualenv you want to use.","Q_Score":1,"Tags":"python,centos,virtualenv,rsyslog","A_Id":8363498,"CreationDate":"2011-10-07T12:35:00.000","Title":"Rsyslog + 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":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"Does something exist that can take as input U+0043 and produce as output the letter C, maybe even a small description of the character ( like LATIN CAPITAL LETTER C )? \nEDIT: the U+0043 is just an example. I would like a generic solution please, that could work for as many codepoints as possible.","AnswerCount":4,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":109,"Q_Id":7689527,"Users Score":0,"Answer":"You could do chr(0x43) do get C.","Q_Score":1,"Tags":"python,unicode","A_Id":7689574,"CreationDate":"2011-10-07T15:36:00.000","Title":"How can I convert from U+0043 to C 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},{"Question":"Is it possible to profile a script run in wlst? I need to profile a python script that migrates data from an XML file to an LDAP.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":244,"Q_Id":7709023,"Users Score":0,"Answer":"So, I am answering my own question! Yes it is possible to profile. The JVM arguements needed for JProfiler\/any other profiler needs to be added to wlst.sh and it works.","Q_Score":0,"Tags":"python,weblogic11g,wlst","A_Id":8122676,"CreationDate":"2011-10-10T05:57:00.000","Title":"Is it possible to profile a script run in WLST?","Data Science and Machine Learning":0,"Database and SQL":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},{"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},{"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},{"Question":"We have devices that run a proprietary FTP client on them. They retrieve media files (AVI videos and Images) as well as XML files from our web service utilizing a python based FTP server. The problem I'm having is that the FTP client wants to download the media files in ASCII mode instead of binary mode. I'd like to continue to use our python FTP server (pyftpdlib) but I can't figure out a way to force the client to use binary mode.\nI've skimmed through the FTP RFC looking for a command\/response sequence that would allow our FTP server to tell the FTP client to use binary instead of ASCII. Does such a command\/response sequence exist?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1814,"Q_Id":7742965,"Users Score":2,"Answer":"You can override the default behaviour or you ftp server by using a custom FTPHandler and overriding the FTPHandler.ftp_TYPE(filetype) method and this way force your server to serve file in binary mode self._current_type = \"i\".","Q_Score":3,"Tags":"python,ftp","A_Id":7743098,"CreationDate":"2011-10-12T15:58:00.000","Title":"Can you force an FTP client to use binary from the server side","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},{"Question":"We are using a basic python log server based on BaseHTTPServer to aggregate our python logs on an ubunutu server. This solution has fulfilled our needs... until now. The number of programs dumping to this log server has grown and now the logger is crippling the system. \nNow that we are back to the drawing board, we are considering using syslog.\nWould it be advantageous to use syslog over other logging facilites.\nThanks for the help","AnswerCount":3,"Available Count":1,"Score":0.2605204458,"is_accepted":false,"ViewCount":3342,"Q_Id":7750560,"Users Score":4,"Answer":"The advantages of using syslog where available (all modern *nix systems, including Linux, FreeBSD, OS-X etc.) are numerous:\n\nPerformance is better: syslog is compiled C and most importantly it works as a separate process so all your logging operations become non-blocking to the applications, processes, and threads that make them\nYou can log from multiple processes\/threads concurrently without worrying about locking. All logging is safely serialized for you so you don't lose data\nYou get standard sortable time-stamps on all logged lines for free\nYou get log rotation for free\nYou get severity level support for free (see man syslog)\nYou can call logging from any language with a C binding, which is virtually any language\nYou can trivially log from shell scripts or command line (via logger)\nYou don't need to reinvent the (how to log) wheel\n\nThe only disadvantage I can think of is that syslog is non portable (to non *nix systems), but if you're on any modern *nix, any alternative is more complicated and likely less reliable.\nThe concern of losing packets because syslog is using UDP may be valid, but in practice on a LAN, I've never found it to be an issue.","Q_Score":6,"Tags":"python,logging,syslog","A_Id":31257970,"CreationDate":"2011-10-13T07:07:00.000","Title":"What are the advantages of using syslog over other logging facilites?","Data Science and Machine Learning":0,"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},{"Question":"I'm using Python to transfer (via scp) and database a large number of files. One of the servers I transfer files to has odd ssh config rules to stop too many ssh requests from a single location. The upshot of this is that my python script, currently looping through files and copying via os.system, hangs after a few files have been transferred.\nIs there a way in which Python could open up an ssh or other connection to the server, so that each file being transferred does not require an instance of ssh login?\nThanks,","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":696,"Q_Id":7757059,"Users Score":0,"Answer":"This is not really python specific, but it probably depends on what libraries you can use.\nWhat you need is a way to send files through a single connection. \n(This is probably better suited to superuser or severfault.com though.)\n\nCreate tarfile locally, upload it and unpack at target? \n\nMaybe you could even run 'tar xz' remotely and upload the file on stdin over SSH? (As MichaelDillon says in the comment, Python can create the tarfile on the fly...)\n\nIs SFTP an option? \nRsync over SSH?\nTwisted is an async library that can handle many sockets\/connections at once. Is probably overkill for your solution though,\n\nHope it helps.","Q_Score":1,"Tags":"python,sockets,ssh,scp","A_Id":7757147,"CreationDate":"2011-10-13T16:07:00.000","Title":"open (and maintain) remote connection 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":1,"Web Development":0},{"Question":"It seems that it is not possible any more to use the PyDev test runner for the latest version of Aptana studio (3.0.5) (containing Pydev v 2.2.2)\nWhen running the unit tests, the following exception is through by the pydev-plugin: AttributeError: 'module' object has no attribute 'exc_clear' (Occurs in 'Aptana Studio 3\\plugins\\org.python.pydev.debug_2.2.2.2011100512\\pysrc\\runfiles.py\", line 72, in main' : 'sys.exc_clear()')\nI figured out that sys.exc_clear() is a Python-2 method that isn't supported any more by Python-3 ...\nI don't know if pydev 2.2.3 fixes this problem ... but it is not available for Aptana yet ...","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":402,"Q_Id":7768237,"Users Score":0,"Answer":"The question has been answered.\n-> Waiting for fix in next stable release\n-> Using nightly until fix available (thanks to Fabio for the hint)","Q_Score":0,"Tags":"eclipse,unit-testing,python-3.x,aptana,pydev","A_Id":7790327,"CreationDate":"2011-10-14T13:21:00.000","Title":"Apatana 3.0.5 (or Eclipse) using Pydev 2.2.2: Unit-tests not working any more for 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":0,"Web Development":0},{"Question":"I still haven't gotten an answer that I'm happy with. Please do submit some answers if you have a nice system for your Python or PHP projects.\n\nI'm having a management issue with my PHP and Python projects. They both have two kinds of code files: files that should be run in the console or web browser, and files that should be included from other files to extend functionality. After my projects grow into large namespace or module trees, it starts getting disorienting that \"executable\" files and library files lay side by side with the same file extensions in all my folders. If PHP and Python were pre-compile languages, this would be the files with the main function.\nFor example, picture I have the namespace com.mycompany.map.address which contained multiple .py or .php files depending on the project. It would contain models for different kinds of addresses and tons of functions for working with addresses. But in addition, it would contain some executable files that runs from the terminal, providing a user tools for searching for addresses, and perhaps adding and removing addresses from a database or such.\nI want a way of distinguish such executable files from the tons and tons of code files in my namespace trees\nIf the files had separate file extensions this wouldn't be a problem. But since they don't, I'm thinking I should separate folders or something, but I don't know what to name them. In PHP I could perform the hack solution of configuring PHP to parse different file extensions, so my project could contain phps or phpx files, for instance.\nIf anyone has some language-independent advice on how to handle this issue, I'd appreciate it. This could also apply to languages such as C, where one project might compile into many executable files. How should one separate the source files containing main functions from the rest of them?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":629,"Q_Id":7768881,"Users Score":0,"Answer":"For my PHP projects, I follow a very Java-esque naming convention (my background):\nindex.php\n\/classes\/{organization type: net, org, com}\/{organization name}\/{component}\n\/includes\/ <- general configuration, etc; all non-executable;\n\/lib\/ <- third party libraries that are tied to specific releases; not modified, patched\/upgraded as needed;\n\/modules\/ <- place for extensions written within the score of the project","Q_Score":1,"Tags":"php,python,project-management","A_Id":7786309,"CreationDate":"2011-10-14T14:11:00.000","Title":"How do I separate my executable files from my library 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":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I'm trying to run some automated functional tests using python and Twill. The tests verify that my application's OAuth login and connection endpoints work properly. \nLuckily Twitter doesn't mind that Twill\/Mechanize is accessing twitter.com. However, Facebook does not like the fact that I'm using Twill to access facebook.com. I get their 'Incompatible Browser' response. I simply want to access their OAuth dialog page and either allow or deny the application I'm testing. Is there a way to configure Twill\/Mechanize so that Facebook will think its a standard browser?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":946,"Q_Id":7772387,"Users Score":1,"Answer":"Try to send user agent header w\/ mechanize.","Q_Score":1,"Tags":"python,facebook,browser,twill","A_Id":7773528,"CreationDate":"2011-10-14T19:06:00.000","Title":"How to configure the python Twill\/Mechanize library to acces Facebook","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},{"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},{"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},{"Question":"I can't import WebOb 1.1 with the Python 2.7 runtime, as WebOb imports io, io imports _io, which is blocked by the SDK. Is there a way to whitelist _io? It is obviously not supposed to be blacklisted.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":201,"Q_Id":7801387,"Users Score":1,"Answer":"From context, it sounds like you're trying to run your app on the dev_appserver. The dev_appserver does not yet support the Python 2.7 runtime; for now you'll have to do your development and testing on appspot.","Q_Score":1,"Tags":"python,google-app-engine,webob","A_Id":7815687,"CreationDate":"2011-10-18T01:06:00.000","Title":"GAE Python 2.7, no _io module?","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},{"Question":"I'm running an embedded Python interpreter in Obj-C. I can run Python scripts just fine, but when I try to import certain standard modules, I get ImportError: No module named random, for instance.\nHowever, I can import certain other modules. My investigations has given me this list so far:\nCan:\n\nimport sys\nimport math\nimport datetime\nimport time\n\nCan't:\n\nimport random\nimport re\nimport cmath\nimport numbers\nimport string\n\nThis is from a python file enclosed in a package, imported via PyImport_Import ('package.module'). There is one extension module loaded via Py_InitModule.\nThis is on Python 2.7.0 - is there any reason some of these modules are available and others not?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":771,"Q_Id":7806031,"Users Score":0,"Answer":"Thomas K set me on the right track, even though the problem was the completely opposite.\nMy Python setup was lacking the standard Python library - the part written in Python (usually distributed through \/Library, \/Lib or \/pylib in the distribution. Once those files were added to my application, all of it imported fine.\nSo, the link between the importable and non-importable modules above were that the importable were written as Python extensions in C, whereas the non-importable are written in pure Python.","Q_Score":0,"Tags":"python,objective-c,import","A_Id":7852425,"CreationDate":"2011-10-18T10:47:00.000","Title":"Can't import specific modules in embedded 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},{"Question":"Is there any way to know by which Python version the .pyc file was compiled?","AnswerCount":6,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":29640,"Q_Id":7807541,"Users Score":57,"Answer":"The first two bytes of the .pyc file are the magic number that tells the version of the bytecodes. The word is stored in little-endian format, and the known values are:\n\n\n\n\nPython version\nDecimal\nHexadecimal\nComment\n\n\n\n\nPython 1.5\n20121\n0x994e\n\n\n\nPython 1.5.1\n20121\n0x994e\n\n\n\nPython 1.5.2\n20121\n0x994e\n\n\n\nPython 1.6\n50428\n0x4cc4\n\n\n\nPython 2.0\n50823\n0x87c6\n\n\n\nPython 2.0.1\n50823\n0x87c6\n\n\n\nPython 2.1\n60202\n0x2aeb\n\n\n\nPython 2.1.1\n60202\n0x2aeb\n\n\n\nPython 2.1.2\n60202\n0x2aeb\n\n\n\nPython 2.2\n60717\n0x2ded\n\n\n\nPython 2.3a0\n62011\n0x3bf2\n\n\n\nPython 2.3a0\n62021\n0x45f2\n\n\n\nPython 2.3a0\n62011\n0x3bf2\n!\n\n\nPython 2.4a0\n62041\n0x59f2\n\n\n\nPython 2.4a3\n62051\n0x63f2\n\n\n\nPython 2.4b1\n62061\n0x6df2\n\n\n\nPython 2.5a0\n62071\n0x77f2\n\n\n\nPython 2.5a0\n62081\n0x81f2\nast-branch\n\n\nPython 2.5a0\n62091\n0x8bf2\nwith\n\n\nPython 2.5a0\n62092\n0x8cf2\nchanged WITH_CLEANUP opcode\n\n\nPython 2.5b3\n62101\n0x95f2\nfix wrong code: for x, in ...\n\n\nPython 2.5b3\n62111\n0x9ff2\nfix wrong code: x += yield\n\n\nPython 2.5c1\n62121\n0xa9f2\nfix wrong lnotab with for loops and storing constants that should have been removed\n\n\nPython 2.5c2\n62131\n0xb3f2\nfix wrong code: for x, in ... in listcomp\/genexp\n\n\nPython 2.6a0\n62151\n0xc7f2\npeephole optimizations and STORE_MAP opcode\n\n\nPython 2.6a1\n62161\n0xd1f2\nWITH_CLEANUP optimization\n\n\nPython 2.7a0\n62171\n0xdbf2\noptimize list comprehensions\/change LIST_APPEND\n\n\nPython 2.7a0\n62181\n0xe5f2\noptimize conditional branches: introduce POP_JUMP_IF_FALSE and POP_JUMP_IF_TRUE\n\n\nPython 2.7a0\n62191\n0xeff2\nintroduce SETUP_WITH\n\n\nPython 2.7a0\n62201\n0xf9f2\nintroduce BUILD_SET\n\n\nPython 2.7a0\n62211\n0x03f3\nintroduce MAP_ADD and SET_ADD\n\n\nPython 3000\n3000\n0xb80b\n\n\n\n\n3010\n0xc20b\nremoved UNARY_CONVERT\n\n\n\n3020\n0xcc0b\nadded BUILD_SET\n\n\n\n3030\n0xd60b\nadded keyword-only parameters\n\n\n\n3040\n0xe00b\nadded signature annotations\n\n\n\n3050\n0xea0b\nprint becomes a function\n\n\n\n3060\n0xf40b\nPEP 3115 metaclass syntax\n\n\n\n3061\n0xf50b\nstring literals become unicode\n\n\n\n3071\n0xff0b\nPEP 3109 raise changes\n\n\n\n3081\n0x090c\nPEP 3137 make __file__ and __name__ unicode\n\n\n\n3091\n0x130c\nkill str8 interning\n\n\n\n3101\n0x1d0c\nmerge from 2.6a0, see 62151\n\n\n\n3103\n0x1f0c\n__file__ points to source file\n\n\nPython 3.0a4\n3111\n0x270c\nWITH_CLEANUP optimization\n\n\nPython 3.0a5\n3131\n0x3b0c\nlexical exception stacking, including POP_EXCEPT\n\n\nPython 3.1a0\n3141\n0x450c\noptimize list, set and dict comprehensions: change LIST_APPEND and SET_ADD, add MAP_ADD\n\n\nPython 3.1a0\n3151\n0x4f0c\noptimize conditional branches: introduce POP_JUMP_IF_FALSE and POP_JUMP_IF_TRUE\n\n\nPython 3.2a0\n3160\n0x580c\nadd SETUP_WITH, tag: cpython-32\n\n\nPython 3.2a1\n3170\n0x620c\nadd DUP_TOP_TWO, remove DUP_TOPX and ROT_FOUR, tag: cpython-32\n\n\nPython 3.2a2\n3180\n0x6c0c\nadd DELETE_DEREF\n\n\n\n\nSources:\n\nPython\/import.c - merged by aix from Python 2.7.2 and Python 3.2.2\nLittle endian hex values for comparison first two bytes of Igor Popov's method added by jimbob","Q_Score":43,"Tags":"python,compilation","A_Id":7807661,"CreationDate":"2011-10-18T12:57:00.000","Title":"Is there a way to know by which Python version the .pyc file was compiled?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm considering writing a program in C++ which will embed a Python interpreter for executing macros created by users. Suppose that I'm intending to release my program under the GPLv3. What is not clear to me is what impact this has on the macros and data created by the users of my program.\nDo any of the requirements of the GPL carry over from my program to the macros written by users of my program? What about to other user data which is stored with the macros, such as images?\nPrograms like The GIMP and Gnumeric have macro languages, but are released under the GPL. I've never seen a discussion of whether user-created GIMP Script-Fu or Gnumeric spreadsheets must also be distributed under the GPL. I suspect that this is not the case, but I haven't been able to turn up any evidence for it. In the case of Gnumeric in particular, macros seem more like data than like plugins. (I'm aware that there's extensive discussion about the GPL and plugins, but I've found no discussion about what qualifies something as a plugin.)\nA confounding issue is that some core functions of may also be implemented as macros which are copied into user data. In this case, the user may be completely unaware that he is even distributing these macros when he distributes his data.\nI'd like not to put my users in a situation which encourages them to violate the GPL, unknowingly or otherwise.","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":186,"Q_Id":7827628,"Users Score":3,"Answer":"No the macros don't become GPL derived works anymore than a 'C' program written on a GPL linux system or with a GPL gcc compiler become GPL.\nIncluding library functions is a little more complicated. If you wrote those library functions then you can let the user do what they want with them. If they are part of the GIMP\/Gnumeric runtime then that's presumably also not a problem. \nBut if you pull the source for the library\/plugin from a GPL (rather than LGPL) app and wrapped it in a library to be called standalone from the user macro then the macro may well be a derived work.","Q_Score":1,"Tags":"c++,python,macros,licensing,gpl","A_Id":7854444,"CreationDate":"2011-10-19T20:21:00.000","Title":"How does the GPL affect macros stored in user data?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I'm considering writing a program in C++ which will embed a Python interpreter for executing macros created by users. Suppose that I'm intending to release my program under the GPLv3. What is not clear to me is what impact this has on the macros and data created by the users of my program.\nDo any of the requirements of the GPL carry over from my program to the macros written by users of my program? What about to other user data which is stored with the macros, such as images?\nPrograms like The GIMP and Gnumeric have macro languages, but are released under the GPL. I've never seen a discussion of whether user-created GIMP Script-Fu or Gnumeric spreadsheets must also be distributed under the GPL. I suspect that this is not the case, but I haven't been able to turn up any evidence for it. In the case of Gnumeric in particular, macros seem more like data than like plugins. (I'm aware that there's extensive discussion about the GPL and plugins, but I've found no discussion about what qualifies something as a plugin.)\nA confounding issue is that some core functions of may also be implemented as macros which are copied into user data. In this case, the user may be completely unaware that he is even distributing these macros when he distributes his data.\nI'd like not to put my users in a situation which encourages them to violate the GPL, unknowingly or otherwise.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":186,"Q_Id":7827628,"Users Score":0,"Answer":"You may want to consider using the LGPL for this reason. I am curious what the FSF has to say about such things though.","Q_Score":1,"Tags":"c++,python,macros,licensing,gpl","A_Id":7854671,"CreationDate":"2011-10-19T20:21:00.000","Title":"How does the GPL affect macros stored in user data?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"Suppose I have a script written in Python or Ruby, or a program written in C. How do I ensure that the script has no access to network capabilities?","AnswerCount":3,"Available Count":3,"Score":0.1325487884,"is_accepted":false,"ViewCount":291,"Q_Id":7843238,"Users Score":2,"Answer":"Unless you're using a sandboxed version of Python (using PyPy for example), there is no reliable way to switch-off network access from within the script itself. Of course, you could run under a VM with the network access shut off.","Q_Score":4,"Tags":"python,c,sandbox","A_Id":7843516,"CreationDate":"2011-10-20T22:55:00.000","Title":"How do I block all network access for a 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},{"Question":"Suppose I have a script written in Python or Ruby, or a program written in C. How do I ensure that the script has no access to network capabilities?","AnswerCount":3,"Available Count":3,"Score":1.2,"is_accepted":true,"ViewCount":291,"Q_Id":7843238,"Users Score":5,"Answer":"You more or less gave a generic answer yourself by tagging it with \"sandbox\" because that's what you need, some kind of sandbox. Things that come to mind are: using JPython or JRuby that run on the JVM. Within the JVM you can create a sandbox using a policy file so no code in the JVM can do thing you don't allow.\nFor C code, it's more difficult. The brute force answer could be to run your C code in a virtual machine with no networking capabilities. I really don't have a more elegant answer right now for that one. :)","Q_Score":4,"Tags":"python,c,sandbox","A_Id":7843275,"CreationDate":"2011-10-20T22:55:00.000","Title":"How do I block all network access for a 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},{"Question":"Suppose I have a script written in Python or Ruby, or a program written in C. How do I ensure that the script has no access to network capabilities?","AnswerCount":3,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":291,"Q_Id":7843238,"Users Score":0,"Answer":"Firewalls can block specific applications or processes from accessing the network. ZoneAlarms is a good one that I have used to do exactly what you want in the past. So it can be done programatically, but I don't know near enough about OS programming to offer any advice on how to go about doing it.","Q_Score":4,"Tags":"python,c,sandbox","A_Id":7843519,"CreationDate":"2011-10-20T22:55:00.000","Title":"How do I block all network access for a 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},{"Question":"I need to write a bunch of scripts to grab diagnostic data from customer environments where our product is installed. Troubleshooting data I need comes various sources including Oracle database, PowerShell commands, WMI, Registry, Windows commands such as netstat, our own property files, log files etc. The results will go into HTML pages, which in turn will be zipped emailed out\/FTPed by the script.\nWhich language is the most suited for this purpose? Python, Ruby or something else? I am new to both Python and Ruby.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":1651,"Q_Id":7858436,"Users Score":1,"Answer":"I started with python and ruby both few months ago. Ruby has loads and loads of issues and I find python really cool. Dint try with scripting. I am working on web apps.\nUsed python script to to interact with database and inserting raw fields. Works really fine.","Q_Score":0,"Tags":"python,ruby,scripting","A_Id":7858486,"CreationDate":"2011-10-22T08:59:00.000","Title":"Ruby vs Python: Which is better suited for scripting utilities on Windows? And why?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I'm trying to interact with a HTML 4.0 website which uses heavily obfuscated javascript to hide the regular HTML elements. What I want to do is to fill out a form and read the returned results, and this is proving harder to do than expected.\nWhen I read the page using Firebug, it gave me the source code deobfuscated, and I can then use this to do what I want to accomplish. The Firebug output showed all the regular elements of a website, such as -tags and the like, which were hidden in the original source.\nI've written the rest of my application in Python, using mechanize to interact with other web services, so I'd rather use an existing Python module to do this if that's possible. The problem is not only how to read the source code in a way mechanize can understand, but also how to generate the response which the web server can interpret. Could I use regular mechanize controls even though the html code is obfuscated?\nIn the beginning of my project I used pywebkitgtk instead of mechanize, but ditched it because it wasn't really implemented that well in python. Most functions are missing. Would that be a sensible method perhaps, to start up a webkit-browser which I read the HTML from, and use that with mechanize?\nAny help would be greatly appreciated, I'm really in a bind here. Thanks!\nEdit: I tried dumping the HTML fetched from mechanize and opening that with pywebkitgtk, using load_html_string, and then evaluating the html that way. Unfortunately, since the document I'm trying to parse loads more resources dynamically, that scripts just stops waiting for resources to be loaded. Note that I can't use webkit to load the document itself since I use mechanize's CookieJar function to allow me to log in first.\nI also tried dumping the HTML from webkit, which for some reason dumped the obfuscated javascript only, while displaying the website perfectly fine. If webkit could dump the deobfuscated javascript the way Firebug does, I could work with that and form a request according to the clean code..","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":754,"Q_Id":7858552,"Users Score":1,"Answer":"Rather than trying to process the page, how about just use Firebug to figure out the names of the form fields, and then use httplib or whatever to send a request with the necessary fields and settings?\nIf it's sent using ajax, you should be able to determine the values being sent to the server in Firebug as well.","Q_Score":1,"Tags":"python,screen-scraping,mechanize,web-scraping,deobfuscation","A_Id":7860906,"CreationDate":"2011-10-22T09:25:00.000","Title":"Parse and interact with obfuscated javascript","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I'm trying to emulate code.InteractiveInterpreter from the embedded Python C API. I'm using PyEval_Evalcode to evaluate the user input. I am trying to evaluate user input in the interpreter and return the output as a string (just like the interpreter would). However, PyEval_Evalcode returns a multitude of datatypes wrapped in PyObject*. Is there any way to do what I am trying to do? \nConstraints: It needs to be done using the embedding api. Cannot be done using PyRun_RunSimpleString() and laying down a code.InteractiveInterpreter.","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":270,"Q_Id":7860958,"Users Score":3,"Answer":"The object returned by PyEval_Evalcode() can be transformed to a Python string using PyObject_Repr() or PyObject_Str(). The resultant python string can be turned into a regular C string with PyString_AsString().","Q_Score":3,"Tags":"python,python-c-api","A_Id":7861240,"CreationDate":"2011-10-22T16:35:00.000","Title":"Evaluating Python Code From the CAPI and getting 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},{"Question":"I'm trying to emulate code.InteractiveInterpreter from the embedded Python C API. I'm using PyEval_Evalcode to evaluate the user input. I am trying to evaluate user input in the interpreter and return the output as a string (just like the interpreter would). However, PyEval_Evalcode returns a multitude of datatypes wrapped in PyObject*. Is there any way to do what I am trying to do? \nConstraints: It needs to be done using the embedding api. Cannot be done using PyRun_RunSimpleString() and laying down a code.InteractiveInterpreter.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":270,"Q_Id":7860958,"Users Score":0,"Answer":"I have binary string and cannot return it as string because of null terminated string.\nif(PyString_Check(pValue))\n {\n const char* s=\/*PyBytes_AsString*\/PyString_AsString(PyObject_Repr(pValue)); \/\/return hex representation in ascii\n int sz=PyString_Size(pValue);\/\/size is valid\n const char* s= PyString_AsString(pValue);\/\/return only below null terminated string\n }","Q_Score":3,"Tags":"python,python-c-api","A_Id":11220657,"CreationDate":"2011-10-22T16:35:00.000","Title":"Evaluating Python Code From the CAPI and getting 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},{"Question":"Python 2.4.x (cannot install any non-stock modules).\nQuestion for you all. (assuming use of subprocess.popen)\nSay you had 20 - 30 machines - each with 6 - 10 files on them that you needed to read into a variable.\nWould you prefer to scp into each machine, once for each file (120 - 300 SCP commands total), reading each file after it's SCP'd down into a variable - then discarding the file.\nOr - SSH into each machine, once for each file - reading the file into memory. (120 - 300 ssh commands total).\n?\nUnless there's some other way to grab all desired files in one shot per machine (files are named YYYYMMDD.HH.blah - range would be given 20111023.00 - 20111023.23). - reading them into memory that I cannot think of?","AnswerCount":4,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1890,"Q_Id":7869552,"Users Score":0,"Answer":"scp lets you:\n\nCopy entire directories using the -r flag: scp -r g0:labgroup\/ .\nSpecify a glob pattern: scp 'g0:labgroup\/assignment*.hs' .\nSpecify multiple source files: scp 'g0:labgroup\/assignment1*' 'g0:labgroup\/assignment2*' .\n\nNot sure what sort of globbing is supported, odds are it just uses the shell for this. I'm also not sure if it's smart enough to merge copies from the same server into one connection.","Q_Score":0,"Tags":"python,ssh,scp","A_Id":7869588,"CreationDate":"2011-10-23T22:00:00.000","Title":"Python - SCP vs SSH for multiple computers and multiple 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":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I need to send sms globally to different timezones to each customer registered online\nThe messages are scheduled to be send each month.\nI have the country details of each cutomer . I would be writing a python script and add it to cronjobs for sending sms.\nThe issue I am facing is knowing a safe time ( sometime during the day) based on the country for sending the SMS.\nMY server runs in Australian\/Melbourne timezone.What is the best way for me to find the safe time to send SMS to a customer from another country","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":125,"Q_Id":7870966,"Users Score":0,"Answer":"You probably want to store each user's timezone in your database and then you can change a particular datetime object's timezone by using datetime.astimezone(tz) . \nNow deciding what a good time to to sms them is entirely up to you.","Q_Score":0,"Tags":"python","A_Id":7871122,"CreationDate":"2011-10-24T03:10:00.000","Title":"Dealing with timezones for sending sms -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},{"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},{"Question":"I like Lettuce, and the feel of testing with it. Could I replace all the tests ( doctests\/unit tests ) in a project with Lettuce features?","AnswerCount":3,"Available Count":3,"Score":1.2,"is_accepted":true,"ViewCount":1121,"Q_Id":7877638,"Users Score":2,"Answer":"I have to disagree with Andy.\nI do agree that the appropriate testing should be done at the appropriate time, and that unit tests (i.e. ones that do not interact with anything outside their unit) do not replace all other forms of testing. \nBut that doesn't necessarily mean that with the proper separation you cannot use a BDD framework (I too haven't used Lettuce) as the runner for your tests.\nI too really like the fact that Gherkin syntax can be pushed back towards business experts, testers and sponsors as a means of capturing the process to follow, so I see no reason why one set of specifications can't be aimed at the Unit level, but another could be aimed at the system and regression levels.\nConsider this (contrived and obviously nowhere near enough granular) example\n\nGiven My test server is updated with last nights build\nWhen I run my regressionTestPack1\nThen my regression results should match the known results for\nregressionTestPack1\n\nI am also not saying that this is appropriate in ever case. You should evaluate what benefit you get from this approach over leaving all your tests in different test running systems. In particular consider what the experience base is of the people performing the testing.\nSo if you are writing a small technical project, as the only the developer and you prefer this syntax, theres no reason not too. Just be very careful you still isolate your unit tests from your system tests from your regression tests.\nIf however you are part of a large team of devs, testers, business analysts, then your case will need to much stronger and is unlikely to actually be valid.","Q_Score":7,"Tags":"python,testing,bdd","A_Id":7994429,"CreationDate":"2011-10-24T14:59:00.000","Title":"Can BDD testing with Lettuce replace all other forms of testing in a 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},{"Question":"I like Lettuce, and the feel of testing with it. Could I replace all the tests ( doctests\/unit tests ) in a project with Lettuce features?","AnswerCount":3,"Available Count":3,"Score":1.0,"is_accepted":false,"ViewCount":1121,"Q_Id":7877638,"Users Score":8,"Answer":"In short, no.\nI haven't used Lettuce, but your question applies equally to other BDD frameworks such as Cucumber.\nThis approach is considered bad practice since integration tests are slower to run and more work to maintain than unit tests.\nAlso, a big advantage of Gherkin syntax is that it's readable by non-technical stakeholders and it can focus on business rules, whereas unit tests generally deal with detailed implementation specifics at the class\/function level not of particular interest to business-focused stakeholders.\nThere's sometimes an overlap between unit tests and integration\/acceptance tests but in general you should aim to find an appropriate balance.","Q_Score":7,"Tags":"python,testing,bdd","A_Id":7878932,"CreationDate":"2011-10-24T14:59:00.000","Title":"Can BDD testing with Lettuce replace all other forms of testing in a 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},{"Question":"I like Lettuce, and the feel of testing with it. Could I replace all the tests ( doctests\/unit tests ) in a project with Lettuce features?","AnswerCount":3,"Available Count":3,"Score":0.0665680765,"is_accepted":false,"ViewCount":1121,"Q_Id":7877638,"Users Score":1,"Answer":"It is a poor idea to use Gherkin\/Lettuce for everything.\n1) You should never do away with manual testing entirely. You might replace repetitive scripted testing, but you need to run the software past someone who can misunderstand or misuse it. Creative, destructive, human testing is important -- but the heavy lifting (90%+ of all testing) should be automated.\n2) Another reason is covered alread: it runs slowly compared to unit tests. I find that the longer it takes to run a test, the less likely people are to run it frequently. You want it to be a non-decision to run the tests after each change, maybe 2 or 3 times every 5 minutes (yes, that fast!).\n3) Personally, I think that writing unittests with sniffer or autonose in a different window gives me the very best environment for test-driving code. I don't know how to do that with lettuce. \n4) Why switch out languages if you don't have to? Unittest is in python, and there are no fixtures or thunks of any sort to get to the code you're interested in testing. It works well with mocks and fakes. Gherkin is fun, but it's got more plumbing involved. The extra plumbing is great if you have non-programmers writing tests, but otherwise is just overhead.","Q_Score":7,"Tags":"python,testing,bdd","A_Id":17815773,"CreationDate":"2011-10-24T14:59:00.000","Title":"Can BDD testing with Lettuce replace all other forms of testing in a 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},{"Question":"I wrote a WSGI application which I need to deploy to a server, however I've been given a server that already has mod_python installed.\nI am not allowed to remove mod_python since there are some mod_python applications running on it already.\nOne option I considered was installing mod_wsgi alongside mod_python, however I went through sources and found that was a bad idea. Apparently mod_wsgi and mod_python don't mix well.\nAnother option I considered was installing mod_fastcgi and deploying it using fastcgi.\nI would love to hear if someone has a better idea which doesn't break the current mod_python applications running on the server.","AnswerCount":4,"Available Count":1,"Score":0.049958375,"is_accepted":false,"ViewCount":1117,"Q_Id":7881474,"Users Score":1,"Answer":"The best solution might be to use mod_proxy and run the Python web app in a different webserver.","Q_Score":5,"Tags":"python,mod-wsgi,mod-python,mod-fastcgi","A_Id":7881775,"CreationDate":"2011-10-24T20:19:00.000","Title":"deploying a WSGI application on mod_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},{"Question":"I will admit that starting programming on your own as a newbie can seem a bit daunting. However after toying around very basically in both Python and currently C++ I'm wondering if C may be more suitable for a hobbyist. By hobbyist I mean someone who foresees no real future in actually programming for a living but rather sees it (at least currently) as an interesting exercise. So while I would like to be able to do things I'm don't really see myself y'know making a 3d game engine.\nI know that I don't NEED to learn C to learn C++. But from what I've read a couple of people have said that C is easier to learn because it's a smaller language. It seems like it would be more suitable to me given that, and I know that C is certainly fine for anything I'd want to do with it, and thus not really need to learn or use it as a stepping stone for C++. From what I can see C would be a) Easier to program with, meaning easier to get in and make things and keep one interested. b) lower level means more flexibility, whereas Python would be hindered perhaps by it's high level nature. C) Still widely used (though perhaps not to the extent of C++)\nA lot of people ask about learning C to get to C++ but I'm wondering more about C's own merits in and of them self. I wonder if what I'm thinking is true or if I've been filled with misconceptions. Thanks for any help :)","AnswerCount":2,"Available Count":1,"Score":0.2913126125,"is_accepted":false,"ViewCount":784,"Q_Id":7909666,"Users Score":3,"Answer":"You're looking at this wrong. What's your goal? If your goal is to \"learn a language\" then you are wasting your time. That is like investing your time into learning to use photoshop with no ambition to ever create any neato graphics.\nInstead of focusing on the tool, focus on what you want to do with it. If I learn how to use a power saw it's probably because I want to build something out of wood, not because I think power saws are just really awesome.\nAsk yourself; what do I want to build? Once you answer that then you set forth finding out which tools would be most appropriate.","Q_Score":2,"Tags":"c++,python,c","A_Id":7909723,"CreationDate":"2011-10-26T22:23:00.000","Title":"Learning programming as a hobbyist... the merits of C vs 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},{"Question":"When I import a module that has a class, what code is executed when that class is first read and the class object created? Is there any way I can influence what happens?\n\nEdit: I realize my question might be a bit too general...\nI'm looking for something more low-level which will allow me to do introspection from C++. I extend my C++ application with Python. I have some classes that are defined in C++ and exposed in Python. The user can inherit from these classes in the scripts and I want to be able to grab details about them when they are first defined.","AnswerCount":5,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":144,"Q_Id":7941660,"Users Score":0,"Answer":"Python is interpreted, so when a Python module is imported any class code at the module level is run, along with those classes' meta-classes -- this is so the classes will exist.\nC++ is compiled: the classes already exist when they are imported; there is no way to control how they are created as they are already created.","Q_Score":4,"Tags":"c++,python,class,metaprogramming,introspection","A_Id":7944715,"CreationDate":"2011-10-29T20:57:00.000","Title":"What code is executed when a class is being defined?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"What is the Python 3 equivalent of python -m SimpleHTTPServer?","AnswerCount":7,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":725970,"Q_Id":7943751,"Users Score":7,"Answer":"Just wanted to add what worked for me:\npython3 -m http.server 8000 (you can use any port number here except the ones which are currently in use)","Q_Score":1528,"Tags":"python,python-3.x,httpserver,simplehttpserver","A_Id":71111456,"CreationDate":"2011-10-30T07:22:00.000","Title":"What is the Python 3 equivalent of \"python -m SimpleHTTPServer\"","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},{"Question":"Is there a way to send command to another interactive shell ? Let's take the example of the meterpreter shell used in metasploit. Could it be a way to say command to this shell from python code, as soon as I get control of a computer and have a meterpreter shell to play with ? \nI mean All this from python code.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":3763,"Q_Id":7953996,"Users Score":0,"Answer":"It will not be easy at all.\nYou will have to know if meterpreter has any means for other programs to communicate with it.\nIf it doesn't, you might want to go through hacking through it, e.g using OS pipes, etc to be able to get it to work.\nIn any case, the code needed for such communication might be beyond Python's power.","Q_Score":1,"Tags":"python,shell,interactive","A_Id":7954357,"CreationDate":"2011-10-31T12:54:00.000","Title":"Send commands to an interactive shell 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},{"Question":"I'm writing a Python library to access Ubuntu One's REST API. (Yes, I know one already exists; this is a scratch-my-itch-and-learn-while-doing-it project.)\nThe library will be a relatively thin wrapper around the REST calls. I would like to be able to unit-test my library, without hitting U1 at all. What's the best practise standard for making this possible? \nAt the moment each REST call is an explicit http request. I can't see how to mock that out, but if I create a (mockable) UbuntuOneRESTAPI class hiding those http calls I suspect it will end up including most of the functionality of the wrapper library, which sort of defeats the purpose.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":604,"Q_Id":7955695,"Users Score":1,"Answer":"Your cutting point is the HTTP requests.\nWrite a mock library which intercepts the sending of the HTTP requests. Instead of sending them, convert them into a String and analyze them to test sending code.\nFor receiving code, mock the response handler. Save a good response from the REST server in a String and create the HTTP response object from it to test your receiver.\nWrite a few test cases which create these requests against the real thing so you can quickly verify that the requests\/responses are good.","Q_Score":1,"Tags":"python,unit-testing,mocking","A_Id":7956472,"CreationDate":"2011-10-31T15:18:00.000","Title":"How to test python library wrapping an external REST service (without hitting the service)","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},{"Question":"Is there any easy way to debug cgi python programs apart from looking at the log file each time the browser generates an error?","AnswerCount":4,"Available Count":1,"Score":0.049958375,"is_accepted":false,"ViewCount":3944,"Q_Id":7956696,"Users Score":1,"Answer":"You could capture (or form by hand) the data and env variables which the CGI script receives, then plainly run the script under your favorite debugger and feed the data to it.\nIn order to capture the incoming data you can just dump it from the script in CGI mode to some log file, then re-use under debugger in standalone mode.","Q_Score":5,"Tags":"python,linux,cgi","A_Id":7957775,"CreationDate":"2011-10-31T16:37:00.000","Title":"Debugging CGI 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},{"Question":"scrapy crawler is called through a shell script, which is used as the command line in a crontab entry. The shell script looks like:\nscrapy crawl targethost.com\nwhen time is due and it did execute, but seems only the constructor is called (I verified with debug output). The problem is solved by re-write the shell script as:\nscrapy crawl targethost.com &> cronlog.log\nI just don't know why.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":359,"Q_Id":7984714,"Users Score":1,"Answer":"Scrapy executes correctly, but doesn't output all its messages to STDOUT, so the simple pipe (>) doesn't redirect everything into your file, only that stuff that goes to STDOUT (which as you say, seems to be the constructor only).\nWith &> it fetches all messages from scrapy and puts them into your log.","Q_Score":0,"Tags":"python,crontab,scrapy","A_Id":7984842,"CreationDate":"2011-11-02T17:29:00.000","Title":"scrapy script called from cron only constructor 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":0,"Web Development":1},{"Question":"I'm in the process of working on programming project that involves some pretty extensive Monte Carlo simulation in Python, and as such the generation of a tremendous number of random numbers. Very nearly all of them, if not all of them, will be able to be generated by Python's built in random module.\nI'm something of a coding newbie, and unfamiliar with efficient and inefficient ways to do things. Is it faster to generate say, all the random numbers as a list, and then iterate through that list, or generate a new random number each time a function is called, which will be in a very large loop?\nOr some other, undoubtedly more clever method?","AnswerCount":5,"Available Count":1,"Score":0.0798297691,"is_accepted":false,"ViewCount":12900,"Q_Id":7988494,"Users Score":2,"Answer":"Code to generate 10M random numbers efficiently and faster:\n\nimport random\nl=10000000\nlistrandom=[]\nfor i in range (l):\n value=random.randint(0,l)\n listrandom.append(value)\nprint listrandom\n\nTime taken included the I\/O time lagged in printing on screen:\n\nreal 0m27.116s\nuser 0m24.391s\nsys 0m0.819s","Q_Score":14,"Tags":"python,random","A_Id":36474703,"CreationDate":"2011-11-02T23:14:00.000","Title":"Efficient way to generate and use millions of random numbers in 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":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Would it be better to use c or c++ for handling computationally intensive tasks in a python program, where speed matters above all. Is there much of a difference between the two ? Which is more cleaner?","AnswerCount":4,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":146,"Q_Id":7989036,"Users Score":0,"Answer":"Both are compiled to native code and usually with the same compiler and thus the same compiler optimizations available. The performance difference you pay for supporting C++ language constructs should be negligible. Choose the one you prefer \/ the one that integrates better with Python \/ the one that integrates better with other native libraries you want to use.","Q_Score":0,"Tags":"c++,python,c","A_Id":7989058,"CreationDate":"2011-11-03T00:36:00.000","Title":"Which is a better extension language for speed optimization for python c or 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},{"Question":"Would it be better to use c or c++ for handling computationally intensive tasks in a python program, where speed matters above all. Is there much of a difference between the two ? Which is more cleaner?","AnswerCount":4,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":146,"Q_Id":7989036,"Users Score":0,"Answer":"The runtime performance you gain from using C++ versus C is negligible. In terms of integrating the code with your Python program (and most other languages) it is almost always easier to do with C. In fact if you're using ctypes to load and run the code (which I'd recommend), you still need to write a C interface around the C++ library.","Q_Score":0,"Tags":"c++,python,c","A_Id":7989440,"CreationDate":"2011-11-03T00:36:00.000","Title":"Which is a better extension language for speed optimization for python c or 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},{"Question":"In mechanize, we have :\nmethod : set_cookiejar()\nBut, why do we need a cookie jar anyway, when we say that mechanize has automatic cookie handling ?\nPlease help !","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":486,"Q_Id":7990321,"Users Score":3,"Answer":"You don't need one -- if you don't specify one, Mechanize will just handle it. You might want to use cookies you have already stored in a jar, or save cookies in a jar for use with other scripts, so Mechanize lets you specify one.","Q_Score":2,"Tags":"python,browser,mechanize,web-scraping","A_Id":7990338,"CreationDate":"2011-11-03T04:36:00.000","Title":"Python - Mechanize : Why does it need CookieJar?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I want to connect to putty and want to do few step:\n\nlogin to Putty\ntype few command to bring down the server\nTraverse to the particular path\nRemove the file from the directory\nAgain start the server\n\nI need to write the code in windows. But my server is in linux.\nHow shall I proceed?\nThanks in advance","AnswerCount":4,"Available Count":1,"Score":0.1488850336,"is_accepted":false,"ViewCount":59795,"Q_Id":7991529,"Users Score":3,"Answer":"you can use code similar to:\ncommand = \"plink.exe -ssh username@\" + hostname + \" -pw password -batch \\\"export DISPLAY='\" + hostname + \"\/unix:0.0' ; \"\nwhich will open an ssh to the desired hostname using username and password\nshutdown:\ncommand += \"sudo \/sbin\/halt\\\"\"\nreboot:\ncommand += \"sudo \/sbin\/reboot\\\"\"\nadd your other commands using the same method as above,\nrun the command with:\npid = subprocess.Popen(command).pid\nAs pointed out by Tadeck, this will only work on a windows machine attempting to connect to a linux machine.","Q_Score":6,"Tags":"python,putty","A_Id":7991590,"CreationDate":"2011-11-03T07:36:00.000","Title":"Connect to putty and type few 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},{"Question":"I have a program in python that includes a class that takes a function as an argument to the __init__ method. This function is stored as an attribute and used in various places within the class. The functions passed in can be quite varied, and passing in a key and then selecting from a set of predefined functions would not give the same degree of flexibility.\nNow, apologies if a long list of questions like this is not cool, but...\n\nIs their a standard way to achieve this in a language where functions aren't first class objects?\nDo blocks, like in smalltalk or objective-C, count as functions in this respect?\nWould blocks be the best way to do this in those languages?\nWhat if there are no blocks?\nCould you add a new method at runtime?\nIn which languages would this be possible (and easy)?\nOr would it be better to create an object with a single method that performs the desired operation?\nWhat if I wanted to pass lots of functions, would I create lots of singleton objects? \nWould this be considered a more object oriented approach?\nWould anyone consider doing this in python, where functions are first class objects?","AnswerCount":4,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":163,"Q_Id":7994777,"Users Score":0,"Answer":"In Smalltalk you'd mostly be using blocks. You can also create classes and instances at runtime.","Q_Score":0,"Tags":"python,oop,first-class-functions","A_Id":8043889,"CreationDate":"2011-11-03T12:22:00.000","Title":"What is the equivalent of passing functions as arguments using an object oriented approach","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a program in python that includes a class that takes a function as an argument to the __init__ method. This function is stored as an attribute and used in various places within the class. The functions passed in can be quite varied, and passing in a key and then selecting from a set of predefined functions would not give the same degree of flexibility.\nNow, apologies if a long list of questions like this is not cool, but...\n\nIs their a standard way to achieve this in a language where functions aren't first class objects?\nDo blocks, like in smalltalk or objective-C, count as functions in this respect?\nWould blocks be the best way to do this in those languages?\nWhat if there are no blocks?\nCould you add a new method at runtime?\nIn which languages would this be possible (and easy)?\nOr would it be better to create an object with a single method that performs the desired operation?\nWhat if I wanted to pass lots of functions, would I create lots of singleton objects? \nWould this be considered a more object oriented approach?\nWould anyone consider doing this in python, where functions are first class objects?","AnswerCount":4,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":163,"Q_Id":7994777,"Users Score":1,"Answer":"I don't understand what you mean by \"equivalent... using an object oriented approach\". In Python, since functions are (as you say) first-class objects, how is it not \"object-oriented\" to pass functions as arguments?\n\na standard way to achieve this in a language where functions aren't first class objects?\n\nOnly to the extent that there is a standard way of functions failing to be first-class objects, I would say.\nIn C++, it is common to create another class, often called a functor or functionoid, which defines an overload for operator(), allowing instances to be used like functions syntactically. However, it's also often possible to get by with plain old function-pointers. Neither the pointer nor the pointed-at function is a first-class object, but the interface is rich enough.\nThis meshes well with \"ad-hoc polymorphism\" achieved through templates; you can write functions that don't actually care whether you pass an instance of a class or a function pointer.\nSimilarly, in Python, you can make objects register as callable by defining a __call__ method for the class.\n\nDo blocks, like in smalltalk or objective-C, count as functions in this respect?\n\nI would say they do. At least as much as lambdas count as functions in Python, and actually more so because they aren't crippled the way Python's lambdas are.\n\nWould blocks be the best way to do this in those languages?\n\nIt depends on what you need.\n\nCould you add a new method at runtime? In which languages would this be possible (and easy)?\n\nLanguages that offer introspection and runtime access to their own compiler. Python qualifies.\nHowever, there is nothing about the problem, as presented so far, which suggests a need to jump through such hoops. Of course, some languages have more required boilerplate than others for a new class.\n\nOr would it be better to create an object with a single method that performs the desired operation? \n\nThat is pretty standard.\n\nWhat if I wanted to pass lots of functions, would I create lots of singleton objects? \n\nYou say this as if you might somehow accidentally create more than one instance of the class if you don't write tons of boilerplate in an attempt to prevent yourself from doing so.\n\nWould this be considered a more object oriented approach?\n\nAgain, I can't fathom your understanding of the term \"object-oriented\". It doesn't mean \"creating lots of objects\".\n\nWould anyone consider doing this in python, where functions are first class objects?\n\nNot without a need for the extra things that a class can do and a function can't. With duck typing, why on earth would you bother?","Q_Score":0,"Tags":"python,oop,first-class-functions","A_Id":7995586,"CreationDate":"2011-11-03T12:22:00.000","Title":"What is the equivalent of passing functions as arguments using an object oriented approach","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":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},{"Question":"I've been an Eclipse user for the last 3 years or more. I do Java EE (and Spring) development in it and so far I've done 90% of my tasks without having to touch the mouse. Typically my Eclipse setup is as follow:\n\nSubclipse (or alternatively I use command line) \nm2clipse (Maven Eclipse plugin) \nData Source Explorer (dealing with SQL)\n\nThe typical Eclipse activities I do (and would like to transfer that to Vim\/Emacs) are (this is for multi-module\/multi-projects\/multi-folder source code):\n\nRefactor (rename method throughout the whole \"open project\")\nJump to class implementation\nSearch for all usage of a particular class or method\nUpdating dependencies (3rd party JARs) via maven pom.xml\nJump to the 3rd party library implementation (maven can download the source.jar if local repository does not have it, eclipse will bring me to the actual Java code for let say, Hibernate entity manager implementation).\nWrite and run unit-test\n\nAll of the above activities would not require me to use mouse. There are a few activities where I would need to use a little bit of mouse such as Global Search file\nLately I've been wanting to try development using VMs. The idea here is to create a barebone VM (let's say to use Ubuntu Server) and start coding there or use Putty\/SSH. \nI have a MacBook Pro 13\" which would benefit of using VIM\/Emacs or any lightweight editor.\nThere are 2 major goals:\n\nMobility (as in, travelling and coding)\nVM as development environment\n\nTools I'd like to use are as follow:\n\nLinux\nRuby, Python, PHP (and occasionally maybe even Java but definitely not Microsoft .NET)\nAny RDBMS\nAny build\/dependency system\nUnit-testing framework\n\nWhat would you recommend: VIM? Emacs? Others? What about other tools? Gnu Screen, ctags, etc. \nHelp me build my dream environment: lightweight, productive, easily replicable :)\nThanks!","AnswerCount":5,"Available Count":3,"Score":0.1194272985,"is_accepted":false,"ViewCount":1355,"Q_Id":8001384,"Users Score":3,"Answer":"I am an Emacs guy (using vi only to edit configuration files under \/etc). I think that with Emacs, you should start it at most daily (and it is very different with vim), and you should configure it in your .emacs file. For example, I compile using the F12 key, with (global-set-key [f12] 'recompile) in my .emacs.","Q_Score":6,"Tags":"python,ruby,linux,vim,emacs","A_Id":8001512,"CreationDate":"2011-11-03T20:24:00.000","Title":"How to become productive using Vim\/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":1,"Web Development":1},{"Question":"I've been an Eclipse user for the last 3 years or more. I do Java EE (and Spring) development in it and so far I've done 90% of my tasks without having to touch the mouse. Typically my Eclipse setup is as follow:\n\nSubclipse (or alternatively I use command line) \nm2clipse (Maven Eclipse plugin) \nData Source Explorer (dealing with SQL)\n\nThe typical Eclipse activities I do (and would like to transfer that to Vim\/Emacs) are (this is for multi-module\/multi-projects\/multi-folder source code):\n\nRefactor (rename method throughout the whole \"open project\")\nJump to class implementation\nSearch for all usage of a particular class or method\nUpdating dependencies (3rd party JARs) via maven pom.xml\nJump to the 3rd party library implementation (maven can download the source.jar if local repository does not have it, eclipse will bring me to the actual Java code for let say, Hibernate entity manager implementation).\nWrite and run unit-test\n\nAll of the above activities would not require me to use mouse. There are a few activities where I would need to use a little bit of mouse such as Global Search file\nLately I've been wanting to try development using VMs. The idea here is to create a barebone VM (let's say to use Ubuntu Server) and start coding there or use Putty\/SSH. \nI have a MacBook Pro 13\" which would benefit of using VIM\/Emacs or any lightweight editor.\nThere are 2 major goals:\n\nMobility (as in, travelling and coding)\nVM as development environment\n\nTools I'd like to use are as follow:\n\nLinux\nRuby, Python, PHP (and occasionally maybe even Java but definitely not Microsoft .NET)\nAny RDBMS\nAny build\/dependency system\nUnit-testing framework\n\nWhat would you recommend: VIM? Emacs? Others? What about other tools? Gnu Screen, ctags, etc. \nHelp me build my dream environment: lightweight, productive, easily replicable :)\nThanks!","AnswerCount":5,"Available Count":3,"Score":0.1973753202,"is_accepted":false,"ViewCount":1355,"Q_Id":8001384,"Users Score":5,"Answer":"If you ask a question which involves \"vim OR emacs\" you will never get an useful answer. It's a religious question, which does not have a correct answer! That said, you should clearly use Vim! ;-)\nBut seriously: Vim is much more lightweight, so it might better suite the scenario you are describing. Vim can be scripted in different languages and you can find many useful scripts at www.vim.org.\nEmacs is \"heavier\", but Lisp is a very powerful scripting languages. So Emacs is much more of a general tool than just a text editor. IDE functionality (like project management) is something I'm missing from time to time in Vim. There are some scripts to do that, but I don't like them. If you need that, I would go for Emacs.","Q_Score":6,"Tags":"python,ruby,linux,vim,emacs","A_Id":8001471,"CreationDate":"2011-11-03T20:24:00.000","Title":"How to become productive using Vim\/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":1,"Web Development":1},{"Question":"I've been an Eclipse user for the last 3 years or more. I do Java EE (and Spring) development in it and so far I've done 90% of my tasks without having to touch the mouse. Typically my Eclipse setup is as follow:\n\nSubclipse (or alternatively I use command line) \nm2clipse (Maven Eclipse plugin) \nData Source Explorer (dealing with SQL)\n\nThe typical Eclipse activities I do (and would like to transfer that to Vim\/Emacs) are (this is for multi-module\/multi-projects\/multi-folder source code):\n\nRefactor (rename method throughout the whole \"open project\")\nJump to class implementation\nSearch for all usage of a particular class or method\nUpdating dependencies (3rd party JARs) via maven pom.xml\nJump to the 3rd party library implementation (maven can download the source.jar if local repository does not have it, eclipse will bring me to the actual Java code for let say, Hibernate entity manager implementation).\nWrite and run unit-test\n\nAll of the above activities would not require me to use mouse. There are a few activities where I would need to use a little bit of mouse such as Global Search file\nLately I've been wanting to try development using VMs. The idea here is to create a barebone VM (let's say to use Ubuntu Server) and start coding there or use Putty\/SSH. \nI have a MacBook Pro 13\" which would benefit of using VIM\/Emacs or any lightweight editor.\nThere are 2 major goals:\n\nMobility (as in, travelling and coding)\nVM as development environment\n\nTools I'd like to use are as follow:\n\nLinux\nRuby, Python, PHP (and occasionally maybe even Java but definitely not Microsoft .NET)\nAny RDBMS\nAny build\/dependency system\nUnit-testing framework\n\nWhat would you recommend: VIM? Emacs? Others? What about other tools? Gnu Screen, ctags, etc. \nHelp me build my dream environment: lightweight, productive, easily replicable :)\nThanks!","AnswerCount":5,"Available Count":3,"Score":0.0399786803,"is_accepted":false,"ViewCount":1355,"Q_Id":8001384,"Users Score":1,"Answer":"Either of those text editors will have a learning curve. That being said I have successfully used emacs to do the following tasks that are in line w\/ what you've asked:\n\nWrite PL\/SQL and execute it on an oracle DB all from the editor.\nWrite, Compile, Run java. \nEdit pom files. \nKeep a pretty good TODO list in org mode.\n\nYou can launch a shell in emacs, and that feature alone does MOST of what you've asked for (SVN, make\/ant\/mvn\/etc).\nIf you're jumping into one of these editors and hoping for pretty eclipse and vis studio features such as the green junit bar, i'm not sure that they exist. Eclipse' refactor tool works pretty well too and I don't know what is possible in emacs. Though with emacs, I've found that someone has typically written some extension to do what i want, you just need to be able to find it and learn how to use it. I'm an emacs neophyte at best but in scaled down projects I've found it to be pretty efficient and I don't have to take my hands off the keyboard very much. \nDisclaimer(java\/ee\/spring eclipse developer by day that messes around with lua and the love framework using emacs at night)","Q_Score":6,"Tags":"python,ruby,linux,vim,emacs","A_Id":8001983,"CreationDate":"2011-11-03T20:24:00.000","Title":"How to become productive using Vim\/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":1,"Web Development":1},{"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},{"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},{"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},{"Question":"I am looking for an algorithm that is implemented in C, C++, Python or Java that calculates the set of winning coalitions for n agents where each agent has a different amount of votes. I would appreciate any hints. Thanks!","AnswerCount":3,"Available Count":2,"Score":0.1973753202,"is_accepted":false,"ViewCount":373,"Q_Id":8019172,"Users Score":3,"Answer":"In other words, you have an array X[1..n], and want to have all the subsets of it for which sum(subset) >= 1\/2 * sum(X), right?\nThat probably means the whole set qualifies. \nAfter that, you can drop any element k having X[k] < 1\/2 * sum(X), and every such a coalition will be fine as an answer, too.\nAfter that, you can proceed dropping elements one by one, stopping when you've reached half of the sum. \nThis is obviously not the most effective solution: you don't want to drop k1=1,k2=2 if you've already tried k1=2,k2=1\u2014but I believe you can handle this.","Q_Score":1,"Tags":"java,c++,python,c,algorithm","A_Id":8019217,"CreationDate":"2011-11-05T08:59:00.000","Title":"Coalition Search Algorithm","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},{"Question":"I am looking for an algorithm that is implemented in C, C++, Python or Java that calculates the set of winning coalitions for n agents where each agent has a different amount of votes. I would appreciate any hints. Thanks!","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":373,"Q_Id":8019172,"Users Score":0,"Answer":"Arrange the number of votes for each of the agents into an array, and compute the partial sums from the right, so that you can find out SUM_i = k to n Votes[i] just by looking up the partial sum.\nThen do a backtrack search over all possible subsets of {1, 2, ...n}. At any point in the backtrack you have accepted some subset of agents 0..i - 1, and you know from the partial sum the maximum possible number of votes available from other agents. So you can look to see if the current subset could be extended with agents number >= i to form a winning coalition, and discard it if not.\nThis gives you a backtrack search where you consider a subset only if it is already a winning coalition, or you will extend it to become a winning coalition. So I think the cost of the backtrack search is the sum of the sizes of the winning coalitions you discover, which seems close to optimal. I would be tempted to rearrange the agents before running this so that you deal with the agents with most votes first, but at the moment I don't see an argument that says you gain much from that.\nActually - taking a tip from Alf's answer - life is a lot easier if you start from the full set of agents, and then use backtrack search to decide which agents to discard. Then you don't need an array of partial sums, and you only generate subsets you want anyway. And yes, there is no need to order agents in advance.","Q_Score":1,"Tags":"java,c++,python,c,algorithm","A_Id":8019235,"CreationDate":"2011-11-05T08:59:00.000","Title":"Coalition Search Algorithm","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},{"Question":"I have a server running nginx + UWSGI + python. UWSGI is running as a daemon with the flag set: --daemonize \/var\/log\/uwsgi.log which logs all application errors.\nI've noticed that on error if I use a python print statement it will write to the log but only on an error. The standard python logging library doesn't seem to affect the log in any situation.\nHow do I point the python logging libraries to use the UWSGI log?","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":11471,"Q_Id":8022495,"Users Score":4,"Answer":"use logging.StreamHandler as logging handler","Q_Score":8,"Tags":"python,logging,nginx,uwsgi","A_Id":8022616,"CreationDate":"2011-11-05T18:58:00.000","Title":"How to write to log in python with nginx + uwsgi","Data Science and Machine Learning":0,"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},{"Question":"I have a server running nginx + UWSGI + python. UWSGI is running as a daemon with the flag set: --daemonize \/var\/log\/uwsgi.log which logs all application errors.\nI've noticed that on error if I use a python print statement it will write to the log but only on an error. The standard python logging library doesn't seem to affect the log in any situation.\nHow do I point the python logging libraries to use the UWSGI log?","AnswerCount":2,"Available Count":2,"Score":0.4621171573,"is_accepted":false,"ViewCount":11471,"Q_Id":8022495,"Users Score":5,"Answer":"uWSGI is a wsgi server, and as such passes a stream in the environ dict passed to the application callable it hosts, using the key wsgi.errors. If you are writing a bare wsgi app, then writing to that stream should do the job. If you are using a framework that abstracts the wsgi interface out (and by the sound of it, you are, print would ordinarily write to sys.stdout, which gets closed on a daemonized process and would never make it to any log file), you will probably need to look into how that framework handles error logging.","Q_Score":8,"Tags":"python,logging,nginx,uwsgi","A_Id":8022729,"CreationDate":"2011-11-05T18:58:00.000","Title":"How to write to log in python with nginx + uwsgi","Data Science and Machine Learning":0,"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},{"Question":"Is there a good way to check a form input using regex to make sure it is a proper style email address? Been searching since last night and everybody that has answered peoples questions regarding this topic also seems to have problems with it if it is a subdomained email address.","AnswerCount":18,"Available Count":2,"Score":-1.0,"is_accepted":false,"ViewCount":384064,"Q_Id":8022530,"Users Score":-4,"Answer":"The only really accurate way of distinguishing real, valid email addresses from invalid ones is to send mail to it. What counts as an email is surprisingly convoluted (\"John Doe\" \" actually is a valid email address), and you most likely want the email address to actually send mail to it later. After it passes some basic sanity checks (such as in Thomas's answer, has an @ and at least one . after the @), you should probably just send an email verification letter to the address, and wait for the user to follow a link embedded in the message to confirm that the email was valid.","Q_Score":240,"Tags":"python,regex,email-validation,email-address","A_Id":8022687,"CreationDate":"2011-11-05T19:05:00.000","Title":"How to check for valid email 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":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Is there a good way to check a form input using regex to make sure it is a proper style email address? Been searching since last night and everybody that has answered peoples questions regarding this topic also seems to have problems with it if it is a subdomained email address.","AnswerCount":18,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":384064,"Q_Id":8022530,"Users Score":0,"Answer":"Use this filter mask on email input:\nemailMask: \/[\\w.\\-@'\"!#$%&'*+\/=?^_{|}~]\/i`","Q_Score":240,"Tags":"python,regex,email-validation,email-address","A_Id":54658606,"CreationDate":"2011-11-05T19:05:00.000","Title":"How to check for valid email 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":1,"System Administration and DevOps":0,"Web Development":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},{"Question":"I've used easy_install to get one or two modules, then I used pip to install the Twitter module.\nHowever the newer version of Python I downloaded can't see these modules, only the built in OSX version can.\nAlso, I am now unable to download NLTK which I need for some examples I'm working through on a really good book called \"Mining the Social Web\".\nAny thoughts?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":840,"Q_Id":8035412,"Users Score":1,"Answer":"Install the packages with the binary from your version of python.\nSo for example if your version is in \/usr\/local\/bin then installing would be either:\n\n\/usr\/local\/bin\/python setup.py ...\n\/usr\/local\/bin\/easy_install ...\n\/usr\/local\/bin\/pip install ...","Q_Score":1,"Tags":"python,macos,python-3.x","A_Id":8035989,"CreationDate":"2011-11-07T10:50:00.000","Title":"Install Python modules on new 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":0,"System Administration and DevOps":0,"Web Development":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},{"Question":"I first learned web programming with php a while back. It has some features that I find very helpful, but the overall language is not something I enjoy, just as a matter of personal preference. I am wondering what alternatives I could use to provide similar functionality using a different underlying programming language (Python? Ruby?).\nWhat I am looking for:\n\ngeneral purpose programming capability\nin-line server-side code embedded in HTML (i.e. I want to be able to make my documents pure HTML if desired, rather than demanding special syntax even where I don't want dynamic content)\naccess to request parameters\nability to send headers, set cookies, etc\n\nPreferably:\n\ndoes not require a separate server process\neasy to connect with Apache\n\nDoes anyone have any suggestions?\nOne thing I tried to do was embedded Ruby (erb) through CGI. This looked like a good fit on paper. Unfortunately, I was not able to get it to work, because I was following a few different guides and the result of combining them did not work out. At any rate, it seems this would not allow me to set arbitrary headers (and more importantly, use sessions and cookies).\nNote: I'm not looking for a full web framework at the moment. Just relatively small amounts of dynamic content among otherwise HTML pages.\nThanks!","AnswerCount":5,"Available Count":1,"Score":0.1194272985,"is_accepted":false,"ViewCount":7993,"Q_Id":8045630,"Users Score":3,"Answer":"I'd say given your requirement\n\nJust relatively small amounts of dynamic content among otherwise HTML pages.\n\nthen, PHP is going to be hard to beat for getting going quickly and a minimum of learning overhead. It avoids all the CGI issues that you would otherwise have to deal with, and is in fact its own templating language. That's why so many get started with it. Once you get past the point of your goal of mixing a little programming logic into HTML pages, and developing more flexible, maintainable and testable applications, then frameworks such as Rails, Django and others will be worth your time to learn.","Q_Score":12,"Tags":"php,python,ruby,web-applications","A_Id":8045724,"CreationDate":"2011-11-08T03:32:00.000","Title":"Alternatives to php for in-line web programming?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"In Python IDE, while we save the script, it will prompt the save Dialog. If we specify the filename as \"Test\". Then file will be saved without extension as \"Test\" and not \"Test.py\".\nIs it possible to save the script with .py extension automatically (as Test.py)?","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":3171,"Q_Id":8048702,"Users Score":2,"Answer":"Unfortunately, IDLE doesn't and can't add the .py extension automatically; you will just have to get into the habit of adding it yourself, or use another IDE like Eclipse or Komodo that will do it for you.","Q_Score":2,"Tags":"python,save,python-idle","A_Id":8058543,"CreationDate":"2011-11-08T10:03:00.000","Title":"Save Python scripts with .py extension 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":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I plan to build a photo-sharing site like Flickr\/Picasa for photographers, with features most suited for them. As you know, if that venture proves successful, many GB to TB of data transfers take place every day.\nThis question is not just about scalability of my application as it grows, but also performance. I would like to make an informed decision. I think I'd go with MySQL database, JavaScript\/jQuery for client-side scripting, but what server-side language with it, is the question - - PHP, Python, Ruby or something else?\nAnd there are definitely somethings to keep in mind when developing an application (i.e., scalable coding) that needs to scale over a period time. If any that you would like to suggest, what are they?\nNOTE: I am specifying \"Photo-sharing site\" in order to give you an idea of my mission. Otherwise, this question wouldn't look as subjective. Kindly take it that way.","AnswerCount":3,"Available Count":3,"Score":0.1325487884,"is_accepted":false,"ViewCount":1102,"Q_Id":8051087,"Users Score":2,"Answer":"PHP can do it well. Python also can do it using web frameworks like Django or turbogears.\nThat being said, language is not an issue as long as it has web capabilities which your post seems to dictate","Q_Score":4,"Tags":"php,python,ruby,scalability","A_Id":8051192,"CreationDate":"2011-11-08T13:25:00.000","Title":"Language best for a Photo-sharing site: PHP, Python, Ruby 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":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I plan to build a photo-sharing site like Flickr\/Picasa for photographers, with features most suited for them. As you know, if that venture proves successful, many GB to TB of data transfers take place every day.\nThis question is not just about scalability of my application as it grows, but also performance. I would like to make an informed decision. I think I'd go with MySQL database, JavaScript\/jQuery for client-side scripting, but what server-side language with it, is the question - - PHP, Python, Ruby or something else?\nAnd there are definitely somethings to keep in mind when developing an application (i.e., scalable coding) that needs to scale over a period time. If any that you would like to suggest, what are they?\nNOTE: I am specifying \"Photo-sharing site\" in order to give you an idea of my mission. Otherwise, this question wouldn't look as subjective. Kindly take it that way.","AnswerCount":3,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":1102,"Q_Id":8051087,"Users Score":0,"Answer":"I've done Web applications in PHP, ColdFusion, Java, and Ruby, with various frameworks. I find Rails to be the most powerful Web framework I've ever used. Nothing can really equal it, because the power comes from the Ruby language, and no other language (except maybe Smalltalk) can really equal that. That said, as long as you use proper development practice, you should be able to get it done in almost any language.\nHowever, you do not want to use MySQL as a database. PostgreSQL is far more powerful and scalable, and doesn't have MySQL's silly limitations and gotchas.","Q_Score":4,"Tags":"php,python,ruby,scalability","A_Id":8052193,"CreationDate":"2011-11-08T13:25:00.000","Title":"Language best for a Photo-sharing site: PHP, Python, Ruby 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":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I plan to build a photo-sharing site like Flickr\/Picasa for photographers, with features most suited for them. As you know, if that venture proves successful, many GB to TB of data transfers take place every day.\nThis question is not just about scalability of my application as it grows, but also performance. I would like to make an informed decision. I think I'd go with MySQL database, JavaScript\/jQuery for client-side scripting, but what server-side language with it, is the question - - PHP, Python, Ruby or something else?\nAnd there are definitely somethings to keep in mind when developing an application (i.e., scalable coding) that needs to scale over a period time. If any that you would like to suggest, what are they?\nNOTE: I am specifying \"Photo-sharing site\" in order to give you an idea of my mission. Otherwise, this question wouldn't look as subjective. Kindly take it that way.","AnswerCount":3,"Available Count":3,"Score":1.2,"is_accepted":true,"ViewCount":1102,"Q_Id":8051087,"Users Score":7,"Answer":"Any. The language doesn't matter. Ruby-fanatics (especially the RubyOnRails sort) will try and tell you that their language will do everything in only 10 lines and it'll make you dinner and pick the kids up from school. Others will tell you that their language is the most secure, fastest, quickest to develop in, etc. Ignore them.\nI love Python and I'd love to recommend it - but seriously, it won't make a difference. Just pick the language you know the best and get writing. So if that's Java, start writing Java. If that's C++, hell, start writing C++.\nI don't believe the people who say that [insert language here] is fastest to develop in. It's all about what you find comfortable. Some langauges provide extra functionality but you can always write a library that provides that if you need it - it shouldn't take too long and, chances are, someone has already done it.\nRemember: Facebook is written in PHP (though they compile a lot of that PHP to C++ now for speed), MySpace was written in C#\/ColdFusion (I believe), Twitter uses Ruby On Rails (though they plan to abandon it apparently), Google uses Java\/Go (I think) and LinkedIn uses ASP.net or something I think. My point is - tonnes of services, tonnes of languages and they're all doing ok. Right now, any language will do.\nMy favourite little phrase is \"just build it\". Whilst it's a good idea to have a nice architecture and think about performance and scalability - if those things will make you abandon the project half way through, what's the point in bothering? Besides, chances are you'll need to recode a large part of it anyway later on, assuming the project grows. Really think that Facebook are using the same code they were at the start?\nSo, in summary, pick whichever language you want. It'll be fine.","Q_Score":4,"Tags":"php,python,ruby,scalability","A_Id":8051120,"CreationDate":"2011-11-08T13:25:00.000","Title":"Language best for a Photo-sharing site: PHP, Python, Ruby 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":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have a few functions written in C for a game project. These functions get called quite a lot (about 2000-4000 times per second). The functions are written in C for raw speed.\nNow, the easiest way for me to include these functions into Python is to use ctypes. The alternative is to write a C extension to Python around these functions (which takes quite a bit of extra effort). So I wondered, not including the initial loading of the DLL, how big is the overhead of ctypes?\n\nI'm using Python 2.7 (the standard CPython release), and I do not want to use an external library like Cython.\nI know this question has been asked before, but I haven't seen much information about the performance comparison between the two options.","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":7501,"Q_Id":8067171,"Users Score":18,"Answer":"I've compared the performance of a C extension vs. a ctypes wrapper. In my particular test, the difference was about 250x. There were multiple calls into the C library so the ctypes wrapper was also executing Python code. The running time for the C library was very short which made the extra overhead for Python code even more significant. So the ratio will likely be different for you but was significant in my case.","Q_Score":25,"Tags":"python,c,ctypes,overhead","A_Id":8069179,"CreationDate":"2011-11-09T15:21:00.000","Title":"ctypes vs C extension","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},{"Question":"I have a few functions written in C for a game project. These functions get called quite a lot (about 2000-4000 times per second). The functions are written in C for raw speed.\nNow, the easiest way for me to include these functions into Python is to use ctypes. The alternative is to write a C extension to Python around these functions (which takes quite a bit of extra effort). So I wondered, not including the initial loading of the DLL, how big is the overhead of ctypes?\n\nI'm using Python 2.7 (the standard CPython release), and I do not want to use an external library like Cython.\nI know this question has been asked before, but I haven't seen much information about the performance comparison between the two options.","AnswerCount":2,"Available Count":2,"Score":1.0,"is_accepted":false,"ViewCount":7501,"Q_Id":8067171,"Users Score":9,"Answer":"The directly C coded interface has the potential to be much much faster. The bottleneck is the interface from Python to C and marshalling arguments and results may for example involve copying strings or converting Python lists to\/from C arrays. If you have a loop that makes several hundred of these calls and some of the data doesn't have to be marshalled separately for each call then all you have to do is recode the loop in C and you may be able to massively reduce the bottleneck. ctypes doesn't give you that option: all you can do is call the existing functions directly.\nOf course that all depends on exactly what sort of functions you are calling and what sort of data you are passing around. It may be that you can't reduce the overheads in which case I would still expect ctypes to be slower but perhaps not significantly.\nYour best best would be to put together some sample of your code written each way and benchmark it. Otherwise there are just too many variables for a definitive answer.","Q_Score":25,"Tags":"python,c,ctypes,overhead","A_Id":8067399,"CreationDate":"2011-11-09T15:21:00.000","Title":"ctypes vs C extension","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},{"Question":"Is there an equivalent of cons in Python? (any version above 2.5)\nIf so, is it built in? Or do I need easy_install do get a module?","AnswerCount":6,"Available Count":1,"Score":0.0333209931,"is_accepted":false,"ViewCount":8394,"Q_Id":8073882,"Users Score":1,"Answer":"No. cons is an implementation detail of Lisp-like languages; it doesn't exist in any meaningful sense in Python.","Q_Score":8,"Tags":"python,lisp,cons","A_Id":8073914,"CreationDate":"2011-11-10T01:12:00.000","Title":"LISP cons 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},{"Question":"When I send credentials using the login method of the python SMTP library, do they go off the wire encrypted or as plaintext?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":232,"Q_Id":8074227,"Users Score":3,"Answer":"They will only be encrypted if you use SMTP with TLS or SSL.","Q_Score":1,"Tags":"python,security,smtp,credentials","A_Id":8074236,"CreationDate":"2011-11-10T02:12:00.000","Title":"sending an email using python SMTP library credentials security","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},{"Question":"I hope this isn't knocked for being too general, but... I recently had occasion to learn web2py for a final year university project. In this subject teams of four had 8 weeks to design a web app. Ultimately i found that web2py was quite versatile, with it being very easy to get a site up and running fast, a lot of options (janrain etc) - but the end \"style\" result relied almost entirely on us.\nAmongst the other teams, who used other frameworks (each team a different one on the whole), a few of the sites came out with a very slick polished look, without them having to spend much photoshop\/css design time and effort. I got the impression that some frameworks are more \"friendly\" when it came to out of the box design elements (buttons, navigation options, widgets, base css etc) while others aren't.\nI have a python (\/C\/java) background, and intend to learn PHP some point. What frameworks exist out there that provided a base for site design beyond the bare bones? And to emphasise, I have browsed the python page listing frameworks, i am more interested in the design aspect - even if just to see if my assumption was correct.","AnswerCount":4,"Available Count":2,"Score":0.049958375,"is_accepted":false,"ViewCount":249,"Q_Id":8077886,"Users Score":1,"Answer":"I feel your pain. As a developer coming from the desktop world and doing some web development, I'm used to setting up the appearance of my application at the same time I select and arrange my user interface widgets.\nYou will just have to accept that browser based software does not work that way. You must separately learn CSS. Hopefully, you'll learn to like this method of specifying the appearance of the application but whether you do or not there really isn't any alternative to this approach in the browser.","Q_Score":0,"Tags":"python,css,frameworks","A_Id":8082137,"CreationDate":"2011-11-10T10:12:00.000","Title":"Web Frameworks with site style inbuilt","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I hope this isn't knocked for being too general, but... I recently had occasion to learn web2py for a final year university project. In this subject teams of four had 8 weeks to design a web app. Ultimately i found that web2py was quite versatile, with it being very easy to get a site up and running fast, a lot of options (janrain etc) - but the end \"style\" result relied almost entirely on us.\nAmongst the other teams, who used other frameworks (each team a different one on the whole), a few of the sites came out with a very slick polished look, without them having to spend much photoshop\/css design time and effort. I got the impression that some frameworks are more \"friendly\" when it came to out of the box design elements (buttons, navigation options, widgets, base css etc) while others aren't.\nI have a python (\/C\/java) background, and intend to learn PHP some point. What frameworks exist out there that provided a base for site design beyond the bare bones? And to emphasise, I have browsed the python page listing frameworks, i am more interested in the design aspect - even if just to see if my assumption was correct.","AnswerCount":4,"Available Count":2,"Score":0.049958375,"is_accepted":false,"ViewCount":249,"Q_Id":8077886,"Users Score":1,"Answer":"So far what I've seen about Yii Framework (PHP) is that it can generate an initial nice Styled Web Application backbone, ready for you to work in it adding your functionality, DBs, User roles, etc. and of course all the freedom to define your own Look and Feel by defining HTML views, CSS, JS, etc.\nI'm about to start learning and using a PHP Framework for my next project. I have never yet used a Framework but I have several years using PHP\/MySQL.\nFor some weeks I have researched on PHP Frameworks and there are CakePHP, CodeIgniter, Zend, Yii, Kohana, etc. and I'm leaning to Yii even though CodeIgniter seems to have more followers I'm stubborn on checking out Yii because of the high praise is getting specially in its quality built and performance.\nI wouldn't know how good the other PHP frameworks are on the \"default visual style\" area.","Q_Score":0,"Tags":"python,css,frameworks","A_Id":8085839,"CreationDate":"2011-11-10T10:12:00.000","Title":"Web Frameworks with site style inbuilt","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I have ArcGIS 9.3, Eclipse Indigo with PyDev plugin installed. I am unable to configure PyDev so the autocompletion of arcgis functions will work.\nI have added python interpreter and path to arcgis bin folder. I am able to run script, import of arcgiscripting works but autocompletion shows only functions that i already used in code, not all possible functions.\nReading other posts i found that in arcgis 10 there is arcpy folder that should be added to pythonpath, i cant find similar folder in arcgis 9.3 version.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":620,"Q_Id":8078073,"Users Score":0,"Answer":"There isn't a similar folder for ArcGIS 9.3. ESRI did a major refactor of the Python API when going from 9.3 to 10 and there are many differences, of which this is one. I found Eclipse very useful for geocoding but I don't recall autocomplete working with ArcGIS 9.3, but I do recall there was an ESRI folder you needed to list in the Eclipse paths though - probably wherever arcgisscript lives. I also remember having to tweak the PYTHONPATH environment variable. Sorry for being vague but my memory is a bit sketchy because I have long since moved to v10.","Q_Score":1,"Tags":"python,eclipse,autocomplete,pydev,arcgis","A_Id":8596504,"CreationDate":"2011-11-10T10:27:00.000","Title":"ArcGIS Eclipse PyDev - code autocomplete not working","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I am trying to set up python environment on AIX 6.1 TL7, python-2.7.1-1.aix6.1.ppc.rpm installation was successful, however when I try to use BaseHttpServer I am getting following error: \n\nImportError: No module named _md5\n\nPlease advise\nThank You, \nm.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1049,"Q_Id":8080885,"Users Score":1,"Answer":"I worked it around by extracting md5.so from hashlib.a. fortunately dynamic library was in the archive.","Q_Score":1,"Tags":"python,aix,import","A_Id":8165999,"CreationDate":"2011-11-10T14:04:00.000","Title":"aix 6.1: python: ImportError: No module named _md5","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I write a python telnet client to communicate with a server through telnet. However, many people tell me that it's no secure. How can I convert it to ssh? Should I need to totally rewrite my program?","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":1247,"Q_Id":8088742,"Users Score":1,"Answer":"While Telnet is insecure, it's essentially just a serial console over a network, which makes it easy to code for. SSH is much, much more complex. There's encryption, authentication, negotiation, etc to do. And it's very easy to get wrong in spectacular fashion.\nThere's nothing wrong with Telnet per se, but if you can change things over the network - and it's not a private network - you're opening yourself up for trouble.\nAssuming this is running on a computer, why not restrict the server to localhost? Then ssh into the computer and telnet to localhost? All the security with minimal hassle.","Q_Score":0,"Tags":"python,security,ssh,telnet","A_Id":8088775,"CreationDate":"2011-11-11T01:44:00.000","Title":"python: convert telnet application to ssh","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},{"Question":"I have a page with a lot of ads being loaded in piece by piece.\nI need to position an element relative to overall page height, which is changing during load, because of ads being added.\nQuestion: Is there a jquery event or similar to detect, when all elements are loaded? I'm currently \"waiting\" with setTimeout, but this is far from nice.\nAn idle event would be nice, which fires once after pageload if no new http requests are made for xyz secs.","AnswerCount":4,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":6659,"Q_Id":8093297,"Users Score":0,"Answer":"Ideally the answer would be $(function(){ }) or window.onload = function(){} that fires after all the DOM contents are loaded. But I guess, the ads on your page starts loading asynchronously after the DOM load. \nSo, assuming you know the number of 'ads' on your page (you said you are loading them piece by piece), my advise would be to increment a counter on each successful 'ad' load. When that counter reaches the total number of ads, you fire a 'all_adv_loaded' function.","Q_Score":3,"Tags":"jquery,events,python-idle","A_Id":8093470,"CreationDate":"2011-11-11T11:26:00.000","Title":"jquery - can I detect once all content is loaded?","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},{"Question":"What tools or techniques can help avoid bugs, especially silly mistakes such as typos, coding in Python and Django?\nI know unit-testing every line of code is the \"proper\" way, but are there any shortcuts?\nI know of pylint, but unfortunately it doesn't check Django ORM named parameters, where a typo can go unnoticed. Is there any tool that can handle this kind of bugs? \nA colleague thought of an idea to gather smart statistics on tokens (for example about named parameters to functions...), and when a once-in-a-code-base token is encountered it is warned as possible typo.\nDo you know of any tool that does something similar?","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":189,"Q_Id":8110952,"Users Score":0,"Answer":"Thank you for your answers, I'll check these tools.\nI wanted to share with you other ideas (none python\/django specific):\n\nAssert conditions in code - but remove from production code.\nRun periodic checks on the data (eg. sending email to dev when found unexpected state) - in case a bug slips by it may be detected faster, before more data is corrupt (but alas after some of it is already corrupt).\nMake a single bottom-line test (perhaps simulating user input), that covers most of the program. It may catch exceptions and asserts and is may be easier to maintain than many tests.","Q_Score":2,"Tags":"python,django,debugging,static-analysis","A_Id":8152166,"CreationDate":"2011-11-13T10:31:00.000","Title":"tools or techniques to help avoid mistakes in 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":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"I've spent last 2 days trying to launch examples from Boost.Python with the \"ImportError: DLL load failed: The specified module could not be found\" error, while trying to load compiled (using bjam) pyd modules. I was using Windows 7 x64, Python 2.7 x64 with Boost 1.47. I've followed up different answers on StackOverflow and other sites incl. fresh installs (Python 32 and 64 bit, Boost precompiled), manual Boost's libraries building, DLL checks with dependency walker and so on, with no luck. I registered to share the solution, which worked here and which I hope may help someone, struggling with the same error ;)","AnswerCount":3,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":5048,"Q_Id":8111664,"Users Score":2,"Answer":"The problem was with the KB2264107 Windows update (http:\/\/support.microsoft.com\/kb\/2264107), \"messing\" with DLL search routine (security fix). Setting the registry value [HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Control\\Session Manager] : CWDIllegalInDllSearch to 0, allowed to properly load DLL files and properly import .pyd modules. This may also happen on other Windows versions.","Q_Score":5,"Tags":"python,windows-7,import,boost-python","A_Id":8115457,"CreationDate":"2011-11-13T12:56:00.000","Title":"Boost.Python examples, Windows 7 x64, \"ImportError: DLL load failed: The specified module could not be found.\"","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I've spent last 2 days trying to launch examples from Boost.Python with the \"ImportError: DLL load failed: The specified module could not be found\" error, while trying to load compiled (using bjam) pyd modules. I was using Windows 7 x64, Python 2.7 x64 with Boost 1.47. I've followed up different answers on StackOverflow and other sites incl. fresh installs (Python 32 and 64 bit, Boost precompiled), manual Boost's libraries building, DLL checks with dependency walker and so on, with no luck. I registered to share the solution, which worked here and which I hope may help someone, struggling with the same error ;)","AnswerCount":3,"Available Count":2,"Score":1.0,"is_accepted":false,"ViewCount":5048,"Q_Id":8111664,"Users Score":6,"Answer":"Two solution, no need to use regedit\n\nadd BOOST_PYTHON_STATIC_LIB marco when build your dll. It will let\nboost.python static link to your dll file rather than dynamic load\nin runtime.\nadd boost.python dll to PATH or copy it to same dir where your dll locate","Q_Score":5,"Tags":"python,windows-7,import,boost-python","A_Id":35737001,"CreationDate":"2011-11-13T12:56:00.000","Title":"Boost.Python examples, Windows 7 x64, \"ImportError: DLL load failed: The specified module could not be found.\"","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I would have a quite simple question, but can't find any suitable automated solution for now. \nI have developed an algorithm that performs a lot of stuff (image processing in fact) in Python. \nWhat I want to do now is to optimize it. And for that, I would love to create a graph of my algorithm.\nKind of an UML chart or sequencial chart in fact, in which functions would be displayed with inputs and ouptuts. \nMy algorithm does not imply complex stuff, and is mainly based on a = f(b) operations (no databases, hardware stuff, server, . . . )\nWould you have any hint? \nThanks by advance !","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":435,"Q_Id":8119900,"Users Score":1,"Answer":"UML generation is provided by pyreverse - it's part of pylint package\nIt generates UML in dot format - or png, etc.\nIt creates UML diagram, so you can easily see basic structure of your code\nI'm not sure if it satisfy all your needs, but it might be helpful","Q_Score":5,"Tags":"python,coding-style","A_Id":8121141,"CreationDate":"2011-11-14T10:01:00.000","Title":"Get the complete structure of a program?","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},{"Question":"Some of the Apache modules are related to programming languages, like mod_php and mod_python. The description is basically \"enables usage of php within apache\" or \"enables usage of python within apache\". I'm trying to understand an overview of how these types of \"language\" modules work.","AnswerCount":2,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":645,"Q_Id":8129088,"Users Score":4,"Answer":"This is relatively simple; When the webserver starts, it will register modules within its core. Language interpreter modules, like mod_php, will register a hook within the page request handler.\nThis means when a user requests a page, the webserver will pass the request to the module, which checks if the requested file is a type that is registered to be executed by the parser behind the module. In PHP's case you are most likely adding \"AddType application\/x-httpd-php .php\" or similar to the httpd.conf file, which mod_php, will take into account when parsing such requests.\nPHP is now in control of the request, which will read the file, parse, compile and execute it and then return it to the request buffer which the webserver will serve as content.\nSame goes for other modules, although their handling of a request is different, they all do the same thing.","Q_Score":1,"Tags":"php,python,apache,mod-python,mod-php","A_Id":8129667,"CreationDate":"2011-11-14T22:26:00.000","Title":"How do mod_php, mod_python, mod_Language 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":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am building an extension of ORMLite to target Android.\nWhat I want to do \nI want to reproduce one of the behavior that Doctrine and Symfony are achieving in PHP with models.\nIn a word: \n\nFrom a yml file generate a bunch of BaseModel class with accessors\nand things that won't change.\nLet the real model inherits from this\nBaseModel so that the user changes could persist even if they regenerate the models from the yml.\n\nMy question\nI was wondering if this is good in practice to try to achieve such an objective on Android or if this will be risky in terms of performance (the heavy usage of inheritance).\nIf you think that it is clumsy, how can I allow the user to change the .yml file, generate the model and do no start from scratch rebuilding the customized aspects of his model.\nI know this can be done by some \"trick\" but I really would like not to reinvent the wheel.\nEDIT\nSorry, I forgot to add: I am using python to do this.\nThanks","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":992,"Q_Id":8153264,"Users Score":2,"Answer":"It's the correct, and probably only, Java way. In Java all calls are virtual anyway unless you use final all over the place, but that means you couldn't even use interfaces. So most calls will probably be virtual dispatch whatever you do. Inheritance does not incur any other significant penalty.\nBesides, Android devices are generally so powerful that trying to sqeeze out tiny bits of performance at the cost of readability and maintainability of the program is almost certainly not needed. In fact, most android devices are almost as powerful as web servers that do the same things in much slower PHP and still manage thousands of users while the Android device serves one.","Q_Score":1,"Tags":"java,android,python,performance,inheritance","A_Id":8153347,"CreationDate":"2011-11-16T14:29:00.000","Title":"Cost of Inheritance Java (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":0,"Web Development":1},{"Question":"What is is the significance of doctest in Sphinx? Can someone help me understand its use with a simple example.","AnswerCount":3,"Available Count":2,"Score":0.1973753202,"is_accepted":false,"ViewCount":308,"Q_Id":8162020,"Users Score":3,"Answer":"Sphinx's doctest is for testing the documentation itself. In other words, it allows for the automatic verification of the documentation's sample code. While it might also verify whether the Python code works as expected, Sphinx is unnecessary for that purpose alone (you could more easily use the standard library's doctest module).\nSo, a real-world scenario (one I find myself in on a regular basis) goes something like this: a new feature is nearing completion, so I write some documentation to introduce the new feature. The new docs contain one or more code samples. Before publishing the documentation, I run make doctest in my Sphinx documentation directory to verify that the code samples I've written for the audience will actually work.","Q_Score":1,"Tags":"python,python-sphinx,restructuredtext","A_Id":18234027,"CreationDate":"2011-11-17T04:12:00.000","Title":"What is the real world use or significance of sphinx doctest?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"What is is the significance of doctest in Sphinx? Can someone help me understand its use with a simple example.","AnswerCount":3,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":308,"Q_Id":8162020,"Users Score":1,"Answer":"I haven't used it myself but it is my understanding that it extends the functionality of doctest. For example it adds testsetup and testcleanup directives which you can put your set-up and tear-down logic in. Making it possible for Sphinx to exclude that in the documentation.","Q_Score":1,"Tags":"python,python-sphinx,restructuredtext","A_Id":18168477,"CreationDate":"2011-11-17T04:12:00.000","Title":"What is the real world use or significance of sphinx doctest?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"How it possible to speed up debugging in PyDev in Eclipse for Google App Engine programs?\n\nHow to speed up code execution?\nHow to speed up application reloading?\n\nPlease share your experience or suggestions.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":291,"Q_Id":8169561,"Users Score":0,"Answer":"How often do you need to reload the application?, the dev server will update all your code and configuration changes without need to reload.","Q_Score":0,"Tags":"python,debugging,google-app-engine,optimization,pydev","A_Id":8169698,"CreationDate":"2011-11-17T15:18:00.000","Title":"How to speed up debugging of python programs in PyDev in Eclipse (esspecially 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},{"Question":"We are currently using nginx as a web server along with PHP-FPM as the php application service. We have a small application which needs to be built but must use Python3. Is their a similar option to use for Python?","AnswerCount":4,"Available Count":1,"Score":0.049958375,"is_accepted":false,"ViewCount":3316,"Q_Id":8185374,"Users Score":1,"Answer":"You can try uwscgi. Easy to config and high performance.","Q_Score":1,"Tags":"python,nginx,php","A_Id":10713125,"CreationDate":"2011-11-18T16:10:00.000","Title":"using python like php with nginx","Data Science and Machine Learning":0,"Database and SQL":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},{"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=,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},{"Question":"I am planning on writing a small program that interacts with a debian based repository - namely doing a partial mirror**. I am planning to write it in python.\nWhat are some tips for working with the repository including already constructed 'wheels' (to save the invention of yet another one)?\nSome issues I have identified\n\nAs it is going to be a partial mirror, I will need to regenerate the package lists (Release,Contents*, Packages.{bz2,gz}). (Maybe debian-installer can do it for me??)\nHow to get changes to package list (I already know that packages do not change, but that the lists only link to the latest file)?\n\n** Already looked into apt-mirror and debmirror. Debmirror is the closest to what I want, however lacking in some features. If apt can deal with multiple releases and architectures then I will consider apt.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":200,"Q_Id":8191239,"Users Score":0,"Answer":"debian-installer doesn't generate repository metadata. For that, you want a tool like reprepro or mini-dinstall. They'll also handle the second point you raised.","Q_Score":1,"Tags":"python,deb","A_Id":8816534,"CreationDate":"2011-11-19T01:49:00.000","Title":"Tips for interacting with debian based repositories","Data Science and Machine Learning":0,"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},{"Question":"How do you manage generated source code files in you repositories and deployment routines with Git (PHP, Python, etc)?\nFor example, I have a repository named \"interfaces\" with Thrift definitions in it. They can be converted to Python, PHP, JS, etc skeletons\/stubs. Other projects in different languages, each in its own repository, want to use those stubs. How to deliver the stubs to the projects?\nI see only two ways:\n\nGenerate the stub files and store them in the \"interfaces\" repository, and this repository should be attached to the projects' ones (as readonly submodule or any other way). But this way introduces a lot of headaches when checking out the updates to the interfaces and the stubs due to overcomplicated \"git submodules\" concepts.\nAttach pure \"interfaces\" repository to each project, and generate stub files as temporary git-ignorable(!) files (with \"make stubs\" or alike). This way, each project can have their own generation settings with their own patches applied (if needed at all). But you need to introduce some compilation commands to PHP\/Python development and production environments (not just \"git pull\").\n\nWhat are the pros and cons of these approaches?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":526,"Q_Id":8201189,"Users Score":0,"Answer":"I think the #2 is way to go, if nothing else because you do not want git to auto merge generated files.\nIn your php or python app initialization code, you could check timestamp on idl files and generated stubs, and issue warning and\/or abort, or start thrift compiler if available.","Q_Score":4,"Tags":"php,python,git,deployment,thrift","A_Id":8208766,"CreationDate":"2011-11-20T11:26:00.000","Title":"How to distribute Thrift-generated code in development and production environments with 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":1,"System Administration and DevOps":0,"Web Development":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},{"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},{"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},{"Question":"I wanted to install WSGI on a RedHat linux box in order to make a Python server interface, but the only way I could find to do that was to use modwsgi, which is an Apache module. The whole reason I'm using WSGI is that I don't want to use Apache, so this kinda defeats the purpose. \nDoes anyone know of actual WSGI packages for RedHat linux or is this the only way? \n----Edit----\nI just found out that WSGI is built into Python 2.5 and higher, so I don't need to install anything. I don't know how to mark this question as solved without answering it myself. Any tips will be appreciated.","AnswerCount":3,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":591,"Q_Id":8221114,"Users Score":0,"Answer":"I found out that WSGI is included in Python 2.5 and above, so you don't need to do any installs. Just say things like from wsgiref import make_server.","Q_Score":1,"Tags":"python,packages,redhat","A_Id":8221263,"CreationDate":"2011-11-22T02:08:00.000","Title":"Using WSGI on Redhat 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},{"Question":"I wanted to install WSGI on a RedHat linux box in order to make a Python server interface, but the only way I could find to do that was to use modwsgi, which is an Apache module. The whole reason I'm using WSGI is that I don't want to use Apache, so this kinda defeats the purpose. \nDoes anyone know of actual WSGI packages for RedHat linux or is this the only way? \n----Edit----\nI just found out that WSGI is built into Python 2.5 and higher, so I don't need to install anything. I don't know how to mark this question as solved without answering it myself. Any tips will be appreciated.","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":591,"Q_Id":8221114,"Users Score":0,"Answer":"WSGI is a protocol. In order to use it you need a WSGI container such as mod_wsgi, Paste Deploy, CherryPy, or wsgiref.","Q_Score":1,"Tags":"python,packages,redhat","A_Id":8221832,"CreationDate":"2011-11-22T02:08:00.000","Title":"Using WSGI on Redhat 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},{"Question":"I'm trying to monitor log files that some process are running on linux(to create a joint log file where log entries are grouped together by when they happen). Currently I'm thinking of opening the files being logged, polling with inotify(or wrapper) and then checking if I can read any more of the file. \nIs there any better way to do this? Perhaps some library which abstracts the reading\/changes in the files watched?","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":3207,"Q_Id":8227308,"Users Score":0,"Answer":"If you do it yourself, you might do something like this: If you detect file modification, get the size of the file. If it's larger than last time you can seek to the previous \"last\" position (i.e. the previous size) and read from there.","Q_Score":5,"Tags":"python,linux,logging","A_Id":8227859,"CreationDate":"2011-11-22T13:07:00.000","Title":"Is there a better way to monitor log files?(linux\/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},{"Question":"I'm trying to monitor log files that some process are running on linux(to create a joint log file where log entries are grouped together by when they happen). Currently I'm thinking of opening the files being logged, polling with inotify(or wrapper) and then checking if I can read any more of the file. \nIs there any better way to do this? Perhaps some library which abstracts the reading\/changes in the files watched?","AnswerCount":3,"Available Count":2,"Score":0.1973753202,"is_accepted":false,"ViewCount":3207,"Q_Id":8227308,"Users Score":3,"Answer":"Why won't a \"tail -f\" be sufficient? You could use popen and pipes to handle this from Python.","Q_Score":5,"Tags":"python,linux,logging","A_Id":8235200,"CreationDate":"2011-11-22T13:07:00.000","Title":"Is there a better way to monitor log files?(linux\/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},{"Question":"when im running C code to call python functions, there's error on Py_Initialize() The error is ImportError: No module named site. Ive tried to put Py_SetProgramName(argv[0]) but it doesnt work. The cmd call is cInterfacePython Test.py multiply 3 2 (exe is cInterfacePython)","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":2355,"Q_Id":8232708,"Users Score":3,"Answer":"I had to muck about a bit with the PATH env-var as well as PYTHONPATH to make things work better when embedding.\nPy_SetProgramName is not important, it's mostly for internal reference etc...\nSo, I suggest you find where python is installed locally (this is available in the registry on Windows machines) and use setenv to set PATH and PYTHONPATH to something appropriate. That would be the python.exe directory for PATH (as in your comment above), as well setting PYTHONPATH to the dir with your own python code and related libraries that you're running from the embedding exe.\nThen run Py_Initialize and see if the right thing happens. If you need to modify PYTHONPATH afterward initialization, modify sys.path using PySys_SetPath().","Q_Score":2,"Tags":"python,c,python-c-api,python-c-extension,python-embedding","A_Id":8233228,"CreationDate":"2011-11-22T19:38:00.000","Title":"embedding python error on initialization","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"when im running C code to call python functions, there's error on Py_Initialize() The error is ImportError: No module named site. Ive tried to put Py_SetProgramName(argv[0]) but it doesnt work. The cmd call is cInterfacePython Test.py multiply 3 2 (exe is cInterfacePython)","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":2355,"Q_Id":8232708,"Users Score":1,"Answer":"I was having the same problem (Windows, both with Visual Studio and MinGW\/g++), and I solved it by adding to PYTHONPATH the path to site.py.\nFor some reason, launching python.exe was possible even without it, and sys.path did contain that path (even when PYTHONPATH did not), and I could \"import site\", but Py_Initialize was not able to do the same thing that python.exe did.","Q_Score":2,"Tags":"python,c,python-c-api,python-c-extension,python-embedding","A_Id":14369084,"CreationDate":"2011-11-22T19:38:00.000","Title":"embedding python error on initialization","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Im using PyUnit to write unit tests for my code. The setup method is called everytime before any test is run.\nIs there a way i can define a method that will be run just once at the beginning before any tests are run ?\nPlease Help\nThank You","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":449,"Q_Id":8240444,"Users Score":0,"Answer":"How about using the constructor of your test class?","Q_Score":6,"Tags":"python,unit-testing,tdd,python-unittest","A_Id":8240560,"CreationDate":"2011-11-23T10:15:00.000","Title":"Running a method just once at the beginning before any tests are run in PyUnit","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have some unit tests that are timing sensitive: an action is timed and an error is triggered if it takes too long. When run individually, these tests pass, but when running nosetest recursively on my modules, they often fail. I run concurrent tests, which likely is one reason why the timing is off. Is there any way to indicate that I want this test to be run with no interruptions?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":163,"Q_Id":8242209,"Users Score":1,"Answer":"I think your problem is dependent from how you implemented the timing. The solution I would personally adopt would be to set an environment variable that controls the behaviour of the tests. Candidates could be:\n\nif WITH_TIMING == False [turn off timing altogether]\nTIME_STRETCH_FACTOR = ... [apply a time-stretching multiplier in case of concurrent test are run, so that for example a time limit of 5 would become 7.5 if TIME_STRETCH_FACTOR would be 1.5]\n\nIf this is not an option, a possible ugly workaround would be to mock the time.time() function, making it return a constant value [this would only work if you use time.time() in your tests directly of course]...\nHTH","Q_Score":0,"Tags":"python,nose,nosetests","A_Id":8242339,"CreationDate":"2011-11-23T12:29:00.000","Title":"Timing issues in Python nose test","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Using Python, I am trying to write to a USB sensor using ioctl. I have loads of examples of reading from devices either directly or via pyusb, or simple file writes, but anything more complicated disappears off the radar. \nI need to use a control_transfer to write Feature Report message\nThe command is ioctl(devicehandle, Operation, Args)\nThe issue I have is determining the correct Operation. The Args, I believe should be a buffer containing the Feature Report for the device? plus a Mutable flag set to true\nAny help or advice would be greatly received\nI should add; the reason for using Python is the code must be device independent.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":5132,"Q_Id":8244887,"Users Score":0,"Answer":"According to the documentation, ioctl() in the fcntl module is unix specific, so it will not work in Windows. There seems to be a Windows variant named DeviceIoControl() that works similarly.\nIOCTLs are declared by the device driver or operating system, so I very much doubt that there are IOCTL operations that have the same operation id (IOCTL number) and same parameters on different operating systems.\nFor Linux, you can check the header files for specific device drivers or possibly some usb core header file for valid IOCTLs.","Q_Score":2,"Tags":"python,usb","A_Id":8245298,"CreationDate":"2011-11-23T15:35:00.000","Title":"Writing to USB device with Python using ioctl","Data Science and Machine Learning":0,"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},{"Question":"I was wondering if it's possible to \u00e9dit an existing pdf file with Pdfminer. It seens to be a powerful tool, but the documentation is poor\/inexisting.\nI found some exemples, but they don't match with my goal. I want to make a search engine which changes the color of my keywords in the pdf file.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2097,"Q_Id":8248622,"Users Score":0,"Answer":"PDFMiner is not for altering existing PDF files, but for extracting text and metadata from them. The closest solution to what you're looking for using PDFMiner would probably be to use the included pdf2txt.py tool to extract the text and then mark that up to highlight your keywords.\nThere's also the simple option of just using a PDF viewer with the built-in ability to find and highlight multiple search terms. I think Adobe Acrobat can do it, but I'm not sure about others.","Q_Score":1,"Tags":"python,pdf","A_Id":8249589,"CreationDate":"2011-11-23T20:28:00.000","Title":"Edit pdf file with PDFMiner","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":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},{"Question":"I have some autogenerated python files that are extremely large (long mathematical equations). Vim slows to a crawl when I open them for editing because I have pyflakes-vim installed. I'd like to be able to disable pyflakes-vim only when I open these long files. Is there a simple way to do this, either before opening the file or even after? I do not want to turn off pyflakes-vim for all python files, just a case-by-case basis.","AnswerCount":3,"Available Count":1,"Score":0.2605204458,"is_accepted":false,"ViewCount":2784,"Q_Id":8275095,"Users Score":4,"Answer":"PyFlakes won't run if b:did_pyflakes_plugin is defined when the plugin is loaded, but once it's loaded I don't think there's an easy way to disable it.\nWhat I would do is give the auto-generated files a specific file name pattern (say *_auto.py) and then add to my .vimrc: autocmd BufReadPre *_auto.py :let b:did_pyflakes_plugin=1.","Q_Score":0,"Tags":"python,vim,pyflakes","A_Id":8275265,"CreationDate":"2011-11-25T23:28:00.000","Title":"How do I disable pyflakes-vim for a particular 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},{"Question":"The t_error() function is used to handle lexing errors that occur when illegal characters are detected. My question is: How can I use this function to get more specific information on errors? Like error type, in which rule or section the error appears, etc.","AnswerCount":3,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":3180,"Q_Id":8284169,"Users Score":3,"Answer":"In general, there is only very limited information available to the t_error() function. As input, it receives a token object where the value has been set to the remaining input text. Analysis of that text is entirely up to you. You can use the t.lexer.skip(n) function to have the lexer skip ahead by a certain number of characters and that's about it. \nThere is no notion of an \"error type\" other than the fact that there is an input character that does not match the regular expression of any known token. Since the lexer is decoupled from the parser, there is no direct way to get any information about the state of the parsing engine or to find out what grammar rule is being parsed. Even if you could get the state (which would simply be the underlying state number of the LALR state machine), interpretation of it would likely be very difficult since the parser could be in the intermediate stages of matching dozens of possible grammar rules looking for reduce actions.\nMy advice is as follows: If you need additional information in the t_error() function, you should set up some kind of object that is shared between the lexer and parser components of your code. You should explicitly make different parts of your compiler update that object as needed (e.g., it could be updated in specific grammar rules).\nJust as aside, there are usually very few courses of action for a bad token. Essentially, you're getting input text that doesn't any known part of the language alphabet (e.g., no known symbol). As such, there's not even any kind of token value you can give to the parser. Usually, the only course of action is to report the bad input, throw it out, and continue.\nAs a followup to Raymond's answer, I would also not advise modifying any attribute of the lexer object in t_error().","Q_Score":3,"Tags":"python,error-handling,lexer,ply","A_Id":8291315,"CreationDate":"2011-11-27T07:11:00.000","Title":"lexer error-handling PLY 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},{"Question":"I need to generate a sine wave sound in Python, and I need to be able to control frequency, duration, and relative volume. By 'generate' I mean that I want it to play though the speakers immediately, not save to a file.\nWhat is the easiest way to do this?","AnswerCount":6,"Available Count":1,"Score":0.1325487884,"is_accepted":false,"ViewCount":68751,"Q_Id":8299303,"Users Score":4,"Answer":"One of the more consistent andeasy to install ways to deal with sound in Python is the Pygame multimedia libraries.\nI'd recomend using it - there is the pygame.sndarray submodule that allows you to manipulate numbers in a data vector that become a high-level sound object that can be playerd in the pygame.mixer module.\nThe documentation in the pygame.org site should be enough for using the sndarray module.","Q_Score":46,"Tags":"python,audio","A_Id":8300219,"CreationDate":"2011-11-28T16:51:00.000","Title":"Generating sine wave sound 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},{"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},{"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},{"Question":"I'm writing an IRC bot using twisted python, and some actions should only be available to channel operators. How do I determine the 'user level' of a user in a channel using twisteds IRCClient?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1572,"Q_Id":8300545,"Users Score":0,"Answer":"You can also use channel access lists if your bot has permissions to do so.","Q_Score":3,"Tags":"python,twisted,irc","A_Id":9563454,"CreationDate":"2011-11-28T18:32:00.000","Title":"Check if user is 'voiced' or 'op' in IRC channel using twisted","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I am working with a Python function that sends mails wich include an attachment and a HTML message......I want to add an image on the HTML message using \n\nWhen I try it, the message respects the tag, but does not display the image I want (it displays the not found image \"X\").....\ndoes anyone know if this is a problem with the MIME thing....because i am using the MIMEMultipart('Mixed').....\nor it is a problem with the path of the image (I'm using the same path for the atachment file and there is no problem with it)....\nI dont know what else could it be!!\nthanks a lot!!","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":431,"Q_Id":8301501,"Users Score":1,"Answer":"You need to write src=\"cid:ContentId\" to refer to an attached image, where ContentId is the ID of the MIME part.","Q_Score":0,"Tags":"python,html,mime-types,sendmail,mime-message","A_Id":8301559,"CreationDate":"2011-11-28T19:53:00.000","Title":"Image in the HTML email message","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},{"Question":"I am working with a Python function that sends mails wich include an attachment and a HTML message......I want to add an image on the HTML message using \n\nWhen I try it, the message respects the tag, but does not display the image I want (it displays the not found image \"X\").....\ndoes anyone know if this is a problem with the MIME thing....because i am using the MIMEMultipart('Mixed').....\nor it is a problem with the path of the image (I'm using the same path for the atachment file and there is no problem with it)....\nI dont know what else could it be!!\nthanks a lot!!","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":431,"Q_Id":8301501,"Users Score":1,"Answer":"In your html you need the fully qualified path to the image: http:\/\/yourdomain.com\/images\/image.jpg\nYou should be able to take the URL in the image tag, paste it into the browser's address bar and view it there. If you can't see it, you've got the wrong path.","Q_Score":0,"Tags":"python,html,mime-types,sendmail,mime-message","A_Id":8301539,"CreationDate":"2011-11-28T19:53:00.000","Title":"Image in the HTML email message","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},{"Question":"I am trying to build a system that accepts text and outputs the phonetic spelling of the words of this text. Any ideas on what libraries can be used in Python and Java?","AnswerCount":4,"Available Count":1,"Score":0.049958375,"is_accepted":false,"ViewCount":5615,"Q_Id":8302553,"Users Score":1,"Answer":"Are you looking for something akin to the international phonetic alphabet (IPA) or some other phonetic output? If ARPAbet is ok, there is the CMU pronouncing dictionary (http:\/\/www.speech.cs.cmu.edu\/cgi-bin\/cmudict). That'll give the ARPAbet rendering of most words in English. I've written some code that converts the ARPAbet spelling to IPA and post to github if you'd like.","Q_Score":8,"Tags":"java,python,text-processing,text-mining,spelling","A_Id":8546969,"CreationDate":"2011-11-28T21:26:00.000","Title":"phonetic spelling in Python and 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":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have been trying to get a project of mine to run but I have run into trouble. After much debugging I have narrowed down the problem but have no idea how to proceed.\nSome background, I am using a python script inside C++ code. This is somewhat documented on Python, and I managed to get it running very well in my basic executable. #include and a -lpython2.6 and everything was grand.\nHowever, difficulty has arisen when running this python script from a shared library(.so). This shared library is \"loaded\" as a \"module\" by a simulation system (OpenRAVE). The system interacts with this module using a virtual method for \"modules\" called SendCommand. The module then starts a boost::thread, giving python its own thread, and returns to the simulation system. However, when python begins importing its modules and thus loading its dynamic libraries it fails, I assume due to the following error:\n ImportError: \/usr\/lib\/python2.6\/dist-packages\/numpy\/core\/multiarray.so: undefined symbol: _Py_ZeroStruct \nI have run ldd on my executable and the shared library, there doesn't some to be a difference. I have also run nm -D on the file above, the _Py_ZeroStruct is indeed undefined. If you guys would like print outs of the commands I would be glad to supply them. Any advice would be greatly appreciated, thank you.\nHere is the full python error:\n\nTraceback (most recent call last):\n File \"\/usr\/lib\/python2.6\/dist-packages\/numpy\/__init__.py\", line 130, in \n import add_newdocs\n File \"\/usr\/lib\/python2.6\/dist-packages\/numpy\/add_newdocs.py\", line 9, in \n from lib import add_newdoc\n File \"\/usr\/lib\/python2.6\/dist-packages\/numpy\/lib\/__init__.py\", line 4, in \n from type_check import *\n File \"\/usr\/lib\/python2.6\/dist-packages\/numpy\/lib\/type_check.py\", line 8, in \n import numpy.core.numeric as _nx\n File \"\/usr\/lib\/python2.6\/dist-packages\/numpy\/core\/__init__.py\", line 5, in \n import multiarray\nImportError: \/usr\/lib\/python2.6\/dist-packages\/numpy\/core\/multiarray.so: undefined symbol: _Py_ZeroStruct\nTraceback (most recent call last):\n File \"\/home\/constantin\/workspace\/OpenRAVE\/src\/grasp_behavior_2.py\", line 3, in \n from openravepy import *\n File \"\/home\/constantin\/workspace\/rospackages\/openrave\/lib\/python2.6\/site-packages\/openravepy\/__init__.py\", line 35, in \n openravepy_currentversion = loadlatest()\n File \"\/home\/constantin\/workspace\/rospackages\/openrave\/lib\/python2.6\/site-packages\/openravepy\/__init__.py\", line 16, in loadlatest\n return _loadversion('_openravepy_')\n File \"\/home\/constantin\/workspace\/rospackages\/openrave\/lib\/python2.6\/site-packages\/openravepy\/__init__.py\", line 19, in _loadversion\n mainpackage = __import__(\"openravepy\", globals(), locals(), [targetname])\n File \"\/home\/constantin\/workspace\/rospackages\/openrave\/lib\/python2.6\/site-packages\/openravepy\/_openravepy_\/__init__.py\", line 29, in \n from openravepy_int import *\nImportError: numpy.core.multiarray failed to import","AnswerCount":4,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":9662,"Q_Id":8302810,"Users Score":2,"Answer":"The solution was linking the python2.6 library with my executable as well.\nEven though the executable made no python calls, it needed to be linked with the python library. I assume its because my shared library doesn't pass the symbols of python library through to the executable. If anyone could explain why my executable (which loads my dynamic library at runtime, without linking) needs those symbols it would be great.\nFor clarification, my program model is something like:\n[My Executable] -(dynamically loads)-> [My Shared Library] -(calls and links with)-> [Python shared Library]","Q_Score":12,"Tags":"python,shared-libraries,undefined-symbol,openrave","A_Id":8313757,"CreationDate":"2011-11-28T21:46:00.000","Title":"Undefined Symbol in C++ When Loading a Python Shared 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":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have been trying to get a project of mine to run but I have run into trouble. After much debugging I have narrowed down the problem but have no idea how to proceed.\nSome background, I am using a python script inside C++ code. This is somewhat documented on Python, and I managed to get it running very well in my basic executable. #include and a -lpython2.6 and everything was grand.\nHowever, difficulty has arisen when running this python script from a shared library(.so). This shared library is \"loaded\" as a \"module\" by a simulation system (OpenRAVE). The system interacts with this module using a virtual method for \"modules\" called SendCommand. The module then starts a boost::thread, giving python its own thread, and returns to the simulation system. However, when python begins importing its modules and thus loading its dynamic libraries it fails, I assume due to the following error:\n ImportError: \/usr\/lib\/python2.6\/dist-packages\/numpy\/core\/multiarray.so: undefined symbol: _Py_ZeroStruct \nI have run ldd on my executable and the shared library, there doesn't some to be a difference. I have also run nm -D on the file above, the _Py_ZeroStruct is indeed undefined. If you guys would like print outs of the commands I would be glad to supply them. Any advice would be greatly appreciated, thank you.\nHere is the full python error:\n\nTraceback (most recent call last):\n File \"\/usr\/lib\/python2.6\/dist-packages\/numpy\/__init__.py\", line 130, in \n import add_newdocs\n File \"\/usr\/lib\/python2.6\/dist-packages\/numpy\/add_newdocs.py\", line 9, in \n from lib import add_newdoc\n File \"\/usr\/lib\/python2.6\/dist-packages\/numpy\/lib\/__init__.py\", line 4, in \n from type_check import *\n File \"\/usr\/lib\/python2.6\/dist-packages\/numpy\/lib\/type_check.py\", line 8, in \n import numpy.core.numeric as _nx\n File \"\/usr\/lib\/python2.6\/dist-packages\/numpy\/core\/__init__.py\", line 5, in \n import multiarray\nImportError: \/usr\/lib\/python2.6\/dist-packages\/numpy\/core\/multiarray.so: undefined symbol: _Py_ZeroStruct\nTraceback (most recent call last):\n File \"\/home\/constantin\/workspace\/OpenRAVE\/src\/grasp_behavior_2.py\", line 3, in \n from openravepy import *\n File \"\/home\/constantin\/workspace\/rospackages\/openrave\/lib\/python2.6\/site-packages\/openravepy\/__init__.py\", line 35, in \n openravepy_currentversion = loadlatest()\n File \"\/home\/constantin\/workspace\/rospackages\/openrave\/lib\/python2.6\/site-packages\/openravepy\/__init__.py\", line 16, in loadlatest\n return _loadversion('_openravepy_')\n File \"\/home\/constantin\/workspace\/rospackages\/openrave\/lib\/python2.6\/site-packages\/openravepy\/__init__.py\", line 19, in _loadversion\n mainpackage = __import__(\"openravepy\", globals(), locals(), [targetname])\n File \"\/home\/constantin\/workspace\/rospackages\/openrave\/lib\/python2.6\/site-packages\/openravepy\/_openravepy_\/__init__.py\", line 29, in \n from openravepy_int import *\nImportError: numpy.core.multiarray failed to import","AnswerCount":4,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":9662,"Q_Id":8302810,"Users Score":0,"Answer":"Check your python-headers and python's runtime. It looks like you have mix of 2.5 and 2.6 versions.","Q_Score":12,"Tags":"python,shared-libraries,undefined-symbol,openrave","A_Id":8303699,"CreationDate":"2011-11-28T21:46:00.000","Title":"Undefined Symbol in C++ When Loading a Python Shared 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":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Many problems I've ran into in Python have been related to not having something in Unicode. Is there any good reason to not use Unicode by default? I understand needing to translate something in ASCII, but it seems to be the exception and not the rule. \nI know Python 3 uses Unicode for all strings. Should this encourage me as a developer to unicode() all my strings?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":131,"Q_Id":8302833,"Users Score":6,"Answer":"Generally, I'm going to say \"no\" there's not a good reason to use string over unicode. Remember, as well, that you don't have to call unicode() to create a unicode string, you can do so by prefixing the string with a lowercase u like u\"this is a unicode string\".","Q_Score":6,"Tags":"python,unicode","A_Id":8302860,"CreationDate":"2011-11-28T21:48:00.000","Title":"Is there any good reason not to use unicode as opposed to 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},{"Question":"In RStudio, you can run parts of code in the code editing window, and the results appear in the console.\nYou can also do cool stuff like selecting whether you want everything up to the cursor to run, or everything after the cursor, or just the part that you selected, and so on. And there are hot keys for all that stuff. \nIt's like a step above the interactive shell in Python -- there you can use readline to go back to previous individual lines, but it doesn't have any \"concept\" of what a function is, a section of code, etc. \nIs there a tool like that for Python? Or, do you have some sort of similar workaround that you use, say, in vim?","AnswerCount":10,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":92404,"Q_Id":8305809,"Users Score":0,"Answer":"Wing IDE, and probably also other Python IDEs like PyCharm and PyDev have features like this. In Wing you can either select and execute code in the integrated Python Shell or if you're debugging something you can interact with the paused debug program in a shell (called the Debug Probe). There is also special support for matplotlib, in case you're using that, so that you can work with plots interactively.","Q_Score":183,"Tags":"python,ide","A_Id":16095116,"CreationDate":"2011-11-29T04:21:00.000","Title":"Is there something like RStudio 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},{"Question":"In Linux, I am trying to debug the C++ code of a shared library which is loaded from Python code. The loading is done using the ctypes package. In Eclipse, I set breakpoints both in the Python and in the C++ code, however Eclipse just skips the breakpoints in the C++ code (breakpoints in the Python code work OK). \nI have tried using attach to application in Eclipse (under Debug Configurations) and choosing the Python process, but it didn't change anything. In the attach to application dialog box I choose the shared library as the Project, and I choose \/usr\/bin\/python2.6 as the C\/C++ application. Is that the correct way?\nI've tried it both before running the python code, and after a breakpoint in the Python code was caught, just before the line calling a function of the shared library.\nEDIT\nMeanwhile I am using a workaround of calling the python code and debugging using a gdb command-line session by attaching to the python process. But I would like to hear a solution to doing this from within Eclipse.","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":3167,"Q_Id":8307425,"Users Score":2,"Answer":"I have been able to debug the c++ shared library loaded by the python in Eclipse successfully. \nThe prerequisites:\nTwo eclipse projects in an eclipse workspace: one is the C++ project, from which the c++ shared library is generated, the other is the python project (PyDev), which loads the generated c++ shared library.\nThe steps are:\n\ncreate a \"Python Run\" debug configuration named PythonDebug with the corresponding python environment and parameters\ncreate a \"C\/C++ Attach to Application\" debug configuration named CppDebug. The project field is the C++ project, leave the C\/C++ Application field empty\nset a breakpoint in python code where after the c++ shared library has already been loaded\nstart the debug session PythonDebug, the program will be breaked at the created breakpoint at step 3\nstart the debug session CppDebug, a menu will be popped up, select python process with correct pid (there will be 3 pids, the correct one can be found in PythonDebug session)\nset a breakpoint in c++ source code where you want the program to break\ncontinue the PythonDebug session\ncontinue the CppDebug session\nthe program will break at the c++ breakpoint\n\nI tested the above procedure with Eclipse Mars version.\nHopefully it helps.","Q_Score":3,"Tags":"python,debugging,gdb,shared-libraries,eclipse-cdt","A_Id":34515642,"CreationDate":"2011-11-29T07:51:00.000","Title":"Eclipse: debug shared library loaded 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},{"Question":"I have two python scripts running as cronjobs.\nScriptA processes log files and insert records to a table, ScriptB uses the records to generate a report.\nI have arranged ScriptA to run one hour before ScriptB, but sometimes ScriptB run before ScriptA finish inserting, thus generating a incorrect report.\nHow do I make sure ScriptB runs right after ScriptA finishes?\nEDIT\nScriptA and ScriptB do very different things, say, one is for saving user data, the other is for internal use. And somewhere else there maybe some ScriptC depending on ScriptA.\nSo I can't just merge these two jobs.","AnswerCount":4,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":3971,"Q_Id":8320304,"Users Score":0,"Answer":"Make it write a file and check if the file is there.","Q_Score":4,"Tags":"python,bash,cron,crontab","A_Id":8320318,"CreationDate":"2011-11-30T02:06:00.000","Title":"How to make sure a script only runs after another 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},{"Question":"I have two python scripts running as cronjobs.\nScriptA processes log files and insert records to a table, ScriptB uses the records to generate a report.\nI have arranged ScriptA to run one hour before ScriptB, but sometimes ScriptB run before ScriptA finish inserting, thus generating a incorrect report.\nHow do I make sure ScriptB runs right after ScriptA finishes?\nEDIT\nScriptA and ScriptB do very different things, say, one is for saving user data, the other is for internal use. And somewhere else there maybe some ScriptC depending on ScriptA.\nSo I can't just merge these two jobs.","AnswerCount":4,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":3971,"Q_Id":8320304,"Users Score":0,"Answer":"an approach that you could use it! is having some flag of control! somewhere, for example in the DB! \nSo ScriptB just runs after that flag is set! and right after it finish it it sets the flag back to default state!\nAnother way that you could implement that flag approach is using file system! Like @Benjamin suggested!","Q_Score":4,"Tags":"python,bash,cron,crontab","A_Id":8320328,"CreationDate":"2011-11-30T02:06:00.000","Title":"How to make sure a script only runs after another 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},{"Question":"I have two python scripts running as cronjobs.\nScriptA processes log files and insert records to a table, ScriptB uses the records to generate a report.\nI have arranged ScriptA to run one hour before ScriptB, but sometimes ScriptB run before ScriptA finish inserting, thus generating a incorrect report.\nHow do I make sure ScriptB runs right after ScriptA finishes?\nEDIT\nScriptA and ScriptB do very different things, say, one is for saving user data, the other is for internal use. And somewhere else there maybe some ScriptC depending on ScriptA.\nSo I can't just merge these two jobs.","AnswerCount":4,"Available Count":3,"Score":1.2,"is_accepted":true,"ViewCount":3971,"Q_Id":8320304,"Users Score":2,"Answer":"One approach would be to make sure that if those two jobs are separate cron jobs - there is enough time inbetween to surely cover the run of job 1. \nAnother approach is locking, as others here suggested, but then note, that cron will not re-run your job just because it completed unsuccessfully because of a lock. So either job2 will have to run in sleep cycles until it doesn't see the lock anymore, or on the contrary sees a flag of job 1 completions, or you'll have to get creative.\nWhy not to trigger 2nd script from the 1st script after it's finished and make it a single cron job?","Q_Score":4,"Tags":"python,bash,cron,crontab","A_Id":8320343,"CreationDate":"2011-11-30T02:06:00.000","Title":"How to make sure a script only runs after another 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},{"Question":"Is there a way to password protect an application which is hosted in gunicorn,\nI did this with .htaccess in apache, but can we do this in gurnicorn?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":3648,"Q_Id":8341797,"Users Score":1,"Answer":"You can also use middleware and for example kill every session and show nothing if it not passes the requirements. For example, you can define middleware which checks if the request comes from the IP you use, if yes - do nothing, if no - stop. Maybe not the best, but solution :)","Q_Score":4,"Tags":"python,django,gunicorn","A_Id":8342278,"CreationDate":"2011-12-01T12:59:00.000","Title":"how to password protect a website hosted on 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},{"Question":"So I'm creating unit tests for all of my scripts, many of which arent oo, and have main-loop code. I was wondering what the standard is for the location of creating unittest classes in relation to the affected script. Should the unit test be in a separate file which imports the script, and then function-alize the mainloop code? Or can it shoved at the end of the the related script?","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":105,"Q_Id":8346580,"Users Score":0,"Answer":"The best practice is to have some related functionality bundled in a module. For that module, you create a separate file with unittests. The convention is to name it test_foo.py if your module is foo.py.\nWhere it sits exactly is not well defined, although a separate directory named test or something similar is common.\nAnd that has nothing to do with the nature of your code. It can be classes or functions, whatever, as long as it's testable. Of course, making it amenable to testing is not always trivial.","Q_Score":2,"Tags":"python,unit-testing","A_Id":8346679,"CreationDate":"2011-12-01T18:44:00.000","Title":"Putting unittest classes in the related script itself vs making a separate 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},{"Question":"So I'm creating unit tests for all of my scripts, many of which arent oo, and have main-loop code. I was wondering what the standard is for the location of creating unittest classes in relation to the affected script. Should the unit test be in a separate file which imports the script, and then function-alize the mainloop code? Or can it shoved at the end of the the related script?","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":105,"Q_Id":8346580,"Users Score":0,"Answer":"One additional reason for not putting the unit tests in source file is that during distribution\/packaging of your python application you can exclude all the directories that contains the tests.","Q_Score":2,"Tags":"python,unit-testing","A_Id":8346919,"CreationDate":"2011-12-01T18:44:00.000","Title":"Putting unittest classes in the related script itself vs making a separate 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},{"Question":"I am currently switching from Eclipse Java Development more and more Python scripting using PyDev. Almost all the time there is a Eclipse backgropund thread called \"reindexing PythonHome...\" which loads my CPU for almost 100%. Unusable to coding in there anymore :\/\nDo you have any idea?\nThanks a lot for your help!\nJohn","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":706,"Q_Id":8359291,"Users Score":1,"Answer":"Disable 'Build Automatically' and 'Refresh Automatically' under \nPreferences->General->Workspace\nDisable 'Code Analysis' entirely, or configure it to only run on save under \nPreferences->PyDev->Editor->Code Analysis","Q_Score":0,"Tags":"python,eclipse,cpu,pydev","A_Id":10102742,"CreationDate":"2011-12-02T16:17:00.000","Title":"Eclipse & Python: 100% CPU load due to PythonHome reindexing","Data Science and Machine Learning":0,"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},{"Question":"I would like to build an application in Google App Engine (Python) that would be fully connected to a single GMail account and then filter e-mails from this account (e.g. filter messages for a certain string and show it on the string). In the future I am also going to implement the option to send messages.\nWhat is the most efficient way to do this (solution provided by Google if possible)?","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":487,"Q_Id":8367381,"Users Score":0,"Answer":"What do you mean by \"fully connected\"?\nIt's possible to set up a GMail filter to forward emails to a different address (say, the email address of your App Engine app). And an App Engine app an send emails (say, to a GMail address). The trick is to set up the GMail filter carefully to avoid loops.","Q_Score":3,"Tags":"python,django,google-app-engine,gmail","A_Id":8373562,"CreationDate":"2011-12-03T11:39:00.000","Title":"Filtering GMail messages in Google App Engine 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":1,"Web Development":1},{"Question":"I would like to build an application in Google App Engine (Python) that would be fully connected to a single GMail account and then filter e-mails from this account (e.g. filter messages for a certain string and show it on the string). In the future I am also going to implement the option to send messages.\nWhat is the most efficient way to do this (solution provided by Google if possible)?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":487,"Q_Id":8367381,"Users Score":0,"Answer":"There is no Api for Gmail in App Engine. The only thing you can do is forwarding messages to App Engine.\nI have used fowarding for building auto responders.\nBut there is an excellent GMail Api in Google Apps Script with lots of functions. Apps scrips uses javascript. And ofcourse your apps script can communicate with App Engine.","Q_Score":3,"Tags":"python,django,google-app-engine,gmail","A_Id":8379161,"CreationDate":"2011-12-03T11:39:00.000","Title":"Filtering GMail messages in Google App Engine 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":1,"Web Development":1},{"Question":"I'm trying to figure out where does the initial sys.path value come from. One ubuntu system suddenly (by which I mean probably manually by someone doing something weird) lost entries at the end of the array.\nAll other hosts: ['', '\/usr\/lib\/python2.7', '\/usr\/lib\/python2.7\/plat-linux2', '\/usr\/lib\/python2.7\/lib-tk', '\/usr\/lib\/python2.7\/lib-old', '\/usr\/lib\/python2.7\/lib-dynload', '\/usr\/local\/lib\/python2.7\/dist-packages', '\/usr\/lib\/python2.7\/dist-packages', '\/usr\/lib\/python2.7\/dist-packages\/gtk-2.0', '\/usr\/lib\/pymodules\/python2.7']\nThat host: ['', '\/usr\/lib\/python2.7', '\/usr\/lib\/python2.7\/plat-linux2', '\/usr\/lib\/python2.7\/lib-tk', '\/usr\/lib\/python2.7\/lib-old', '\/usr\/lib\/python2.7\/lib-dynload', '\/usr\/local\/lib\/python2.7\/dist-packages', '\/usr\/lib\/python2.7\/dist-packages']\nThe \/usr\/lib\/pymodules\/python2.7 path is the one I actually care about. But where does it come from on the healthy nodes?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":649,"Q_Id":8405855,"Users Score":4,"Answer":"It comes from the python-support package, specifically from the \/usr\/lib\/python2.7\/dist-packages\/python-support.pth file that is installed.\nThere shouldn't be any modules installed to that directory manually and any package installing modules to that directory should have a dependency on the python-support package, so you shouldn't have to worry about whether it is in sys.path or not.","Q_Score":4,"Tags":"python,import,path","A_Id":8405986,"CreationDate":"2011-12-06T19:48:00.000","Title":"Where does the initial sys.path come from","Data Science and Machine Learning":0,"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},{"Question":"Background:\nI am writing an ebook editing program in python. Currently it utilizes a source-code view for editing, and I would like to port it over to a wysiwyg view for editing. The best (only?) html renderer I could find for python was webkit (I am using the PyQt version).\nQuestion:\nHow do I accomplish wysiwyg editing? The requirements\/issues are as follows:\n\nAn ebook may be up to 10,000 paragraphs \/ 1,000,000\ncharacters.\n\nPyQt Webkit (ContentEditable): No problem.\nPyQt Webkit (TinyMce, etc): Takes forever to open them!\n\nThe format is

...<\/p>

...<\/p>...<\/body>. The body element contains only paragraphs, there are no divs, etc (but in the paragraph there may be spans, links, etc.). Editing must take place with no significant delays as far as the user is concerned.\n\nPyQt Webkit (ContentEditable): If you try deleting text across multiple paragraphs, it takes forever!! My understanding is that this is because it resets the common-parent of the elements being changed - i.e. the entire body element, since two different paragraphs are being deleted\/merged. But, there should be no need for this - it should need only delete\/merge\/change those individual paragraphs!\n\n\nI am open to implementing my own wysiwyg editing, but for the life of me I can't figure out how to delete\/cut\/paste\/merge\/change the html code correctly. I searched online for articles about html wysiwyg design theory, and came up dry.\nThanks!","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":1587,"Q_Id":8412215,"Users Score":1,"Answer":"Can i suggest a complete another approach ? Since your ebook is only

<\/p>:\n\nSplit the text on

<\/p> to get an indexed array of all your paragraphs\nMake your own pagination system, and fill the screen with N paragraphs, that automatically get enough text to show from the indexed array\nWhen you are doing selection, you can use [paragraph index + character index in the paragraph] for selection start \/ end\nThen implement cut\/copy\/paste\/delete\/undo\/redo based on thoses assumptions.\n\n(Note: when you'll do a selection, since the start point is saved, you can safely change the text on the screen \/ pagination, until the selection end.)","Q_Score":2,"Tags":"python,html,wysiwyg","A_Id":8413073,"CreationDate":"2011-12-07T08:17:00.000","Title":"Python\/Javascript: WYSIWYG html editor - Handle large documents fast and\/or design theory","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},{"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},{"Question":"I mostly do work in Python, but I have been using some of the Ruby stuff for Server Configuration Management (ie Puppet and Chef). I also use Ubuntu\/Debian as my primary Linux distro for servers.\nWhy is there a weird Debian\/Ruby conflict over Gems, and not a similar showdown between Debian\/Python over Pip?\nPersonally, I don't mind installing newer packages then the \"system\" approves of. I know Debian wants to make a stable system, but when I am running my own application code on the server, I can guarantee you it's not stable to begin with. \nAnyway, I would be interested to know if Pip is doing something different, or if it's an ego thing or whatever?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":3102,"Q_Id":8433881,"Users Score":0,"Answer":"I think you should raise your problem about gem\/debian and what are you going to do with it specially.\nI am using pip and debian now and still no problem by now.","Q_Score":5,"Tags":"python,ruby,rubygems,pip","A_Id":8507138,"CreationDate":"2011-12-08T16:04:00.000","Title":"Python Pip vs Ruby Gems","Data Science and Machine Learning":0,"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},{"Question":"I have an interesting project going on at our workplace. The task, that stands before us, is such:\n\nBuild a custom server using Python\nIt has a web server part, serving REST\nIt has a FTP server part, serving files\nIt has a SMTP part, which receives mail only\nand last but not least, a it has a background worker that manages lowlevel file IO based on requests received from the above mentioned services\n\nObviously the go to place was Twisted library\/framework, which is an excelent networking tool. However, studying the docs further, a few things came up that I'm not sure about.\nHaving Java background, I would solve the task (at least at the beginning) by spawning a separate thread for each service and going from there. Being in Python however, I cannot do that for any reasonable purpose as Python has GIL. I'm not sure, how Twisted handles this. I would expect, that Twisted has large (if not majority) code written in C, where GIL is not the issue, but that I couldn't find the docs explained to my satisfaction. \nSo the most oustanding question is: Given that Twisted uses Reactor as it's main design pattern, will it be able to:\n\nServe all those services needed\nDo it in a non-blocking fashion (it should, according to docs, but if someone could elaborate, I'd be grateful)\nBe able to serve about few hundreds of clients at once\nServe large file downloads in a reasonable way, meaning that it can serve multiple clients, using multiple services, downloading and uploading large files.\n\nLarge files being in the order of hundres of MB, or few GB. The size is not important, it's the time that the client has to stay connected to the server that matters.\nEdit: I'm actually inclined to go the way of python multiprocessing, but not sure, whether that's a correct thing to do with Twisted etc.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":216,"Q_Id":8443994,"Users Score":3,"Answer":"Serve all those services needed\n\nYes.\n\nDo it in a non-blocking fashion (it should, according to docs, but if someone could elaborate, I'd be grateful)\n\nTwisted's uses the common reactor model. I\/O goes through your choice of poll, select, whatever to determine if data is available. It handles only what is available, and passes the data along to other stages of your app. This is how it is non-blocking.\nI don't think it provides non-blocking disk I\/O, but I'm not sure. That feature not what most people need when they say non-blocking.\n\nBe able to serve about few hundreds of clients at once\n\nYes. No. Maybe. What are those clients doing? Is each hitting refresh every second on a browser making 100 requests? Is each one doing a numerical simulation of galaxy collisions? Is each sending the string \"hi!\" to the server, without expecting a response?\nTwisted can easily handle 1000+ requests per second.\n\nServe large file downloads in a reasonable way, meaning that it can serve multiple clients, using multiple services, downloading and uploading large files.\n\nSure. For example, the original version of BitTorrent was written in Twisted.","Q_Score":1,"Tags":"python,twisted","A_Id":8445796,"CreationDate":"2011-12-09T10:14:00.000","Title":"Compound custom service server using Twisted","Data Science and Machine Learning":0,"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},{"Question":"I'm tracking a linux filesystem (that could be any type) with pyinotify module for python (which is actually the linux kernel behind doing the job). Many directories\/folders\/files (as much as the user want to) are being tracked with my application and now i would like track the md5sum of each file and store them on a database (includes every moving, renaming, new files, etc).\nI guess that a database should be the best option to store all the md5sum of each file... But what should be the best database for that? Certainly a very performatic one. I'm looking for a free one, because the application is gonna be GPL.","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1214,"Q_Id":8461306,"Users Score":0,"Answer":"You could try Redis. It is most certainly fast.\nBut really, since you're tracking a filesystem, and disks are slow as snails in comparison to even a medium-fast database, performance shouldn't be your primary concern.","Q_Score":0,"Tags":"python,database,database-performance,pyinotify","A_Id":8463655,"CreationDate":"2011-12-11T01:36:00.000","Title":"most performatic free database for file system tracking","Data Science and Machine Learning":0,"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},{"Question":"I would like to compare different methods of finding roots of functions in python (like Newton's methods or other simple calc based methods). I don't think I will have too much trouble writing the algorithms\nWhat would be a good way to make the actual comparison? I read up a little bit about Big-O. Would this be the way to go?","AnswerCount":7,"Available Count":4,"Score":0.0,"is_accepted":false,"ViewCount":2621,"Q_Id":8483522,"Users Score":0,"Answer":"I just finish a project where comparing bisection, Newton, and secant root finding methods. Since this is a practical case, I don't think you need to use Big-O notation. Big-O notation is more suitable for asymptotic view. What you can do is compare them in term of:\nSpeed - for example here newton is the fastest if good condition are gathered\nNumber of iterations - for example here bisection take the most iteration\nAccuracy - How often it converge to the right root if there is more than one root, or maybe it doesn't even converge at all. \nInput - What information does it need to get started. for example newton need an X0 near the root in order to converge, it also need the first derivative which is not always easy to find.\nOther - rounding errors\nFor the sake of visualization you can store the value of each iteration in arrays and plot them. Use a function you already know the roots.","Q_Score":5,"Tags":"python,performance,algorithm,math,numerical-methods","A_Id":26903947,"CreationDate":"2011-12-13T02:11:00.000","Title":"Comparing Root-finding (of a function) algorithms 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},{"Question":"I would like to compare different methods of finding roots of functions in python (like Newton's methods or other simple calc based methods). I don't think I will have too much trouble writing the algorithms\nWhat would be a good way to make the actual comparison? I read up a little bit about Big-O. Would this be the way to go?","AnswerCount":7,"Available Count":4,"Score":0.0285636566,"is_accepted":false,"ViewCount":2621,"Q_Id":8483522,"Users Score":1,"Answer":"Big-O notation is designed to describe how an alogorithm behaves in the limit, as n goes to infinity. This is a much easier thing to work with in a theoretical study than in a practical experiment. I would pick things to study that you can easily measure that and that people care about, such as accuracy and computer resources (time\/memory) consumed.\nWhen you write and run a computer program to compare two algorithms, you are performing a scientific experiment, just like somebody who measures the speed of light, or somebody who compares the death rates of smokers and non-smokers, and many of the same factors apply.\nTry and choose an example problem or problems to solve that is representative, or at least interesting to you, because your results may not generalise to sitations you have not actually tested. You may be able to increase the range of situations to which your results reply if you sample at random from a large set of possible problems and find that all your random samples behave in much the same way, or at least follow much the same trend. You can have unexpected results even when the theoretical studies show that there should be a nice n log n trend, because theoretical studies rarely account for suddenly running out of cache, or out of memory, or usually even for things like integer overflow. \nBe alert for sources of error, and try to minimise them, or have them apply to the same extent to all the things you are comparing. Of course you want to use exactly the same input data for all of the algorithms you are testing. Make multiple runs of each algorithm, and check to see how variable things are - perhaps a few runs are slower because the computer was doing something else at a time. Be aware that caching may make later runs of an algorithm faster, especially if you run them immediately after each other. Which time you want depends on what you decide you are measuring. If you have a lot of I\/O to do remember that modern operating systems and computer cache huge amounts of disk I\/O in memory. I once ended up powering the computer off and on again after every run, as the only way I could find to be sure that the device I\/O cache was flushed.","Q_Score":5,"Tags":"python,performance,algorithm,math,numerical-methods","A_Id":8484871,"CreationDate":"2011-12-13T02:11:00.000","Title":"Comparing Root-finding (of a function) algorithms 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},{"Question":"I would like to compare different methods of finding roots of functions in python (like Newton's methods or other simple calc based methods). I don't think I will have too much trouble writing the algorithms\nWhat would be a good way to make the actual comparison? I read up a little bit about Big-O. Would this be the way to go?","AnswerCount":7,"Available Count":4,"Score":0.0285636566,"is_accepted":false,"ViewCount":2621,"Q_Id":8483522,"Users Score":1,"Answer":"You can get wildly different answers for the same problem just by changing starting points. Pick an initial guess that's close to the root and Newton's method will give you a result that converges quadratically. Choose another in a different part of the problem space and the root finder will diverge wildly.\nWhat does this say about the algorithm? Good or bad?","Q_Score":5,"Tags":"python,performance,algorithm,math,numerical-methods","A_Id":8487731,"CreationDate":"2011-12-13T02:11:00.000","Title":"Comparing Root-finding (of a function) algorithms 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},{"Question":"I would like to compare different methods of finding roots of functions in python (like Newton's methods or other simple calc based methods). I don't think I will have too much trouble writing the algorithms\nWhat would be a good way to make the actual comparison? I read up a little bit about Big-O. Would this be the way to go?","AnswerCount":7,"Available Count":4,"Score":0.1418931938,"is_accepted":false,"ViewCount":2621,"Q_Id":8483522,"Users Score":5,"Answer":"The answer from @sarnold is right -- it doesn't make sense to do a Big-Oh analysis.\nThe principal differences between root finding algorithms are:\n\nrate of convergence (number of iterations)\ncomputational effort per iteration\nwhat is required as input (i.e. do you need to know the first derivative, do you need to set lo\/hi limits for bisection, etc.)\nwhat functions it works well on (i.e. works fine on polynomials but fails on functions with poles)\nwhat assumptions does it make about the function (i.e. a continuous first derivative or being analytic, etc)\nhow simple the method is to implement\n\nI think you will find that each of the methods has some good qualities, some bad qualities, and a set of situations where it is the most appropriate choice.","Q_Score":5,"Tags":"python,performance,algorithm,math,numerical-methods","A_Id":8483756,"CreationDate":"2011-12-13T02:11:00.000","Title":"Comparing Root-finding (of a function) algorithms 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},{"Question":"How do you get the name of a win32com.client.gencache.EnsureDispath name? \nFor example, I have an application named \"xxxxx\", and the Python object browser detects it when I use makepy.py. How do I get name like \"Excel.Application\"?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":333,"Q_Id":8483683,"Users Score":0,"Answer":"You can use the combrowser.py to find the running application on your PC. Go to the win32com library folder and you can find the python script.\nYou can get the list of all the running application. Sometimes it would be tricky if you get the token or moniker of the application instead of the name. But you can use those moniker to reach the application instead.","Q_Score":2,"Tags":"python,win32com","A_Id":71846830,"CreationDate":"2011-12-13T02:37:00.000","Title":"How to Get gencache.EnsureDispatch 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":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"This is part of some preliminary research and I am having a difficult time figuring out what options might be available or if this is even a situation where a solution even exists.\nEssentially we have an existing python based simulation that we would like to make available to people via the web. It can be pretty processor intensive, so while we could just run the sim server side and write a client that connects to it, this would not be ideal.\nWriting a UI in Flash\/Flex or HTML5, not a problem. However, is there any way to keep the core simulation logic in python without having it live server side? Is there any existing way to embed python modules in either of these technologies?\nThanks all.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":451,"Q_Id":8484253,"Users Score":1,"Answer":"Pyjamas: Python->Javascript, set of widgets for use in a browser or a desktop\nSkulpt: Python written in Javascript\nEmscripten: C\/C++ -> LLVM -> Javascript\nEmpythoned: Based on emscripten and cpython, working on a stdlib? There are bugs to file","Q_Score":2,"Tags":"python,apache-flex,html","A_Id":8484821,"CreationDate":"2011-12-13T04:16:00.000","Title":"Python in a webapp (client side)","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"We have a growing library of apps depending on a set of common util modules. We'd like to:\n\nshare the same utils codebase between all projects\nallow utils to be extended (and fixed!) by developers working on any project\nhave this be reasonably simple to use for devs (i.e. not a big disruption to workflow)\ncross-platform (no diffs for devs on Macs\/Win\/Linux)\n\nWe currently do this \"manually\", with the utils versioned as part of each app. This has its benefits, but is also quite painful to repeatedly fix bugs across a growing number of codebases. \nOn the plus side, it's very simple to deal with in terms of workflow - util module is part of each app, so on that side there is zero overhead.\nWe also considered (fleetingly) using filesystem links or some such (not portable between OS's)\nI understand the implications about release testing and breakage, etc. These are less of a problem than the mismatched utils are at the moment.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":250,"Q_Id":8486942,"Users Score":3,"Answer":"You can take advantage of Python paths (the paths searched when looking for module to import).\nThus you can create different directory for utils and include it within different repository than the project that use these utils. Then include path to this repository in PYTHONPATH.\nThis way if you write import mymodule, it will eventually find mymodule in the directory containing utils. So, basically, it will work similarly as it works for standard Python modules.\nThis way you will have one repository for utils (or separate for each util, if you wish), and separate repositories for other projects, regardless of the version control system you use.","Q_Score":4,"Tags":"python","A_Id":8487730,"CreationDate":"2011-12-13T09:34:00.000","Title":"Sharing util modules between actively developed apps","Data Science and Machine Learning":0,"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},{"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},{"Question":"I'm making a scan server for my company, which will be used to launch scans from tools such as nessus, nmap, nikto etc. I've written the pages in php, so once the scan is launched it backgrounds the process and returns the PID. Part of the design spec is that once a scan has finished, the results are then emailed to the appropiate consultant. This is where I'm looking for some ideas, for I'm not sure how to go about doing this. \nWould I be best making the php script feed the PID to instances of a python (my main language) script, which constantly checked to see if the process had finished, for example? I did try putting this process checking loop in the PHP page, but obviously this makes the PHP page pause whilst it waits for the scan to complete, which doesn't work for me unfortunately as multiple scans will be being run. \nOr would I be better creating a database which stored state information about the process? I have no database experience but this could be a good time to learn.\nAny suggestions? Even some ideas that I can google would be much appreciated!\nThanks","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":95,"Q_Id":8508457,"Users Score":2,"Answer":"When I face this kind of problem, I usually do a Python daemon that does the whole job, and have the PHP just sending messages to this Python daemon. These messages can be something very simple, like a bunch of files in a directory that is constantly checked, or registers in database.\nHow good this implmeentation is would depend on the scale of your application.","Q_Score":1,"Tags":"php,python,process","A_Id":8508562,"CreationDate":"2011-12-14T16:57:00.000","Title":"How to perform an action when a process has finished, whilst there are multiple processes are running","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"The title makes it obvious, is this a good idea? I've been looking for a robotics simulator in languages i know (i know ruby best, then c++, then python -- want to strengthen here--, forget about javascript, but i know it). \n\ni found something called pyro, but it probably doesn't fit my needs (listed below). \n\nIn my last university term i learned c++, then they took me to RobotC (which was only about 2 months of the term). Pyro seems similar but now i want something different.\n\nI need something that allows to import graphics, allows 3d environments, allows to easily modify actions robot can perform. Also provides other things necessary for robot programming, like a sensor.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":867,"Q_Id":8513998,"Users Score":0,"Answer":"I would suggest you to go for ROS(gazebo) and write your nodes in C++ or python. You can follow Lentin Joseph's book on Learning Robotics Using Python. It helps you in building autonomous bots with ROS and OpenCV.","Q_Score":2,"Tags":"c++,python,ruby,robotics,panda3d","A_Id":48337393,"CreationDate":"2011-12-15T01:24:00.000","Title":"Panda3d Robotics","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"The title makes it obvious, is this a good idea? I've been looking for a robotics simulator in languages i know (i know ruby best, then c++, then python -- want to strengthen here--, forget about javascript, but i know it). \n\ni found something called pyro, but it probably doesn't fit my needs (listed below). \n\nIn my last university term i learned c++, then they took me to RobotC (which was only about 2 months of the term). Pyro seems similar but now i want something different.\n\nI need something that allows to import graphics, allows 3d environments, allows to easily modify actions robot can perform. Also provides other things necessary for robot programming, like a sensor.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":867,"Q_Id":8513998,"Users Score":0,"Answer":"Panda 3D is a good language to write your own robot system in. It's written by CMU people, so it's very clean and makes a lot of sense. It allows you to import very complex models from Maya or Blender. It supports 3D environments. Although it has its own scripting language for running actions (animations) imported from your modeling package, I prefer to write my own robot driver. It supports three different physics engines, including its own basic version, Open Dynamics Engine (ODE), and most recently Bullet. Although it supports collision detection, which allows triggering, it is an animation and graphic rendering system, not a robotics system per se, and so you'll have to craft your own sensor simulations beside or on top of it. All in all, though, it is quite satisfactory. Good luck.","Q_Score":2,"Tags":"c++,python,ruby,robotics,panda3d","A_Id":10025027,"CreationDate":"2011-12-15T01:24:00.000","Title":"Panda3d Robotics","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I want to use a program written in a high level language like Java or Python to talk to a GSM Modem.\nI want to be able to tell the modem what number to call and when to call it. I also want to be able to read and send text messages.\nI do NOT need to handle voice transmission in either direction of the call.\nI'd appreciate recommendations of any applicable libraries and specific modems that are good to start with? I like Java but am willing to try something else.\nThanks","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":4955,"Q_Id":8549259,"Users Score":0,"Answer":"Almost all modems and (phones which support tethering to your PC) can do this. All modems are equally good at it.There are no starter's modems. Just go through the AT commands specific to your applications and thats it.","Q_Score":2,"Tags":"java,python,mobile,gsm,modem","A_Id":8605549,"CreationDate":"2011-12-18T01:41:00.000","Title":"Programming a GSM phone\/modem to make phone calls","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I am writing a desktop application in Python. This application requires the user to input their GMail email and password (however an account must be created specifically for this app, so it's not their personal (read: important) GMail account). I was wondering what would be the best way to store those login credentials. I don't need it to be super secure, but would like something more than storing it as plain text.\nThank you in advance.","AnswerCount":4,"Available Count":2,"Score":0.049958375,"is_accepted":false,"ViewCount":1583,"Q_Id":8550193,"Users Score":1,"Answer":"Any chance you could not store the information on disk at all? I think that's always the most secure approach, if you can manage it. Can you check the credentials and then discard that information? \nYou can always encrypt the information if that doesn't work, but the decryption mechanism and key would probably have to reside in your program, then. Still, it might meet your criterion of not super-secure but better than plain text.","Q_Score":4,"Tags":"python,security","A_Id":8550234,"CreationDate":"2011-12-18T06:21:00.000","Title":"Where to store user credentials in a Python desktop 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},{"Question":"I am writing a desktop application in Python. This application requires the user to input their GMail email and password (however an account must be created specifically for this app, so it's not their personal (read: important) GMail account). I was wondering what would be the best way to store those login credentials. I don't need it to be super secure, but would like something more than storing it as plain text.\nThank you in advance.","AnswerCount":4,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":1583,"Q_Id":8550193,"Users Score":0,"Answer":"Use the platform's native configuration storage mechanism (registry, GConf, plist).","Q_Score":4,"Tags":"python,security","A_Id":8550200,"CreationDate":"2011-12-18T06:21:00.000","Title":"Where to store user credentials in a Python desktop 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},{"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},{"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},{"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},{"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},{"Question":"I need a tool to access my email inbox via some convenient interface. For example, I need to get the timestamps of letters from some address. I need that data to build some mailing statistics.\nWhat can I use to do that? Maybe there is an API in Thunderbird or something like that. I work under Windows.\nThank you in advance.\nEDIT: Maybe I can do that with some Python library?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":411,"Q_Id":8560684,"Users Score":2,"Answer":"Your best bet is to use a programming language that has a simple IMAP library which you can use to connect to your account. Then you will have to write a script that can do your statistics. \nSince you asked for an API I assume that you know how to use a scripting language like PHP, Python or Ruby which all have an IMAP library available.","Q_Score":0,"Tags":"python,api,email,statistics","A_Id":8560732,"CreationDate":"2011-12-19T11:32:00.000","Title":"Mail inbox analyzer","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I use eclipse (cdt) for c++ projects. It contains some test scripts in python. Is there anyway I could get syntax highlighting and auto completion(if possible) when viewing a python script? Or should I load the complete python perspective?","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":2419,"Q_Id":8562189,"Users Score":2,"Answer":"You can just open your python file in the C\/C++ perspective and get full syntax highlighting and auto completion.\n\nIf that does not work for you, then perhaps you don't have PyDev installed. Find it and install it using Help > Eclipse Marketplace.\nIf that still does not work for you (if you double-click it the file is opened as plain text, or gets executed in a command shell) then perhaps somehow the wrong editor got associated to it. Right click the file, then select Open With > Python Editor. You'll need to do this once: Eclipse will remember your choice.\n\n\nNote: You can open any file in any perspective, and the corresponding editor will always open for you. A perspective is just a grouping of views that should be helpful for you in the given context. It does not enable or disable any additionally installed software.","Q_Score":1,"Tags":"python,eclipse-cdt","A_Id":8587142,"CreationDate":"2011-12-19T13:41:00.000","Title":"How to edit a python file in eclipse when in C++ 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":0,"Web Development":0},{"Question":"I'm attempting to get Eclipse + PyDev set up so I don't need to alter the PYTHONPATH from within Eclipse, but rather it will inherit the PYTHONPATH from the .profile document from inside my home directory. Is that possible, or do I need to actually add the PYTHONPATH locations using Eclipse's PYTHONPATH editor? I ask because I am getting different errors when going from Terminal-based python to python in Eclipse, using the same files.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":603,"Q_Id":8569486,"Users Score":0,"Answer":"You need to configure it inside Eclipse. Now, provided have a shell that has the PYTHONPATH properly setup, you should be able to start Eclipse from it and when adding an interpreter (you may want to remove your currently configured interpreter), it should automatically pick all of the PYTHONPATH you had setup from the shell (some of those may be unchecked in the wizard at that time, so, you have to go on and check those too -- just don't add the paths from files you'll be editing inside your project, as those should be added to the PYTHONPATH for your project so that PyDev is able to track changes on those files to properly offer you code-completion).","Q_Score":0,"Tags":"python,eclipse,pythonpath","A_Id":8658155,"CreationDate":"2011-12-20T00:43:00.000","Title":"How to make Eclipse inherit $PYTHONPATH 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":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I need to test application with testers around the world. I've written class for saving important data to the file. What is the easiest way to send this file (or simple coded string) from tester's pc to me (I suppose to some server, or a special mail?) without interrupting the tester in a Python?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":197,"Q_Id":8573807,"Users Score":2,"Answer":"I think what you want is a Version Control System such as mercurial, git, etc","Q_Score":0,"Tags":"python","A_Id":8573933,"CreationDate":"2011-12-20T10:12:00.000","Title":"Python - online data collection","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"Should my wsgi directory be completely outside of www? \nDocumentRoot \/usr\/local\/www\/\nWSGIScriptAlias \/ \/usr\/local\/wsgi\/\nSomething like that, yeah?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":508,"Q_Id":8583541,"Users Score":1,"Answer":"You don't need a DocumentRoot when using a WSGIScriptAlias \/.\nThe answer to your actual question: it's probably best, yeah. I usually set the DocumentRoot to a 404 folder (folder with an index.html that shows a 404 page) and the WSGIScriptAlias to the actual script. Whether the 404 folder is actually useful? No idea, I've never seen it get hit. However, it's a good idea to keep them separated to avoid direct access to the contents of your code... which is something I have seen happen.","Q_Score":0,"Tags":"python,django,mod-wsgi,wsgi","A_Id":8583560,"CreationDate":"2011-12-21T00:00:00.000","Title":"mod_wsgi directory outside of DocumentRoot?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"How can I get paramiko to do the equivalent of setting \"TCPKeepAlive yes\" in ~\/.ssh\/config?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":383,"Q_Id":8588506,"Users Score":2,"Answer":"Got it: Transport.set_keepalive. Use in conjunction with the timeout argument to SSHClient.connect to set the socket timeout.","Q_Score":2,"Tags":"python,ssh,paramiko","A_Id":8588973,"CreationDate":"2011-12-21T10:39:00.000","Title":"Can I enable TCPKeepAlive with paramiko?","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},{"Question":"I wanted to recompile PIL after having installed libjpeg because it threw the decoder jpeg not available whenever I tried importing JPEG images.\nSo, I've downloaded libjpeg, compiled it and installed it. Then I removed the .\/build folder from PIL's source cache, and recompiled it (using sudo python setup.py install). \nNow the selftest.py thing is failing with *** The _imaging C module is not installed. I have no idea what the issue is.\n\nThere are no symbol errors.\nThe _imaging module is importable\nAll dylibs are loaded properly (according to -v)\nThe decoder error is still there.\n\nDoes anyone know what could be causing this? I'm on OS X Lion.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":672,"Q_Id":8590714,"Users Score":1,"Answer":"What would I try:\n\nRemove old PIL and install new it from scratch (maybe it did not override properly).\nIf you missed something when compiling the libjpeg, like path specifications it will not find some of the libraries, so I recomend trying MacPorts py27-pil port for PIL installation, which will place all dependancies.","Q_Score":0,"Tags":"python,python-imaging-library","A_Id":8591901,"CreationDate":"2011-12-21T13:41:00.000","Title":"Can't get PIL to work on Mac OS X","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},{"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},{"Question":"I just want to find out what the user has set for the timeout period for autolock, which is in Settings->General->Auto-Lock in iOS. How can I find this?\nThanks,","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":592,"Q_Id":8599703,"Users Score":1,"Answer":"Actually, just found out from apple...there is no public API for this.","Q_Score":2,"Tags":"ios,settings,python-idle,auto-lock","A_Id":8608563,"CreationDate":"2011-12-22T05:17:00.000","Title":"can we access the autolock setting that the user has set in 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":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"It gives me the error on line 23 of the repo file:\n\nexec: python: not found. \n\nthe thing is, I have python installed in C:\\Python27 (the default)\nI'm using the Git Bash when typing in these commands. I've tried to move the python folder into the git directory to run the repo file and it still says the same thing.\nI've tried to run the python interpreter and then run the repo file, but it says the same thing. \nAnybody have any suggestions? I just wanna download the android source code through the git and repo.","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":593,"Q_Id":8617208,"Users Score":2,"Answer":"It seems to me that you should add python to your path variable.","Q_Score":1,"Tags":"android,python,git,repository","A_Id":8617691,"CreationDate":"2011-12-23T14:31:00.000","Title":"\"Error: Python not found\" when trying to access the android 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":0,"System Administration and DevOps":1,"Web Development":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\nInstead I get >\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 :\nFile \"\", line 1, in \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},{"Question":"In my server written in Stackless Python, I occasionally am getting large spikes in CPU usage for 5-10 seconds durations. This happens sporadically so I'm having trouble tracking it down. \nI've used cProfile to try and determine where these spikes are coming from but cProfile gives an overall picture of where time is being spent per function. What I would really like to know is whether the CPU spikes are due to some processing occurring in a single tasklet (and stalling other tasklets) or if there are multiple tasklets doing a lot of processing (ie. as each becomes active, each is doing a lot of work).\nIs there a convenient way to hook into the scheduler in Stackless Python so that I can add some timing code? In other words, is there a function that is invoked when a tasklet becomes active and when it becomes inactive that I can hook into?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":184,"Q_Id":8631091,"Users Score":0,"Answer":"I haven't found an explicit function to hook into when a tasklet blocks\/resumes, but since Channel.receive() is typically when the block\/resume occurs, I hooked into every occurrence of that happening.","Q_Score":1,"Tags":"python,profiling,stackless,green-threads","A_Id":8660039,"CreationDate":"2011-12-25T19:11:00.000","Title":"Stackless Python - profile single tasklet execution 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},{"Question":"What's the easiest way to calculate the execution time of a Python script?","AnswerCount":4,"Available Count":3,"Score":0.049958375,"is_accepted":false,"ViewCount":6333,"Q_Id":8631743,"Users Score":1,"Answer":"Under linux:\ntime python script.py","Q_Score":4,"Tags":"python,performance-testing","A_Id":8631751,"CreationDate":"2011-12-25T21:45:00.000","Title":"Easiest way to calculate execution time of 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":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"What's the easiest way to calculate the execution time of a Python script?","AnswerCount":4,"Available Count":3,"Score":0.2449186624,"is_accepted":false,"ViewCount":6333,"Q_Id":8631743,"Users Score":5,"Answer":"Using Linux time command like this : time python file.py\nOr you can take the times at start and at end and calculate the difference.","Q_Score":4,"Tags":"python,performance-testing","A_Id":8631753,"CreationDate":"2011-12-25T21:45:00.000","Title":"Easiest way to calculate execution time of 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":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"What's the easiest way to calculate the execution time of a Python script?","AnswerCount":4,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":6333,"Q_Id":8631743,"Users Score":0,"Answer":"How about using time?\nexample:\ntime myPython.py","Q_Score":4,"Tags":"python,performance-testing","A_Id":8631755,"CreationDate":"2011-12-25T21:45:00.000","Title":"Easiest way to calculate execution time of 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":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"If I use command ssh -f server 'cp \/file1 \/file2 & >\/dev\/null 2>\/dev\/null ; disown;' it detaches well and command is runned in the background. But is there any variant of -f key for paramiko?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1175,"Q_Id":8650148,"Users Score":0,"Answer":"You have to create new thread\/process, for example using Python threading module. Paramiko has to write to socket after finishing Django request.","Q_Score":2,"Tags":"python,ssh,paramiko","A_Id":8650409,"CreationDate":"2011-12-27T23:00:00.000","Title":"python-paramiko - run command in background","Data Science and Machine Learning":0,"Database and SQL":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},{"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},{"Question":"Not sure what the above error means. I just installed ghmm on my mac and get this error every time I do a import ghmm. I do not get this message on my ghmm install on my linux machine and other than that all functions appear to be fine.\nI wondering if anyone has seen this before and if there's anything I can do to get rid of this. The only thing I did different between the two installs was the autogen.sh file was refering to \"libtoolize\" which doesn't exist on my mac so I changed it to its replacement \"glibtoolize\" which allowed it to compile and install fine.\nAny suggestions on what this error actually means(and hopefully how I can solve it) would be great.\n(I couldn't find the answer on google but this program does not appear to be specific to ghmm)","AnswerCount":3,"Available Count":1,"Score":0.1325487884,"is_accepted":false,"ViewCount":403,"Q_Id":8658934,"Users Score":2,"Answer":"eaj is correct that initstate needs more than 8 bytes for state information. The best way to do this for ghmm is with either the --enable-gsl or --with-rng=bsd option for .\/configure. --with-rng=bsd makes the type \"ghmm_rng_state_t\" 8 bytes instead of 1. See rng.h in the ghmm directory.","Q_Score":2,"Tags":"python,linux,macos","A_Id":9056422,"CreationDate":"2011-12-28T17:05:00.000","Title":"random: not enough state (1 bytes); ignored","Data Science and Machine Learning":0,"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},{"Question":"I have two scripts, a python script and a perl script.\nHow can I make the perl script run the python script and then runs itself?","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":11721,"Q_Id":8659226,"Users Score":1,"Answer":"It may be simpler to run both scripts from a shell script, and use pipes (assuming that you're in a Unix environment) if you need to pass the results from one program to the other","Q_Score":3,"Tags":"python,perl","A_Id":8659430,"CreationDate":"2011-12-28T17:34:00.000","Title":"Run a python script in 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":1,"Web Development":0},{"Question":"I have an NSMutableArray filled with BeziarPaths. I'd like to serialize it so that its accessible on Python. Someone suggested to me that I can try GZIP + InkML or GZIP +JSON. I was wondering what the best way to do this is. I am also really new to this, so example code would be extremely helpful.\nThanks","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":318,"Q_Id":8661415,"Users Score":0,"Answer":"Choose what you like most. Both are standards, but JSON is a generic format used for serializing dictionaries and arrays, while InkML focuses on drawing related objects.\nJSON support is available in both Python and Objective-C, while InkML has no built-in support in either.","Q_Score":1,"Tags":"python,objective-c,serialization","A_Id":8661467,"CreationDate":"2011-12-28T21:15:00.000","Title":"Objective C to Python Serialization","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},{"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},{"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},{"Question":"Is there a shared binary format between iOS and Python? I found binary property lists. \nI have a list of UIBeziarPaths in an array that I want to be able to send to Python. I am just looking for something that will very efficiently be able to do that. I looked into the text based formats like JSON except they seem less efficient than a binary format for this purpose.","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":217,"Q_Id":8662519,"Users Score":1,"Answer":"Python has a struct standard module that allows easy manipulation of simple binary formats with conversion to python types (struct.unpack) or in the opposite direction (struct.pack).","Q_Score":1,"Tags":"python,ios,binary","A_Id":8662573,"CreationDate":"2011-12-28T23:40:00.000","Title":"Shared binary format between iOS 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":0},{"Question":"Is there a shared binary format between iOS and Python? I found binary property lists. \nI have a list of UIBeziarPaths in an array that I want to be able to send to Python. I am just looking for something that will very efficiently be able to do that. I looked into the text based formats like JSON except they seem less efficient than a binary format for this purpose.","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":217,"Q_Id":8662519,"Users Score":1,"Answer":"There are no formats specifically designed for iOS\/Python. There are numerous data interchange formats you could use, including protocol buffers, BSON, ASN.1 (if you're that way inclined) and even a range of binary XML serialisation formats.\nOTOH, I would strongly favour JSON (a textual format) unless bandwidth is exceptionally tight.\nEDIT: I was awfully remiss not to mention another strong contender for binary transmission: BERT. I would favour BERT over any other binary format, but note my comments to the original question regarding encoding size.","Q_Score":1,"Tags":"python,ios,binary","A_Id":8662606,"CreationDate":"2011-12-28T23:40:00.000","Title":"Shared binary format between iOS 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":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},{"Question":"I'm developing a C++ application that is extended\/ scriptable with Python. Of course C++ is much faster than Python, in general, but does that necessarily mean that you should prefer to execute C++ code over Python code as often as possible?\nI'm asking this because I'm not sure, is there any performance cost of switching control between code written in C++ and code written in Python? Should I use code written in C++ on every occasion, or should I avoid calling back to C++ for simple tasks because any speed gain you might have from executing C++ code is outmatched by the cost of switching between languages?\nEdit: I should make this clear, I'm not asking this to actually solve a problem. I'm asking purely out of curiosity and it's something worth keeping in mind for the future. So I'm not interested in alternative solutions, I just want to know the answer, from a technical standpoint. :)","AnswerCount":4,"Available Count":4,"Score":0.0,"is_accepted":false,"ViewCount":991,"Q_Id":8675062,"Users Score":0,"Answer":"The best metric should be something that wieghs up for you....\n\nMakes development, debugging and testing easier (lowers dev cost)\nLowers the cost of maintenance \nmeets the performance requirement (provides solution)","Q_Score":11,"Tags":"c++,python,performance","A_Id":8675094,"CreationDate":"2011-12-30T00:46:00.000","Title":"Price of switching control between C++ 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":0},{"Question":"I'm developing a C++ application that is extended\/ scriptable with Python. Of course C++ is much faster than Python, in general, but does that necessarily mean that you should prefer to execute C++ code over Python code as often as possible?\nI'm asking this because I'm not sure, is there any performance cost of switching control between code written in C++ and code written in Python? Should I use code written in C++ on every occasion, or should I avoid calling back to C++ for simple tasks because any speed gain you might have from executing C++ code is outmatched by the cost of switching between languages?\nEdit: I should make this clear, I'm not asking this to actually solve a problem. I'm asking purely out of curiosity and it's something worth keeping in mind for the future. So I'm not interested in alternative solutions, I just want to know the answer, from a technical standpoint. :)","AnswerCount":4,"Available Count":4,"Score":1.2,"is_accepted":true,"ViewCount":991,"Q_Id":8675062,"Users Score":1,"Answer":"The cost is present but negligible. That's because you probably do a fair bit of work converting python's high level datatypes to C++-compatible representations. Of course this is similar to the cost of calling one C++ function from another, there's some overhead. The rules for when it's a good idea to switch from python to C++ are:\nA function with few arguments\nA function which does a large amount of processing on a small amount of data\nA function which is called as rarely as possible - consolidate function calls if possible","Q_Score":11,"Tags":"c++,python,performance","A_Id":8675109,"CreationDate":"2011-12-30T00:46:00.000","Title":"Price of switching control between C++ 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":0},{"Question":"I'm developing a C++ application that is extended\/ scriptable with Python. Of course C++ is much faster than Python, in general, but does that necessarily mean that you should prefer to execute C++ code over Python code as often as possible?\nI'm asking this because I'm not sure, is there any performance cost of switching control between code written in C++ and code written in Python? Should I use code written in C++ on every occasion, or should I avoid calling back to C++ for simple tasks because any speed gain you might have from executing C++ code is outmatched by the cost of switching between languages?\nEdit: I should make this clear, I'm not asking this to actually solve a problem. I'm asking purely out of curiosity and it's something worth keeping in mind for the future. So I'm not interested in alternative solutions, I just want to know the answer, from a technical standpoint. :)","AnswerCount":4,"Available Count":4,"Score":0.0996679946,"is_accepted":false,"ViewCount":991,"Q_Id":8675062,"Users Score":2,"Answer":"Keep it simple and tune performance as needed. The primary reason for embedding an interpreter in a C++ app is to allow run-time configuration\/data to specify some processing - i.e. you can modify the script without recompiling the C++ program - that's your guide for when to call into the interpreter. Once in some interpreter call, the primary reasons to call back into C++ are:\n\nto access or update some data that can't reasonably be exposed as a parameter to the call (or via some other registration process the interpreter supports)\nto get better performance during some critical part of the processing\n\nFor the latter, try the script first (assuming it's as easy to develop there), then if it's slow identify where and how some C++ code might help. If\/where performance does prove a problem - as a general guideline when calling from C++ to the interpreter or vice versa: try to line up as much work as possible then make the call into the other system. If you get stuck, come back to stackoverflow with a specific problem and actual code.","Q_Score":11,"Tags":"c++,python,performance","A_Id":8675394,"CreationDate":"2011-12-30T00:46:00.000","Title":"Price of switching control between C++ 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":0},{"Question":"I'm developing a C++ application that is extended\/ scriptable with Python. Of course C++ is much faster than Python, in general, but does that necessarily mean that you should prefer to execute C++ code over Python code as often as possible?\nI'm asking this because I'm not sure, is there any performance cost of switching control between code written in C++ and code written in Python? Should I use code written in C++ on every occasion, or should I avoid calling back to C++ for simple tasks because any speed gain you might have from executing C++ code is outmatched by the cost of switching between languages?\nEdit: I should make this clear, I'm not asking this to actually solve a problem. I'm asking purely out of curiosity and it's something worth keeping in mind for the future. So I'm not interested in alternative solutions, I just want to know the answer, from a technical standpoint. :)","AnswerCount":4,"Available Count":4,"Score":1.0,"is_accepted":false,"ViewCount":991,"Q_Id":8675062,"Users Score":8,"Answer":"I don't know there is a concrete rule for this, but a general rule that many follow is to:\n\nPrototype in python. This is quicker to write, and may be easier to read\/reason about.\nOnce you have a prototype, you can now identify the slow portions that should be written in c++ (through profiling).\nDepending on the domain of your code, the slow bits are usually isolated to the 'inner loop' types of code, so the number of switches between python an this code should be relatively small.\nIf your program is sufficiently fast, you've successfully avoided prematurely optimizing your code by writing too much in c++.","Q_Score":11,"Tags":"c++,python,performance","A_Id":8675112,"CreationDate":"2011-12-30T00:46:00.000","Title":"Price of switching control between C++ 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":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},{"Question":"I've recently started experimenting with using Python for web development. So far I've had some success using Apache with mod_wsgi and the Django web framework for Python 2.7. However I have run into some issues with having processes constantly running, updating information and such.\nI have written a script I call \"daemonManager.py\" that can start and stop all or individual python update loops (Should I call them Daemons?). It does that by forking, then loading the module for the specific functions it should run and starting an infinite loop. It saves a PID file in \/var\/run to keep track of the process. So far so good. The problems I've encountered are:\n\nNow and then one of the processes will just quit. I check ps in the morning and the process is just gone. No errors were logged (I'm using the logging module), and I'm covering every exception I can think of and logging them. Also I don't think these quitting processes has anything to do with my code, because all my processes run completely different code and exit at pretty similar intervals. I could be wrong of course. Is it normal for Python processes to just die after they've run for days\/weeks? How should I tackle this problem? Should I write another daemon that periodically checks if the other daemons are still running? What if that daemon stops? I'm at a loss on how to handle this.\nHow can I programmatically know if a process is still running or not? I'm saving the PID files in \/var\/run and checking if the PID file is there to determine whether or not the process is running. But if the process just dies of unexpected causes, the PID file will remain. I therefore have to delete these files every time a process crashes (a couple of times per week), which sort of defeats the purpose. I guess I could check if a process is running at the PID in the file, but what if another process has started and was assigned the PID of the dead process? My daemon would think that the process is running fine even if it's long dead. Again I'm at a loss just how to deal with this.\n\nAny useful answer on how to best run infinite Python processes, hopefully also shedding some light on the above problems, I will accept\n\nI'm using Apache 2.2.14 on an Ubuntu machine.\nMy Python version is 2.7.2","AnswerCount":3,"Available Count":1,"Score":0.1325487884,"is_accepted":false,"ViewCount":36296,"Q_Id":8685695,"Users Score":2,"Answer":"I assume you are running Unix\/Linux but you don't really say. I have no direct advice on your issue. So I don't expect to be the \"right\" answer to this question. But there is something to explore here.\nFirst, if your daemons are crashing, you should fix that. Only programs with bugs should crash. Perhaps you should launch them under a debugger and see what happens when they crash (if that's possible). Do you have any trace logging in these processes? If not, add them. That might help diagnose your crash.\nSecond, are your daemons providing services (opening pipes and waiting for requests) or are they performing periodic cleanup? If they are periodic cleanup processes you should use cron to launch them periodically rather then have them run in an infinite loop. Cron processes should be preferred over daemon processes. Similarly, if they are services that open ports and service requests, have you considered making them work with INETD? Again, a single daemon (inetd) should be preferred to a bunch of daemon processes.\nThird, saving a PID in a file is not very effective, as you've discovered. Perhaps a shared IPC, like a semaphore, would work better. I don't have any details here though.\nFourth, sometimes I need stuff to run in the context of the website. I use a cron process that calls wget with a maintenance URL. You set a special cookie and include the cookie info in with wget command line. If the special cookie doesn't exist, return 403 rather than performing the maintenance process. The other benefit here is login to the database and other environmental concerns of avoided since the code that serves normal web pages are serving the maintenance process.\nHope that gives you ideas. I think avoiding daemons if you can is the best place to start. If you can run your python within mod_wsgi that saves you having to support multiple \"environments\". Debugging a process that fails after running for days at a time is just brutal.","Q_Score":38,"Tags":"python,apache,daemon,infinite-loop","A_Id":8685801,"CreationDate":"2011-12-31T01:39:00.000","Title":"How do I run long term (infinite) 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":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"For a git repository that is shared with others, is it a vulnerability to expose your database password in the settings.py file? (My initial thought was no, since you still need the ssh password.)","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":104,"Q_Id":8696469,"Users Score":2,"Answer":"That assumes your database is only accessible from one specific host, and even then, why would you want to give a potential attacker another piece of information? Suppose you deploy this to a shared host and I have an account on there, I could connect to your database just by logging into my account on that box.\nAlso, depending on who you are writing this for and what kind of auditing they need to go through (PCI, state audits, etc), this might just not be allowed.\nI would try to find a way around checking in the password.","Q_Score":1,"Tags":"python,django","A_Id":8696496,"CreationDate":"2012-01-02T00:09:00.000","Title":"Exposing passwords 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},{"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},{"Question":"I'm a fan of Ruby but I don't oppose Python. ( I have 2+ years of Ruby experience and maybe 2 months of Python ).\nAnyway, I need to create a service for both the Mac and Windows (and Linux, actually) that takes certain files from different directories and sends them to S3. I could use .NET on Windows but I don't want to use Objective-C and I would love to keep my code-base the same on all platforms.\nSo after digging around a little, it looks like I should be able to compile either Ruby or Python to byte-code and distribute an interpreter to run the code. \nBut, am I wrong in assuming that Python has better support for compiling code? As in .pyc byte code?\nAlso, I would prefer the end user not be able to read my source code but I'm not going to the end of the world to try and stop them.\nThanks!","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1058,"Q_Id":8707238,"Users Score":0,"Answer":"Use whatever language you know well, I know python and use that to develop windows desktop applications and end user can't distinguish it with say a C# or C++ app","Q_Score":3,"Tags":"python,ruby,compilation,distribution","A_Id":8716554,"CreationDate":"2012-01-03T02:16:00.000","Title":"Should I use Python or Ruby for creating a cross-platform, compiled 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":1,"Web Development":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},{"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},{"Question":"I'm starting a web project in Python and I'm looking for a process manager that offers reloading in the same manner as PHP-FPM.\nI've built stuff with Python before and Paste seems similar to what I want, but not quite.\nThe need for the ability to reload the process rather than restart is to allow long-running tasks to complete uninterrupted where necessary.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1732,"Q_Id":8718870,"Users Score":1,"Answer":"How about supervisor with uwsgi?","Q_Score":2,"Tags":"python,nginx,php","A_Id":8718932,"CreationDate":"2012-01-03T21:28:00.000","Title":"Is there a Python equivalent to PHP-FPM?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I'm relatively new to both Python and bash. However, I am finding Python much more intuitive and easier than bash. I have a few bash scripts I have managed to cobble together, but I would like to replace them with Python scripts - for ease of maintenance etc.\nThe bash scripts essentially run python scripts, check the returned status code and act appropriately (e.g. log a message, fire off an email etc) - this is functionality that I thing I can for the most part, reproduce in a Python script.\nThe one thing I am not sure of how to do, is how to run a python script from another python script and get the returned status code.\nCan anyone post a snippet here that will show how to run a small python script 'test.py' from a main python script 'master.py' and correctly retrieve the return code after running test.py from master.py?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2400,"Q_Id":8724557,"Users Score":0,"Answer":"I would suggest you to look at the subprocess module in python. You can start another process using it, manipulate its streams and get the return code.","Q_Score":6,"Tags":"python,bash","A_Id":8724602,"CreationDate":"2012-01-04T09:26:00.000","Title":"How to run a python script from another python script and get the returned status 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":1,"Web Development":0},{"Question":"Is it possible to open a non-blocking ssh tunnel from a python app on the heroku cedar stack? I've tried to do this via paramiko and also asyncproc with no success.\nOn my development box, the tunnel looks like this:\nssh -L local_port:remote_server:remote_port another_remote_server","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":476,"Q_Id":8735487,"Users Score":1,"Answer":"Can you please post the STDERR of ssh -v -L .....? May be you need to disable the tty allocation and run ssh in batch mode.","Q_Score":1,"Tags":"python,ssh,heroku,paramiko,cedar","A_Id":8735515,"CreationDate":"2012-01-04T23:16:00.000","Title":"open an ssh tunnel from heroku python app on the cedar stack?","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},{"Question":"I'm trying to use a file that uses PIL and when I try to run it I get the following error:\nImportError: The _imaging C module is not installed\nI know theres a bunch of threads online about this but most of them see pretty specific. I'm 100% sure there is no problem with the code I'm running. Python version 2.7.2 64bit windows 7. I've been trying to fix it for almost an hour or so and I'm losing my mind. Any suggestions?","AnswerCount":4,"Available Count":1,"Score":0.049958375,"is_accepted":false,"ViewCount":6417,"Q_Id":8747299,"Users Score":1,"Answer":"try to install pillow. you can install it with the command: pip install pillow \nyou have install the python-imaging??\nsudo apt-get install python-imaging. install first the python-imaging and next install the pillow","Q_Score":0,"Tags":"python,module,imaging","A_Id":11829919,"CreationDate":"2012-01-05T17:56:00.000","Title":"Python: PIL _imaging C module","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},{"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},{"Question":"I'm trying to add a python egg to my eclipse pydev path via Eclipse Settings -> PyDev -> Interpreter - Python -> New Egg\/Zip(s), and in the dialog where I browse to the egg file, and click the \"open\" button on the dialog, it simply keeps the dialog open and browses into the egg.\nThis is on OS X with Helios SR 2.","AnswerCount":3,"Available Count":3,"Score":0.0665680765,"is_accepted":false,"ViewCount":2346,"Q_Id":8750530,"Users Score":1,"Answer":"Go to:\nWindow > Preferences > PyDev > Interpreter - (Python, Iron python, or Jython) > Libraries\nYou can add a new folder, using the New folder Button,\nYou can add a new egg, using the New Egg button,\nor remove.\nIf you are experimenting with new versions of libraries, I suggest to remove the old versions, restart eclipse, install the new ones, then restart eclipse again.\nCheers !! happy PyDeving !!","Q_Score":1,"Tags":"python,eclipse,pydev","A_Id":21244922,"CreationDate":"2012-01-05T22:07:00.000","Title":"How to add Python Egg to Eclipse Pydev paths? New Egg button not behaving as expected","Data Science and Machine Learning":0,"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},{"Question":"I'm trying to add a python egg to my eclipse pydev path via Eclipse Settings -> PyDev -> Interpreter - Python -> New Egg\/Zip(s), and in the dialog where I browse to the egg file, and click the \"open\" button on the dialog, it simply keeps the dialog open and browses into the egg.\nThis is on OS X with Helios SR 2.","AnswerCount":3,"Available Count":3,"Score":0.1325487884,"is_accepted":false,"ViewCount":2346,"Q_Id":8750530,"Users Score":2,"Answer":"On my Mac I have some .egg's that are files, and some .egg's that are folders, for example my SQLObject is a folder but my oauth is a file. I am not exactly sure why, it could be because of how I downloaded and installed them.\nThe ones that are folders can't be chosen by the \"Add zip\/jar\/egg\" chooser, but the simple solution is just to include those via \"Add source folder\".","Q_Score":1,"Tags":"python,eclipse,pydev","A_Id":21922683,"CreationDate":"2012-01-05T22:07:00.000","Title":"How to add Python Egg to Eclipse Pydev paths? New Egg button not behaving as expected","Data Science and Machine Learning":0,"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},{"Question":"I'm trying to add a python egg to my eclipse pydev path via Eclipse Settings -> PyDev -> Interpreter - Python -> New Egg\/Zip(s), and in the dialog where I browse to the egg file, and click the \"open\" button on the dialog, it simply keeps the dialog open and browses into the egg.\nThis is on OS X with Helios SR 2.","AnswerCount":3,"Available Count":3,"Score":1.2,"is_accepted":true,"ViewCount":2346,"Q_Id":8750530,"Users Score":1,"Answer":"Perhaps this only on OS X, but simple solution was to just add the egg as a folder via New Folder. I'm guessing the New Egg\/Zip button is for OS's that don't treat Zips\/Eggs as folders.","Q_Score":1,"Tags":"python,eclipse,pydev","A_Id":8750576,"CreationDate":"2012-01-05T22:07:00.000","Title":"How to add Python Egg to Eclipse Pydev paths? New Egg button not behaving as expected","Data Science and Machine Learning":0,"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},{"Question":"I'm installing python on custom location on a internal server.\nUnfortunately, I can't make full internet connection here. Most of sites are block by firewall. (essentially pypi repository!) Please don't ask the reason. And I don't have root account, so I have to install python from source.\nI did install python from source successfully! But the problem is any of easy_install or pip is not installable because the sites are not accessible form here. :(\nHow can I install them under current situation?","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":18613,"Q_Id":8754520,"Users Score":0,"Answer":"Download the source tarballs of the relevant modules and install them locally.","Q_Score":7,"Tags":"python,installation","A_Id":8754536,"CreationDate":"2012-01-06T07:06:00.000","Title":"How to install python from source without internet connection?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I installed python2.7 as an alternate version of python. I was attempting to utilize a newer version of mod_python and I needed 2.7. The default python (\/bin\/python) is 2.6. Unfortunately now, calling python from the command line calls \/usr\/local\/bin\/python2.7. I realize that I can set up a number of links pointing back to \/bin\/python--I just don't think this is a great idea. The OS (CentOS6) uses 2.6.2 by default, and I don't want the OS to use another version of python. I installed 2.7 from source, but forgot to specify 'make altinstall' rather than 'make install'. This is a semi-work related server, so I need to implement something that will permanently fix the problem. I realize .profile and .bashrc have paths for python, but these appear to be more for bash logins via ssh. I need to find a way to change the system's default python path back to 2.6.2. How would one go about doing this? Thank you for your help.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":5778,"Q_Id":8764562,"Users Score":4,"Answer":"This is because \/usr\/local\/bin comes before \/bin in your $PATH.\nWhat does which python say? I suspect it gives a symlink \/usr\/local\/bin\/python to \/usr\/local\/bin\/python2.7. Changing that symlink to \/bin\/python or removing it altogether should fix your problem.","Q_Score":2,"Tags":"python,linux,centos","A_Id":8764672,"CreationDate":"2012-01-06T21:08:00.000","Title":"Installed a python2.7 as an alternate, but path to default 2.6 is destroyed. System path file for default 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},{"Question":"If I run a python script via python foo.py then I can get the contents of the script by reading the file sys.argv[0]. Is it possible to get the contents of the script (e.g., as a string) if the script is passed to the python interpreter via python -c \"$(cat foo.py)\"?","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":48,"Q_Id":8766312,"Users Score":1,"Answer":"As far as I know, it's not possible.","Q_Score":1,"Tags":"python","A_Id":8766362,"CreationDate":"2012-01-07T00:39:00.000","Title":"Get the text of a python script that is passed via the `-c` option","Data Science and Machine Learning":0,"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},{"Question":"If I run a python script via python foo.py then I can get the contents of the script by reading the file sys.argv[0]. Is it possible to get the contents of the script (e.g., as a string) if the script is passed to the python interpreter via python -c \"$(cat foo.py)\"?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":48,"Q_Id":8766312,"Users Score":0,"Answer":"No. As far as I know, It wont be possible. When you call \"$(cat foo.py)\", shell will get only the contents and the reference is lost.","Q_Score":1,"Tags":"python","A_Id":8766445,"CreationDate":"2012-01-07T00:39:00.000","Title":"Get the text of a python script that is passed via the `-c` option","Data Science and Machine Learning":0,"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},{"Question":"I am looking for an open source monitoring solution (preferably in Python) that works with ssh or snmp and does not require the installation of an agent (like Nagios, ZenOSS, munin). \nAre you aware of such a solution?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":482,"Q_Id":8770914,"Users Score":0,"Answer":"All tools that allow you to run scripts to gather metrics can basically run commands over a ssh connection on the target box. \nThe question is though if this makes a lot of sense as you rely on the network connection always being available and for each (set of) property(s) you need to run a new remote connection with all its overhead.\nSnmp does by definition of the protocol require you to run an snmp agent on the target box.","Q_Score":0,"Tags":"python,open-source,monitoring","A_Id":8777056,"CreationDate":"2012-01-07T15:53:00.000","Title":"open source monitoring solution without the need of an agent","Data Science and Machine Learning":0,"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},{"Question":"I've heard a lot about ZeroMQ and its advantages, but I'm not really sure what it is. What are some example uses, what is it trying to replace (if anything), what problem does it solve, what are the alternatives out there, etc.? And, what is a \"messaging library\"?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":2626,"Q_Id":8784336,"Users Score":1,"Answer":"ZeroMQ, as it's name suggests most probably is a messaging provider. A messaging API is needed to send and recieve messages using these message providers. And you need to integrate these providers with your application server (view documentation). Some MQ supports multiple platforms like Ruby, Java, Php and Others. It is used for loose coupling between two modules in an enterprise application. If you are a Java Programmer, refer to JMS Specifications (Java Mesaging Service) at Oracle's site.","Q_Score":2,"Tags":"python,networking,zeromq","A_Id":8784472,"CreationDate":"2012-01-09T05:36:00.000","Title":"What is ZeroMQ?","Data Science and Machine Learning":0,"Database and SQL":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},{"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},{"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},{"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},{"Question":"I have a simple python server script which forks off multiple instances (say N) of C++ program. The C++ program generates some events that need to be captured.\nThe events are currently being captured in a log file (1 logfile per forked process). In addition, i need to periodically (T minutes) get the rate at which the events are being produced across all child processes to either the python server or some other program listening for these events (still not sure). Based on rate of these events, some \"re-action\" may be taken by the server (say reduce the number of forked instances)\nSome pointers i have briefly looked at:\n\ngrep log files - go through the running process log files (.running), filter those entries generated in the last T minutes, analyse the data and report\nsocket ipc - add code to c++ program to send the events to some server program which analyses the data after T minutes, reports and starts all over again\nredis\/memcache (not sure completely) - add code to c++ program to use some distributed store to capture all the generated data, analyses the data after T minutes, reports and starts all over again\n\nPlease let me know your suggestions.\nThanks","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":160,"Q_Id":8796882,"Users Score":0,"Answer":"if time is not of the essence (T minutes sounds like it is long compared to whatever events are happening in the C++ programs that are kicked off) then dont make things any more complicated than they need to be. forget IPC (sockets, shared mem, etc), just have each C++ program log what you need to know about time\/performance and let the python script check logs every T minutes that you need the data. dont waste time overcomplicating something that you can do in a simple manner","Q_Score":0,"Tags":"c++,python,ipc,redis,distributed","A_Id":8810895,"CreationDate":"2012-01-09T23:59:00.000","Title":"Request for suggestions on doing IPC\/event capture","Data Science and Machine Learning":0,"Database and SQL":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},{"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},{"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},{"Question":"I am fairly new to programming and I am trying to learn the python Nose module for testing a code (myscript.py) that takes 2 input files and writes 2 output files. I want to write a test.py script (to run using Nose) that will take a bunch of test files, run them as input files, and then evaluate the output files by comparing them to known output. I understand that it is better to test functions individually, but my questions are applicable to either scenario.\nHere is my confusion. How do I specify that test.py is supposed to run on myscript.py? Does test.py need to actually open up myscript.py? If so, I presume I would \"import myscript.py\"? Could\/should I actually generate input\/output files during testing, or should I use something like StringIO?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":348,"Q_Id":8813669,"Users Score":0,"Answer":"Better to create a functions which accept text as an argument and return text as well. These functions should be placed in the myscript.py and tested in the tests.py.","Q_Score":1,"Tags":"python,unit-testing,nose","A_Id":8814746,"CreationDate":"2012-01-11T03:05:00.000","Title":"Basics of Using Python Nose","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have setup a run configuration in Eclipse and need to send SIGINT (Ctrl+C) to the program. There is cleanup code in the program that runs after SIGINT, so pressing Eclipse's \"Terminate\" buttons won't work (they send SIGKILL I think). Typing CTRL+C into the Console also doesn't work.\nHow do I send SIGINT to a process running inside an Eclipse Console?\n(FWIW I am running a Twisted daemon and need Twisted to shutdown correctly, which only occurs on SIGINT)","AnswerCount":5,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":15315,"Q_Id":8814383,"Users Score":0,"Answer":"in some versions, you can do the following.\nIn the Debug perspective, you can open a view called \"Signals\"\n(Window\/Show View\/Signals\" or Left-Bottom Icon).\nYou will get a list of all supported signals. Right-click and \"Resume\nwith Signal\" will give you the result you need.","Q_Score":29,"Tags":"python,eclipse,twisted,sigint","A_Id":61871564,"CreationDate":"2012-01-11T05:01:00.000","Title":"Sending SIGINT (Ctrl-C) to program running in Eclipse 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":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I have very little knowledge in testing and I wish to seek guidance in the following scenario - I have a piece of code where it takes in some arguments (filename, path etc) and uploads the file specified to a remote ftp server. So, the goal of the testing would be to check if the file is uploaded to the correct directory in the ftp server.\nNow, I don't suppose I should involve the remote server in my test script, so should I setup a ftp server locally and mimick the file structure, or is there a mock ftp tool available in python to facilitate these scenarios?\nAlso, is this unit testing or functional testing?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2285,"Q_Id":8815201,"Users Score":0,"Answer":"We have some functional tests that truly do hit a real FTP server that we keep running as part of our staging environment. The config of our Django project is slightly different when running tests, so it hits this 'test' FTP server rather than any of our real servers or any of our client's. Having said that, these are amongst our slowest-to-run tests, so I'm looking to rewrite them to use an ftp server on the localhost, started & shut down by the test that needs it.\nA mock ftp server sounds like a good idea. Can't wait to try it out, thanks @Bryce. For third-party servers in general, it might be problematic to be sure that your mocks actually matched the server API, but for FTP, this seems stable and well-understood enough that this shouldn't be a problem.\nFunctional testing invokes your entire system end-to-end, to check that user-visible behavior is what your spec says it should be, to assure you that your product really works, so you can confidently deploy new versions no matter what changes the code contains. The primary failing of functional tests is to exercise product code in ways that differ from production (e.g. only running part of the code, running against a different database schema or vendor) They generally use real data, are large and hard to write (database setup in particular), and slow to run. It's often very difficult to write enough functional tests to verify your entire program's behavior for all possible permutations of inputs, and if you did write them, they would take forever to run. So instead, you write a small number of judiciously chosen functional tests to demonstrate key user workflows, and then augment these with unit tests:\nUnit tests invoke a very small amount of code, such as a single function or method. The primary goal of unit tests is to be fast to run, and easy to write, so that you can write hundreds or thousands of them, get good coverage, and run them all, in a couple of seconds at most, before you commit. (or maybe even every time you hit save from your editor.) The primary failing of unittests is to be slow.\nTests which sound like they are a bit inbetween these two extremes are integration tests, that don't test the whole system end-to-end, but do test several layers or components are integrated properly. Sometimes these are useful, or are the easiest test to write, but they are lacking in the primary virtues of either proving the product as a whole actually works, or being very fast to run. As a result, I think one should strive to write the minimum number of integration tests you can get away with. (personally I think that number is zero for most projects, but other people disagree.)","Q_Score":2,"Tags":"python,unit-testing,testing","A_Id":10704251,"CreationDate":"2012-01-11T06:43:00.000","Title":"python test sending files over ftp","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I need to manipulate large numbers in Python that fit into 64 bits. Currently, my code is running on a 64-bit platform but there is small but distinct possibility that it will have to run on a 32-bit platform. Consequently, I would prefer to use long type to represent my numbers. I understand there is a performance impact for using long over int type. How bad is it? I'll be performing a lot of divisions and multiplications on them, but the results should all fit into 64 bits, too.","AnswerCount":2,"Available Count":2,"Score":0.2913126125,"is_accepted":false,"ViewCount":904,"Q_Id":8828909,"Users Score":3,"Answer":"If you're going to be doing a lot of heavy number crunching, have a look at \"numpy\".","Q_Score":5,"Tags":"python,performance,cpython","A_Id":8829028,"CreationDate":"2012-01-12T01:08:00.000","Title":"Performance impact of using long vs. int 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},{"Question":"I need to manipulate large numbers in Python that fit into 64 bits. Currently, my code is running on a 64-bit platform but there is small but distinct possibility that it will have to run on a 32-bit platform. Consequently, I would prefer to use long type to represent my numbers. I understand there is a performance impact for using long over int type. How bad is it? I'll be performing a lot of divisions and multiplications on them, but the results should all fit into 64 bits, too.","AnswerCount":2,"Available Count":2,"Score":0.2913126125,"is_accepted":false,"ViewCount":904,"Q_Id":8828909,"Users Score":3,"Answer":"If your program does a lot of numerical computations - to a point that performance matters, you should profile it, and have the numerical part running in native code. You should not have to worry if internally the numbers are Python \"integers\" or \"long\" - so much that Python 3 removes the type difference.\nThere are several approaches for it, from using numpy, cython, a C extension, running your program using pypy instead of the standard cpython, and even take a look at corepy - what you should not do is to have a numeric intensive task running in pure python if performance is an issue there. Event he most complicated of these - creating a C extension in the form of a single function that just perform the calculations is simple enough to be well worth the performance gains in this case.","Q_Score":5,"Tags":"python,performance,cpython","A_Id":8829078,"CreationDate":"2012-01-12T01:08:00.000","Title":"Performance impact of using long vs. int 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},{"Question":"I'm building various python-based projects that use pip\/buildout to install dependencies. But I don't like the idea of someone deleting a github project and crippling my apps, or a network outage meaning I can't perform a deployment.\nHow do other people solve this?\nI've got various ideas, but I think perhaps the one that sounds most promising would be some kind of caching proxy server. I'd point pip to use this internal proxy server which would cache a copy of the downloaded project, and periodically check for updates (if there's a net connection) before serving cached versions.\nDoes anything like this already exist?\nUse case:\nI have a project which I deploy to web server 1. I add new features with a remote dependency, and when I come to update to the production web server, PyPi is down so I can't deploy. Or perhaps when I come to set up a new web server, a dependency has disappeared from github or wherever. \nHow can I make it so my deployments\/dev environments can always be brought up regardless of what happens in the wider world?\nAlso, when I deploy, I won't deploy over the top of existing code. Rather I'll build a new virtualenv and switch over to it so I can rollback if anything goes wrong. So each time I deploy I'll need to rebuild my environment and will need dependencies to exist.\nSo I'm looking for a solution that will insulate me against short-term network outages to servers hosting dependencies, as well as guarding against projects being deleted.","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":495,"Q_Id":8838782,"Users Score":0,"Answer":"You should keep a \"reference copy\" of the projects on which you depend.\nIf someone removes the project from GitHub (and PyPi and all the mirrors, and every other site on the net) then you have the source and can now distribute it.","Q_Score":1,"Tags":"python,pip,pypi","A_Id":8839036,"CreationDate":"2012-01-12T16:44:00.000","Title":"Caching Python requirements for production deployments","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm building various python-based projects that use pip\/buildout to install dependencies. But I don't like the idea of someone deleting a github project and crippling my apps, or a network outage meaning I can't perform a deployment.\nHow do other people solve this?\nI've got various ideas, but I think perhaps the one that sounds most promising would be some kind of caching proxy server. I'd point pip to use this internal proxy server which would cache a copy of the downloaded project, and periodically check for updates (if there's a net connection) before serving cached versions.\nDoes anything like this already exist?\nUse case:\nI have a project which I deploy to web server 1. I add new features with a remote dependency, and when I come to update to the production web server, PyPi is down so I can't deploy. Or perhaps when I come to set up a new web server, a dependency has disappeared from github or wherever. \nHow can I make it so my deployments\/dev environments can always be brought up regardless of what happens in the wider world?\nAlso, when I deploy, I won't deploy over the top of existing code. Rather I'll build a new virtualenv and switch over to it so I can rollback if anything goes wrong. So each time I deploy I'll need to rebuild my environment and will need dependencies to exist.\nSo I'm looking for a solution that will insulate me against short-term network outages to servers hosting dependencies, as well as guarding against projects being deleted.","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":495,"Q_Id":8838782,"Users Score":0,"Answer":"I have exactly the same requirements, and also use buildout to manage my deployments. I try not to install ANY of my package dependencies system-wide; I let buildout install eggs for all of them into my buildout. That way if I depend on a newer version of some package in rev N+1 of my project, and at \"go-live\" time N+1 falls on its face, I can roll back to N and automatically get the packge dependencies that N worked with. \nWe run a private eggbasket server, and configure buildout to fetch packages only from that. Server contents were initialized by allowing buildout to grab eggs from the network one time, then copying the downloaded eggs. \nThis way, upgrades to each package are totally under control and I can ensure that 2 successive buildouts of the same snapshot of my code will build out the same thing. When I want to upgrade all, I will let buildout fetch most-recent-versions again, test test test, then copy my eggs to the eggbasket server to go into production mode.","Q_Score":1,"Tags":"python,pip,pypi","A_Id":8839967,"CreationDate":"2012-01-12T16:44:00.000","Title":"Caching Python requirements for production deployments","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":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},{"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},{"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},{"Question":"Does doxygen doesn't work properly on python script with a shebang?\nI tried one python script with shebang to my company's tool directory and ran doxygen.\nIt was not able to display namespace (functions) at all.\nPlease share if you guys faced similar experience.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":221,"Q_Id":8890199,"Users Score":0,"Answer":"that sounds to me like a scripting problem and not like a conflict between Shebang and doxygen","Q_Score":0,"Tags":"python,doxygen,shebang","A_Id":8892855,"CreationDate":"2012-01-17T05:40:00.000","Title":"Shebang conflict with doxygen","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"Does doxygen doesn't work properly on python script with a shebang?\nI tried one python script with shebang to my company's tool directory and ran doxygen.\nIt was not able to display namespace (functions) at all.\nPlease share if you guys faced similar experience.","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":221,"Q_Id":8890199,"Users Score":1,"Answer":"enable EXTRACT_ALL to YES in the config file, doxygen will generate proper desired results.\nBut the question still remains, why doxygen failed to generate documentation file for python with EXTRACT_ALL = NO.\nAnyone with better answer can help me here.","Q_Score":0,"Tags":"python,doxygen,shebang","A_Id":9170986,"CreationDate":"2012-01-17T05:40:00.000","Title":"Shebang conflict with doxygen","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I would like to access the array with something like array[5000][440] meaning 5000ms from the start and 440hz and it would give me a value of the frequency's amplitude at this very position.\nI could not find something like that here, if there is, please point me to it.","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":521,"Q_Id":8899336,"Users Score":0,"Answer":"You're operating under a couple of misconceptions.\nYou can't get the frequency of a wave at a particular point in time. You need to select a window of time, including many points before and after the point of interest. The more points you include, the more resolution you'll have in your frequency breakdown. You'll need to run some sort of windowing function on those points, then subject them to a FFT.\nOnce you have the results of the FFT, the numbers will correspond to frequencies but it won't be a simple relationship. You don't have any control over the frequency corresponding to each output, that was already determined by the sampling frequency of your signal combined with the number of samples. I'm afraid I don't have the conversion formula at hand. Each frequency will have two components, a real and an imaginary, and the amplitude will be sqrt(r**2+i**2).","Q_Score":1,"Tags":"python,audio,fft,amplitude","A_Id":8903087,"CreationDate":"2012-01-17T17:55:00.000","Title":"How do I make python load a big(2hours) wave-file and convert it's contents into a time-frequency array?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I have a standard Apache2 installation on an Ubuntu server. The default settings use ScriptAlias to refer \/cgi-bin\/ to \/usr\/lib\/cgi-bin\/. If I place my Python CGI script in \/usr\/lib\/cgi-bin\/ it executes.\nI created \/var\/www\/cgi-bin\/ with appropriate permissions, removed the ScriptAlias line, changed the Directory entry in the default file for the site, moved the CGI file to \/var\/www\/cgi-bin\/ and restarted Apache2, but I was not able to get the script to run. It was appearing as a text file in the browser instead of being executed. The HTML file calling the script refers to \/cgi-bin\/SCRIPT, so I left that unchanged. I tried variations on \/cgi-bin and \/var\/www\/cgi-bin in the config files without success. How can I get a Python CGI file to run from \/var\/www\/cgi-bin?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":3691,"Q_Id":8910770,"Users Score":0,"Answer":"please make sure:\n\nthe file you are calling itself has enough permission\nthe file you are calling has an extension that is is in the .htaccess file (see newtover's answer)\nspecify how you want to run the script in the first line of the file. If you are calling foo.pl, make sure #!\/usr\/bin\/perl is in the first line.","Q_Score":1,"Tags":"python,apache2,cgi","A_Id":8911061,"CreationDate":"2012-01-18T13:17:00.000","Title":"Execute Python CGI from \/cgi-bin\/ 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":1,"Web Development":0},{"Question":"I've built python 2.7 debug with MSVC 2008 to debug a script that imports M2Crypto. When I run my script, python_d correctly creates a Python_Eggs cache, and copies both the __m2crypto.pyd and __m2crypto_d.pyd into it. But then it attempts to load the non-debug python module from the cache, and terminates because it contains no debug information. I've rebuilt both openssl and M2Crypto and made certain that no other copies exist on the build machine (a VM.) I've traced through python itself and cannot discover why it will not load the _d.pyd.\nAny ideas why this is happening?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":394,"Q_Id":8917800,"Users Score":1,"Answer":"First, the problem was that python attempted to load the non-debug version of __m2crypto.pyd, which failed, because it lacked dependent components. This caused python to terminate - not because the module was not found, but because one if its children was not found. This is a critical error for python, and whether this is a bug in python is for other minds to contemplate.\nUsing DEPENDENCY, I discovered that the openssl libraries were not installed into the python home folder. This was because the script that makes the M2Crypto distribution package has a \"feature\" which does not include these files. So the following resolved the issue:\n\nBuild openssl with debug\nModify the setup() call in M2Crypto\\setup.py to include data_files=['ssleay32.dll','libeay32.dll']\nBuild M2Crypto with debug, using the openssl debug\nInstall M2Crypto.\nProfit!\n\nAfterwards, I was able to import M2Crypto into both python and python_d.","Q_Score":1,"Tags":"python,m2crypto","A_Id":8945972,"CreationDate":"2012-01-18T21:34:00.000","Title":"python_d 2.7 will not load __m2crypto_d.pyd","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"EDIT: Solved, thanks everyone!\nWhat I would like to be able to do in simple terms is take user input from one programming language, convert it into another programming language and have it compiled automatically. \nFor example (simplified and not precisely what I want to do but along similar lines):\n1) Write a python script, userData = raw_input(\"blah blah blah, example, example\")\n2) if userData == \"blah blah blah, example, example\", serialize to a text file called \"example.cpp\" and put in some predetermined data which is based on the user's input (written in C++ form, though represented as a string in python script). For simplification this predetermined data will be called predeterminedData.\n3) The extent of predeterminedData will be essentially a cout << \"this is a different message to before\" << endl;\n4) The compiler (g++\/gcc) compiles this automatically and the overall program structure calls the newly created executable file.\nIf someone could help point me toward the topic\/topics I should read up on to be able to achieve this - if it's possible - that'd be fantastic.\nEdit: I've made a classic mistake I think. In an attempt to not be accused of asking other people to do my \"homework\" for me I've been too vague and consequently misleading. Thank you for the responses so far but perhaps now I should be more specific. It isn't particularly python nor c++ specific but I will explain beneath. I apologize for not being more explicit before.\nWhat I actually want to achieve is quite simple. I want to use user input from one programming language (python, c++, java) and have it create a Lilypond script which will automatically compile and create a midi file.\nSo for example:\n1) User is asked to enter alphabetically a series of notes: e.g. \"C\" then \"E\" then \"F\", so on and so on.\n2) These \"notes\" are checked by a control loop statement and a string is created in the Lilypond script and serialized to a file which is compatible with its compiler (example.ly)\n3) This file is automatically compiled by the Lilypond compiler and creates a midi file (example.midi)\n4) Later in the program this example.midi can be called on and played back because of this creation process. It would not have existed prior to this creation.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":161,"Q_Id":8918183,"Users Score":5,"Answer":"To me it sounds like you just want to write a user interface for interactive creation of lilypond files.\nI don't see what all this has to do with compilation. Your python script will need to write a file in lilypond notation and afterwards your script needs to call lilypond on that file (e.g. with os.system). You could even skip writing to a file and just pipe the output to stdin which lilypond can also read.","Q_Score":0,"Tags":"c++,python","A_Id":8918813,"CreationDate":"2012-01-18T22:06:00.000","Title":"Automatic compiling between languages","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},{"Question":"I am trying to build a set of git utilities with python. I am using subprocess.Popen to run the git binary. Right now I am just trying to find the best way to determine that there was an error in running a git command.\nMy question is whether or not git will always return a returncode of 0 on a successful git command and always return a returncode of non-zero on a unsuccessful call? I just want to make sure that checking the returncode is a safe way to detect an error so that I can exit the script if a git command was unsuccessful.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":220,"Q_Id":8954383,"Users Score":1,"Answer":"Yes, git (and any well-behaved *nix program) will always return 0 for success and non-zero for failure. This is the paradigm on GNU\/Linux systems, and since Git was made by the same person who made Linux, you can bet it follows the convention.","Q_Score":0,"Tags":"python,git,bash","A_Id":8954535,"CreationDate":"2012-01-21T15:58:00.000","Title":"Calling Git Binary From Python And Error Codes","Data Science and Machine Learning":0,"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},{"Question":"I want to ask if I should include the function that I am testing inside the unittest file (such that I will have one file, unittest.py), or I should just import it in the unittest file (I will have two files, unittest.py and function.py). I am seeing both methods when I read in the web, however I find the first testing that I described as redundant.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":42,"Q_Id":8955752,"Users Score":4,"Answer":"Two separate files of course. The idea is the unit test should be non-intrusive and should sit in the own file, usually clearly put under a test directory and\/or named test_*. I have never seen people put it in the same file unless it is the most trivial demo.","Q_Score":2,"Tags":"python,unit-testing,function","A_Id":8955802,"CreationDate":"2012-01-21T18:58:00.000","Title":"Should I include the function that I am testing inside the unittest file, or should I just import it in the unittest 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},{"Question":"I'm trying to improve the speed of an algorithm and, after looking at which operations are being called, I'm having difficulty pinning down exactly what's slowing things up. I'm wondering if Python's deepcopy() could possibly be the culprit or if I should look a little further into my own code.","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":8858,"Q_Id":8957400,"Users Score":0,"Answer":"The complexity of deepcopy() is dependant upon the size (number of elements\/children) of the object being copied. \nIf your algorithm's inputs do not affect the size of the object(s) being copied, then you should consider the call to deeopcopy() to be O(1) for the purposes of determining complexity, since each invocation's execution time is relatively static.\n(If your algorithm's inputs do have an effect on the size of the object(s) being copied, you'll have to elaborate how. Then the complexity of the algorithm can be evaluated.)","Q_Score":4,"Tags":"python,complexity-theory,deep-copy","A_Id":8957592,"CreationDate":"2012-01-21T22:48:00.000","Title":"What is the runtime complexity of Python's deepcopy()?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to improve the speed of an algorithm and, after looking at which operations are being called, I'm having difficulty pinning down exactly what's slowing things up. I'm wondering if Python's deepcopy() could possibly be the culprit or if I should look a little further into my own code.","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":8858,"Q_Id":8957400,"Users Score":1,"Answer":"What are you using deepcopy for? As the name suggests, deepcopy copies the object, and all subobjects recursively, so it is going to take an amount of time proportional to the size of the object you are copying. (with a bit of overhead to deal with circular references)\nThere isn't really any way to speed it up, if you are going to copy everything, you need to copy everything.\nOne question to ask, is do you need to copy everything, or can you just copy part of the structure.","Q_Score":4,"Tags":"python,complexity-theory,deep-copy","A_Id":8957598,"CreationDate":"2012-01-21T22:48:00.000","Title":"What is the runtime complexity of Python's deepcopy()?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"On a lab machine where I can't just go clobbering things, there appears to be more than one version of python installed. \nIf I python --version I see 2.7.1. \nI've installed numpy via \"apt-get install numpy\" and it says it is installed, but when I try to import it it isn't found. \nWhen I do a find on the machine for numpy I see it in the \/usr\/lib\/python2.5\/site-packages\/numpy folder. I assume this is the problem... that apt-get put it in the 2.5 version instead of the 2.7. \nHow do I resolve this? Is there a way to tell apt-get which python I'm talking about when I do an install? Or do I abandon aptitude and use pip or something?","AnswerCount":4,"Available Count":2,"Score":0.049958375,"is_accepted":false,"ViewCount":10268,"Q_Id":8964736,"Users Score":1,"Answer":"Apt\/dpkg have a Debian way of managing multiple installed versions of Python (I believe it is called python-support). Any extra package, like numpy, that you install will automatically be built and available for all the versions of Python supported by that package AND installed by dpkg. Since numpy supports every Python, your info tells me that the only Debian python package on your system is 2.5, and the 2.7 in your PATH is probably in \/usr\/local. When you install the numpy package it doesn't know about the locally built 2.7. You can always easy_install. \nThe suggestion to use virtualenv is a good one. I have a production system I support using python 2.5, which has been dropped from debian unstable; virtualenv makes it possible to work with whatever version you need. SInce python is needed by so many tools it's better leave system python at whatever Debian wants it to be.","Q_Score":4,"Tags":"python,numpy,aptitude","A_Id":8966563,"CreationDate":"2012-01-22T21:12:00.000","Title":"Multiple versions of python when installing a package with aptitude","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"On a lab machine where I can't just go clobbering things, there appears to be more than one version of python installed. \nIf I python --version I see 2.7.1. \nI've installed numpy via \"apt-get install numpy\" and it says it is installed, but when I try to import it it isn't found. \nWhen I do a find on the machine for numpy I see it in the \/usr\/lib\/python2.5\/site-packages\/numpy folder. I assume this is the problem... that apt-get put it in the 2.5 version instead of the 2.7. \nHow do I resolve this? Is there a way to tell apt-get which python I'm talking about when I do an install? Or do I abandon aptitude and use pip or something?","AnswerCount":4,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":10268,"Q_Id":8964736,"Users Score":0,"Answer":"Debian allows for multiple Pythons to be installed (the python2.5 and python2.6 packages). A Python library like numpy in the package python-numpy can support multiple of these, but particular libraries installed through the package manager are not necessarily supported on all of these. You can use apt-cache show python-numpy | grep Python-Version to see which versions are supported. If 2.7 is not supported, you'll have to install from source or (e.g.) pip, easy_install, etc.\nHowever, you may have a local installation of Python 2.7 (compiled and installed from sources outside of the repos). Your distro sounds a little out of date (on Linux Mint 12, only 2.6 and 2.7 are supported for numpy), so it's possible there aren't official packages for Python 2.7. If you do which python and it's in \/usr\/local or anywhere other than \/usr\/bin, then you've got a local installation and you will need to install the package using source or easy_install and friends.\nThat said, my opinion is that if you just need these libs for development, you should keep them in a sandbox (like virtualenv) in your home directory. That way you have better control over the exact version you have.","Q_Score":4,"Tags":"python,numpy,aptitude","A_Id":8976574,"CreationDate":"2012-01-22T21:12:00.000","Title":"Multiple versions of python when installing a package with aptitude","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"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},{"Question":"I am looking for a library to parse command-line parameters that would work identically in Java, C\/C++, Python and (preferably) shell. By \"identical\" I mean (1) have exactly the same rules for parsing of the parameters in all three languages, (2) use the same configuration files or have similar API to specify the parameters, (3) have similar APIs to access the values of the parameters. \nI've always used getopt in C and Apache CLI in Java but it would be nice to use the same specification for the parameters across multiple languages.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":393,"Q_Id":8992077,"Users Score":1,"Answer":"getopt is also usable in Python and shell. Python has the argparse module, which is much easier to use (particularly for more complex argument parsing), but if you want consistency across all those languages, I don't know of any better option than getopt. If Java doesn't have a getopt implementation, you could possibly write one yourself without too much effort.","Q_Score":4,"Tags":"java,python,c,parsing,command-line","A_Id":8993917,"CreationDate":"2012-01-24T18:31:00.000","Title":"Parser for command line parameters in Java\/C\/C++\/Python\/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":1},{"Question":"I want If I am editing a php file I should be able to press a key combination or click a menu item that'll launch the php-cli and run my current file? How do I do it in Notepad++.\nAlso I need this for Python.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":3513,"Q_Id":9001046,"Users Score":1,"Answer":"You could check out the \"Run\" menu option. It allows you to bind key combinations to applications.","Q_Score":1,"Tags":"php,python,editor,notepad++","A_Id":9001202,"CreationDate":"2012-01-25T10:23:00.000","Title":"How can I integrate PHP\/Python Interpreter to Notepad++","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm using Pyramid framework and I want to access the IP address from which the request originated. I assume it's in the request object (passed to every view function) somewhere, but I can't find documentation which tells me where it is.","AnswerCount":3,"Available Count":1,"Score":0.2605204458,"is_accepted":false,"ViewCount":5593,"Q_Id":9007887,"Users Score":4,"Answer":"Or you can use request.environ['REMOTE_ADDR']","Q_Score":15,"Tags":"python,pyramid","A_Id":9010633,"CreationDate":"2012-01-25T18:12:00.000","Title":"Getting the request IP address 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":0},{"Question":"I have (3) md5sums that I need to combine into a single hash. The new hash should be 32-characters, but is case-sensitive and can be any letter or number. What's the best way to do this in Python?","AnswerCount":4,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":1664,"Q_Id":9009807,"Users Score":2,"Answer":"The easiest way would be to combine the 3 sums into a single 96-character string and run an MD5 hash on that.","Q_Score":3,"Tags":"python,md5,hashlib","A_Id":9009930,"CreationDate":"2012-01-25T20:30:00.000","Title":"Combine (3) 32-char hex hashes into a single unique 32-char hash?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"In C\/C++ like languages, closing zeromq socket explicitly is a must, which I understand. But in some higher level languages, such as php and python, which have garbage collection mechanism, do I need to close the sockets explicitly?\nIn php, there is no ZMQSocket::close() and in python, pyzmq's doc says socket.close() can be omitted since it will be closed automatically during garbage collection.\nSo my question is, do I need to manually close it or not?...","AnswerCount":4,"Available Count":2,"Score":0.049958375,"is_accepted":false,"ViewCount":13070,"Q_Id":9019873,"Users Score":1,"Answer":"You don't. You might close or delete things explicitly in Python when:\n\nOrdering becomes important, such as requiring the connection to be closed before you can proceed.\nYour references to the objects will persist for a long time, and the resource will no longer be required after some time. This might happen if you're storing them in lists or as member variables. You should explicitly close the resource, or remove references to it when you are done.\n\nGenerally speaking it's pedantic and premature to even think about such things in Python.","Q_Score":8,"Tags":"python,zeromq","A_Id":9019940,"CreationDate":"2012-01-26T14:47:00.000","Title":"Should I close zeromq socket explicitly 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},{"Question":"In C\/C++ like languages, closing zeromq socket explicitly is a must, which I understand. But in some higher level languages, such as php and python, which have garbage collection mechanism, do I need to close the sockets explicitly?\nIn php, there is no ZMQSocket::close() and in python, pyzmq's doc says socket.close() can be omitted since it will be closed automatically during garbage collection.\nSo my question is, do I need to manually close it or not?...","AnswerCount":4,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":13070,"Q_Id":9019873,"Users Score":3,"Answer":"It is always correct to close any I\/O resources when you are done with them. The garbage collector will close them off eventually. It may close it immediately once the last reference goes out of scope. It may close it as your program is exiting. While you wait for it to do so, the resource remains open taking up memory, consuming file pointers, and eating up your system resources in general. For a small, short lived program this may not be a big issue, but if your software is long living or establishes a lot of connections, this will come back to hurt you.\nThe answer is: it depends. If your system is reliant on the socket getting closed, then you are safer closing them explicitly. If you are fine with the socket getting closed at some indeterminate future time, you can save yourself a little bit of coding time and simplify your program a bit by just letting the garbage collector handle it.","Q_Score":8,"Tags":"python,zeromq","A_Id":9399409,"CreationDate":"2012-01-26T14:47:00.000","Title":"Should I close zeromq socket explicitly 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},{"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},{"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},{"Question":"I am trying very hard to develop a much deeper understanding of programming as a whole. I understand the textbook definition of \"binary\", but what I don't understand is exactly how it applies to my day to day programming? \nThe concept of \"binary numbers\" vs .. well... \"regular\" numbers, is completely lost on me despite my best attempts to research and understand the concept. \nI am someone who originally taught myself to program by building stupid little adventure games in early DOS Basic and C, and now currently does most (er, all) of my work in PHP, JavaScript, Rails, and other \"web\" languages. I find that so much of this logic is abstracted out in these higher level languages that I ultimately feel I am missing many of the tools I need to continue progressing and writing better code. \nIf anyone could point me in the direction of a good, solid practical learning resource, or explain it here, it would be massively appreciated.\nI'm not so much looking for the 'definition' (I've read the wikipedia page a few times now), but more some direction on how I can incorporate this new-found knowledge of exactly what binary numbers are into my day to day programming, if at all. I'm primarily writing in PHP these days, so references to that language specifically would be very helpful. \nEdit: As pointed out.. binary is a representation of a number, not a different system altogether.. So to revise my question, what are the benefits (if any) of using binary representation of numbers rather than just... numbers.","AnswerCount":8,"Available Count":4,"Score":0.024994793,"is_accepted":false,"ViewCount":1423,"Q_Id":9041185,"Users Score":1,"Answer":"rather more of an experience rather than a solid answer:\nactually, you don't actually need binary because it's pretty much abstracted in programming nowadays (depending on what you program). binary has more use in the systems design and networking.\nsome things my colleagues at school do in their majors:\n\nprocessor instruction sets and operations (op codes)\nnetworking and data transmission\nhacking (especially memory \"tampering\". more of hex but still related)\nmemory allocation (in assembly, we use hex but sometimes binary)\n\nyou need to know how these \"regular numbers\" are represented and understood by the machine - hence all those \"conversion lessons\" like hex to binary, binary to octal etc. machines only read binary.","Q_Score":6,"Tags":"php,python,binary,binary-data","A_Id":9041341,"CreationDate":"2012-01-27T22:57:00.000","Title":"How do \"binary\" numbers relate to my everyday programming?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying very hard to develop a much deeper understanding of programming as a whole. I understand the textbook definition of \"binary\", but what I don't understand is exactly how it applies to my day to day programming? \nThe concept of \"binary numbers\" vs .. well... \"regular\" numbers, is completely lost on me despite my best attempts to research and understand the concept. \nI am someone who originally taught myself to program by building stupid little adventure games in early DOS Basic and C, and now currently does most (er, all) of my work in PHP, JavaScript, Rails, and other \"web\" languages. I find that so much of this logic is abstracted out in these higher level languages that I ultimately feel I am missing many of the tools I need to continue progressing and writing better code. \nIf anyone could point me in the direction of a good, solid practical learning resource, or explain it here, it would be massively appreciated.\nI'm not so much looking for the 'definition' (I've read the wikipedia page a few times now), but more some direction on how I can incorporate this new-found knowledge of exactly what binary numbers are into my day to day programming, if at all. I'm primarily writing in PHP these days, so references to that language specifically would be very helpful. \nEdit: As pointed out.. binary is a representation of a number, not a different system altogether.. So to revise my question, what are the benefits (if any) of using binary representation of numbers rather than just... numbers.","AnswerCount":8,"Available Count":4,"Score":0.0,"is_accepted":false,"ViewCount":1423,"Q_Id":9041185,"Users Score":0,"Answer":"As a web guy, you no doubt understand the importance of unicode. Unicode is represented in hexidecimal format when viewing character sets not supported by your system. Hexidecimal also appears in RGB values, and memory addresses. Hexideciaml is, among many things, a shorthand for writing out long binary characters.\nFinally, binary numbers work as the basis of truthiness: 1 is true, while 0 is always false.\nGo check out a book on digital fundementals, and try your hand at boolean logic. You'll never look at if a and not b or c the same way again!","Q_Score":6,"Tags":"php,python,binary,binary-data","A_Id":9041392,"CreationDate":"2012-01-27T22:57:00.000","Title":"How do \"binary\" numbers relate to my everyday programming?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying very hard to develop a much deeper understanding of programming as a whole. I understand the textbook definition of \"binary\", but what I don't understand is exactly how it applies to my day to day programming? \nThe concept of \"binary numbers\" vs .. well... \"regular\" numbers, is completely lost on me despite my best attempts to research and understand the concept. \nI am someone who originally taught myself to program by building stupid little adventure games in early DOS Basic and C, and now currently does most (er, all) of my work in PHP, JavaScript, Rails, and other \"web\" languages. I find that so much of this logic is abstracted out in these higher level languages that I ultimately feel I am missing many of the tools I need to continue progressing and writing better code. \nIf anyone could point me in the direction of a good, solid practical learning resource, or explain it here, it would be massively appreciated.\nI'm not so much looking for the 'definition' (I've read the wikipedia page a few times now), but more some direction on how I can incorporate this new-found knowledge of exactly what binary numbers are into my day to day programming, if at all. I'm primarily writing in PHP these days, so references to that language specifically would be very helpful. \nEdit: As pointed out.. binary is a representation of a number, not a different system altogether.. So to revise my question, what are the benefits (if any) of using binary representation of numbers rather than just... numbers.","AnswerCount":8,"Available Count":4,"Score":0.0996679946,"is_accepted":false,"ViewCount":1423,"Q_Id":9041185,"Users Score":4,"Answer":"Here is a brief history to help your understanding and I will get to your question at the end.\nBinary is a little weird because we are so used to using a base 10 number system. This is because humans have 10 fingers, when they ran out they had to use a stick, toe or something else to represent 10 fingers. This it not true for all cultures though, some of the hunter gatherer populations (such as the Australian Aboriginal) used a base 5 number system (one hand) as producing large numbers were not necessary.\nAnyway, the reason base 2 is important in computing is because a circuit can have two states, low voltage and high voltage; think of this like a switch (on and off). Place 8 of these switches together and you have 1 byte (8 bits). The best way to think of a bit is 1=on and 0=off which is exactly how it is represented in binary. You might then have something like this 10011100 where 1's are high volts and 0 are low volts. In early computers, physical switches were used which the the operator could turn on and off to create a program.\nNowadays, you will rarely need to use binary number in modern programming. The only exceptions I can think of is bitwise arithmetic which are very fast and efficient ways of solving certain problems or maybe some form of computer hacking. All I can suggest is learn the basics of it but don't worry about actually using it in everyday programming.","Q_Score":6,"Tags":"php,python,binary,binary-data","A_Id":9041557,"CreationDate":"2012-01-27T22:57:00.000","Title":"How do \"binary\" numbers relate to my everyday programming?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying very hard to develop a much deeper understanding of programming as a whole. I understand the textbook definition of \"binary\", but what I don't understand is exactly how it applies to my day to day programming? \nThe concept of \"binary numbers\" vs .. well... \"regular\" numbers, is completely lost on me despite my best attempts to research and understand the concept. \nI am someone who originally taught myself to program by building stupid little adventure games in early DOS Basic and C, and now currently does most (er, all) of my work in PHP, JavaScript, Rails, and other \"web\" languages. I find that so much of this logic is abstracted out in these higher level languages that I ultimately feel I am missing many of the tools I need to continue progressing and writing better code. \nIf anyone could point me in the direction of a good, solid practical learning resource, or explain it here, it would be massively appreciated.\nI'm not so much looking for the 'definition' (I've read the wikipedia page a few times now), but more some direction on how I can incorporate this new-found knowledge of exactly what binary numbers are into my day to day programming, if at all. I'm primarily writing in PHP these days, so references to that language specifically would be very helpful. \nEdit: As pointed out.. binary is a representation of a number, not a different system altogether.. So to revise my question, what are the benefits (if any) of using binary representation of numbers rather than just... numbers.","AnswerCount":8,"Available Count":4,"Score":0.049958375,"is_accepted":false,"ViewCount":1423,"Q_Id":9041185,"Users Score":2,"Answer":"To me, one of the biggest impacts of a binary representation of numbers is the difference between floating point values and our \"ordinary\" (base-10 or decimal) notion of fractions, decimals, and real numbers.\nThe vast majority of fractions cannot be exactly represented in binary. Something like 0.4 seems like it's not a hard number to represent; it's only got one place after the decimal, it's the same as two fifths or 40%, what's so tough? But most programming environments use binary floating point, and cannot represent this number exactly! Even if the computer displays 0.4, the actual value used by the computer is not exactly 0.4. So you get all kinds of unintuitive behavior when it comes to rounding and arithmetic.\nNote that this \"problem\" is not unique to binary. For example, using our own base-10 decimal notation, how do we represent one third? Well, we can't do it exactly. 0.333 is not exactly the same as one third. 0.333333333333 is not exactly one third either. We can get pretty close, and the more digits you let us use, the closer we can get. But we can never, ever be exactly right, because it would require an infinite number of digits. This is fundamentally what's happening when binary floating point does something we don't expect: The computer doesn't have an infinite number of binary digits (bits) to represent our number, and so it can't get it exactly right, but gives us the closest thing it can.","Q_Score":6,"Tags":"php,python,binary,binary-data","A_Id":9041603,"CreationDate":"2012-01-27T22:57:00.000","Title":"How do \"binary\" numbers relate to my everyday programming?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have the following requirements (from the client) for zipping a number of files. \nIf the zip file created is less than 2**31-1 ~2GB use compression to create it (use zipfile.ZIP_DEFLATED), otherwise do not compress it (use zipfile.ZIP_STORED).\nThe current solution is to compress the file without zip64 and catching the zipfile.LargeZipFile exception to then create the non-compressed version.\nMy question is whether or not it would be worthwhile to attempt to calculate (approximately) whether or not the zip file will exceed the zip64 size without actually processing all the files, and how best to go about it? The process for zipping such large amounts of data is slow, and minimizing the duplicate compression processing might speed it up a bit.\nEdit: I would upvote both solutions, as I think I can generate a useful heuristic from a combination of max and min file sizes and compression ratios. Unfortunately at this time, StackOverflow prevents me from upvoting anything (until I have a reputation higher than noob). Thanks for the good suggestions.","AnswerCount":3,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":1620,"Q_Id":9042086,"Users Score":0,"Answer":"A heuristic approach will always involve some false positives and some false negatives.\nThe eventual size of the zipped file will depend on a number of factors, some of which are not knowable without running the compression process itself.\nZip64 allows you to use many different compression formats, such as bzip2, LZMA, etc.\nEven the compression format may do the compression differently depending on the data to be compressed. For example, bzip2 can use Burrows-Wheeler, run length encoding and Huffman among others. The eventual size of the file will then depend on the statistical properties of the data being compressed.\nTake Huffman, for instance; the size of the symbol table depends on how randomly-distributed the content of the file is.\nOne can go on and try to profile different types of data, serialized binary, text, images etc. and each will have a different normal distribution of final zipped size.\nIf you really need to save time by doing the process only once, apart from building a very large database and using a rule-based expert system or one based on Bayes' Theorem, there is no real 100% approach to this problem.\nYou could also try sampling blocks of the file at random intervals and compressing this sample, then linearly interpolating based on the size of the file.","Q_Score":1,"Tags":"python,zip","A_Id":9042877,"CreationDate":"2012-01-28T01:09:00.000","Title":"Calculate (approximately) if zip64 extensions are required without relying on exceptions?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I have the following requirements (from the client) for zipping a number of files. \nIf the zip file created is less than 2**31-1 ~2GB use compression to create it (use zipfile.ZIP_DEFLATED), otherwise do not compress it (use zipfile.ZIP_STORED).\nThe current solution is to compress the file without zip64 and catching the zipfile.LargeZipFile exception to then create the non-compressed version.\nMy question is whether or not it would be worthwhile to attempt to calculate (approximately) whether or not the zip file will exceed the zip64 size without actually processing all the files, and how best to go about it? The process for zipping such large amounts of data is slow, and minimizing the duplicate compression processing might speed it up a bit.\nEdit: I would upvote both solutions, as I think I can generate a useful heuristic from a combination of max and min file sizes and compression ratios. Unfortunately at this time, StackOverflow prevents me from upvoting anything (until I have a reputation higher than noob). Thanks for the good suggestions.","AnswerCount":3,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":1620,"Q_Id":9042086,"Users Score":0,"Answer":"I can only think of two ways, one simple but requires manual tuning, and the other may not provide enough benefit to justify the complexity.\n\nDefine a file size at which you just skip the zip attempt, and tune it to your satisfacton by hand.\nKeep a record of the last N filesizes between the smallest failure to zip ever observed and the largest successful zip ever observed. Decide what the acceptable probability of an incorrect choice resulting in an file that should be zipped not being zipped (say 5%). set your \"don't bother trying to zip\" threshold such that it would have resulted in that percentage of files that would have been erroneously left unzipped.\n\nIf you absolutely can never miss an opportunity to zip file that should have been zipped then you've already got the solution.","Q_Score":1,"Tags":"python,zip","A_Id":9042227,"CreationDate":"2012-01-28T01:09:00.000","Title":"Calculate (approximately) if zip64 extensions are required without relying on exceptions?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I have the following requirements (from the client) for zipping a number of files. \nIf the zip file created is less than 2**31-1 ~2GB use compression to create it (use zipfile.ZIP_DEFLATED), otherwise do not compress it (use zipfile.ZIP_STORED).\nThe current solution is to compress the file without zip64 and catching the zipfile.LargeZipFile exception to then create the non-compressed version.\nMy question is whether or not it would be worthwhile to attempt to calculate (approximately) whether or not the zip file will exceed the zip64 size without actually processing all the files, and how best to go about it? The process for zipping such large amounts of data is slow, and minimizing the duplicate compression processing might speed it up a bit.\nEdit: I would upvote both solutions, as I think I can generate a useful heuristic from a combination of max and min file sizes and compression ratios. Unfortunately at this time, StackOverflow prevents me from upvoting anything (until I have a reputation higher than noob). Thanks for the good suggestions.","AnswerCount":3,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":1620,"Q_Id":9042086,"Users Score":0,"Answer":"The only way I know of to estimate the zip file size is to look at the compression ratios for previously compressed files of a similar nature.","Q_Score":1,"Tags":"python,zip","A_Id":9042092,"CreationDate":"2012-01-28T01:09:00.000","Title":"Calculate (approximately) if zip64 extensions are required without relying on exceptions?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I am looking for an existing library or code samples, to extract the relevant parts from a mime message structure in order to perform analysis on the textual content of those parts.\nI will explain:\nI am writing a library (in Python) that is part of a project that needs to iterate over very large amount of email messages through IMAP. For each message, it needs to determine what are the mime parts it will need in order to analyze the textual content of the message that require the least amount of parsing (e.g. prefer text\/plain over text\/html or rich text) and without duplicates (i.e. if text\/plain exists, ignore the matching text\/html). It also needs to address nested parts (text attachments, forwarded messages, etc) and all this without downloading the entire message body (takes too much time and bandwidth). The end goal is later to retrieve only those parts in order to perform some statistical and pattern analysis on the text content of those messages (excluding any markup, meta data, binary data, etc).\nThe libraries and examples I've seen, require the full message body in order to assemble the message structure and understand the content of the message. I am trying to achieve this using the response from the IMAP FETCH command with the BODYSTRUCTURE data item.\nBODYSTRUCTURE should contain enough information to achieve my goal but although the structure and returned data are officially documented in the relevant RFCs (3501, 2822, 2045), the amount of nesting, combinations and various quirks all add up to make the task very tedious and error prune.\nDoes anyone know any libraries that can help to achieve this or any code samples (preferably in Python but any language will do)?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1090,"Q_Id":9045626,"Users Score":0,"Answer":"Answering my own question for the sake of completeness and to close this question.\nI couldn't find any existing library that answers the requirements. I ended up writing my own code to fetch BODYSTRUCTURE tree, parse it and store it in an internal structure. This gives me the control I need to decide which exact parts of the message I need to actually download and take into account various cases like attachments, forwards, redundant parts (plain text vs html) etc.","Q_Score":0,"Tags":"python,email,imap,mime","A_Id":13953238,"CreationDate":"2012-01-28T13:32:00.000","Title":"MIME message structure parsing and analysis","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},{"Question":"I am retrieving emails from my email server using IMAPClient (Python), by checking for emails flagged with \"\\Recent\". After the email has been read the email server automatically sets the email flag to \"\\Seen\".\nWhat I want to do is reset the email flag to \"\\Recent\" so when I check the email directly on the server is still appears as unread.\nWhat I'm finding is that IMAPClient is throwing an exception when I try to add the \"\\Recent\" flag to an email using IMAPClient's \"set_flag\" definition. Adding any other flag works fine.\nThe IMAPClient documentation say's the Recent flag is read-only, but I was wondering if there is still a way to mark an email as un-read. \nFrom my understanding email software like Thunderbird allows you to set emails as un-read so I assume there must be a way to do it.\nThanks.","AnswerCount":4,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":5938,"Q_Id":9058865,"Users Score":1,"Answer":"Disclaimer: I'm familiar with IMAP but not Python-IMAPClient specifically.\nNormally the 'seen' flag determines if an email summary will be shown normal or bold.\nYou should be able to reset the seen flag. However the recent flag may not be under your direct control. The imap server will set it if notices new messages arriving.","Q_Score":4,"Tags":"python,imaplib","A_Id":9059000,"CreationDate":"2012-01-30T03:00:00.000","Title":"How to change email flag to Recent using IMAPClient","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I have a GPS module connected through serial port(USB->Virtual COM port). A measurement software is using this port, so with other software I can't access to the data. I would like to create two virtual COM port and share this data through that. Is it possible using Python? Is there any opensource example written in Python?","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":732,"Q_Id":9065831,"Users Score":2,"Answer":"I don't think you can do that if you cannot modify the sources of the measurement software.\nSerial port protocols are written as \"point to point\" protocols, so there's no general way to multiplex them. You can write a program that shares the access to the GPS module (handling it exclusively and exposing an API to multiple programs), but every program that wanted to use the GPS module should be written to talk to your API and not directly to the serial port - and in this case it can be done only if you can change the measurement software.\nNotice that probably it's not impossible to implement your \"virtual port\" solution, but it would be an ad-hoc hack (it would work just with that specific protocol) and it may be quite complicated: you would need to emulate two GPS modules and multiplex the requests to the real GPS module; depending on how does it work (e.g. if it has a \"complicated\" persistent state) it may be simple or very complicated. But surely Python wouldn't be enough, to emulate serial ports you have to go in kernel mode.","Q_Score":0,"Tags":"python,serial-port","A_Id":9065933,"CreationDate":"2012-01-30T14:56:00.000","Title":"Share serial port on Windows 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},{"Question":"I have a GPS module connected through serial port(USB->Virtual COM port). A measurement software is using this port, so with other software I can't access to the data. I would like to create two virtual COM port and share this data through that. Is it possible using Python? Is there any opensource example written in Python?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":732,"Q_Id":9065831,"Users Score":0,"Answer":"Do you need two-way communication, or just reading? You could build or buy hardware to physically split the Rx data line so you could use two COM ports, each of which would read the same data. You could do this with Tx data as well, but you would have to be careful about trashing the data if both ports tried to write at the same time.","Q_Score":0,"Tags":"python,serial-port","A_Id":9068214,"CreationDate":"2012-01-30T14:56:00.000","Title":"Share serial port on Windows 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},{"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},{"Question":"I just created an EGG file on a python project and it created a zip file which contained the source as well as the python compiled file(s). Does it make sense to ship the source as part of the EGG file, if so how can I avoid it during egg file creation?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":121,"Q_Id":9078985,"Users Score":1,"Answer":"(a) It makes sense\n(b) If you really want to avoid it, then just delete the .py files from the egg.\n(c) I bet one can reconstruct the full source (less comments) from .pyc files.","Q_Score":1,"Tags":"python,python-3.x","A_Id":9080000,"CreationDate":"2012-01-31T11:46:00.000","Title":"Does it make sense to ship python source files as part of the egg 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},{"Question":"I am currently working on a project using python to implement p2p communication between two (or more) computers. Although I am pretty proficient with python, I am by no means an expert; programming and encryption are by no means my profession, simply a hobby. However, in working on this project I have been attempting to learn more about encryption as well as network programming.\nAs of right now I have written a pretty powerful class that communicates well over a network and I am trying to improve it by implementing RSA to encrypt the connections between peers on the network; this is where I've run into some difficulty.\nI have previously used pycrypto to do some basic encryption\/decryption in python and am thus-far quite comfortable with all of the tools involved -- including the necessary public-key ciphers. Moreover, I am also aware that pycrypto has some shortcomings, in the fact that it only implements the bare-bones, low level encryption\/decryption algorithms needed to implement RSA and does not implement a full protocol for public-key encryption. I also know that pycrypto contains some other useful tools such as an AllOrNothing transform which can be used for padding the communication, etc. However, my question is: can anyone recommend any online articles, books, blog posts, projects, etc. which can help me in my quest to implement an effective RSA protocol?\nLastly, I understand that this is a touchy subject with cryptologists in that amateur-implemented protocols usually mean less security in the program. As I noted above, this project is a mere learning experience; if I was completing this project professionally I would surely use M2Crypto or some other professionally-implemented, secure protocol -- i.e. SSL\/TLS. Alas, I am merely trying to learn more about encryption by implementing my own model of a proven protocol to create a secure connection between two peers.\nThanks,\nKevin","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":6921,"Q_Id":9093046,"Users Score":0,"Answer":"pycrypto has some shortcomings, in the fact that it only implements the bare-bones, low level encryption\/decryption algorithms needed to implement RSA and does not implement a full protocol for public-key encryption.\n\nThe current version PyCrypto (2.6) does support all major RSA protocols for signature and encryption namely those specified in PKCS#1 (v1.5, PSS, OAEP).","Q_Score":9,"Tags":"python,encryption,rsa,pycrypto","A_Id":13454184,"CreationDate":"2012-02-01T08:50:00.000","Title":"Implementing full RSA 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},{"Question":"I recently came across the dataType called bytearray in python. Could someone provide scenarios where bytearrays are required?","AnswerCount":4,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":36917,"Q_Id":9099145,"Users Score":56,"Answer":"A bytearray is very similar to a regular python string (str in python2.x, bytes in python3) but with an important difference, whereas strings are immutable, bytearrays are mutable, a bit like a list of single character strings.\nThis is useful because some applications use byte sequences in ways that perform poorly with immutable strings. When you are making lots of little changes in the middle of large chunks of memory, as in a database engine, or image library, strings perform quite poorly; since you have to make a copy of the whole (possibly large) string. bytearrays have the advantage of making it possible to make that kind of change without making a copy of the memory first.\nBut this particular case is actually more the exception, rather than the rule. Most uses involve comparing strings, or string formatting. For the latter, there's usually a copy anyway, so a mutable type would offer no advantage, and for the former, since immutable strings cannot change, you can calculate a hash of the string and compare that as a shortcut to comparing each byte in order, which is almost always a big win; and so it's the immutable type (str or bytes) that is the default; and bytearray is the exception when you need it's special features.","Q_Score":50,"Tags":"python,types","A_Id":9099337,"CreationDate":"2012-02-01T16:09:00.000","Title":"Where are python bytearrays 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":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"We have numerous python classes that do not seem to need __init__, initialising them empty is either perfectly acceptable or even preferable. PyLint seems to think this is a bad thing. Am I missing some insight into why having no __init__ is a Bad Smell? Or should I just suppress those warnings and get over it?","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":9818,"Q_Id":9100616,"Users Score":13,"Answer":"What are you using these classes for?\nIf they are just a grouping of functions that do not need to maintain any state, there is no need for an __init__() but it would make more sense to just move all of those functions into their own module.\nIf they do maintain a state (they have instance variables) then you should probably have an __init__() so that those variables can be initialized. Even if you never provide values for them when the class is created, it is generally a good idea to have them defined so that your method calls are not referencing instance variables that may or may not exist.\nThat being said, if you don't need an __init__(), feel free to ignore that warning.\nedit: Based on your comment, it seems like you are fine with the AttributeError you will get on referencing variables before initialization. That is a perfectly fine way to program your classes so in that case ignoring the warning from PyLint is reasonable.","Q_Score":22,"Tags":"python,pylint","A_Id":9100718,"CreationDate":"2012-02-01T17:46:00.000","Title":"Why does PyLint warn about no __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},{"Question":"We have numerous python classes that do not seem to need __init__, initialising them empty is either perfectly acceptable or even preferable. PyLint seems to think this is a bad thing. Am I missing some insight into why having no __init__ is a Bad Smell? Or should I just suppress those warnings and get over it?","AnswerCount":2,"Available Count":2,"Score":0.1973753202,"is_accepted":false,"ViewCount":9818,"Q_Id":9100616,"Users Score":2,"Answer":"Usually you will at least use the __init__() method to initialize instance variables. If you are not doing this, then by all means turn off that warning.","Q_Score":22,"Tags":"python,pylint","A_Id":9100640,"CreationDate":"2012-02-01T17:46:00.000","Title":"Why does PyLint warn about no __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},{"Question":"For imported module, is it possible to get the importing module (name)? I'm wondering if inspect can achieve it or not~","AnswerCount":4,"Available Count":2,"Score":0.1488850336,"is_accepted":false,"ViewCount":106,"Q_Id":9106166,"Users Score":3,"Answer":"Even if you got it to work, this is probably less useful than you think since subsequent imports only copy the existing reference instead of executing the module again.","Q_Score":2,"Tags":"python","A_Id":9106241,"CreationDate":"2012-02-02T02:04:00.000","Title":"Is it possible to get \"importing module\" in \"imported module\" 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":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"For imported module, is it possible to get the importing module (name)? I'm wondering if inspect can achieve it or not~","AnswerCount":4,"Available Count":2,"Score":0.1488850336,"is_accepted":false,"ViewCount":106,"Q_Id":9106166,"Users Score":3,"Answer":"It sounds like you solved your own problem: use the inspect module. I'd traverse up the stack until I found a frame where the current function was not __import__. But I bet if you told people why you want to do this, they'd tell you not to.","Q_Score":2,"Tags":"python","A_Id":9106211,"CreationDate":"2012-02-02T02:04:00.000","Title":"Is it possible to get \"importing module\" in \"imported module\" 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":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"In many different code environments' official documentation I see UTF-8 expressed either as upper- or lower- case, and also with and without the dash. Are there any places where one or the other is important to use?\nSome places where these strings are found include:\n\nThe PHP manual in reference to header() arguments (HTTP headers)\nThe PHP manual in reference to PHP function arguments\nThe PHP manual in reference to internal configuration\nThe MySQL manual in reference to configuration\nPython 2 code encoding declaration\nBash locale configuration\nHTML meta tags\nXML doctypes","AnswerCount":2,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":699,"Q_Id":9117378,"Users Score":8,"Answer":"This is indeed wildly different. One place will accept only one form; the other place will only accept the other.\nListing here which is correct in which situation is not a good idea - it would be a huge and pointless open-ended list. Simply always look up in the respective documentation which form(s) is\/are accepted for the specific situation.","Q_Score":4,"Tags":"php,python,mysql,html,utf-8","A_Id":9117402,"CreationDate":"2012-02-02T17:56:00.000","Title":"Are there any places where utf8 vs. utf-8 vs. UTF8 vs. UTF-8 makes a difference?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I have a bunch of mp3 files that are pretty old and don't have any copy rights. Yet, the place I got them from has filled the copy right tags with its own website url. \nI was wondering if there's an easy way to remove these tags programmatically? There's a winamp add on that allows me to do this for each song, but that's not very feasible.\nEdit: Is copyright part of the ID3 tags?\nThanks,\n-Roozbeh","AnswerCount":7,"Available Count":3,"Score":0.0285636566,"is_accepted":false,"ViewCount":45647,"Q_Id":9125733,"Users Score":1,"Answer":"You can just use VLC player. Click on Tools->Media Information","Q_Score":3,"Tags":"php,python,id3","A_Id":19575869,"CreationDate":"2012-02-03T08:31:00.000","Title":"How can I remove the copyright tag from ID3 of mp3s in python or php?","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},{"Question":"I have a bunch of mp3 files that are pretty old and don't have any copy rights. Yet, the place I got them from has filled the copy right tags with its own website url. \nI was wondering if there's an easy way to remove these tags programmatically? There's a winamp add on that allows me to do this for each song, but that's not very feasible.\nEdit: Is copyright part of the ID3 tags?\nThanks,\n-Roozbeh","AnswerCount":7,"Available Count":3,"Score":-0.0285636566,"is_accepted":false,"ViewCount":45647,"Q_Id":9125733,"Users Score":-1,"Answer":"No Need Of any PHP code\nJust Reproduce the mp3 file i.e.either burn & rip or cut the size &time making a new file where you can specify your own multitudes of options","Q_Score":3,"Tags":"php,python,id3","A_Id":39645756,"CreationDate":"2012-02-03T08:31:00.000","Title":"How can I remove the copyright tag from ID3 of mp3s in python or php?","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},{"Question":"I have a bunch of mp3 files that are pretty old and don't have any copy rights. Yet, the place I got them from has filled the copy right tags with its own website url. \nI was wondering if there's an easy way to remove these tags programmatically? There's a winamp add on that allows me to do this for each song, but that's not very feasible.\nEdit: Is copyright part of the ID3 tags?\nThanks,\n-Roozbeh","AnswerCount":7,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":45647,"Q_Id":9125733,"Users Score":0,"Answer":"Yes Yes This works!\nJust download the latest version of VLC media player. Open the mp3 file in it. \nRight click on file > choose 'information' > edit publisher & copyright information there > click 'Save Metadata' below.\nAnd u r done. :)","Q_Score":3,"Tags":"php,python,id3","A_Id":26053995,"CreationDate":"2012-02-03T08:31:00.000","Title":"How can I remove the copyright tag from ID3 of mp3s in python or php?","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},{"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},{"Question":"I have one testing module that I want to use for android testing. I have the files but there is no installation file for it, so I added the module to PATH variable, even then it doesn't work I try to import it.\nAny way to make it work. Do I have to paste them in Python folder only (and what it the Python file location).\nIn windows, I use to paste all the files in Python folder and everything works perfectly fine. Here in Ubuntu I'm not able to find the location so I added it in PATH.\nAny way out! \nAny help is appreciated.\nCheers\nSome details: Python version: 2.7.2, Ubuntu 11.10 OS, Python module is in file\/folder format with no \"setup.py\" file to install, Location of module already in PATH variable, Everything else in Python is working beside that module, same worked in Windows XP with Python 2.7.2 after copy pasting.","AnswerCount":2,"Available Count":1,"Score":0.4621171573,"is_accepted":false,"ViewCount":14142,"Q_Id":9143570,"Users Score":5,"Answer":"You can add a __init__.py file without any content to the directory which yo want to import.\nThe init.py files are required to make Python treat the directories as containing packages; this is done to prevent directories with a common name, such as string , from unintentionally hiding valid modules that occur later (deeper) on the module search path.","Q_Score":6,"Tags":"python","A_Id":42944983,"CreationDate":"2012-02-04T19:00:00.000","Title":"Python module not working (not able to import) even after including it in PATH 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},{"Question":"Given a protobuf serialization is it possible to get a list of all tag numbers that are in the message? Generally is it possible to view the structure of the message without the defining .proto files?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":428,"Q_Id":9158329,"Users Score":2,"Answer":"Most APIs will indeed have some form of reader-based API that allows you to enumerate a raw protobuf stream. However, that by itself is not enough to fully understand the data, since without the schema the interpretation is ambiguous:\n\na varint could be zig-zag encoded (sint32\/sint64), or not (int32\/int64\/uint32\/uint64) - radically changing the meaning, or a boolean, or an enum\na fixed-32\/fixed-64 could be a signed or unsigned integer, or could be an IEEE754 float\/double\na length-prefixed chunk could be a UTF-8 string, a BLOB, a sub-message, or a \"packed\" repeated set of primitives; if it is a sub-message, you'll have to repeat recursively\n\nSo... yes and no. Certainly you can get the field numbers of the outermost message.\nAnother approach would be to use the regular API against a type with no members (message Naked {}), and then query the unexpected data (i.e. all of it) via the \"extension\" API that many implementations provide.","Q_Score":2,"Tags":"java,python,google-api,protocol-buffers","A_Id":9158407,"CreationDate":"2012-02-06T09:54:00.000","Title":"Can all tag numbers be extracted from a given protobuf serialization?","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},{"Question":"I have made an extensive script that runs fine when started from the command line or IDLE. But when I try to run it with cron it keeps giving errors:\nIOError: [Errno 32] Broken pipe","AnswerCount":1,"Available Count":1,"Score":0.761594156,"is_accepted":false,"ViewCount":1106,"Q_Id":9172046,"Users Score":5,"Answer":"If your script runs too long, cron will close its stdout\/stderr that are normally redirected to a log file (through cron). Attempting to print after the timeout will give you broken pipe.\nA solution is to use logging or print only to your own log files and never to stdout.\nAlso, cron has different envinronment, specified at the top of crontab or cron.(daily|hourly|...) files. Make sure it is correct, especially if you rely on PATH or HOME that are set at login.","Q_Score":1,"Tags":"python","A_Id":9173292,"CreationDate":"2012-02-07T06:43:00.000","Title":"Broken pipe\" when running python with cron","Data Science and Machine Learning":0,"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},{"Question":"I'm working with a binary file that references another file using absolute paths.\nThe path contains both japanese and ascii characters.\nThe length of the string is given, so I can just read that many bytes and convert it into a string.\nHowever the problem is trying to convert the string. If I specify the encoding as ascii, it'll fail on the japanese characters. If I specify it as japanese encoding (shift-jis or something), it won't read the english characters properly.\nOne byte is used for each ascii character, while two bytes are used for each japanese character.\nWhat is the fastest and cleanest way to convert these bytes into a string? The encodings are known. Will the same technique work in older versions of python.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":993,"Q_Id":9187540,"Users Score":3,"Answer":"This sounds like you have fallen victim for a misunderstand the basics of Unicode and encodings. It may be that you have not, but misunderstandnings are common and understandable, while the situation you describe are not.\nA string of bytes that contains mixed encodings are, per definition, invalid in any of these encodings. If this really was the case, you would have to split the bytes string into it's parts, and decode every part separately. In this case it would probably mean splitting on the path separators, so it would be reasonably easy, but in other cases it would not. However, I serously doubt that this is the case, as it would mean that your source is insane. That happens, but it is unlikely. :-)\nIf the source gives you one path as a bytes string, it is most likely that this string uses only one encoding. It may contain both Japanese and ASCII-characters and still be using one encoding. The most common encodings that can handle both Japanese and ASCII are UTF-8 and UTF-16. My guess is that your source uses one of those. In fact, since you write \"One byte is used for each ascii character, while two bytes are used for each japanese character\" it is probably UTF-8. It could also be Shift JIS, but it seems you already tried that.\nIf not, please explain what your source is, and give examples of the byte strings (in ASCII\/HEX) that you are given.","Q_Score":0,"Tags":"unicode,python-3.x,string-parsing","A_Id":9191732,"CreationDate":"2012-02-08T03:36:00.000","Title":"Working with strings with mixed encodings in 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":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a solid understanding of OOP and its idioms in Java. \nNow I am coding in python, and I am in a situation where having multiple inheritance may be useful, however (and this may be due to years of java code), i am reluctant to do it and I am considering using composition instead of inheritance in order to avoid potential conflicts with potential equal method names.\nQuestion is, am i being to strict or too java focused regarding this thing. Or using multiple inheritance in python is not only possible but also encouraged.\nThanks for your time :)","AnswerCount":2,"Available Count":1,"Score":0.2913126125,"is_accepted":false,"ViewCount":2803,"Q_Id":9187921,"Users Score":3,"Answer":"I would still prefer composition to inheritance, whether multiple or single. Really getting into duck typing is a bit like having loads of implicit interfaces everywhere, so you don't even need inheritance (or abstract classes) very much at all in Python. But that's prefer composition, not never use inheritance. If inheritance (even multiple) is a good fit and composition isn't, then use inheritance.","Q_Score":6,"Tags":"python","A_Id":9188059,"CreationDate":"2012-02-08T04:40:00.000","Title":"Multiple inheritance in python vs composition","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have some assemblies written in C#, which I want to use with IronPython interpreter. These assemblies use NLog for logging, and if I use them from C# code, I can provide NLog settings with the NLog.config. But how can I configure logging if I use ipy.exe interpreter?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":169,"Q_Id":9189734,"Users Score":0,"Answer":"Put nlog.config next to the ipy.exe.","Q_Score":1,"Tags":"c#,ironpython,nlog","A_Id":9235739,"CreationDate":"2012-02-08T08:17:00.000","Title":"How do I use NLog with IronPython 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":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm looking at using a crypto lib such as pycrypto for encrypting\/decrypting fields in my python webapp db. But encryption algorithms require a key. If I have an unencrypted key in my source it seems silly to attempt encryption of db fields as on my server if someone has access to the db files they will also have access to my python sourcecode.\nIs there a best-practice method of securing the key used? Or an alternative method of encrypting the db fields (at application not db level)?\nUPDATE: the fields I am trying to secure are oauth tokens.\nUPDATE: I guess there is no common way to avoid this. I think I'll need to encrypt the fields anyway as it's likely the db files will get backed up and moved around so at least I'll reduce the issue to a single vulnerable location - viewing my source code.\nUPDATE: The oauth tokens need to be used for api calls while the user is offline, therefore using their password as a key is not suitable in this case.","AnswerCount":3,"Available Count":3,"Score":0.0665680765,"is_accepted":false,"ViewCount":6258,"Q_Id":9198494,"Users Score":1,"Answer":"Symmetric encryption is indeed useless, as you have noticed; however for certain fields, using asymmetric encryption or a trapdoor function may be usable:\n\nif the web application does not need to read back the data, then use asymmetric encryption. This is useful e.g. for credit card data: your application would encrypt the data with the public key of the order processing system, which is on a separate machine that is not publically accessible.\nif all you need is equality comparison, use a trapdoor function, such as a message digest, ideally with a salt value. This is good for passwords that should be unrecoverable on the server.","Q_Score":11,"Tags":"python,database,web-applications,cryptography,pycrypto","A_Id":9198661,"CreationDate":"2012-02-08T17:34:00.000","Title":"How to store a crypto key securely?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I'm looking at using a crypto lib such as pycrypto for encrypting\/decrypting fields in my python webapp db. But encryption algorithms require a key. If I have an unencrypted key in my source it seems silly to attempt encryption of db fields as on my server if someone has access to the db files they will also have access to my python sourcecode.\nIs there a best-practice method of securing the key used? Or an alternative method of encrypting the db fields (at application not db level)?\nUPDATE: the fields I am trying to secure are oauth tokens.\nUPDATE: I guess there is no common way to avoid this. I think I'll need to encrypt the fields anyway as it's likely the db files will get backed up and moved around so at least I'll reduce the issue to a single vulnerable location - viewing my source code.\nUPDATE: The oauth tokens need to be used for api calls while the user is offline, therefore using their password as a key is not suitable in this case.","AnswerCount":3,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":6258,"Q_Id":9198494,"Users Score":0,"Answer":"Before you can determine what crypto approach is the best, you have to think about what you are trying to protect and how much effort an attacker will be ready to put into getting the key\/information from your system.\nWhat is the attack scenario that you are trying to remedy by using crypto? A stolen database file?","Q_Score":11,"Tags":"python,database,web-applications,cryptography,pycrypto","A_Id":9198676,"CreationDate":"2012-02-08T17:34:00.000","Title":"How to store a crypto key securely?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I'm looking at using a crypto lib such as pycrypto for encrypting\/decrypting fields in my python webapp db. But encryption algorithms require a key. If I have an unencrypted key in my source it seems silly to attempt encryption of db fields as on my server if someone has access to the db files they will also have access to my python sourcecode.\nIs there a best-practice method of securing the key used? Or an alternative method of encrypting the db fields (at application not db level)?\nUPDATE: the fields I am trying to secure are oauth tokens.\nUPDATE: I guess there is no common way to avoid this. I think I'll need to encrypt the fields anyway as it's likely the db files will get backed up and moved around so at least I'll reduce the issue to a single vulnerable location - viewing my source code.\nUPDATE: The oauth tokens need to be used for api calls while the user is offline, therefore using their password as a key is not suitable in this case.","AnswerCount":3,"Available Count":3,"Score":1.2,"is_accepted":true,"ViewCount":6258,"Q_Id":9198494,"Users Score":5,"Answer":"If you are encrypting fields that you only need to verify (not recall), then simple hash with SHA or one-way encrypt with DES, or IDEA using a salt to prevent a rainbow table to actually reveal them. This is useful for passwords or other access secrets.\nPython and webapps makes me think of GAE, so you may want something that is not doing an encrypt\/decrypt on every DB transaction since these are already un-cheap on GAE. \nBest practice for an encrypted databased is to encrypt the fields with the users own secret, but to include an asymmetric backdoor that encrypts the users secret key so you (and not anyone who has access to the DB source files, or the tables) can unencrypt the users key with your secret key, should recovery or something else necessitate. \nIn that case, the user (or you or trusted delegate) can retireve and unencrypt their own information only. You may want to be more stringent in validating user secrets if you are thinking you need to secure their fields by encryption. \nIn this regards, a passphrase (as opposed to a password) of some secret words such \"in the jungle the mighty Jungle\" is a good practice to encourage.\nEDIT: Just saw your update. The best way to store OAuth is to give them a short lifespan, only request resources your need and re-request them over getting long tokens. It's better to design around getting authenticated, getting your access and getting out, than leaving the key under the backdoor for 10 years. \nSince, if you need to recall OAuth when the user comes online, you can do as above and encrypt with a user specfic secret. You could also keygen from an encrypted counter (encrypted with the user secret) so the actual encryption key changes at each transaction, and the counter is stored in plaintext. But check specific crypto algo discussion of this mode before using. Some algorithms may not play nice with this.","Q_Score":11,"Tags":"python,database,web-applications,cryptography,pycrypto","A_Id":9198785,"CreationDate":"2012-02-08T17:34:00.000","Title":"How to store a crypto key securely?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I've never written a proper test until now, only small programs that I would dispose of after the test succeeded. I was looking through Python's unittest module and tutorials around the web, but something's not clear to me.\nHow much should one TestCase cover? I've seen examples on the web that have TestCase classes with only one method, as well as classes that test almost the entire available functionality.\nIn my case, I'm trying to write a test for a simple bloom filter. How do you think I should organize my test cases?","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":204,"Q_Id":9199551,"Users Score":1,"Answer":"I would create one TestCase with several test methods. A bloom filter has simple semantics, so only one TestCase. I usually add a TestCase per feature.","Q_Score":4,"Tags":"python,unit-testing","A_Id":9199631,"CreationDate":"2012-02-08T18:48:00.000","Title":"How much should one TestCase cover?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've never written a proper test until now, only small programs that I would dispose of after the test succeeded. I was looking through Python's unittest module and tutorials around the web, but something's not clear to me.\nHow much should one TestCase cover? I've seen examples on the web that have TestCase classes with only one method, as well as classes that test almost the entire available functionality.\nIn my case, I'm trying to write a test for a simple bloom filter. How do you think I should organize my test cases?","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":204,"Q_Id":9199551,"Users Score":5,"Answer":"To put it simple: one unit test should cover single feature of your program. That's all there is to say. That's why they're called unit tests.\nOf course, what we understand by feature may vary. Think about smallest parts of your program that might break or not work as expected. Think about business requirements of your code. Those are parts that you want each to be covered by dedicated unit test.\nUsually, unit tests are small, isolated and atomic. They should be easy to understand, they should fail\/pass independently from one another, and should execute fast. Fairly good indication of proper unit tests is single assertion - if you find yourself writing more, you probably test too much and it's a sign you need more than one test for given feature. However, this is not a strict rule - the more complex code is involved, the more complex unit tests tend to be.\nWhen writing tests, it's easy to split your code functionality and test those separated parts (this should give you the idea of atomicity of your tests). For example, if you have a method that verifies input then calls a service and finally returns result, you usually want to have all three (verify, call, return) steps covered.","Q_Score":4,"Tags":"python,unit-testing","A_Id":9199764,"CreationDate":"2012-02-08T18:48:00.000","Title":"How much should one TestCase cover?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm using Eclipse + PyDev to work on python web projects.\nSometimes I need to run debug session on production server rather then locally, due to specific environment.\nI was wondering if there is a way to run isolated remote debugging session, so the other users don't experience any issues, and code execution doesn't suspend for them?\nThanks.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":79,"Q_Id":9220493,"Users Score":0,"Answer":"I don't think this is possible out of the box... you'd need to architecture your production server so that this would be possible (i.e.: when you send a given request it should spawn a different interpreter just to handle your request for debugging purposes and shutdown that interpreter after the debug session ends), but you have to make sure that the debugger will actually run in a separate interpreter, otherwise it could end up tracing more things from other people (and in the best situation it'd only make things slower and in the worse it could end up having unexpected consequences because of some interaction of the debugger with your code).","Q_Score":0,"Tags":"python,eclipse,debugging,pydev","A_Id":9226643,"CreationDate":"2012-02-09T23:20:00.000","Title":"Isolated debugging session with 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},{"Question":"I'm currently using the C\/Python API to read data from a large binary file.\nThis result in Python is not as efficient as the pure C result (time x2) because, I think, of the time took to wrap things up into a PyObject. Typically, I store 42-elements tuples in a PyArrayObject. To do this, I use:\nPyObject *r = Py_BuildValue(\"(f, I, i, K, f, K, K, etc..)\", a, b, c, etc...) ;\nMy question is the following: Is there a more efficient way to do it (quicker execution time)?\nFor example: will PyTuple_Pack(n, args) do it more quickly ?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":796,"Q_Id":9228771,"Users Score":0,"Answer":"For time critical code, I create a tuple of the desired length and then create the components individually and stuff them into the tuple.","Q_Score":0,"Tags":"python,c","A_Id":9231111,"CreationDate":"2012-02-10T13:51:00.000","Title":"C\/Python API : efficiency of Py_BuildValue use","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},{"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},{"Question":"I want to calculate all the three dihedral angles in a residue.\ncalc_dihedral(atom1, atom2, atom3, atom4) of Biopython requires vector coordinates of four atoms as arguments and returns an output of a single value. I'm not sure which of the three angles output represents.\nPlease suggest which atoms in the residue are required to calculate which angle and in what order the atom coordinates should be given in the function as arguments.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":1649,"Q_Id":9240115,"Users Score":1,"Answer":"We need backbone atoms only N,CA,C. so for the protein chain we get N,CA,C,N,CA,C,N,CA,C,N,CA,C.\nwe need to define them in plane, to find out the angle we need two planes (plane1: C,N,CA)(plane2: N,CA,C). we neglect the N,CA for first residue. Consider the bolded atoms only. so you submit the bolded atoms (3 atoms of one residue and 4th atom from the second residue.) I dont know about omega.","Q_Score":0,"Tags":"python,biopython","A_Id":10908585,"CreationDate":"2012-02-11T12:12:00.000","Title":"Which atoms are required by Biopython's calc_dihedral() to calculate all 3 dihedral angles?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I have learned in my University time Pascal and C and RedHat Linux\/Unix . \nTo get quickly one job, i started learning Microsoft Visual Basic 6.0 for speed in development etc. In that time, with C its like more time consuming and i was not confident to use it for job purpose, where most of the companies demand fast\/rapid development.\nAfter that i had problems with my companies because they want web applications, then i started using PHP which is also great, because customers demand web projects and they expect Google like applications in short time frame, which is doable because PHP gives that speed and its huge community.\nTo explain my need for Go-lang is following:\n\nPHP the syntax is friendly compared to C\/Pascal. \nI was very happy to learn Python, but its syntax is very much different then C. \nWhich just not gonna work with me to accept and really learn it better and better. \nI have tried to learn Ruby, at-least so that i can have the knowledge of Python \nlike syntax, but i really skipped Ruby because of 2x time slower then PHP\n\nTherefore, \nIs Go-lang is the perfect choice for SPEED vs PHP vs Ruby, for Web development + Gtk?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":8545,"Q_Id":9241091,"Users Score":4,"Answer":"Alas, I'd love to have 1 asset that I could use for all conditions but it's just not available in the world of computing. You're going to have to learn 2 or more.\nPHP is very widely used, so you might as well stick with it. If you can create decent webapps using it, go for it. I would suggest learning C\/C++ too so you can write any high-performance modules using that and call them from your PHP code. That's probably the best of all worlds for your webapps.\nIf you wanted to write for desktops, I think you'll be best off learning C++ with Qt (and look at Wt) (as it appears you're a Linux dev), or C#\/VB.NET for Windows. \nFor mobiles, learn C\/C++ as you can write apps in that no matter which platform even if you have to put up with some platform-dependant extensions - you either have to learn Java for Android, Objective-C for iOS, or (well we're not quite sure what MS has planned for Windows Phone 8, but I hear they like native code again, that means C++\/CX). You can see where I'm going with this!\nso anyway, if you're happy with PHP then keep with it. There is a ton of code out there that runs PHP so it's not like you're working with some bleeding-edge or hardly-used obscure language.","Q_Score":2,"Tags":"php,python,ruby-on-rails,ruby,go","A_Id":9241134,"CreationDate":"2012-02-11T14:48:00.000","Title":"Stick with PHP or learn Go-lang?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I have to run some student-made code that they made as homework, I'm running this on my own computer (Mac OS), and I'm not entirely certain they won't accidentally \"rm -rf \/\" my machine. Is there an easy way to run their python scripts with reduced permissions, so that e.g. they can access only a certain directory? Is PyPy the way to go?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":224,"Q_Id":9242713,"Users Score":0,"Answer":"Create a new user account \"student\". Run your students' scripts as \"student\". Worst case, the script will destroy this special user account. If this happens, just delete user \"student\" and start over.","Q_Score":1,"Tags":"python,unix,sandbox","A_Id":9242880,"CreationDate":"2012-02-11T18:13:00.000","Title":"Run python script with reduced permissions","Data Science and Machine Learning":0,"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},{"Question":"(Note: I\u2019ve Linux in mind, but the problem may apply on other platforms.)\nProblem: Linux doesn\u2019t do suid on #! scripts nor does it activate \u201cLinux capabilities\u201d on them.\nWhy dow we have this problem? Because during the kernel interpreter setup to run the script, an attacker may have replaced that file. How? The formerly trusted suid\/capability-enabled script file may be in a directory he has control over (e.g. can delete the not-owned trusted file, or the file is actually a symbolic link he owns).\nProper solution: make the kernel allow suid\/cap scripts if: a) it is clear that the caller has no power over the script file -or- like a couple of other operating systems do b) pass the script as \/dev\/fd\/x, referring to the originally kernel-opened trusted file.\nAnswer I\u2019m looking for: for kernels which can\u2019t do this (all Linux), I need a safe \u201cnow\u201d solution.\nWhat do I have in mind? A binary wrapper, which does what the kernel does not, in a safe way.\nI would like to\n\nhear from established wrappers for (Python) scripts that pass Linux capabilities and possibly suid from the script file to the interpreter to make them effective.\nget comments on my wrapper proposed below\n\nProblems with sudo: sudo is not a good wrapper, because it doesn\u2019t help the kernel to not fall for that just explained \u201cscript got replaced\u201d trap (\u201cman sudo\u201d under caveats says so).\n\nProposed wrapper\n\nactually, I want a little program, which generates the wrapper\n\ncommand line, e.g.: sudo suid_capability_wrapper .\/script.py\nscript.py has already the suid bit and capabilites set (no function, just information)\n\nthe generator suid_capability_wrapper does\n\ngenerate C(?) source and compile\ncompile output into: default: basename script.py .py, or argument -o\nset the wrapper owner, group, suid like script.py\nset the permitted capabilities like script.py, ignore inheritable and effective caps\nwarn if the interpreter (e.g. \/usr\/bin\/python) does not have the corresponding caps in its inheritable set (this is a system limitation: there is no way to pass on capabilites without suid-root otherwise)\n\nthe generated code does:\n\ncheck if file descriptors 0, 1 and 2 are open, abort otherwise (possibly add more checks for too crazy environment conditions)\nif compiled-in target script is compiled-in with relative path, determine self\u2019s location via \/proc\/self\/exe\ncombine own path with relative path to the script to find it\ncheck if target scripts owner, group, permissions, caps, suid are still like the original (compiled-in) [this is the only non-necessary safety-check I want to include: otherwise I trust that script]\nset the set of inherited capabilities equal to the set of permitted capabilities\nexecve() the interpreter similar to how the kernel does, but use the script-path we know, and the environment we got (the script should take care of the environment)\n\n\nA bunch of notes and warnings may be printed by suid_capability_wrapper to educate the user about:\n\nmake sure nobody can manipulate the script (e.g. world writable)\nbe aware that suid\/capabilities come from the wrapper, nothing cares about suid\/xattr mounts for the script file\nthe interpreter (python) is execve()ed, it will get a dirty environment from here\nit will also get the rest of the standard process environment passed through it, which is ... ... ... (read man-pages for exec to begin with)\nuse #!\/usr\/bin\/python -E to immunize the python interpreter from environment variables\nclean the environment yourself in the script or be aware that there is a lot of code you run as side-effect which does care about some of these variables","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2470,"Q_Id":9242989,"Users Score":0,"Answer":"You don't want to use a shebang at all, on any file - you want to use a binary which invokes the Python interpreter, then tells it to start the script file for which you asked.\nIt needs to do three things:\n\nStart a Python interpreter (from a trusted path, breaking chroot jails and so on). I suggest statically linking libpython and using the CPython API for this, but it's up to you.\nOpen the script file FD and atomically check that it is both suid and owned by root. Don't allow the file to be altered between the check and the execution - be careful.\nTell CPython to execute the script from the FD you opened earlier.\n\nThis will give you a binary which will execute all owned-by-root-and-suid scripts under Python only. You only need one such program, not one per script. It's your \"suidpythonrunner\".\nAs you surmised, you must clear the environment before running Python. LD_LIBRARY_PATH is taken care of by the kernel, but PYTHONPATH could be deadly.","Q_Score":3,"Tags":"python,c,sudo,suid","A_Id":9243141,"CreationDate":"2012-02-11T18:46:00.000","Title":"Is this a safe suid\/capability wrapper 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},{"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},{"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},{"Question":"I'm creating a game in which I have a somewhat complex method for creating entities.\nWhen a level is loaded, the loading code reads a bunch of YAML files that contain attributes of all the different possible units. Using the YAML file, it creates a so-called EntityResource object. This EntityResource object serves as the authoritative source of information when spawning new units. The goal is twofold:\n\nDeter cheating by implementing a hash check on the output of the YAML file\nAid in debugging by having all unit information come from a single, authoritative source.\n\nThese EntityResource objects are then fed into an EntityFactory object to produce units of a specific type.\nMy question is as follows. Is there a way to create sublcasses of EntityResource dynamically, based on the contents of the YAML file being read in?\nAlso, I would like each of these YAML-file-derived subclasses to be assigned a singleton metaclass. Any caveats?","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":9225,"Q_Id":9269902,"Users Score":1,"Answer":"When I hear \"creating subclasses on the fly\" I understand \"create objects that behave differently on the fly\", which is really a question of configuration.\nIs there anything you need that you can't get by just reading in some data and creating an object that decides how it is going to behave based on what it reads?\nHere's the metaphor: I'm a handy guy -- I can put together any IKEA item you throw at me. But I'm not a different person each time, I'm just the same handy guy reading a different set of diagrams and looking for different kinds of screws and pieces of wood. That's my reasoning for subclassing not being the natural solution here.","Q_Score":11,"Tags":"python,class,singleton,subclass,subclassing","A_Id":9269944,"CreationDate":"2012-02-13T23:59:00.000","Title":"Is there a way to create subclasses on-the-fly?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":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},{"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},{"Question":"I am making a python script that in the case of EXT filesystem, will create symbolic links of some stuff, otherwise it will move the files.\nHow can I know the type of the filesystem of a directory?","AnswerCount":2,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":168,"Q_Id":9319122,"Users Score":4,"Answer":"What you probably should do is to just try to make the link and if it fails, copy.\nIt'll give you the advantage that you'll automatically support all file systems with soft links without having to do advanced detection or keeping an updated list of supported file systems.","Q_Score":1,"Tags":"python,windows,linux","A_Id":9319169,"CreationDate":"2012-02-16T21:10:00.000","Title":"Finding out if the current filesystem supports symbolic links","Data Science and Machine Learning":0,"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},{"Question":"I have a python web application that I have configured in apache as:\nWSGIScriptAlias \/firetalk \/scripts\/firetalkServer2\nWhen I access this from javascript using XMLHttpRequest, WSGI\/Apache end up launching multiple instances which breaks what I am trying to accomplish.\nSo, is there any way to limit WSGI\/Apache to a single instance of the specified python script?\nThank you.","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":676,"Q_Id":9321335,"Users Score":2,"Answer":"Put the WSGI app in daemon mode and tell it to use a single process. Note that this could have a detrimental effect on performance.","Q_Score":0,"Tags":"python,apache,wsgi","A_Id":9321430,"CreationDate":"2012-02-17T00:38:00.000","Title":"How to keep WSGI from launching multiple 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":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"My friend told me that I should use assembly to get my code to run faster, but it's really hard to program in and I don't know where to begin. \nAre there any programs that can generate assembly from an easier language like python??","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":945,"Q_Id":9321875,"Users Score":1,"Answer":"Your friend is wrong. Most programs don't get demonstrably faster when written in assembly. What makes assembly code fast is that assembly code programmers generally worry a lot about speed and size, and so that's the focus of their efforts. Most compilers can do a much better job of creating fast programs than an only-average programmer can in assembly.","Q_Score":0,"Tags":"python,assembly","A_Id":9338218,"CreationDate":"2012-02-17T01:54:00.000","Title":"need an assembly code generator","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":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},{"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},{"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},{"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},{"Question":"I am a fairly proficient vim user, but friends of mine told me so much good stuff about emacs that I decided to give it a try -- especially after finding about the aptly-named evil mode...\nAnyways, I am currently working on a python script that requires user input (a subclass of cmd.Cmd). In vim, if I wanted to try it, I could simply do :!python % and then could interact with my script, until it quits. In emacs, I tried M-! python script.py, which would indeed run the script in a separate buffer, but then RETURNs seems not to be sent back to the script, but are caught by the emacs buffer instead. I also tried to have a look at python-mode's C-c C-c, but this runs the script in some temporary directory, whereas I just want to run it in (pwd).\nSo, is there any canonical way of doing that?","AnswerCount":6,"Available Count":1,"Score":0.1325487884,"is_accepted":false,"ViewCount":10228,"Q_Id":9324802,"Users Score":4,"Answer":"I don't know about canonical, but if I needed to interact with a script I'd do M-xshellRET and run the script from there.\nThere's also M-xterminal-emulator for more serious terminal emulation, not just shell stuff.","Q_Score":8,"Tags":"python,emacs","A_Id":9325028,"CreationDate":"2012-02-17T08:04:00.000","Title":"Running interactive python script from 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":1,"Web Development":0},{"Question":"(first question on StackOverflow, glad to be there :))\nI am using IronPython 2.7.1 and C# .net 4.0.\nI use C# to launch my python script.\nI have about 20 personal modules that are imported a lots of time.\nE.g :\nIf I have module1.py, module2.py, module3.py, module4.py\nand main_script.py.\nmain_script.py imports module1 and module2\nBoth module1 and module2 import module3.\nmodule1 and module3 import module4\netc.\nModules can have a large amount of code lines.\nWhat I see is when I execute my main_script.py, it takes about 4-5 sec to just import modules.\nI tried to use pyc.py to compile all my modules in a dll, and then used ngen on it, but I saw no differences when adding this dll using myEngine.Runtime.LoadAssembly().\nThen I wanted to use py_compile.py to get the pyc files, but is seems not working as the IronPython.Runtime.FunctionCode type is not supported in the IronPython.Modules.MarshalWriter class (function WriteObject(object o). (I got \"unmarshallable object\" exception when trying to compile).\nI am not very familiar with Python nor IronPython, and maybe I did not understood all the subtleties of the language (I think so, actually). I was searching the net for a solution, but it seems I am stuck right now.\nAny idea to improve the import performance ?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1258,"Q_Id":9327606,"Users Score":3,"Answer":"Taking 4-5 seconds to do imports, especially for large modules, is not unexpected for IronPython 2.7.1. I would pyc.py to improve it, but I also think that it isn't as useful as it once was - IronPython's imports are a lot faster than they used to be, so pyc.py is less useful.\nThe thing is, IronPython does a lot more than Python does when it imports a module[1]. Python has to parse it and produce bytecode which it then executes. IronPython has to produce DLR trees which are then converted to interpreter instructions - and possibly also IL if they trip the compilation limit, which means running the .NET JIT to produce machine code.\nAll of that work is wasted if the script only takes a few seconds to run; IronPython is better for long-running processes. However, the short Python script is extremely common, and IronPython is extremely poor for those sorts of scripts.\nThere are two ways we're working at solving this, one of which you alluded to. Work is being done to support standard .pyc files with an interpreter optimized for startup time but not throughput - short scripts will benefit, but long-running code will suffer. Second, porting IronPython to mobile platforms requires disabling dynamic code generation, so making the DLR interpreter fast will be very important; this work will make uncompiled code faster to start as well.\nThe one thing we cannot overcome is the fact that .NET processes generally take longer to start than plain C ones. That overhead can be reduced, but it requires some fairly deep optimization that probably won't be done for a while.\n[1] Python's import process is so fast that the stat calls to find the file are much greater than the time to parse & compile it.","Q_Score":1,"Tags":"import,module,ironpython","A_Id":9332166,"CreationDate":"2012-02-17T11:41:00.000","Title":"Import module in IronPython 2.7.1 very 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":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"When I log into a page in my browser, I get 3 cookies: tips, ipb_member_id and ip_pass_hash. I need those last two to access some pages I can only see when logged in. When I log in via the browser it works fine, but under mechanize I only get the tips cookie.\nAre there any flags I have to set up for this to work, or is there any module I might need? I can't link to the page here. Though I do know Python's Mechanize + cookielib stores the cookies correctly, since I already have a working version for it.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":362,"Q_Id":9338948,"Users Score":0,"Answer":"I am working on the same issue (I want to get all cookies loaded on a page).\nI think it's impossible with mechanize. One reason is that it doesn't support javascript, so anything a little bit complex (such as a img loaded on a js event, which set a new cookie) will not work.\nI am considering other options as webkit :http:\/\/stackoverflow.com\/questions\/4730906\/automating-chrome\nif you find a good way to gather all the cookies, let me know :)","Q_Score":0,"Tags":"python,ruby,cookies,mechanize","A_Id":11950195,"CreationDate":"2012-02-18T05:46:00.000","Title":"Ruby\/Mechanize: Not getting all the cookies after logging into a page","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I'd like to know if there is any implemented python library for GPS trajectory pre-processing such as compression, smoothing, filtering, etc.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":2133,"Q_Id":9339169,"Users Score":1,"Answer":"Expanding on my comment, a Kalman filter is the usual choice for estimating position and velocity from noisy sensor readings.\nHere's what Wikipedia has to say on the topic (emphasis mine:)\n\nThe Kalman filter is an algorithm, commonly used since the 1960s for\n improving vehicle navigation (among other applications, although\n aerospace is typical), that yields an optimized estimate of the\n system's state (e.g. position and velocity). The algorithm works\n recursively in real time on streams of noisy input observation data\n (typically, sensor measurements) and filters out errors using a\n least-squares curve-fit optimized with a mathematical prediction of\n the future state generated through a modeling of the system's physical\n characteristics.\n\nThe Kalman filter is the basic version; there's also the extended Kalman filter and unscented Kalman filter (though my control systems lecturer never got around to telling us what those were actually used for.)\n@stark has provided a link to an implementation of the Kalman filter in Python (not sure of the quality.) You may be able to find others, or roll your own with scipy.","Q_Score":3,"Tags":"python,gps","A_Id":9343253,"CreationDate":"2012-02-18T06:22:00.000","Title":"Python library for GPS trajectory pre-processing?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"Python extension modules written in C are faster than the equivalent programs written in pure Python. How do these extension modules compare (speed wise) to programs written in pure C? Are programs written in pure C even faster than the equivalent Python extension module?","AnswerCount":2,"Available Count":2,"Score":0.4621171573,"is_accepted":false,"ViewCount":2535,"Q_Id":9345201,"Users Score":5,"Answer":"Being a Python extension doesn't affect the execution speed of a piece of code, except insofar as the Python invoking it is slower than the equivalent C would be, and the compiler is less able to aggressively unroll and inline code which crosses the C\/Python boundary.\nThat is to say, if you just have Python code call a C function, and then you do all your work in that function, the only performance difference is going to be the amount of time you spent before getting into the C side of things. From that point on, it is native C.","Q_Score":14,"Tags":"python,c","A_Id":9345227,"CreationDate":"2012-02-18T23:35:00.000","Title":"Speed of Python Extensions in C vs. 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},{"Question":"Python extension modules written in C are faster than the equivalent programs written in pure Python. How do these extension modules compare (speed wise) to programs written in pure C? Are programs written in pure C even faster than the equivalent Python extension module?","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":2535,"Q_Id":9345201,"Users Score":15,"Answer":"How do these extension modules compare (speed wise) to programs written in pure C?\n\nThey are slightly slower due to the translation between Python data structures -> C types. Disregarding this translation the actual C code runs at exactly the same speed as a regular C function would.\n\nAre programs written in pure C even faster than the equivalent Python extension module?\n\nC programs (written entirely in C) can be faster than Python programs using the C extension modules. If the C program and the extension module are written with the same level of complexity, coder skill, algorithmic complexity, etc., the C program will win every time. However, if you're not a C guru and you're competing with a highly optimized Python C extension Python could be faster.","Q_Score":14,"Tags":"python,c","A_Id":9345231,"CreationDate":"2012-02-18T23:35:00.000","Title":"Speed of Python Extensions in C vs. 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},{"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},{"Question":"We send email using appengine's python send_mail api. \nIs there any way to tell why an email that is sent to only one recipient would be marked as SPAM. This seems to only happen when appengine's python send_mail api sends to Gmail.\nIn our case we are sending email as one of the administrators of our appengine application.\nAnd the email is a confirmation letter for an order that the user just purchased, so it is definitely NOT SPAM.\nCan anyone help with this? \nIt seems odd because it is only GMail users that seem to be reporting this issue and we are sending from appengine (All Google servers) I love Google but sometimes Google is stricter to itself than to others :)\nI've added the spf TXT record to DNS such as \"v=spf1 include:_spf.google.com ~all\"\n(I'm hoping that will help)\nI've tried to add a List-Unsubscribe header to the email but it seems app engine python send mail does not support this header.\nThanks,\nRalph","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":691,"Q_Id":9367049,"Users Score":1,"Answer":"My guess would be that the content of the mail looks \"spammy\" for Google, but you can do some things that might help you. \nI would suggest you, since this is a confirmation mail, add another admin for your app an email like: do-not-reply@domain.com and use that one for the confirmation emails. Add more text to the body and include the unsubscribe links as well, so your users will have the possibility to not receive more email from your app. Maybe you wouldn't like the last part, but you have to give that options to your users, so this email won't be marked as SPAM.","Q_Score":3,"Tags":"python,google-app-engine,email,gmail,spam-prevention","A_Id":9374887,"CreationDate":"2012-02-20T19:16:00.000","Title":"AppEngine python send email api is marked as SPAM by Gmail email reader","Data Science and Machine Learning":0,"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},{"Question":"Does anybody know a python function (proven to work and having its description in internet) which able to make minimum search for a provided user function when argument is an array of integers?\nSomething like\nscipy.optimize.fmin_l_bfgs_b\nscipy.optimize.leastsq\nbut for integers","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":569,"Q_Id":9367630,"Users Score":0,"Answer":"There is no general solution for this problem. If you know the properties of the function it should be possible to deduce some bounds for the variables and then test all combinations. But that is not very efficient.\nYou could approximate a solution with scipy.optimize.leastsq and then round the results to integers. The quality of the result of course depends on the structure of the function.","Q_Score":0,"Tags":"python,numpy,scipy","A_Id":9367777,"CreationDate":"2012-02-20T20:01:00.000","Title":"Optimizer\/minimizer for integer argument","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},{"Question":"I can't seem to find what's the default encoding for io.StringIO in Python3. Is it the locale as with stdio?\nHow can I change it?\nWith stdio, seems that just reopening with correct encoding works, but there's no such thing as reopening a StringIO.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":19442,"Q_Id":9368865,"Users Score":14,"Answer":"The class io.StringIO works with str objects in Python 3. That is, you can only read and write strings from a StringIO instance. There is no encoding -- you have to choose one if you want to encode the strings you got from StringIO in a bytes object, but strings themselves don't have an encoding.\n(Of course strings need to be internally represented in some encoding. Depending on your interpreter, that encoding is either UCS-2 or UCS-4, but you don't see this implementation detail when working with Python.)","Q_Score":13,"Tags":"encoding,utf-8,python-3.x,stringio","A_Id":9368909,"CreationDate":"2012-02-20T21:43:00.000","Title":"io.StringIO encoding in 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":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am working on some programs in spanish, so I need to use accent marks. This is why I use \n # -*- coding: iso-8859-1 -*- and on all my programs (python). I tested in chrome,firefox and safari and they all work puttin the accent marks. The only one that does not work is IE8. It does not apply the accent mark, and add some other character instead.\nDoes anyone know if there is a problem with IE8?\nIs it better to use UTF-8 instead?","AnswerCount":2,"Available Count":2,"Score":0.3799489623,"is_accepted":false,"ViewCount":1203,"Q_Id":9370343,"Users Score":4,"Answer":"It is better to use UTF-8.\nNote that \"iso-8859-1\" is a common mislabeling of \"windows-1252\", also known as \"cp1252\". Try being more explicit and see if this resolves your issues.","Q_Score":3,"Tags":"python,html,utf-8,iso-8859-1","A_Id":9370450,"CreationDate":"2012-02-21T00:08:00.000","Title":"ISO-8859-1 Not working on IE","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},{"Question":"I am working on some programs in spanish, so I need to use accent marks. This is why I use \n # -*- coding: iso-8859-1 -*- and on all my programs (python). I tested in chrome,firefox and safari and they all work puttin the accent marks. The only one that does not work is IE8. It does not apply the accent mark, and add some other character instead.\nDoes anyone know if there is a problem with IE8?\nIs it better to use UTF-8 instead?","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":1203,"Q_Id":9370343,"Users Score":2,"Answer":"Yes, it is better to use UTF-8 instead.\nYour question really cannot be answered unless you also provide the bytes that you are sending.","Q_Score":3,"Tags":"python,html,utf-8,iso-8859-1","A_Id":9370369,"CreationDate":"2012-02-21T00:08:00.000","Title":"ISO-8859-1 Not working on IE","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},{"Question":"I am using emacs 23 -nw and xterm installed on Debian Squeeze. I need highlighting with python but I don't have it. How can I enable it? \nEdit:\nThanks for all answers, the problem is that\n\nI have googled a lot, really.\nI have the code on a file with extension .py\nThe script starts with #!\/usr\/bin\/python, as one of the the answers points I have changed to !#\/usr\/bin\/env python\nI used M-x and tried to find something related to python, well there many options which do not solve my problem.\n\nSorry my question was not very precise and I even accept -10 but I don't have highlight which would give me red highlight for lines starting # etc. To be more precise I have a very a dull highlight; lines with # are white, lines between \"\"\" \"\"\" are green, some of the variable names are yellow but don't know why not all. [import, as, from] are light blue, [open, max, and other function names] are dark blue etc. And besides my 200 lines of code is working.","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":4284,"Q_Id":9371542,"Users Score":1,"Answer":"I'm not sure if this is right, but try the following.\n1) M-x\n2) type in \"python-mode\". Tab completion works here so type in \"pyth\" and hit tab and you can see what your options are.\nmj","Q_Score":3,"Tags":"python,emacs,highlight","A_Id":9371607,"CreationDate":"2012-02-21T03:02:00.000","Title":"Python highlighting 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":0},{"Question":"I am using emacs 23 -nw and xterm installed on Debian Squeeze. I need highlighting with python but I don't have it. How can I enable it? \nEdit:\nThanks for all answers, the problem is that\n\nI have googled a lot, really.\nI have the code on a file with extension .py\nThe script starts with #!\/usr\/bin\/python, as one of the the answers points I have changed to !#\/usr\/bin\/env python\nI used M-x and tried to find something related to python, well there many options which do not solve my problem.\n\nSorry my question was not very precise and I even accept -10 but I don't have highlight which would give me red highlight for lines starting # etc. To be more precise I have a very a dull highlight; lines with # are white, lines between \"\"\" \"\"\" are green, some of the variable names are yellow but don't know why not all. [import, as, from] are light blue, [open, max, and other function names] are dark blue etc. And besides my 200 lines of code is working.","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":4284,"Q_Id":9371542,"Users Score":0,"Answer":"Emacs 23 should know about Python out of the box. Does the name of your Python file end with .py, or does the file have #!\/usr\/bin\/env python as the first line? If you're creating a new file, make sure the filename ends with .py. You can also use M-x python-mode as mentioned in another answer. If none of that works, check that your terminal actually supports color.","Q_Score":3,"Tags":"python,emacs,highlight","A_Id":9371634,"CreationDate":"2012-02-21T03:02:00.000","Title":"Python highlighting 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":0},{"Question":"How would I go about setting up one github user and ssh key and then replicating that to several other laptops so they can all use the same account? It would be optimal if I could copy a configuration file so I wouldn't have to apply it one laptop at a time - I could apply it through server administration.\nThis isn't a typical github setup so don't worry about this being the correct way to set it up.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":189,"Q_Id":9381247,"Users Score":0,"Answer":"Setup the project the way github describes.\nCreate your ssh keys.\nTar or Zip everything up.\nDistribute and Untar\/Unzip.\nDone.","Q_Score":0,"Tags":"python,git,github","A_Id":9381435,"CreationDate":"2012-02-21T16:29:00.000","Title":"Multiple laptops with same github account and SSH key","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"Hi is there a way out to gracefully shutdown the bottle server. In a way it should be able to do few steps before it eventually stops. This is critical for some clean up of threads and db state etc avoiding the corrupt state during the restart.\nI am using mod wsgi apache module for running the bottle server.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":758,"Q_Id":9389138,"Users Score":2,"Answer":"In mod_wsgi you can register atexit callbacks and they will be called on normal process shutdown. You don't have too long to do stuff though. If embedded mode, or daemon mode and shutdown caused by Apache restart, you have only 3 seconds as Apache will kill off processes forcibly after that. If daemon mode and trigger is due to touching WSGI script file or you explicitly sent daemon process a signal, you have 5 seconds, which is when mod_wsgi will decide it is taking too long and forcibly kill them.\nSee the 'atexit' module in Python.","Q_Score":1,"Tags":"python,mod-wsgi,bottle","A_Id":9389919,"CreationDate":"2012-02-22T04:34:00.000","Title":"Gracefull shutdown of bottle python 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":1,"Web Development":0},{"Question":"I have Apache running on OSX Lion and MacPorts Python and some packages installed with MacPorts. \nThere are some Python cgi scripts that I'd like to run. It looks like Apache uses the Python that is installed with Lion. How can I configure Apache so that the cgi scripts are run with the MacPorts Python and sites-packages (PYTHONPATH I guess)?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":366,"Q_Id":9407472,"Users Score":0,"Answer":"Edit the shebang line in the CGI scripts to point to the other executable.","Q_Score":0,"Tags":"python,macos,apache","A_Id":9407550,"CreationDate":"2012-02-23T05:03:00.000","Title":"OSX and setting PATH for 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":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},{"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},{"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},{"Question":"What is the base language Python is written in?","AnswerCount":6,"Available Count":1,"Score":0.1651404129,"is_accepted":false,"ViewCount":106795,"Q_Id":9451929,"Users Score":5,"Answer":"You get a good idea if you compile python from source. Usually it's gcc that compiles the *.c files","Q_Score":98,"Tags":"python","A_Id":17551576,"CreationDate":"2012-02-26T09:23:00.000","Title":"Base language 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":1,"System Administration and DevOps":0,"Web Development":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},{"Question":"Which would it make more sense to code an IRC bot in: Python 2 or 3? With 3 I heard you have to do extra stuff because it's unicode(?).","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":355,"Q_Id":9454974,"Users Score":0,"Answer":"It shouldn't matter.\nPython 3 is more Unicode compatible, but that's only a good thing.\nThe most obvious and visible thing changed in Python 3 is print. In Python 3.0 it is a function and requires parentheses.","Q_Score":0,"Tags":"python,irc","A_Id":9454999,"CreationDate":"2012-02-26T16:48:00.000","Title":"Python 2 vs Python 3 for an IRC bot?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've tried to create a twill test that changes the proxy server settings of 2 different tests. I need to trigger this change in runtime without relaunching the test script.\nI've tried to use the \"http_proxy\" environment variable by setting os.environ[\"HTTP_PROXY\"], but it's only changes the proxy setting for the first test, and does not works on the second and third tests.\nCould you please suggest a way to change twill's proxy settings on runtime ?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":478,"Q_Id":9456442,"Users Score":0,"Answer":"Set the proxy environment variable before you run the twill script. \nsh\/ksh\/bash\nexport HTTP_PROXY=blah:8080\ncsh\nsetenv HTTP_PROXY blah:8080\nIt's worth nothing, this should work by setting os.environ['http_proxy'], but it might not if you set it after you import twill. Twill may be checking this once on startup? The only 100% safe way I would imagine is exporting the variable so that all further child processes will get it as their environment.","Q_Score":0,"Tags":"python,mechanize,twill","A_Id":9465091,"CreationDate":"2012-02-26T19:35:00.000","Title":"twill - changing the proxy server setting in runtime","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I'm a big fan of discovering sentences that can be rapped very quickly. For example, \"gotta read a little bit of Wikipedia\" or \"don't wanna wind up in the gutter with a bottle of malt.\" (George Watsky) \nI wanted to write a program in Python that would enable me to find words (or combinations of words) that can be articulated such that it sounds very fast when spoken. \nI initially thought that words that had a high syllable to letter ratio would be the best, but upon writing a Python program to do find those words, I retrieved only very simple words that didn't really sound fast (e.g. \"iowa\"). \nSo I'm at a loss at what actually makes words sound fast. Is it the morpheme to letter ratio? Is it the number of alternating vowel-consonant pairs? \nHow would you guys go about devising a python program to resolve this problem?","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":1243,"Q_Id":9459745,"Users Score":2,"Answer":"I would say it's a good idea to start by taking the examples you gave or other ones you like and doing some sort of analysis for all your ideas on them: e.g. phoneme to to letter ratio, etc; whatever sounds reasonable and that you can calculate. The more samples the better. Hopefully this will give you a good idea of what properties the lines and words you already enjoy share, which should lead you in the right direction.\nOtherwise, my laymen's guess is that short vowels (obviously) and hard consonants like 't', some 'p's, hard 'g's, etc, will be best - they make the lines sound staccato and rapid-fire.\n(wanted to leave this as a comment cause it's not really an answer, but it's too long :)","Q_Score":13,"Tags":"python,algorithm,word,nlp,linguistics","A_Id":9466414,"CreationDate":"2012-02-27T03:38:00.000","Title":"Find words and combinations of words that can be spoken the quickest","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Is there any easy way to initiate ssh connection with Python 3 without using popen? I would like to achieve password and password less authentication.","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1977,"Q_Id":9465807,"Users Score":0,"Answer":"No. Paramiko does not work with Python 3.x yet","Q_Score":0,"Tags":"ssh,python-3.x,connection","A_Id":17140320,"CreationDate":"2012-02-27T13:28:00.000","Title":"How to initiate ssh connection with Python 3","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},{"Question":"I have an python application in production (on CentOS 6.2 \/ Python 2.6.6) that takes up to:\n\n800M VIRT \/ 15M RES \/ 2M SHR\n\nThe same app run on (Fedora 16 \/ Python 2.7.2) \"only\" takes up to:\n\n56M VIRT \/ 15M RES \/ 2M SHR\n\nIs it an issue ?\nWhat's the explanation of this difference ?\nI'm wondering if it could go wrong anytime with such an amount of virtual memory ?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1159,"Q_Id":9479492,"Users Score":0,"Answer":"What does the application do? What libraries does it use? What else is different between those machines? It's hard to give a general answer.\nThe VIRT value indicates how much memory the process has requested from the operating system in one way or another. But Linux is lazy in this respect: that memory won't actually be allocated to the process until the process tries to do something with it.\nThe RES value indicates how much memory is actually resident in RAM and currently in use by the process. This excludes pages that haven't yet been touched by the process or that have been swapped out to disk. Since the RES values are small and identical for both of those processes, there's probably nothing to worry about.","Q_Score":2,"Tags":"python,memory","A_Id":9951397,"CreationDate":"2012-02-28T09:35:00.000","Title":"Python VIRT Memory Usage","Data Science and Machine Learning":0,"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},{"Question":"We can write a piece of python code and put it in already compiled \".pyc\" file and use it. I am wondering that is there any kind of gain in terms of performance or it is just a kind of modular way of grouping the code. \nThanks a lot","AnswerCount":5,"Available Count":2,"Score":0.0399786803,"is_accepted":false,"ViewCount":9152,"Q_Id":9485905,"Users Score":1,"Answer":"I'm not sure about .pyc files (very minor gain is at least not creating .pyc files again), but there's a '-O' flag for the Python interpreter which produces optimised bytecode (.pyo files).","Q_Score":8,"Tags":"python,pyc","A_Id":9485942,"CreationDate":"2012-02-28T16:36:00.000","Title":"is there any kind of performance gain while using .pyc 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},{"Question":"We can write a piece of python code and put it in already compiled \".pyc\" file and use it. I am wondering that is there any kind of gain in terms of performance or it is just a kind of modular way of grouping the code. \nThanks a lot","AnswerCount":5,"Available Count":2,"Score":0.0399786803,"is_accepted":false,"ViewCount":9152,"Q_Id":9485905,"Users Score":1,"Answer":"Yes, simply because the first time you execute a .py file, it is compiled to a .pyc file. \nSo basically you have to add the compilation time. Afterwards, the .pyc file should be always used.","Q_Score":8,"Tags":"python,pyc","A_Id":9485947,"CreationDate":"2012-02-28T16:36:00.000","Title":"is there any kind of performance gain while using .pyc 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},{"Question":"This question might seem vague, sorry. Does anybody have experience writing RegEx with Objective-C and Python? I am wondering about the performance of one vs the other? Which is faster in terms of 1. runtime speed, and 2. memory consumption? I have a Mac OS application that is always running in the background, and I'd like my app to index some text files that are being saved, and then save the result... I could write a regex method in my app in Obj-C, or I could potentially write a separate app using Perl or Python (just a beginner in Python).\n(Thanks, I got some good info from some of you already. Boo to those who downvoted; I am here to learn, and I might have some stupid questions time to time - part of the deal.)","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":601,"Q_Id":9486827,"Users Score":2,"Answer":"If you\u2019re looking for raw speed, neither of those two would be a very good choice. For execution speed, you\u2019d choose Perl. For how quickly you could code it up, either Python or Perl alike would easily beat the time to write it in Objective C, just as both would easily beat a Java solution. High-level languages that take less time to code up are always a win if all you\u2019re measuring is time-to-solution compared with solutions that take many more lines of code.\nAs far as actual run-time performance goes, Perl\u2019s regexes are written in very tightly coded C, and are known to be the fastest and most flexible regexes available. The regex optimizer does a lot of very clever things to the compiled regex program, such as applying an Aho\u2013Corasick start-point optimization for finding the start of an alternation trie, running in O(1) time. Nobody else does that. Heck, I don\u2019t think anybody else but Perl even bothers to optimize alternations into tries, which is the thing that takes you from O(n) to O(1), because the compiler spent more time doing something smart so that the interpreter runs much faster. Perl regexes also offer substantial improvements in debugging and profiling. They\u2019re also more flexible than Python\u2019s, but the debugging alone is enough to tip the balance.\nThe only exception on performance matters is with certain pathological patterns that degenerate when run under any recursive backtracker, whether Perl\u2019s, Java\u2019s, or Python\u2019s. Those can be addressed by using the highly recommended RE2 library, written by Russ Cox, as a replacement plugin. I know it\u2019s available as a transparent replacement regex engine for Perl, and I\u2019m pretty sure I remember seeing that it was also available for Python, too.\nOn the other hand, if you really want to use Python but just want a more expressive and robust regex library, particularly one that is well-behaved on Unicode, then you want to use Matthew Barnett\u2019s regex module, available for both Python2 and Python3. Besides conforming to tr18\u2019s level-1 compliance requirements (that\u2019s the standards doc on Unicode regexes), it also has all kinds of other clever features, some of which are completely sui generis. If you\u2019re a regex connoisseur, it\u2019s very much worth checking out.","Q_Score":1,"Tags":"python,objective-c,regex","A_Id":9487143,"CreationDate":"2012-02-28T17:30:00.000","Title":"RegEx performance in Objective-C vs 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},{"Question":"I want to send lots of numbers via zeromq but converting them to str is inefficient. What is the best way to send numbers via zmq?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":2967,"Q_Id":9489560,"Users Score":3,"Answer":"You state that converting numbers to str is inefficient. And yet, unless you have a truly exotic network, that is exactly what must occur no matter what solution is chosen, because all networks in wide use today are byte-based.\nOf course, some ways of converting numbers to byte-strings are faster than others. Performing the conversion in C code will likely be faster than in Python code, but consider also whether it is acceptable to exclude \"long\" (bignum) integers. If excluding them is not acceptable, the str function may be as good as it gets.\nThe struct and cpickle modules may perform better than str if excluding long integers is acceptable.","Q_Score":1,"Tags":"python,zeromq,pyzmq","A_Id":9491177,"CreationDate":"2012-02-28T20:52:00.000","Title":"send a number by zeromq pyzmq","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I would like to contribute to open source Python project hosted on github.\nBut the code base comes as module that needs to be installed using pip or smth like this.\nWhich means I do \"git clone\", \"setup.py install\" the code will be placed after installation into another (non repo) folder.\nThe question is which folder I should edit\/commit code then and what's the standard solution foe such a multi-folder issue.","AnswerCount":1,"Available Count":1,"Score":0.537049567,"is_accepted":false,"ViewCount":119,"Q_Id":9499396,"Users Score":3,"Answer":"You'd normally do setup.py develop or pip install -e .\nSo you don't want the installer to copy it anywhere else.\nUsing this mode, a special link file is created in your site-packages directory. This link points back to the current folder or 'root package'. Any changes you make to the software here will be reflected immediately without having to do an install again.","Q_Score":0,"Tags":"python,open-source,github","A_Id":9499693,"CreationDate":"2012-02-29T12:44:00.000","Title":"Contributing to Python: edit git\/cloned code or installed 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},{"Question":"I want to display all the Internet History Information of a system using Python. The index.dat file holds all the history information of user, but it's encoded. How can I decode it?\n[I have heard about WinInet Method INTERNET_CACHE_ENTRY_INFO. It provides information about websites visited, hit counts, etc.]\nAre there any libraries available in Python for achieving this? If not, are there any alternatives available?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":5552,"Q_Id":9506894,"Users Score":1,"Answer":"If you wanted to do this for Firefox history, it's an SQLITE database in the file places.sqlite in the user's firefox profile. It can be opened with python's sqlite3 library. Now if you only care about Explorer (as implied by your mention of index.dat), well I don't know about that.","Q_Score":2,"Tags":"python,internet-explorer,browser-cache,browser-history","A_Id":9508666,"CreationDate":"2012-02-29T21:27:00.000","Title":"How do I Retrieve and Display the Internet History Information 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},{"Question":"What's the best way to call C++ function from shared object in python. Can I can solve this problem without additional python extension?","AnswerCount":3,"Available Count":2,"Score":0.1325487884,"is_accepted":false,"ViewCount":459,"Q_Id":9516431,"Users Score":2,"Answer":"If you have the C++ source code, I would say boost python is the best way because it's very easy to get this up and running and it's flexible. If you don't have C++ source then checkout ctypes.","Q_Score":1,"Tags":"c++,python,shared-objects","A_Id":9516707,"CreationDate":"2012-03-01T12:41:00.000","Title":"The best way to call C++ function from shared object 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},{"Question":"What's the best way to call C++ function from shared object in python. Can I can solve this problem without additional python extension?","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":459,"Q_Id":9516431,"Users Score":1,"Answer":"Another way is to use swig (http:\/\/www.swig.org\/) to generate a python module wrapping the C++ code.","Q_Score":1,"Tags":"c++,python,shared-objects","A_Id":9516904,"CreationDate":"2012-03-01T12:41:00.000","Title":"The best way to call C++ function from shared object 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},{"Question":"I am working with an ARM Cortex M3 on which I need to port Python (without operating system). What would be my best approach? I just need the core Python and basic I\/O.","AnswerCount":6,"Available Count":1,"Score":0.0333209931,"is_accepted":false,"ViewCount":7622,"Q_Id":9519346,"Users Score":1,"Answer":"fyi I just ported CPython 2.7x to non-POSIX OS. That was easy.\nYou need write pyconfig.h in right way, remove most of unused modules. Disable unused features.\nThen fix compile, link errors. Then it just works after fixing some simple problems on run.\nIf You have no some POSIX header, write one by yourself. Implement all POSIX functions, that needed, such as file i\/o.\nTook 2-3 weeks in my case. Although I have heavily customized Python core. Unfortunately cannot opensource it :(.\nAfter that I think Python can be ported easily to any platform, that has enough RAM.","Q_Score":24,"Tags":"python,embedded","A_Id":24161759,"CreationDate":"2012-03-01T15:52:00.000","Title":"Porting Python to an embedded 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},{"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},{"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},{"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},{"Question":"i'm trying to work out which language to work with in VS2010, c# or Python.\nI understand that there are better ide's for Python out there but i like the VS IDE environment.\nIf Iron python can do everything CS and VB can do in VS2010 i'll be happy. But can it?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1931,"Q_Id":9534242,"Users Score":0,"Answer":"If Iron python can do everything C# and VB can do in VS2010 i'll be happy. But can it?\n\nNo, C# and VB, and to a lesser extent F#, are the primary languages for Visual Studio. Microsoft support for IronPython has been dropped and it seems to be stagnating.\nIf you are just writing console based code then you may be OK with IronPython, but if you are doing any GUI work then I would not recommend it.\nEven then, the fact that the language no longer has MS backing leaves me with a bad feeling. I would not invest time and effort into writing IronPython code because I suspect that it will become a dead end.","Q_Score":2,"Tags":"python,visual-studio-2010","A_Id":9534308,"CreationDate":"2012-03-02T13:38:00.000","Title":"Python in VS2010","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a dll built in c++, under VS2010, and I am calling it from a python project.\nI had an error, inside the dll, and I would have liked to be able to debug using VS tools, step into the solution until I reach the task that \"read an invalid memory location\". \nThe debug \/ stepping into functions didn't step into the function code inside the dll. \nI tried to attach the debugger (and run the python code from command line\/ stop at a raw_input that gave me the pid, then attach the debugger). Same thing happened. I hit the breakpoints inside the python code, but none inside the dll.\nI eventually found my error, after much banging my head against my monitor, using old-style trace inside the dll. But there has to be a way to be able to debug an existing\/ open project inside VS... I am going to run into this again, so I hope to learn something now, and avoid damage to my monitor in the future. :)\nNote: the c++ dll and the pdb file are located both in the same directory as the python file, they are of course automatically built into the Debug folder, and they are also in a folder located into the system path. Any possible DEBUG symbols are enabled. I am using python 2.7.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":1816,"Q_Id":9540220,"Users Score":1,"Answer":"You need to have the .pdb file in your bin directory if you want to be able to step into and debug a dll, otherwise you will not have access to any of the debugging symbols. This .pdb allows visual studio to read the .dll file and step into its method calls.","Q_Score":1,"Tags":"c++,python,visual-studio-2010,debugging,dll","A_Id":9540284,"CreationDate":"2012-03-02T20:54:00.000","Title":"debugging a c++ dll in VS2010, 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":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to send a python script I wrote on my Mac to my friends. Problem is, I don't want to send them the code that they can edit. How can I have my script change from an editable text file, to a program that you click to run?","AnswerCount":5,"Available Count":2,"Score":-0.0399786803,"is_accepted":false,"ViewCount":4391,"Q_Id":9542814,"Users Score":-1,"Answer":"You could try py2exe (http:\/\/www.py2exe.org\/) since it compiles your code into an exe file, they should have a hell of a time trying to decompose it.","Q_Score":4,"Tags":"python,macos,text,compiler-construction","A_Id":9542902,"CreationDate":"2012-03-03T02:18:00.000","Title":"\"Compiling\" 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},{"Question":"I'm trying to send a python script I wrote on my Mac to my friends. Problem is, I don't want to send them the code that they can edit. How can I have my script change from an editable text file, to a program that you click to run?","AnswerCount":5,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":4391,"Q_Id":9542814,"Users Score":0,"Answer":"If your friends are on windows you could use py2exe, but if they're on Mac I'm not sure there's an equivalent. Either way, compiling like that breaks cross platform compatability, which is the whole point of an interpreted language really...\nPython just isn't really set up to hide code like that, it's against it's philosophy as far as I can tell.","Q_Score":4,"Tags":"python,macos,text,compiler-construction","A_Id":9543052,"CreationDate":"2012-03-03T02:18:00.000","Title":"\"Compiling\" 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},{"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},{"Question":"I have my python script set to run from cron in Ubuntu Server. However it might take longer time to finish, before another cron event will try to start it. I would like to determine such case from script itself and if running then gracefully terminate it from python script.","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":3425,"Q_Id":9555742,"Users Score":1,"Answer":"Save your pid to a file; if the file already exists, check that the process that left its PID is still alive. (This is safer than trying to ensure you always remove the file: You can't). The full process goes like this:\nCheck if the checkpoint file exists. If it does not, write your PID into the file and go ahead with the computation.\nIf the file exists: Read the PID and check if the process is, in fact, still alive. The best way to do that is with \"kill -0\" (from python: os.kill), which doesn't bother the running process but fails if it does not exist. If the process is still running, exit. Otherwise, write your PID to the file etc.\nThere's a small chance of a race condition, but if your process is getting restarted at infrequent intervals, that should be entirely harmless: Your process could always quit in favor of a running process that exits a second later, so what does it matter if the running process manages to quit first?","Q_Score":1,"Tags":"python,ubuntu-10.04","A_Id":9555991,"CreationDate":"2012-03-04T14:39:00.000","Title":"How to determine if my python script is running?","Data Science and Machine Learning":0,"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},{"Question":"I have my python script set to run from cron in Ubuntu Server. However it might take longer time to finish, before another cron event will try to start it. I would like to determine such case from script itself and if running then gracefully terminate it from python script.","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":3425,"Q_Id":9555742,"Users Score":0,"Answer":"There are two obvious solutions:\n\nSome kind of lock file, which it checks. If the lock file exists, then don't start, otherwise create it. (Or more aptly, in true python 'ask for forgiveness, not permission' style, try to make it and catch the error if it exists - stopping a race condition). You need to be careful to ensure this gets cleaned up when the script ends, however - even on errors, otherwise it could block future runs. Traditionally this is a .pid file which contains the process id of the running process.\nUse ps to check for the running process. With this solution it is harder to stop the race condition, however.","Q_Score":1,"Tags":"python,ubuntu-10.04","A_Id":9555781,"CreationDate":"2012-03-04T14:39:00.000","Title":"How to determine if my python script is running?","Data Science and Machine Learning":0,"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},{"Question":"I tried to figure it out, the most secure and flexible solution for storing in config file some credentials for database connection and other private info. \nThis is inside a python module for logging into different handlers (mongodb, mysqldb, files,etc) the history of users activity in the system. \nThis logging module, is attached with a handler and its there where I need to load the config file for each handler. I.E. database, user, pass, table, etc. \nAfter some research in the web and stackoverflow, I just saw mainly the security risks comparison between Json and CPickle, but concerning the eval method and the types restriction, more than the config file storage issue. \nI was wondering if storing credentials in json is a good idea, due to the security risks involved in having a .json config file in the server (from which the logging handler will read the data). I know that this .json file could be retrieved by an http request. If the parameters are stored in a python object inside a .py code, I guess there is more security due to the fact that any request of this file will be interpreted first by the server, but I am loosing the flexibility of modularization and easy modification of this data.\nWhat would you suggest for this kind of Security issues while storing this kind of config files in the server and accessed by some Python class? \nThanks in advance, \nLuchux.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":427,"Q_Id":9567579,"Users Score":0,"Answer":"I'd think about encrypting the credentials file. The process that uses it will need a key\/password to decrypt it, and you can store that somewhere else-- or even enter it interactively on server start-up. That way you don't have a single point of failure (though of course a determined intruder can eventually put the pieces together).\n(Naturally you should also try to secure the server so that your credentials can't just be fetched by http request)","Q_Score":0,"Tags":"python,json,security,configuration-files,pickle","A_Id":9568058,"CreationDate":"2012-03-05T13:37:00.000","Title":"Security issues storing config file in json\/CPickle","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm using boto to spawn a new EC2 instance based on an AMI.\nThe ami.run method has a number of parameters, but none for \"name\" - maybe it's called something different?","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":9225,"Q_Id":9575148,"Users Score":1,"Answer":"In EC2 there's no api to change the actually name of the machine. You basically have two options.\n\nYou can pass the desired name of the computer in the user-data and when the server starts run a script that will change the name of the computer.\nYou can use an EC2 tag to name the server ec2-create-tags --tag:Name=. Downside to this solution is the server wont actually update to this name. This tag is strictly for you or for when you're querying the list of servers in aws.\n\nGenerally speaking if you're at the point where you want your server to configure itself when starting up I've found that renaming your computer in EC2 just causes more trouble than it's worth. I suggest not using them if you don't have to. Using the tags or elb instances is the better way to go.","Q_Score":23,"Tags":"python,amazon-ec2,amazon-web-services,boto","A_Id":9575281,"CreationDate":"2012-03-05T22:39:00.000","Title":"With boto, how can I name a newly spawned EC2 instance?","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},{"Question":"I'm using pyramid web framework. I was confused by the relationship between the cookie and session. After looked up in wikipedia, did I know that session is an abstract concept and cookie may just be an kind of approach (on the client side).\nSo, my question is, what's the most common implementation (on both the client and server)? Can somebody give some example (maybe just description) codes? (I wouldn't like to use the provided session support inside the pyramid in order to learn)","AnswerCount":3,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":365,"Q_Id":9576263,"Users Score":2,"Answer":"In general, the cookie stored with the client is just a long, hard-to-guess hash code string that can be used as a key into a database. On the server side, you have a table mapping those session hashes to primary keys (a session hash should never be a primary key) and expiration timestamps.\nSo when you get a request, first thing you do is look for the cookie. If there isn't one, create a session entry (cookie + expiration timestamp) in the database table. If there is one, look it up and make sure it hasn't expired; if it has, make a new one. In either case, if you made a new cookie, you might want to pass that fact down to later code so it knows if it needs to ask for a login or something. If you didn't need to make a new cookie, reset the expiration timestamp so you don't expire the session too soon.\nWhile handling the view code and generating a response, you can use that session primary key to index into other tables that have data associated with the session. Finally, in the response sent back to the client, set the cookie to the session key hash.\nIf someone has cookies disabled, then their session cookie will always be new, and any session-based features won't work.","Q_Score":1,"Tags":"python,session,cookies,pyramid","A_Id":9576386,"CreationDate":"2012-03-06T00:35:00.000","Title":"Is cookie a common and secure implementation of 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":1},{"Question":"I'm using pyramid web framework. I was confused by the relationship between the cookie and session. After looked up in wikipedia, did I know that session is an abstract concept and cookie may just be an kind of approach (on the client side).\nSo, my question is, what's the most common implementation (on both the client and server)? Can somebody give some example (maybe just description) codes? (I wouldn't like to use the provided session support inside the pyramid in order to learn)","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":365,"Q_Id":9576263,"Users Score":1,"Answer":"A session is (usually) a cookie that has a unique value. This value maps to a value in a database or held in memory that then tells you what session to load. PHP has an alternate method where it appends a unique value to the end of every URL (if you've ever seen PHPSESSID in a URL you now know why) but that has security implications (in theory).\nOf course, since cookies are sent back and forth with every request unless you're talking over HTTPS you are sending the only way to know (reliably) that the client you are talking to now is the same one you logged in ten seconds ago to anyone on the same wireless network. See programs like Firesheep for reasons why switching to HTTPS is a good idea.\nFinally, if you do want to build your own I, was given some advice on the matter by a university professor. Give out a new token on every page load and invalidate all a users tokens if an invalid token is used. This just means that if an attacker does get a token and logs in to it whilst it is still valid when the victim clicks a link both parties get logged out.","Q_Score":1,"Tags":"python,session,cookies,pyramid","A_Id":9576390,"CreationDate":"2012-03-06T00:35:00.000","Title":"Is cookie a common and secure implementation of 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":1},{"Question":"I have some C++ code that delivers events to Python objects. Observers are kept as weak_ptrs, so they don't have to deregister.\nThis works in C++, but bridging weak pointers and Python weak references is troublesome (I also want Python event handlers not being kept alive by subscriptions, same as in C++ code). In order to have a live observer, something needs to have a shared pointer to it while the object is alive, so it boils down to having an observer in Python land control the lifetime of a C++ observer object.\nThe approaches I've come up with so far involve a fair amount of boilerplate and intermediate objects (e.g. creating another PyTypeObject for a type that keeps a C++ observer and a weak reference to the Python observer and setting it as a member of Python observer, so it dies with it).\nThe question is, is there any obvious way to do it?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":107,"Q_Id":9577314,"Users Score":0,"Answer":"I would write a python wrapper over the C++ module and dispatch to python observers in the python wrapper. Would that be enough?\nWhen you mention that something needs to have a shared pointer, would it be enough if that shared pointer is on the stack until given observer returns?","Q_Score":4,"Tags":"c++,python,weak-references","A_Id":9737868,"CreationDate":"2012-03-06T02:59:00.000","Title":"Track the lifetime of a CPython object from C extension","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},{"Question":"I hope you guys can spare a moment with some ideas on how to develop my idea.\nI have an Asterisk-based telephone switch . When an incoming call is arriving, I can make sure the server runs an external script of any language.\nHere comes my development work. I would like to notify a group of listening clients about the call, and probably open a browser page on their computer.\nWhat kind of approach would you take for this sort of server-based push notification? (with no iPhone involved)\nI am open to any language.\nThanks","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":335,"Q_Id":9595076,"Users Score":0,"Answer":"Maybe have a look at www.pubnub.com .. its commercial, but lets you send 5 million messages a month for free. Essentially it lets you create a named channel, and have X number of clients connect to it and send messages back and forth. \nUsing one of these services would of course require you to write a client to distribute to your users (in your language of choice) and tie's you in somewhat (shouldn't really be a problem as you could swap in some other solution later if they go under or whatever.) \nThe upside would be, very good x-platform support and a very clean API, infrastructure taken care of for you (for example clients can still connect the the channel even if your asterisk box is down or whatever)\n(and no, I don't work for pubnub! but it seems like a no-brainer to use it with the 5mil messages free deal!)","Q_Score":0,"Tags":"python,notifications,push-notification,server-push","A_Id":9595261,"CreationDate":"2012-03-07T02:39:00.000","Title":"Cross Platform Event 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},{"Question":"I am using smtplib sendmail and \\n (line feed) is being added where there was just \\r (carriage return). \nThis corrupts the file for use with the UNIX tnef utility. How can I keep the line feed from being added?\nThanks","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":433,"Q_Id":9610221,"Users Score":0,"Answer":"Email servers are free to change line endings IIRC. They could be various platforms.\nIf you are transmitting an attachment, use a suitable encoding such as Base64.","Q_Score":0,"Tags":"python,email,carriage-return,smtplib","A_Id":9610703,"CreationDate":"2012-03-07T22:37:00.000","Title":"Python's smtplib sendmail is inserting line feed","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I have data across several computers stored in folders. Many of the folders contain 40-100 G of files of size from 500 K to 125 MB. There are some 4 TB of files which I need to archive, and build a unfied meta data system depending on meta data stored in each computer.\nAll systems run Linux, and we want to use Python. What is the best way to copy the files, and archive it. \nWe already have programs to analyze files, and fill the meta data tables and they are all running in Python. What we need to figure out is a way to successfully copy files wuthout data loss,and ensure that the files have been copied successfully. \nWe have considered using rsync and unison use subprocess.POPEn to run them off, but they are essentially sync utilities. These are essentially copy once, but copy properly. Once files are copied the users would move to new storage system.\nMy worries are 1) When the files are copied there should not be any corruption 2) the file copying must be efficient though no speed expectations are there. The LAN is 10\/100 with ports being Gigabit. \nIs there any scripts which can be incorporated, or any suggestions. All computers will have ssh-keygen enabled so we can do passwordless connection.\nThe directory structures would be maintained on the new server, which is very similar to that of old computers.","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":836,"Q_Id":9618641,"Users Score":0,"Answer":"I think rsync is the solution. If you are concerned about data integrity, look at the explanation of the \"--checksum\" parameter in the man page.\nOther arguments that might come in handy are \"--delete\" and \"--archive\". Make sure the exit code of the command is checked properly.","Q_Score":0,"Tags":"python,file,rsync,unison","A_Id":9619361,"CreationDate":"2012-03-08T13:49:00.000","Title":"What is the best utility\/library\/strategy with Python to copy files across multiple computers?","Data Science and Machine Learning":0,"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},{"Question":"I have an embedded device with Python installed on in. Is it possible to explicitly access registers in pure Python, or should I write C extensions for my Python code?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":548,"Q_Id":9619207,"Users Score":5,"Answer":"It seems that you can't access the low level registers. I recommend just writing a short C extension code to allow Python to access the registers you need.","Q_Score":5,"Tags":"python,c,embedded","A_Id":9619591,"CreationDate":"2012-03-08T14:28:00.000","Title":"Accessing low-level registers of an embedded device 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},{"Question":"I am new to this whole python deal, and admit that I am half lost - don't know whether I am coming or going. So, here's the question and I hope someone can assist me.\nI am running a RedHat system and by default, it has python 2.4 installed. I have a python script that gives me an error when attempting to import json. \nI have checked my phpinfo and it shows that I have json version 1.2.1 (or something or other) - so why isn't Python recognizing that this json does exist? Is there a file that I need to edit to manually enter or edit where python looks for the json at, and if so, where?\nI even tried installing simplejson and also python 3 - nothing has worked so far, and I have run out of hair to pull out.\nAny help would be greatly appreciated - thanks in advance.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":7168,"Q_Id":9624584,"Users Score":0,"Answer":"python needs the python module for json, which is not the same as the php module for json.\nThere are some to pick from, e.g. you can use python-cjson, so make sure that this module is installed.\nYou can ask rpm about which packages are installed like this: rpm -qa | grep json","Q_Score":2,"Tags":"python,linux,json","A_Id":9624622,"CreationDate":"2012-03-08T20:38:00.000","Title":"Python - import json returning module not found","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"In my game, there is are ActionFactory (makes AbstractActions), AbstractAction (actions that could exist), PotentialAction (actions that a being could do, which are assosietted with a specific being) classes. I need a name for a class that reperessents an actual, choosen action which was done by a specific being, has specific targets, and possibly arguments.","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":84,"Q_Id":9628303,"Users Score":0,"Answer":"Would CompletedAction, FinishedAction, ClosedAction, or PastAction be of any use?","Q_Score":1,"Tags":"python,naming-conventions,variable-names","A_Id":9628338,"CreationDate":"2012-03-09T02:52:00.000","Title":"What is a good name for chosen actions, possibly in the past?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"In my game, there is are ActionFactory (makes AbstractActions), AbstractAction (actions that could exist), PotentialAction (actions that a being could do, which are assosietted with a specific being) classes. I need a name for a class that reperessents an actual, choosen action which was done by a specific being, has specific targets, and possibly arguments.","AnswerCount":3,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":84,"Q_Id":9628303,"Users Score":0,"Answer":"I went with RealAction, mainly because of API consistency - all actual, specific real-world classes are prefixed with Real (and have an associated Potential class)","Q_Score":1,"Tags":"python,naming-conventions,variable-names","A_Id":9710839,"CreationDate":"2012-03-09T02:52:00.000","Title":"What is a good name for chosen actions, possibly in the past?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I have a custom codechecker in python, Also there is a bigger project running in PHP, which stores users code in MySQL database.\nI am new to python, so I'm not sure how I can pass the code from PHP to Python.\nDo I have to store the file to the filesystem to pass it to Python? (In that case too many files might be created, and their cleanup after execution has to be taken care)","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":109,"Q_Id":9628893,"Users Score":2,"Answer":"To expand on Brad's answer, there's several options, each with pros & cons...\n\nPipes (ie: STDIN\/STDOUT): proc_open()\nShared memory: shmop_open()\nAF_UNIX family sockets: socket_bind()\n\nYou'll probably want to use the first option but read up on the others before making a commitment.","Q_Score":0,"Tags":"php,python","A_Id":9629033,"CreationDate":"2012-03-09T04:21:00.000","Title":"Passing code to python from 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":0},{"Question":"I am running my Test Harness which is written in Python. Before running a test through this test harness, I am exporting some environment variables through a shell script which calls the test harness after exporting the variables. When the harness comes in picture, it checks if the variables are in the environment and does operations depending on the values in the env variables. \nHowever after the test is executed, I think the environment variables values aren't getting cleared as the next time, it picks up those values even if those aren't set through the shell script. \nIf they are set explicitly, the harness picks up the new values but if we clear it next time, it again picks up the values set in 1st run.\nI tried clearing the variables using \"del os.environ['var']\" command after every test execution but that didn't solve the issue. Does anybody know why are these values getting preserved?\nOn the shell these variables are not set as seen in the 'env' unix command. It is just in the test harness that it shows the values. None of the env variables store their values in any text files.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":2224,"Q_Id":9634473,"Users Score":1,"Answer":"A subshell can change variables it inherited from the parent, but the changes made by the child don't affect the parent.\nWhen a new subshell is started, in which the variable exported from the parent is visible. The variable is unsetted by del os.environ['var'], but the value for this variable in the parent stays the same.","Q_Score":2,"Tags":"python,environment-variables","A_Id":9634524,"CreationDate":"2012-03-09T13:00:00.000","Title":"Environment variables getting preserved in Python script even after exiting","Data Science and Machine Learning":0,"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},{"Question":"I know perl and python is tested solution for this kind of log parsing and data mining - \nAnybody have experience dealing with syslog parsing with Java ?\nI have to create a Java demon anyway to load the parsed output to DB .. \nSo I was thinking why not going all the way - \npython might be useful when I will be running it on different environment.","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":838,"Q_Id":9641974,"Users Score":0,"Answer":"I recently started writing python scripts, but recently i wrote a java gc log parser to print the timestamp when a gc happened and counts etc, and i found Python real easy in writing it. What kind of fields are you interested while parsing the syslogs? I think if you know what you are looking for in the logs(patterns etc) then it becomes easy to write a script which would do that for you.\nAnkit.","Q_Score":0,"Tags":"java,python,parsing,logging","A_Id":9642425,"CreationDate":"2012-03-09T22:42:00.000","Title":"Log parser solutions python\/perl vs 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":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I know perl and python is tested solution for this kind of log parsing and data mining - \nAnybody have experience dealing with syslog parsing with Java ?\nI have to create a Java demon anyway to load the parsed output to DB .. \nSo I was thinking why not going all the way - \npython might be useful when I will be running it on different environment.","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":838,"Q_Id":9641974,"Users Score":1,"Answer":"I translated some Java GC log parser\/analyzer from Perl to Java. In Java the code looked like more lines and the code obviously more verbose but the execution was at least 5 times faster.","Q_Score":0,"Tags":"java,python,parsing,logging","A_Id":11693757,"CreationDate":"2012-03-09T22:42:00.000","Title":"Log parser solutions python\/perl vs 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":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I want to take results from a web page, sent from dom as json through ajax, then send this data to a python script, run it, then return the new results back as json. I was told a php script running gearman would be a good bet, but I'm still not sure how that would work.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":703,"Q_Id":9642259,"Users Score":0,"Answer":"Put your Python script in your CGI directory and use the cgi and json modules in your script to read AJAX from post\/get params. Of course you can do a system call from PHP to run a Python script, but I can't think of a good reason why you would.","Q_Score":0,"Tags":"php,javascript,python,gearman","A_Id":9642671,"CreationDate":"2012-03-09T23:18:00.000","Title":"How can I run a python script through a webserver and return results to javascript?","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},{"Question":"What makes parsing a text file in 'r' mode more convenient than parsing it in 'rb' mode?\nEspecially when the text file in question may contain non-ASCII characters.","AnswerCount":4,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":84866,"Q_Id":9644110,"Users Score":13,"Answer":"The difference lies in how the end-of-line (EOL) is handled. Different operating systems use different characters to mark EOL - \\n in Unix, \\r in Mac versions prior to OS X, \\r\\n in Windows. When a file is opened in text mode, when the file is read, Python replaces the OS specific end-of-line character read from the file with just \\n. And vice versa, i.e. when you try to write \\n to a file opened in text mode, it is going to write the OS specific EOL character. You can find what your OS default EOL by checking os.linesep.\nWhen a file is opened in binary mode, no mapping takes place. What you read is what you get. Remember, text mode is the default mode. So if you are handling non-text files (images, video, etc.), make sure you open the file in binary mode, otherwise you\u2019ll end up messing up the file by introducing (or removing) some bytes.\nPython also has a universal newline mode. When a file is opened in this mode, Python maps all of the characters \\r, \\n and \\r\\n to \\n.","Q_Score":67,"Tags":"python,file-io,text-parsing","A_Id":31152300,"CreationDate":"2012-03-10T05:13:00.000","Title":"Difference between parsing a text file in r and rb 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},{"Question":"I want to use \"Importa\u00e7\u00e3o de petr\u00f3leo\" in my program.\nHow can I do that because all encodings give me errors as cannot encode.","AnswerCount":6,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":518,"Q_Id":9644338,"Users Score":0,"Answer":"Help on class unicode in module builtin:\nclass unicode(basestring)\n | unicode(string [, encoding[, errors]]) -> object\n |\n | Create a new Unicode object from the given encoded string.\n | encoding defaults to the current default string encoding.\n | errors can be 'strict', 'replace' or 'ignore' and defaults to 'strict'.\n | \ntry using \"utf8\" as the encoding for unicode()","Q_Score":1,"Tags":"python,unicode,encoding","A_Id":9644413,"CreationDate":"2012-03-10T06:05:00.000","Title":"How to encode 'Importa\u00e7\u00e3o de petr\u00f3leo' string 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},{"Question":"I have been trying to get the hang of TDD and unit testing (in python, using nose) and there are a few basic concepts which I'm stuck on. I've read up a lot on the subject but nothing seems to address my issues - probably because they're so basic they're assumed to be understood.\n\nThe idea of TDD is that unit tests are written before the code they test. Unit test should test small portions of code (e.g. functions) which, for the purposes of the test, are self-contained and isolated. However, this seems to me to be highly dependent on the implementation. During implementation, or during a later bugfix it may become necessary to abstract some of the code into a new function. Should I then go through all my tests and mock out that function to keep them isolated? Surely in doing this there is a danger of introducing new bugs into the tests, and the tests will no longer test exactly the same situation?\nFrom my limited experience in writing unit tests, it appears that completely isolating a function sometimes results in a test that is longer and more complicated than the code it is testing. So if the test fails all it tells you is that there is either a bug in the code or in the test, but its not obvious which. Not isolating it may mean a much shorter and easier to read test, but then its not a unit test...\nOften, once isolated, unit tests seem to be merely repeating the function. E.g. if there is a simple function which adds two numbers, then the test would probably look something like assert add(a, b) == a + b. Since the implementation is simply return a + b, what's the point in the test? A far more useful test would be to see how the function works within the system, but this goes against unit testing because it is no longer isolated.\nMy conclusion is that unit tests are good in some situations, but not everywhere and that system tests are generally more useful. The approach that this implies is to write system tests first, then, if they fail, isolate portions of the system into unit tests to pinpoint the failure. The problem with this, obviously, is that its not so easy to test corner cases. It also means that the development is not fully test driven, as unit tests are only written as needed.\n\nSo my basic questions are:\n\nShould unit tests be used everywhere, however small and simple the function?\nHow does one deal with changing implementations? I.e. should the implementation of the tests change continuously too, and doesn't this reduce their usefulness?\nWhat should be done when the test gets more complicated than the code its testing?\nIs it always best to start with unit tests, or is it better to start with system tests, which at the start of development are much easier to write?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1322,"Q_Id":9654020,"Users Score":5,"Answer":"Regarding your conclusion first: both unit tests and system tests (integration tests) both have their use, and are in my opinion just as useful. During development I find it easier to start with unit tests, but for testing legacy code I find your approach where you start with the integration tests easier. I don't think there's a right or wrong way of doing this, the goal is to make a safetynet that allows you to write solid and well tested code, not the method itself.\n\nI find it useful to think about each function as an API in this context. The unit test is testing the API, not the implementation. If the implementation changes, the test should remain the same, this is the safety net that allows you to refactor your code with confidence. Even if refactoring means taking part of the implementation out to a new function, I will say it's ok to keep the test as it is without stubbing or mocking the part that was refactored out. You will probably want a new set of tests for the new function however.\nUnit tests are not a holy grail! Test code should be fairly simple in my opinion, and it should be little reason for the test code itself to fail. If the test becomes more complex than the function it tests, it probably means you need to refactor the code differently. An example from my own past: I had some code that took some input and produced some output stored as XML. Parsing the XML to verifying that the output was correct caused a lot of complexity in my tests. However realizing that the XML-representation was not the point, I was able to refactor the code so that I could test the output without messing with the details of XML.\nSome functions are so trivial that a separate test for them adds no value. In your example you're not really testing your code, but that the '+' operator in your language works as expected. This should be tested by the language implementer, not you. However that function won't need to get very much more complex before adding a test for it is worthwhile.\n\nIn short, I think your observations are very relevant and point towards a pragmatic approach to testing. Following some rigorous definition too closely will often get in the way, even though the definitions themselves may be necessary for the purpose of having a way to communicate about the ideas they convey. As said, the goal is not the method, but the result; which for testing is to have confidence in your code.","Q_Score":7,"Tags":"python,unit-testing,tdd","A_Id":9654684,"CreationDate":"2012-03-11T10:04:00.000","Title":"How to approach unittesting and TDD (using python + nose)","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I'm using Pydev with Eclipse. Is it possible to execute a line of python code or a text selection with my IDE? Thanks!","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":3017,"Q_Id":9664539,"Users Score":1,"Answer":"CTRL+ALT+ENTER will execute the selected lines.","Q_Score":1,"Tags":"python,eclipse,pydev","A_Id":22150831,"CreationDate":"2012-03-12T09:30:00.000","Title":"Execute Python line of 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":0,"System Administration and DevOps":0,"Web Development":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},{"Question":"pymat doesnt seem to work with current versions of matlab, so I was wondering if there is another equivalent out there (I havent been able to find one). The gist of what would be desirable is running an m-file from python (2.6). (and alternatives such as scipy dont fit since I dont think they can run everything from the m-file). \nThanks in advance!","AnswerCount":4,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":5746,"Q_Id":9675386,"Users Score":2,"Answer":"You can always start matlab as separate subprocess and collect results via std.out\/files. (see subprocess package).","Q_Score":2,"Tags":"python,matlab","A_Id":9675452,"CreationDate":"2012-03-12T21:56:00.000","Title":"Running m-files from 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},{"Question":"I'm using Django to power a site where I pull in tweets from twitter timelines for use (for about 50 different people). I want to keep a large dictionary of all the tweets in a cache so I don't have to poll twitter every page-refresh. Right now I have it so when it retrieves tweets (30) from twitter, it saves it in the default cache with the key being that user's ID. However, I want it to save these in the long-term so the list of tweets for a user grows over time.\nMy question is, if I save them using the file-system cache instead, will the files themselves (pickled dictionaries) get deleted after the timeout value, or will it just re-read them into the cache from the file? That way, I could still add to the file over time. Thanks!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":970,"Q_Id":9707816,"Users Score":1,"Answer":"The filesystem cache in Django works like any of the other caches, when the timeout value expires, the cache is \"invalidated\". In the case of files, that means it will be deleted\/overwritten.\nIf you want long-term storage, you need to use a a long-term storage solution (Django's cache framework is specifically not a long-term storage solution). Just save the tweets to your DB or manually to a file. You can still implement caching in addition to this, but you need to handle the long-term storage end.","Q_Score":0,"Tags":"python,django","A_Id":9707962,"CreationDate":"2012-03-14T18:22:00.000","Title":"Do files with filesystem caching in Django delete after timeout?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I am reading through code for optimization routines (Nelder Mead, SQP...). Languages are C++, Python. I observe that often conversion from double to float is performed, or methods are duplicated with double resp. float arguments. Why is it profitable in optimization routines code, and is it significant? In my own code in C++, should I be careful for types double and float and why?\nKind regards.","AnswerCount":3,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":958,"Q_Id":9709513,"Users Score":6,"Answer":"Often the choice between double and float is made more on space demands than speed. Modern processors are capable of operating on double quite fast.\nFloats may be faster than doubles when using SIMD instructions (such as SSE) which can operate on multiple values at a time. Also if the operations are faster than the memory pipeline, the smaller memory requirements of float will speed things overall.","Q_Score":7,"Tags":"c++,python,algorithm,optimization,scipy","A_Id":9709955,"CreationDate":"2012-03-14T20:10:00.000","Title":"Double or float - optimization routines","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am reading through code for optimization routines (Nelder Mead, SQP...). Languages are C++, Python. I observe that often conversion from double to float is performed, or methods are duplicated with double resp. float arguments. Why is it profitable in optimization routines code, and is it significant? In my own code in C++, should I be careful for types double and float and why?\nKind regards.","AnswerCount":3,"Available Count":2,"Score":0.1325487884,"is_accepted":false,"ViewCount":958,"Q_Id":9709513,"Users Score":2,"Answer":"Other times that I've come across the need to consider the choice between double and float types in terms of optimisation include:\n\nNetworking. Sending double precision data across a socket connection\nwill obviously require more time than sending half that amount of\ndata.\nMobile and embedded processors may only be able to handle high\nspeed single precision calculations efficiently on a coprocessor.\n\nAs mentioned in another answer, modern desktop processors can handle double precision Processing quite fast. However, you have to ask yourself if the\n double precision processing is really required. I work with audio,\n and the only time that I can think of where I would need to process\n double precision data would be when using high order filters where\n numerical errors can accumulate. Most of the time this can be avoided\n by paying more careful attention to the algorithm design. There are,\n of course, other scientific or engineering applications where double\n precision data is required in order to correctly represent a huge\n dynamic range.\nEven so, the question of how much effort to spend on considering the data type to use really depends on your target platform. If the platform can crunch through doubles with negligible overhead and you have memory to spare then there is no need to concern yourself. Profile small sections of test code to find out.","Q_Score":7,"Tags":"c++,python,algorithm,optimization,scipy","A_Id":9710279,"CreationDate":"2012-03-14T20:10:00.000","Title":"Double or float - optimization routines","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a problem I've been dealing with lately. My application asks its users to upload videos, to be shared with a private community. They are teaching videos, which are not always optimized for web quality to start with. The problem is, many of the videos are huge, way over the 50 megs I've seen in another question. In one case, a video was over a gig, and the only solution I had was to take the client's video from box.net, upload it to the video server via FTP, then associate it with the client's account by updating the database manually. Obviously, we don't want to deal with videos this way, we need it to all be handled automatically.\nI've considered using either the box.net or dropbox API to facilitate large uploads, but would rather not go that way if I don't have to. We're using PHP for the main logic of the site, though I'm comfortable with many other languages, especially Python, but including Java, C++, or Perl. If I have to dedicate a whole server or server instance to handling the uploads, I will.\nI'd rather do the client-side using native browser JavaScript, instead of Flash or other proprietary tech.\nWhat is the final answer to uploading huge files though the web, by handling the server response in PHP or any other language?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":200,"Q_Id":9712898,"Users Score":2,"Answer":"It is possible to raise the limits in Apache and PHP to handle files of this size. The basic HTTP upload mechanism does not offer progressive information, however, so I would usually consider this acceptable only for LAN-type connections.\nThe normal alternative is to locate a Flash or Javascript uploader widget. These have the bonus that they can display progressive information and will integrate well with a PHP-based website.","Q_Score":4,"Tags":"java,php,javascript,c++,python","A_Id":9712935,"CreationDate":"2012-03-15T01:44:00.000","Title":"Uploading huge files with PHP or any other language?","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},{"Question":"netbean IDE support when downloading PHP bundle version. I also found a download of netbean for python. But How can I let one netbean IDE support both PHP and python?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":400,"Q_Id":9719937,"Users Score":1,"Answer":"For first download netbeans for php support, and form plugin manager install python support.","Q_Score":0,"Tags":"php,python,netbeans,ide","A_Id":9719988,"CreationDate":"2012-03-15T12:43:00.000","Title":"How to make netbean IDE support both python and 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},{"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},{"Question":"I have a completely non-interactive python program that takes some command-line options and input files and produces output files. It can be fairly easily tested by choosing simple cases and writing the input and expected output files by hand, then running the program on the input files and comparing output files to the expected ones. \n1) What's the name for this type of testing?\n2) Is there a python package to do this type of testing? \nIt's not difficult to set up by hand in the most basic form, and I did that already. But then I ran into cases like output files containing the date and other information that can legitimately change between the runs - I considered writing something that would let me specify which sections of the reference files should be allowed to be different and still have the test pass, and realized I might be getting into \"reinventing the wheel\" territory. \n(I rewrote a good part of unittest functionality before I caught myself last time this happened...)","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1131,"Q_Id":9726214,"Users Score":0,"Answer":"Functional testing. Or regression testing, if that is its purpose. Or code coverage, if you structure your data to cover all code paths.","Q_Score":4,"Tags":"python,testing","A_Id":9726303,"CreationDate":"2012-03-15T18:50:00.000","Title":"Testing full program by comparing output file to reference file: what's it called, and is there a package for 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},{"Question":"I have a program that regularly appends small pieces (say 8 bytes) of sensitive data to a number of logfiles. I would like this data to be encrypted. I want the program to start automatically at boot time, so I don't want to type a password at program start. I also don't want it to store a password somewhere, since that would almost defeat the purpose of encryption.\nFor these reasons, it seems to me that public key encryption would be a good choice. The program knows my public key, but my private key is password protected somewhere else.\nSo far, so good. But when I try to use PyCrypto to RSA (or ElGamal)-encrypt a small 5-byte string, the output explodes to 128 bytes. My logfiles are large enough as it is... On the other hand, when I try a symmetric crypto, like Blowfish, the output string is just as large as the input string.\nSo, my question is: Is there a reasonably secure public key encryption algorithm where I can encrypt data 8 bytes at a time and don't have it blow up? (I guess a factor of 2 would be OK). I think what I want is a public key stream cipher.\nIf there is not such a thing, I think I will just give up and use a symmetric crypto and give the password manually on startup.","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":2836,"Q_Id":9737757,"Users Score":1,"Answer":"What you need is to do something like SSL does: exchange a key using public key encryption, then use symmetric encryption. Asymmetric encryption is very inefficient in terms of performance, and should not be used for such stuff.","Q_Score":3,"Tags":"python,encryption,public-key-encryption","A_Id":9738049,"CreationDate":"2012-03-16T13:02:00.000","Title":"Is there a public key stream cipher encryption?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I have a program that regularly appends small pieces (say 8 bytes) of sensitive data to a number of logfiles. I would like this data to be encrypted. I want the program to start automatically at boot time, so I don't want to type a password at program start. I also don't want it to store a password somewhere, since that would almost defeat the purpose of encryption.\nFor these reasons, it seems to me that public key encryption would be a good choice. The program knows my public key, but my private key is password protected somewhere else.\nSo far, so good. But when I try to use PyCrypto to RSA (or ElGamal)-encrypt a small 5-byte string, the output explodes to 128 bytes. My logfiles are large enough as it is... On the other hand, when I try a symmetric crypto, like Blowfish, the output string is just as large as the input string.\nSo, my question is: Is there a reasonably secure public key encryption algorithm where I can encrypt data 8 bytes at a time and don't have it blow up? (I guess a factor of 2 would be OK). I think what I want is a public key stream cipher.\nIf there is not such a thing, I think I will just give up and use a symmetric crypto and give the password manually on startup.","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":2836,"Q_Id":9737757,"Users Score":5,"Answer":"Typically this is solved in the way that the program creates some (real) random numbers which are used as a secret key to a symmetric encryption algorithm.\nIn you program you have to do something like:\n\nGenerate some real random data (maybe use \/dev\/random) as a secret key.\nEncrypt the secret key with the public key algorithm.\nUse the secret key for some other symmetric algorithm.\n\nTo decrypt this, \n\nUse the private key to decrypt the secret key.\nUse the secret key and the symmetric algorithm to decrypt the data.\n\nYou might want to get some random data (e.g. >=256bit) for a 'good' key.","Q_Score":3,"Tags":"python,encryption,public-key-encryption","A_Id":9738026,"CreationDate":"2012-03-16T13:02:00.000","Title":"Is there a public key stream cipher encryption?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I have some big mysql databases with data for calculations and some parts where I need to get data from external websites.\nI used python to do the whole thing until now, but what shall I say: its not a speedster.\nNow I'm thinking about mixing Python with C++ using Boost::Python and Python C API.\nThe question I've got now is: what is the better way to get some speed. \nShall I extend python with some c++ code or shall I embedd python code into a c++ programm?\nI will get fore sure some speed increment using c++ code for the calculating parts and I think that calling the Python interpreter inside of an C-application will not be better, because the python interpreter will run the whole time. And I must wrap things python-libraries like mysqldb or urllib3 to have a nice way to work inside c++.\nSo what whould you suggest is the better way to go: extending or embedding?\n( I love the python language, but I'm also familiar with c++ and respect it for speed )\nUpdate:\nSo I switched some parts from python to c++ and used multi threading (real one) in my c modules and my programm now needs instead of 7 hours 30 minutes :))))","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":2903,"Q_Id":9746586,"Users Score":2,"Answer":"In my opinion, in your case it makes no sense to embed Python in C++, while the reverse could be beneficial.\nIn most of programs, the performance problems are very localized, which means that you should rewrite the problematic code in C++ only where it makes sense, leaving Python for the rest.\nThis gives you the best of both world: the speed of C++ where you need it, the ease of use and flexibility of Python everywhere else. What is also great is that you can do this process step by step, replacing the slow code paths by the by, leaving you always with the whole application in an usable (and testable!) state.\nThe reverse wouldn't make sense: you'd have to rewrite almost all the code, sacrificing the flexibility of the Python structure.\nStill, as always when talking about performance, before acting measure: if your bottleneck is not CPU\/memory bound switching to C++ isn't likely to produce much advantages.","Q_Score":1,"Tags":"c++,python,embedding,extending","A_Id":9746618,"CreationDate":"2012-03-17T01:56:00.000","Title":"Speed - embedding python in c++ or extending python with 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":0,"Web Development":0},{"Question":"I'm using OS X with Sublime text build 2181, and I am having trouble using the Yaml module in a Sublime Text plugin.\nI have installed PyYaml by doing python setup.py install. When I go to the python console, and try import yaml I have no problems. But when I try to save my Sublime Text plugin with the import yaml statement, I keep getting ImportError: No module name yaml\nI'm using the pre-installed version of Python, version 2.7.\nLast line of the install output:\nWriting \/Users\/me\/Developer\/Cellar\/python\/2.7.2\/lib\/python2.7\/site-packages\/PyYAML-3.10-py2.7.egg-info\nAny help would be greatly appreciated.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":5021,"Q_Id":9752808,"Users Score":1,"Answer":"\/Users\/me\/Developer\/Cellar\/python\/2.7.2\/lib\/python2.7 doesn't seem like a pre-installed version of Python on a Mac. Can you try to identify the system-wide Python installation and use the explicit path to the python executable to execute setup.py install? Then try the Sublime Text plug-in.\nThe default Mac OS X Python should be located at \/Library\/Frameworks\/Python.framework\/Versions\/...","Q_Score":0,"Tags":"python,yaml,sublimetext","A_Id":9752868,"CreationDate":"2012-03-17T18:54:00.000","Title":"Python SublimeText plugin - No module named Yaml","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have used twitter search API to collect lots of tweets given a search keyword. Now that I have this collection of tweets, I'd like to find out which tweet has been retweeted most. \nSince search API does not have retweet_count, I have to find some other way to check how many times each tweet has been retweeted. The only clue I have is that I have ID number for each tweet. Is there any way I could use these ID numbers to figure out how many times each tweet has been retweeted??\nI am using twitter module for python.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":1571,"Q_Id":9758636,"Users Score":0,"Answer":"I am currently studying twitter structure and had found out that is a field called tweet_count associated with each tweet as to # of times that particular original tweet has been retweeted","Q_Score":1,"Tags":"python,api,twitter","A_Id":29076949,"CreationDate":"2012-03-18T13:16:00.000","Title":"Getting Retweet Count of a Given Tweet ID Number","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},{"Question":"I have used twitter search API to collect lots of tweets given a search keyword. Now that I have this collection of tweets, I'd like to find out which tweet has been retweeted most. \nSince search API does not have retweet_count, I have to find some other way to check how many times each tweet has been retweeted. The only clue I have is that I have ID number for each tweet. Is there any way I could use these ID numbers to figure out how many times each tweet has been retweeted??\nI am using twitter module for python.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":1571,"Q_Id":9758636,"Users Score":0,"Answer":"i don't think so, since one can either retweet using the retweet command or using a commented retweet. At least the second alternative generates a new tweet id","Q_Score":1,"Tags":"python,api,twitter","A_Id":9758703,"CreationDate":"2012-03-18T13:16:00.000","Title":"Getting Retweet Count of a Given Tweet ID Number","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},{"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},{"Question":"In OpenERP 6.0.1, I've created a server action to send a confirmation email after an invoice is confirmed, and linked it to appropriately to the invoice workflow. now normally when an invoice is confirmed, an email is automatically sent.\nis there a way to set a date for when the email should be sent instead of being sent immediately? like \"send email after one week of confirmation\" ?","AnswerCount":3,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":1470,"Q_Id":9771171,"Users Score":0,"Answer":"i dont know but i think you can also use the sheduled actions in administration->shedular->sheduled actions or else ir.cron is the best option for sheduling outgoing emails","Q_Score":4,"Tags":"python,openerp","A_Id":10222065,"CreationDate":"2012-03-17T17:03:00.000","Title":"openerp schedule server action","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"In OpenERP 6.0.1, I've created a server action to send a confirmation email after an invoice is confirmed, and linked it to appropriately to the invoice workflow. now normally when an invoice is confirmed, an email is automatically sent.\nis there a way to set a date for when the email should be sent instead of being sent immediately? like \"send email after one week of confirmation\" ?","AnswerCount":3,"Available Count":3,"Score":1.2,"is_accepted":true,"ViewCount":1470,"Q_Id":9771171,"Users Score":9,"Answer":"There is a one object ir.cron which will run on specific time period. There you can specify the time when you want to sent the mail. \nThis object will call the function which you given in Method attribute. In this function you have to search for those invoices which are in created state. Then check the date when it created and if its >=7 days then send mail.\nOr\nYou can create ir.cron on specific workflow action of the invoice which will have Next Execution Date as after the 7 or 8 days.","Q_Score":4,"Tags":"python,openerp","A_Id":9784730,"CreationDate":"2012-03-17T17:03:00.000","Title":"openerp schedule server action","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"In OpenERP 6.0.1, I've created a server action to send a confirmation email after an invoice is confirmed, and linked it to appropriately to the invoice workflow. now normally when an invoice is confirmed, an email is automatically sent.\nis there a way to set a date for when the email should be sent instead of being sent immediately? like \"send email after one week of confirmation\" ?","AnswerCount":3,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":1470,"Q_Id":9771171,"Users Score":0,"Answer":"With OpenERO 6.1 New Email Engine has Email Queue so what you just need to do it queue your Email on that email queue and we already have one Scheduled Action which processes this email queue at defined interval, so what you can do it you can change the trigger time of the same action. and you can see the email Engine api for how to queue your emails in email queue.\nRegards","Q_Score":4,"Tags":"python,openerp","A_Id":10615931,"CreationDate":"2012-03-17T17:03:00.000","Title":"openerp schedule server action","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I'm working on a large python project using vim with tagexplorer, pythoncomplete, and ctags. Tag-based code-browsing and code-completion features don't work the way they should unfortunately because ctags doesn't tie instances to types.\nHypothetical scenarios:\n\nAuto Complete: vim won't auto-complete method on() in myCar.ignition().on() because ctags doesn't know that ignition() returns TypeIgnition. \nCode Browsing: vim won't browse into TypeCar when I click on myCar but instead presents me with multiple definition matches, incorrect matches, or no matches because ctags doesn't backtrack and tie instances to types.\n\nThe problem seems to stem from python being a dynamically typed language. Neither scenario would present a challenge otherwise. Is there an effective alternative to tags-based code-browsing and code-completion and an IDE or vim plugin that implements it well? \nNote: Please vote \"re-open\". Solutions to this problem are valuable to the community. The question was originally formulated very vaguely, that's no longer the case.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":273,"Q_Id":9774966,"Users Score":0,"Answer":"Commercial IDE for python like wing (www.wingware.com) and pycharm (www.jetbrains.com\/pycharm) are better to solve majority of code-completion issues. Of course, they are not free though. I myself, when use eclipse with pydev plugin was not able to get satisfactory results.","Q_Score":10,"Tags":"python,ruby,vim,code-completion","A_Id":9775180,"CreationDate":"2012-03-19T17:31:00.000","Title":"How to address python code-browsing and code-completion issues in vim?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I am trying to connect an android device to specific AP without keycodes. I am looking for adb shell commands or monkeyrunner script that can perform the same.\nHope you guys can help me with this.\nPS. After researching for days only way I found is using wpa_cli in adb shell. But couldnt exactly connect because I was not able to find the exact codes.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":799,"Q_Id":9776529,"Users Score":0,"Answer":"wpa_cli should work.Open wpa_cli>>\n add_network\n set_network ssid \"APSSID\"\n set_network key_mgmt NONE \\if ap is confgrd in open none\n save_config\n enable \nthese set of commands should work if WiFI is ON in UI.\nusing Monkeyrunner navigate using keycode is the only option OR \nyou need to make an APK for ur specific operations","Q_Score":1,"Tags":"android,python,android-intent,android-emulator,monkeyrunner","A_Id":10211905,"CreationDate":"2012-03-19T19:24:00.000","Title":"How to connect android device to specific AP with adb shell or monkeyrunner","Data Science and Machine Learning":0,"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},{"Question":"I have to write a daemon program that constantly runs in the background and performs some simple tasks. The logic is not complicated at all, however it has to run for extended periods of time and be stable. \nI think C++ would be a good choice for writing this kind of application, however I'm also considering Python since it's easier to write and test something quickly in it. \nThe problem that I have with Python is that I'm not sure how its runtime environment is going to behave over extended periods of time. Can it eat up more and more memory because of some GC quirks? Can it crash unexpectedly? I've never written daemons in Python before, so if anyone here did, please share your experience. Thanks!","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":2480,"Q_Id":9779200,"Users Score":1,"Answer":"I've written many things in C\/C++ and Perl that are initiated when a LINUX box O.S. boots, launching them using the rc.d.\nAlso I've written a couple of java and python scripts that are started the same way I've mentioned above, but I needed a little shell-script (.sh file) to launch them and I used rc.5.\nLet me tell you that your concerns about their runtime environments are completely valid, you will have to be careful about wich runlevel you'll use... (only from rc.2 to rc.5, because rc.1 and rc.6 are for the System).\nIf the runlevel is too low, the python runtime might not be up at the time you are launching your program and it could flop. e.g.: In a LAMP Server MySQL and Apache are started in rc.3 where the Network is already available.\nI think your best shot is to make your script in python and launch it using a .sh file from rc.5.\nGood luck!","Q_Score":18,"Tags":"python,daemon","A_Id":9779553,"CreationDate":"2012-03-19T23:00:00.000","Title":"Is writing a daemon in Python a good idea?","Data Science and Machine Learning":0,"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},{"Question":"I have to write a daemon program that constantly runs in the background and performs some simple tasks. The logic is not complicated at all, however it has to run for extended periods of time and be stable. \nI think C++ would be a good choice for writing this kind of application, however I'm also considering Python since it's easier to write and test something quickly in it. \nThe problem that I have with Python is that I'm not sure how its runtime environment is going to behave over extended periods of time. Can it eat up more and more memory because of some GC quirks? Can it crash unexpectedly? I've never written daemons in Python before, so if anyone here did, please share your experience. Thanks!","AnswerCount":3,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":2480,"Q_Id":9779200,"Users Score":14,"Answer":"I've written a number of daemons in Python for my last company. The short answer is, it works just fine. As long as the code itself doesn't have some huge memory bomb, I've never seen any gradual degradation or memory hogging. Be mindful of anything in the global or class scopes, because they'll live on, so use del more liberally than you might normally. Otherwise, like I said, no issues I can personally report.\nAnd in case you're wondering, they ran for months and months (let's say 6 months usually) between routine reboots with zero problems.","Q_Score":18,"Tags":"python,daemon","A_Id":9779293,"CreationDate":"2012-03-19T23:00:00.000","Title":"Is writing a daemon in Python a good idea?","Data Science and Machine Learning":0,"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},{"Question":"Should Python library modules start with #!\/usr\/bin\/env python?\nLooking at first lines of *.py in \/usr\/share\/pyshared (where Python libs are stored in Debian) reveals that there are both files that start with the hashbang line and those that do not.\nIs there a reason to include or omit this line?","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1029,"Q_Id":9783482,"Users Score":0,"Answer":"if you want your script to be an executable, you have to include this line","Q_Score":8,"Tags":"python,coding-style,shebang","A_Id":9783492,"CreationDate":"2012-03-20T08:27:00.000","Title":"Should Python library modules start with #!\/usr\/bin\/env 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},{"Question":"I'm connecting a several identical USB-MIDI devices and talking to them using Python and pyportmidi. I have noticed that when I run my code on Linux, occasionally the MIDI ports of the devices are enumerated in a different order, so I send messages to the wrong devices. As the devices do not have unique identifiers, I am told that I should identify them by which USB port they are connected to.\nIs there any way to retrieve this information? My app will run on Linux, but Mac OS support is useful for development.\nIt's annoying because they usually enumerate in a sensible order - the first device in the hub is the first device in portmidi, but sometimes they don't - usually the first 2 devices are switched. I have to physically move the devices without unplugging to fix them.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":455,"Q_Id":9790715,"Users Score":0,"Answer":"lsusb should do the trick. All devices and their respective hubs are listed there.","Q_Score":3,"Tags":"python,usb,midi,pyportmidi","A_Id":9790821,"CreationDate":"2012-03-20T16:19:00.000","Title":"Is it possible to find out which USB port a MIDI device is connected to in portmidi \/ pyportmidi","Data Science and Machine Learning":0,"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},{"Question":"I've been able to deploy a test application by using pyramid with pserve and running pceleryd (I just send an email without blocking while it is sent).\nBut there's one point that I don't understand: I want to run my application with mod_wsgi, and I don't understand if I can can do it without having to run pceleryd from a shell, but if I can do something in the virtualhost configuration.\nIs it possible? How?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":530,"Q_Id":9808628,"Users Score":1,"Answer":"There are technically ways you could use Apache\/mod_wsgi to manage a process distinct from that handling web requests, but the pain point is that Celery will want to fork off further worker processes. Forking further processes from a process managed by Apache can cause problems at times and so is not recommended.\nYou are thus better of starting up Celery process separately. One option is to use supervisord to start it up and manage it.","Q_Score":0,"Tags":"python,celery,pyramid,celeryd","A_Id":9813506,"CreationDate":"2012-03-21T16:17:00.000","Title":"using celery with pyramid and 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},{"Question":"First I want to clearify that I mean by reverse engineering something like \"decompiling\" and getting back the original source code or something similiar.\nYesterday I read a question about someone who wanted to protect his python code from \"getting stolen\" in other words: he didn't like that someone can read his python code.\nThe interesting thing I read was that someone said that the only reliable way to \"protect\" his code from getting reverse engineered is by using a Webservice.\nSo I could actually only write some GUIs in Python, PHP, whatever and do the \"very secret code\" I want to protect via a Webservice. (Basically sending variables to the host and getting results back).\nIs it really impossible to reverse engineer a Webservice (via code and without hacking into the Server)? Will this be the future of modern commercial applications? The cloud-hype is already here. So I wouldn't wonder.\nI'm very sorry if this topic was already discussed, but I couldn't find any resources about this.\nEDIT: The whole idea reminds me of AJAX. The code is executed on the server and the content is sent to the client and \"prettified\". The client himself doesnt see what php-code or other technology is behind.","AnswerCount":3,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":276,"Q_Id":9811655,"Users Score":0,"Answer":"Yes, \nAll they could do is treat your web service as a black box, query the WSDL for all the parameters it accepts and the data that it returns. \nThey could then submit different variables and see what different results are. The \"code\" could not be seen or stolen (with proper security) but the inputs and outputs could be duplicated.\nIf you want to secure your \"very secret code\" a web service is a great way to protect the actual code.\n-sb","Q_Score":1,"Tags":"python,web-services,open-source,reverse","A_Id":9811793,"CreationDate":"2012-03-21T19:38:00.000","Title":"Reverse Engineer a program working as a webservice, the future?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"First I want to clearify that I mean by reverse engineering something like \"decompiling\" and getting back the original source code or something similiar.\nYesterday I read a question about someone who wanted to protect his python code from \"getting stolen\" in other words: he didn't like that someone can read his python code.\nThe interesting thing I read was that someone said that the only reliable way to \"protect\" his code from getting reverse engineered is by using a Webservice.\nSo I could actually only write some GUIs in Python, PHP, whatever and do the \"very secret code\" I want to protect via a Webservice. (Basically sending variables to the host and getting results back).\nIs it really impossible to reverse engineer a Webservice (via code and without hacking into the Server)? Will this be the future of modern commercial applications? The cloud-hype is already here. So I wouldn't wonder.\nI'm very sorry if this topic was already discussed, but I couldn't find any resources about this.\nEDIT: The whole idea reminds me of AJAX. The code is executed on the server and the content is sent to the client and \"prettified\". The client himself doesnt see what php-code or other technology is behind.","AnswerCount":3,"Available Count":3,"Score":1.2,"is_accepted":true,"ViewCount":276,"Q_Id":9811655,"Users Score":1,"Answer":"Wow, this is awesome! I've never thought it this way, but you could create a program that crawls an api, and returns as an output a django\/tastypie software that mimics everything the api does.\nBy calling the service, and reading what it says, you can parse it, and begin to see the relationships between objects inside the api. Having this, you can create the models, and tastypie takes it from this point.\nThe awesome thing about this, is that normal people (or at least not backend developers) could create an api just by describing what they want to be as an output. I've seen many android\/iphone developers creating a bunch of static xml or json, so they can call their service, and start the frontend development. Well what if that was enough? Take some xml\/json files as input, get a backend as an output.","Q_Score":1,"Tags":"python,web-services,open-source,reverse","A_Id":9812028,"CreationDate":"2012-03-21T19:38:00.000","Title":"Reverse Engineer a program working as a webservice, the future?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"First I want to clearify that I mean by reverse engineering something like \"decompiling\" and getting back the original source code or something similiar.\nYesterday I read a question about someone who wanted to protect his python code from \"getting stolen\" in other words: he didn't like that someone can read his python code.\nThe interesting thing I read was that someone said that the only reliable way to \"protect\" his code from getting reverse engineered is by using a Webservice.\nSo I could actually only write some GUIs in Python, PHP, whatever and do the \"very secret code\" I want to protect via a Webservice. (Basically sending variables to the host and getting results back).\nIs it really impossible to reverse engineer a Webservice (via code and without hacking into the Server)? Will this be the future of modern commercial applications? The cloud-hype is already here. So I wouldn't wonder.\nI'm very sorry if this topic was already discussed, but I couldn't find any resources about this.\nEDIT: The whole idea reminds me of AJAX. The code is executed on the server and the content is sent to the client and \"prettified\". The client himself doesnt see what php-code or other technology is behind.","AnswerCount":3,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":276,"Q_Id":9811655,"Users Score":0,"Answer":"It depends on what you mean by reverse engineering: by repeatedly sending input and analyzing the output the behaviour of your code can still be seen. I wouldn't have your code but I can still see what the system does. This means I could build a similar system that does the same thing, given the same input.\nIt would be hard to catch exceptional cases (such as output that is different on one day of the year only) but the common behaviour can certainly be copied. It is similar to analyzing the protocol of an instant messaging client: you may not have the original code but you can still build a copy.","Q_Score":1,"Tags":"python,web-services,open-source,reverse","A_Id":9812274,"CreationDate":"2012-03-21T19:38:00.000","Title":"Reverse Engineer a program working as a webservice, the future?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I'm running Python scripts as a CGI under Apache 2.2. These scripts rely on environment variables set in my .bashrc to run properly. The .bashrc is never loaded, and my scripts fail.\nI don't want to duplicate my bashrc by using a bunch of SETENV commands; the configuration files will easily get out of sync and cause hard-to-find bugs.\nI'm running apache as my user, not as root. I'm starting\/stopping it manually, so the \/etc\/init.d script shouldn't matter at all (I think).\nGiven these constraints, what can I do to have my .bashrc loaded when my CGI is called?\nEdit: I use \/usr\/sbin\/apache2ctl to do the restarting.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2452,"Q_Id":9815655,"Users Score":0,"Answer":"What? Surely you don't mean that your scripts rely on configurations in some account's personal home directory.\nApache config files can export environment variables to CGI scripts, etc.\nMaybe your program is too dependent on too many environment variables. How about supporting a configuration file: \/etc\/mypythonprogram.rc. There can be a single environment variable telling the program to use an alternative config file, for flexibility.","Q_Score":2,"Tags":"python,bash,cgi,apache","A_Id":9815735,"CreationDate":"2012-03-22T02:33:00.000","Title":"Apache httpd doesn't load .bashrc","Data Science and Machine Learning":0,"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},{"Question":"One difference is that \".\/script.py\" only works if script.py is executable (as in file permissions), but \"python script.py\" works regardless. However, I strongly suspect there are more differences, and I want to know what they are.\nI have a Django website, and \"python manage.py syncdb\" works just fine, but \".\/manage.py syncdb\" creates a broken database for some reason that remains a mystery to me. Maybe it has to do with the fact that syncdb prompts for a superuser name and password from the command line, and maybe using \".\/manage.py syncdb\" changes the way it interacts with the command line, thus mangling the password. Maybe? I am just baffled by this bug. \"python manage.py syncdb\" totally fixes it, so this is just curiosity.\nThanks.\nEdit: Right, right, I forgot about the necessity of the shebang line #!\/usr\/bin\/python. But I just checked, \"python manage.py syncdb\" and \".\/manage.py syncdb\" are using the same Python interpreter (2.7.2, the only one installed, on Linux Mint 12). Yet the former works and the latter does not.\nCould the environment variables seen by the Python code be different? My code does require $LD_LOADER_PATH and $PYTHON_PATH to be set special for each shell.","AnswerCount":4,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":2513,"Q_Id":9826313,"Users Score":0,"Answer":".\/script.py runs the interpreter defined in the #! at the beginning of the file. For example, the first line might be #! \/usr\/bin\/env python or #! \/usr\/bin\/python or something else like that. If you look at what interpreter is invoked, you might be able to fix that problem.","Q_Score":6,"Tags":"python,django,posix,sh","A_Id":9826394,"CreationDate":"2012-03-22T16:16:00.000","Title":"When invoking a Python script, what is the difference between \".\/script.py\" and \"python script.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":1,"Web Development":0},{"Question":"One difference is that \".\/script.py\" only works if script.py is executable (as in file permissions), but \"python script.py\" works regardless. However, I strongly suspect there are more differences, and I want to know what they are.\nI have a Django website, and \"python manage.py syncdb\" works just fine, but \".\/manage.py syncdb\" creates a broken database for some reason that remains a mystery to me. Maybe it has to do with the fact that syncdb prompts for a superuser name and password from the command line, and maybe using \".\/manage.py syncdb\" changes the way it interacts with the command line, thus mangling the password. Maybe? I am just baffled by this bug. \"python manage.py syncdb\" totally fixes it, so this is just curiosity.\nThanks.\nEdit: Right, right, I forgot about the necessity of the shebang line #!\/usr\/bin\/python. But I just checked, \"python manage.py syncdb\" and \".\/manage.py syncdb\" are using the same Python interpreter (2.7.2, the only one installed, on Linux Mint 12). Yet the former works and the latter does not.\nCould the environment variables seen by the Python code be different? My code does require $LD_LOADER_PATH and $PYTHON_PATH to be set special for each shell.","AnswerCount":4,"Available Count":2,"Score":0.049958375,"is_accepted":false,"ViewCount":2513,"Q_Id":9826313,"Users Score":1,"Answer":"In Linux using terminal you can execute any file -if the user has execute permission- by typing \n.\/fileName. When the OS sees a valid header like #! \/usr\/bin\/python (or for perl #! \/usr\/bin\/python), It will call the python or perl (appropriate) interpreter to execute the program. You can use the command python script.py directly because, python is a executable program located at \/usr\/bin (or somewhere else) which is in a environmental variable $PATH,\nthat corresponding to directory of executables.","Q_Score":6,"Tags":"python,django,posix,sh","A_Id":9826923,"CreationDate":"2012-03-22T16:16:00.000","Title":"When invoking a Python script, what is the difference between \".\/script.py\" and \"python script.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":1,"Web Development":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},{"Question":"Are there any best practices for the use of higher-level Python constructs such as threading.Condition, and collections.deque from modules written in C? In particular:\n\nAvoiding dict lookup costs, for methods and members\nAccessing parts of these constructs that are in C directly where possible\nWhen to reimplement desired functionality locally and not import from elsewhere in the standard library","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":120,"Q_Id":9834761,"Users Score":2,"Answer":"String lookups on a dict are very cheap in Python, but if desired you can cache them in a struct.\nThere usually is no provision for doing so, since these libraries are meant to be accessed via Python and not C. It is still possible to generate your own headers that match the definitions in the C modules, but they would need to be maintained per Python version.\nThere's no good answer for this one. It comes down to \"fast\" vs. \"fast enough\".","Q_Score":1,"Tags":"python,c,cpython,python-c-api,python-c-extension","A_Id":9834834,"CreationDate":"2012-03-23T05:58:00.000","Title":"Using higher-level Python constructs from 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},{"Question":"Background\nI would like my Python script to pause before exiting using something similar to:\nraw_input(\"Press enter to close.\")\nbut only if it is NOT run via command line. Command line programs shouldn't behave this way.\nQuestion\nIs there a way to determine if my Python script was invoked from the command line:\n$ python myscript.py\nverses double-clicking myscript.py to open it with the default interpreter in the OS?","AnswerCount":13,"Available Count":1,"Score":0.0153834017,"is_accepted":false,"ViewCount":35970,"Q_Id":9839240,"Users Score":1,"Answer":"This is typically done manually\/, I don't think there is an automatic way to do it that works for every case. \nYou should add a --pause argument to your script that does the prompt for a key at the end.\nWhen the script is invoked from a command line by hand, then the user can add --pause if desired, but by default there won't be any wait.\nWhen the script is launched from an icon, the arguments in the icon should include the --pause, so that there is a wait. Unfortunately you will need to either document the use of this option so that the user knows that it needs to be added when creating an icon, or else, provide an icon creation function in your script that works for your target OS.","Q_Score":36,"Tags":"python,command-line","A_Id":9839781,"CreationDate":"2012-03-23T12:32:00.000","Title":"How to determine if Python script was run via 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},{"Question":"Suppose the following imagined scenario:\n\nI have a site that is used for military recruits.\nMilitary recruits and only military recruits may sign up on this site. - The easiest way to authenticate would be to get a list of pre-authorized email addresses. However, the military obviously will not release their email address list.\nHow would I authenticate these individuals to sign up?\n\nMy initial thought would be that I could get a sha3 hash of the email addresses. Then, when people register, I would check the sha3 of the email address they entered against the database. Basically, this would be a way to get a boolean back of whether the email is in the system without knowing the email address. \nDoes this sound like a realistic approach, that would ensure the anonymity of the email address? Any better ideas to accomplish this?","AnswerCount":3,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":134,"Q_Id":9844679,"Users Score":0,"Answer":"This is a workable zero-knowledge proof. However, if you have the co-operation of the military, one would think you could do better... You could get a (otherwise non-sensical) serial number and initial password from the military, and then have the recruits sign in using that.\nThis will solve the problem of people not having a 1:1 relationship to an e-mail address, and be much harder to guess, too, since you need to guess the password as well as the serial number.","Q_Score":2,"Tags":"python,security,encryption","A_Id":9852214,"CreationDate":"2012-03-23T18:33:00.000","Title":"Authenticating email address without being able to view email 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},{"Question":"Suppose the following imagined scenario:\n\nI have a site that is used for military recruits.\nMilitary recruits and only military recruits may sign up on this site. - The easiest way to authenticate would be to get a list of pre-authorized email addresses. However, the military obviously will not release their email address list.\nHow would I authenticate these individuals to sign up?\n\nMy initial thought would be that I could get a sha3 hash of the email addresses. Then, when people register, I would check the sha3 of the email address they entered against the database. Basically, this would be a way to get a boolean back of whether the email is in the system without knowing the email address. \nDoes this sound like a realistic approach, that would ensure the anonymity of the email address? Any better ideas to accomplish this?","AnswerCount":3,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":134,"Q_Id":9844679,"Users Score":0,"Answer":"I think it is insecure to have just a hash of the email address as hashing algorithm is not reversible but it is theoretically possible to have incorrect email that has the same hash as correct one. It is true for md5 hash algorithm and theoretically true for any other.\nI suggest to use some kind of salt (additional hash function payload) or personal registration keys and of cause do not use md5 ever.\nWith the salt that you know and \"military\" knows you can receive just hashes from \"military\" and be kindly sure that encryption is fair enough to identify recruits by email. But this technique is vulnerable to random hash coincident still.\nProbably, the best way to be sure that recruit's email is truly valid is to give recruits unique registration codes on \"military\" side, than they need to give you pairs of registration code and the hash of the code and the corresponding email. Than every recruit will need to provide that registration code and you will be able to recalculate the recruit's personal hash from his email and registration code.\nThe benefit of the second way is that even you will not be able to easy brute force the hashes into emails if the \"military\" will give you not just the pairs of code\/hash but the list of the codes for every hash, only one of which will be correct.\nUpdate: The paranoia culmination way. You receive just a number of hashes from \"military\" two times more than the recruits number is. Every recruit receives unique registration code. Than you will need to calculate registration code hash first and check if you have it. Than you will need to combine this hash with the email and check if you have the second hash. This way you will not be able to reverse emails yourself ever.","Q_Score":2,"Tags":"python,security,encryption","A_Id":9852047,"CreationDate":"2012-03-23T18:33:00.000","Title":"Authenticating email address without being able to view email 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},{"Question":"Suppose the following imagined scenario:\n\nI have a site that is used for military recruits.\nMilitary recruits and only military recruits may sign up on this site. - The easiest way to authenticate would be to get a list of pre-authorized email addresses. However, the military obviously will not release their email address list.\nHow would I authenticate these individuals to sign up?\n\nMy initial thought would be that I could get a sha3 hash of the email addresses. Then, when people register, I would check the sha3 of the email address they entered against the database. Basically, this would be a way to get a boolean back of whether the email is in the system without knowing the email address. \nDoes this sound like a realistic approach, that would ensure the anonymity of the email address? Any better ideas to accomplish this?","AnswerCount":3,"Available Count":3,"Score":1.2,"is_accepted":true,"ViewCount":134,"Q_Id":9844679,"Users Score":1,"Answer":"Sounds good, as long as the \"military\" is convinced, correctly or not, that the hashing is truly irreversible, and is willing to trust you with the hashed list of addresses. (What is sha5, by the way? Afaik sha3 is the latest generation). \nIf they will not entrust you with even the cryptographically hashed list, the alternative would be to delegate the authentication: You forward the email address to the military through a secure connection, and they tell you whether it's ok or not. It would be slower but you only need to do it once, at sign-up time.","Q_Score":2,"Tags":"python,security,encryption","A_Id":9851795,"CreationDate":"2012-03-23T18:33:00.000","Title":"Authenticating email address without being able to view email 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},{"Question":"I downloaded the colorama module for python and I double clicked the setup.py. The screen flashed, but when I try to import the module, it always says 'No Module named colorama'\nI copied and pasted the folder under 'C:\\Python26\\Lib\\site-packages' and tried to run the setup from there. Same deal. Am I doing something wrong?\nThanks,\nMike","AnswerCount":11,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":125711,"Q_Id":9846683,"Users Score":0,"Answer":"Re-installing colorama might not work right away. If there is a colorama .egg in site-packages, you need to remove that file first and then pip install colorama.","Q_Score":17,"Tags":"python,colorama","A_Id":51990615,"CreationDate":"2012-03-23T21:27:00.000","Title":"How to install Colorama 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},{"Question":"I downloaded the colorama module for python and I double clicked the setup.py. The screen flashed, but when I try to import the module, it always says 'No Module named colorama'\nI copied and pasted the folder under 'C:\\Python26\\Lib\\site-packages' and tried to run the setup from there. Same deal. Am I doing something wrong?\nThanks,\nMike","AnswerCount":11,"Available Count":3,"Score":0.0544914242,"is_accepted":false,"ViewCount":125711,"Q_Id":9846683,"Users Score":3,"Answer":"Run the following command in Google shell:\nsudo pip3 install colorama","Q_Score":17,"Tags":"python,colorama","A_Id":68844752,"CreationDate":"2012-03-23T21:27:00.000","Title":"How to install Colorama 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},{"Question":"I downloaded the colorama module for python and I double clicked the setup.py. The screen flashed, but when I try to import the module, it always says 'No Module named colorama'\nI copied and pasted the folder under 'C:\\Python26\\Lib\\site-packages' and tried to run the setup from there. Same deal. Am I doing something wrong?\nThanks,\nMike","AnswerCount":11,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":125711,"Q_Id":9846683,"Users Score":0,"Answer":"I have also experienced this problem. Following the instructions to install sudo pip install colorama I receive the message: \nRequirement already satisfied: colorama in \/usr\/lib\/python2.7\/dist-packages. \nThe problem for me is that I am using python3 in my header code #!usr\/bin\/env python3.\nChanging this to#!usr\/bin\/env python works - sorry, I don't know how to get it to work with python 3!","Q_Score":17,"Tags":"python,colorama","A_Id":54669213,"CreationDate":"2012-03-23T21:27:00.000","Title":"How to install Colorama 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},{"Question":"I have an application that emails individuals on different occurrences. The entire application is on a single server. I am currently sending emails through SendGrid. At what volume of emails would it make sense to use a system like RabbitMQ to send out emails? \nMaximum rate = 1 email per minute? 1 email per second? 10 emails per second? How would I evaluate when the switch makes sense?","AnswerCount":3,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":1146,"Q_Id":9847451,"Users Score":5,"Answer":"Why are you considering RabbitMQ ? it is better to consider using a MTA\/Mail relay like Postfix where you submit your emails and it handles them for you in a queue.\nYou can configure it to dispatch the queue on different mail relays, set the email throughput, how much retry shall be made on a failed sending ...","Q_Score":2,"Tags":"python,email,smtp,rabbitmq,amqp","A_Id":9847881,"CreationDate":"2012-03-23T22:47:00.000","Title":"At what email volume to use AMQP","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I have an application that emails individuals on different occurrences. The entire application is on a single server. I am currently sending emails through SendGrid. At what volume of emails would it make sense to use a system like RabbitMQ to send out emails? \nMaximum rate = 1 email per minute? 1 email per second? 10 emails per second? How would I evaluate when the switch makes sense?","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":1146,"Q_Id":9847451,"Users Score":1,"Answer":"Having Rabbitmq is good option when your are considering scaling in future, I mean in terms of new smpt send mail workers or new email server, as of now if you have single server and not going to more in it then rabbitmq will load your server even more and will be issue to maintain, but if your going to have more then 100 mails per second then it makes sense to have rabbitmq its goal to make your calling function free as soon as possible by offloading all the load from function to rabbitmq queue and then save it till worker or consumer doesn't pick them, this will help in fail cases too as your having your mails saved in rabbitmq and if the consumer fails you still have your mails, when it starts (smtp send worker) then rabbitmq will provide the rest of the mails to it. I hope this makes sense, please feel free to ask other stuff about it, I used rabbitmq for sending mail but in my case we are having one server running only rabbitmq only so there it makes sense.","Q_Score":2,"Tags":"python,email,smtp,rabbitmq,amqp","A_Id":27737869,"CreationDate":"2012-03-23T22:47:00.000","Title":"At what email volume to use AMQP","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I am confused about using php or python for implementing server program.\nI seems that there are not only syntax differences.\nFor example, the php program is short-lived (only exist when request comes and die when response is generated) and it can only store things in DB rather than memory.\nBut for python (using TwistedWeb), the python program is long-lived. It can hold things in memory, doing something else when there are no request.\nAm I wrong? I am confused and please help me to clarify it.","AnswerCount":3,"Available Count":1,"Score":0.1325487884,"is_accepted":false,"ViewCount":763,"Q_Id":9857067,"Users Score":2,"Answer":"Both PHP and Python can be used for long running programs. \nPHP was designed as a embeddable programing language for web servers. In the environment it is commonly set up in the web server (generally Apache with mod_php) has PHP running in it and the entire PHP environment is set up and torn down for each request. \nPython was designed as a general purpose language. When used for developing web applications it is generally run separately from the web server process and it has requests routed to it by the web server (Apache, ngix, etc.)\nThere is no reason that this has to be this way - you can set up a Python program to run over CGI (where it will be re-started for each request) and you can set up PHP to run as a FastCGI program and it will be run separately from the web server and stay up between requests.\nHowever, if you want to persist important information (for example statistics about the total number of requests received or the total amount of work performed) between requests you will be far better off persisting them to the filesystem (via files, a database, etc) or to another in-memory process like Redis or Memcached. Even when the application process is run separate of the web server it often spawns several child processes and these processes are started and stopped after serving a certain number of requests (or after a certain amount of uptime) in order to release system resources. Important information needs to be persisted elsewhere (and backed-up regularly).","Q_Score":0,"Tags":"php,python","A_Id":9857192,"CreationDate":"2012-03-25T00:58:00.000","Title":"php vs python for server 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":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm thinking about trying to convert a Scons (Python) script to another build system but was wondering if there was a Python-analysis library available in order to 'interrogate' the Scons\/Python script? \nWhat I'm [possibly] after is something along the lines of Java's reflection mechanism, in fact, if this is possible via say Jython\/Java, coding in Java, that would be best for me as a Java dev (I have no real background in Python).\nWhat I need to be able to do is extract the variable assigment values etc. for certain named class types and methods within the script, so that I can transfer them to my new output format.\nAny ideas?\nThanks\nRich","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":95,"Q_Id":9860029,"Users Score":0,"Answer":"If your current scons files are very regular and consistent it may be easier to do something \"dumb\" with standard text-editing tools. If you want to get smarter, you should notice that scons is itself a Python program, and it loads your build files which are also Python. So you could make your own \"special\" version of scons which implements the functions your build scripts use (to add programs, libraries, whatever). Then you could run your build scripts in your \"fake\" scons program and have your functions dump their arguments in a format suitable for your new build system.\nIn other words, don't think of the problem in terms of analyzing the Python grammar completely--realize that you can actually run your build scripts as Python code and hijack their behavior.\nEasier said than done, I'm sure.","Q_Score":0,"Tags":"java,python,reflection,jython,scons","A_Id":9865039,"CreationDate":"2012-03-25T12:14:00.000","Title":"\"Analyse\" the Python language to dissect a Scons build 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},{"Question":"I'm thinking about trying to convert a Scons (Python) script to another build system but was wondering if there was a Python-analysis library available in order to 'interrogate' the Scons\/Python script? \nWhat I'm [possibly] after is something along the lines of Java's reflection mechanism, in fact, if this is possible via say Jython\/Java, coding in Java, that would be best for me as a Java dev (I have no real background in Python).\nWhat I need to be able to do is extract the variable assigment values etc. for certain named class types and methods within the script, so that I can transfer them to my new output format.\nAny ideas?\nThanks\nRich","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":95,"Q_Id":9860029,"Users Score":0,"Answer":"I doubt it's the best tool for migrating scons, but python's inspect module offers some reflection facilities. For the rest, you can simply poke inside live classes and objects: Python has some data hiding but does not enforce access restrictions.","Q_Score":0,"Tags":"java,python,reflection,jython,scons","A_Id":9874850,"CreationDate":"2012-03-25T12:14:00.000","Title":"\"Analyse\" the Python language to dissect a Scons build 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},{"Question":"I am planning to build, for lack of a better term, a multi user Customer Relationship Manager (CRM) and I want to create a unique identifier that is easy to transmit in email, via text, and verbally to other team members.\nFor Example:\nI upload my list of 100 customers and John Smith and his phone number are included in that list. Upon upload, I want to generate a hidden fingerprint \/ unique identifier for John Smith in the database, and then propagate a 12 digit number that can be shared publicly.\nIn my mind like this - john smith + ph: 5557898095 = fingerprint: 7e013d7962800374e6e67dd502f2d7c0 displays to end user id number: 103457843983\nMy question is - what method or process should I use to take the name and phone number, generate a hidden key, and then translate to a displayable key that is linked to the hidden one?\nI hope this clear. I mainly want to use the right logic process.","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":739,"Q_Id":9860276,"Users Score":0,"Answer":"Assuming your real ID is the auto_incremented field in your customer table, then just have a second table that maps your public ID to the real ID.\nAssuming you're using some sort of hashing algorithm to generate your public ID, it'd be a simple process to do a lookup on that table when you create a new user to detect a clash with an existing user, then regenerate a new ID until there's no clash (e.g. include system time as part of your hash input, then just keep regenerating until you find a unique ID)","Q_Score":1,"Tags":"php,python,mysql","A_Id":9860314,"CreationDate":"2012-03-25T12:56:00.000","Title":"Unique Key Generation Logic","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"My boss has given me a list of around 3500 companies and wants the generic contact email for each of them by tomorrow. I know this sounds retarded, and it is, but our client is demanding it. The approach I'd like to take is this:\n\nCarry out a google search for company name\nIdentify company website and redirect to it\nStep through website links to find a contact us \/ about us page\nLocate and return the first email address on the page\n\nI've done a bit of python here and there, but nothing web based or with regex... though I get the basic ideas I don't know if I would be able to execute this in the next 12 hours.\nIf anyone has any help on how I could script this with python or ruby I would be very appreciative......","AnswerCount":2,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":1967,"Q_Id":9866104,"Users Score":4,"Answer":"I would look to a more non-technical solution. You could split out the 3500 names and post them to Amazon Mechanical Turk as a HIT, paying 1 cent for each. Then instead writing code to scrape Google, you write code to create the hits and let real people do the \"scraping\" of the company websites.\nDon't know if that will work for you but that's probably what I'd do.\nHope that helps!\nBrandon","Q_Score":0,"Tags":"python,ruby,regex,email","A_Id":9866851,"CreationDate":"2012-03-26T03:02:00.000","Title":"Extract company contact details from google","Data Science and Machine Learning":0,"Database and SQL":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},{"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},{"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},{"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},{"Question":"For some reason my 64 bit EPD can't import wx.\nI also tried to install the wxPython2.8-osx-unicode-py2.7 version from the wx site.\nIt installed successfully, but is no where to be found on my harddrive.\nI checked the sitepackes for 2.7 and the EPD 7.2.2. where all the modules usually should be installed. \nI am confused. \nThis raises a similar question. \nHow can I install modules that are not part of EPD ?\nI also didn't have luck to install other modules.\nAnd every time I try to import older modules it doesn't work as well.\nOften I get error message that architectures in universal rapper is wrong.\nFor example pygame doesn\u2019t have a 64 bit version that works with 2.7, so I installed the 32 bit version.\nIf I try to do the trick arch -i386 \/Path to python , I get \"Bad CPU type in executable\".\nI am running a 64bit version of Python on a 64 bit Mac OS.\nI wonder if the Enthougt 7.2 is equivalent with the 2.7 Python.\nAnd if not, what I assume, what the differences are.\nAny hints who can solve this, would be awesome.\nThanks for your patients.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":682,"Q_Id":9896687,"Users Score":1,"Answer":"I had the same problem. The only way around it that has worked for me is to uninstall your EPD version ($ sudo remove-EPD-7.2-1, or whichever version you have) and reinstall the 32 bit version. Wx comes as part of the EPD package, so once you have downloaded the 32 bit version there is no need to download and install wx.","Q_Score":1,"Tags":"python,64-bit,pygame,wxwidgets,enthought","A_Id":11151178,"CreationDate":"2012-03-27T19:53:00.000","Title":"enthought python distribution wx","Data Science and Machine Learning":0,"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},{"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},{"Question":"I'm obtaining a PID, using python, of a CGI script, however, the PID is not valid i.e. can't Taskkill it from CL. I get:\n\"Process: no process found with pid xxxx\" where xxxx is the pid\nI thought maybe I have to kill a parent python shell instance, but os.ppid doesn't work in windows.\nSo then I installed psutil python module and can now get parent PID, but it just shows the parent as the actual WebServer (Abyss), which I don't think I want to kill, since it is the http process that I notice runs constantly and not just a CGI interpreter instance.\nUsing psutil I CAN get the process status of the actual script, using the pid returned by os.getpid(), and see that it is running. So the pid works for purposes of process information retrieval using psutil. But this gets me no further to obtaining the actual PID I need to kill the script, using EITHER Taskkill on the CL or via kill() from psutil!\nWhat exactly is a cgi shell script from a process perspective, and if it is not a process, why is os.getpid() returning a pid?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":222,"Q_Id":9912121,"Users Score":0,"Answer":"Why are you assured that your CGI script are still working when you try to kill it? Web server starts one instance of CGI script for one request and when script finishes it... just finishes.","Q_Score":0,"Tags":"python,windows,process,kill","A_Id":9912713,"CreationDate":"2012-03-28T16:47:00.000","Title":"Determing PID of CGI Script on 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},{"Question":"I want some help to generate a report in PDF\/Doc(MS Word) format . I\u2019m not able to find any module to generated report in doc, except \u201cdocx\u201d which I\u2019m not able to comprehend. Actually I\u2019m actual task is to generate the report in Doc only, but as I\u2019m not able to find a module to work on it, I opt for PDF. I\u2019m using \u201cReport Lab\u201d module, but I\u2019m finding some limitation in that. It write anything based on co-ordinate system. The problem I\u2019m facing with that the report is usually a string, whose length is not limited, so sometime it goes beyond the canvas( Pdf Page). Also there is not functionality I guess to do format font with Bold, Italics and Underline. \nIf you know any module to generate report in PDF or Doc, please let me know. My requirement is:\n\nAble to add an image at an header.\nChange fonts and other properties, like Bold, Italics, and Underline\nAble to draw basic shape like line\nWrite string, as a statement, as we are able to do with able to write into txt file using python(not on co-ordinate system basis)","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":1604,"Q_Id":9919509,"Users Score":1,"Answer":"I should point out you can do all the stuff you want in ReportLab by using the supporting PLATYPUS module. It lets you easily build documents out of objects in code. Alternatively, there is RML, a ReportLab way of building documents from an HTML-like markup language.","Q_Score":2,"Tags":"python,ms-word,pdf-generation,report,reportlab","A_Id":9930989,"CreationDate":"2012-03-29T05:22:00.000","Title":"Need help to generate report in PDF or Doc 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},{"Question":"I want some help to generate a report in PDF\/Doc(MS Word) format . I\u2019m not able to find any module to generated report in doc, except \u201cdocx\u201d which I\u2019m not able to comprehend. Actually I\u2019m actual task is to generate the report in Doc only, but as I\u2019m not able to find a module to work on it, I opt for PDF. I\u2019m using \u201cReport Lab\u201d module, but I\u2019m finding some limitation in that. It write anything based on co-ordinate system. The problem I\u2019m facing with that the report is usually a string, whose length is not limited, so sometime it goes beyond the canvas( Pdf Page). Also there is not functionality I guess to do format font with Bold, Italics and Underline. \nIf you know any module to generate report in PDF or Doc, please let me know. My requirement is:\n\nAble to add an image at an header.\nChange fonts and other properties, like Bold, Italics, and Underline\nAble to draw basic shape like line\nWrite string, as a statement, as we are able to do with able to write into txt file using python(not on co-ordinate system basis)","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":1604,"Q_Id":9919509,"Users Score":1,"Answer":"You could also try and generate LaTeX Code, which you then compile to PDF.","Q_Score":2,"Tags":"python,ms-word,pdf-generation,report,reportlab","A_Id":9931947,"CreationDate":"2012-03-29T05:22:00.000","Title":"Need help to generate report in PDF or Doc 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},{"Question":"I'm new for python. How can I get gevent-py2.7-win64.egg, my system is win32, and I need a 64bit module of gevent","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":377,"Q_Id":9923175,"Users Score":0,"Answer":"first test cmd easy_install gevent\nif failed, just go google python setuptools and then installed it and easy_install gevent \njust let the setuptools to help you choose the suitable module","Q_Score":0,"Tags":"python,gevent","A_Id":9923444,"CreationDate":"2012-03-29T10:03:00.000","Title":"How can I get gevent-py2.7-win64.egg","Data Science and Machine Learning":0,"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},{"Question":"I'm having a problem with eclipse+pydev. It suddenly refuses to parse a .py file as a python script, which means no syntax highlighting, code completion etc. It worked up until now, but I couldn't find a way to convince it to re parse it. re-opening the file, re-starting the IDE does not help. I suspect deleting some kind of meta-data file would do the trick.\nHas anyone here encountered this and has a quick solution? I would greatly appreciate that!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":439,"Q_Id":9926088,"Users Score":2,"Answer":"Right click on the python file you care about and see what the default editor is. You can manually switch any file type here. If it's plain text, just switch it back to PyDev.\nTo ensure that the setting is global, go to Window > Preferences > General > Editors > File associations and look for .py, .pyw, and .pyx. They should all be set to \"Python Editor (default)\". If not, just select it and select default. If it's not there at all, you can select the \"add\" button and add it from there.","Q_Score":1,"Tags":"python,eclipse,pydev","A_Id":9926632,"CreationDate":"2012-03-29T13:14:00.000","Title":"eclipse pydev refuses to parse a .py 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},{"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},{"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},{"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},{"Question":"I am registering a signal for remote debugging:\nsignal.signal(signal.SIGUSR1, lambda x,y: remote_debug(x, y, emp_id))\nWhile normally very fast, log statements show this command (register) sometimes takes 5 to 10 seconds to execute. What is causing this? How can I fix it?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":69,"Q_Id":9938238,"Users Score":0,"Answer":"The Python callback code is not actually called right away in Python. The C code in Python just sets a flag when it gets a signal. It only runs the handler when it returns to the interpreter. If your code path is currently working in an extension module in compiled code the handler won't get run until it finishes.\nThe only way to fix it is to ensure that the execution path doesn't spend a lot of time in a C function. What function are you running at that time? Another culprit is the standard time.sleep() method. Use signal.pause() instead.","Q_Score":2,"Tags":"python,signals","A_Id":9939503,"CreationDate":"2012-03-30T06:50:00.000","Title":"What can make signal.signal block for a long 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},{"Question":"I'm making a server which is controlled by php scripts, i have clients (androidphones) who calls these script to control the server. I'm saving the ip's the php receives to the DB. \nnow i'm looking for a way to check if these ip's are still reachable..\nthis is what i tried so far:\n\nCron job -> i'm developing with usbwebserver so i cant use php from cmd \nmake a ping request to the ip from the php script: if available it will return rather \"fast\" but if it fails i get the maximum excution error. this way of working get me the results i want but without the possibilty of threading this, this solution isnt going to perform in time as i wanted. is there a way this approach could work?\nsomething i'm considering: -\n\nmake a request to de device through http, and do something with the result i get back, is this even possible (making a request from server to client)? \nmaking a python script that gets the ip from db and makes the ping calls and stores the results back into the db. \nmaking timestamps when a device connects and check timestamps from other devices, if max time was exceeded then update DB\n\n\nany suggestions?","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":692,"Q_Id":9942423,"Users Score":0,"Answer":"This will not work, as you will always must have your client responding. I suggest using the client (eg. in html using javascript) to make a connection (ping) every minute from your script on the client to your server, and in your cronjobs letting a script run every x minutes to update the clients that didn't within x.","Q_Score":0,"Tags":"php,python,mysql,request,ip","A_Id":9942581,"CreationDate":"2012-03-30T11:54:00.000","Title":"PHP make a request check if client is available via ip","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},{"Question":"I'm making a server which is controlled by php scripts, i have clients (androidphones) who calls these script to control the server. I'm saving the ip's the php receives to the DB. \nnow i'm looking for a way to check if these ip's are still reachable..\nthis is what i tried so far:\n\nCron job -> i'm developing with usbwebserver so i cant use php from cmd \nmake a ping request to the ip from the php script: if available it will return rather \"fast\" but if it fails i get the maximum excution error. this way of working get me the results i want but without the possibilty of threading this, this solution isnt going to perform in time as i wanted. is there a way this approach could work?\nsomething i'm considering: -\n\nmake a request to de device through http, and do something with the result i get back, is this even possible (making a request from server to client)? \nmaking a python script that gets the ip from db and makes the ping calls and stores the results back into the db. \nmaking timestamps when a device connects and check timestamps from other devices, if max time was exceeded then update DB\n\n\nany suggestions?","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":692,"Q_Id":9942423,"Users Score":0,"Answer":"There is absolutely no point in such checking.\nYou will always have these IPs UP.\nJust because an android client seldom have a real IP but using Net via some router\/proxy.\nWeb is one-way road.\nTo implement a heart-beat feature you have to make your android clients to ping server.","Q_Score":0,"Tags":"php,python,mysql,request,ip","A_Id":9942749,"CreationDate":"2012-03-30T11:54:00.000","Title":"PHP make a request check if client is available via ip","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},{"Question":"I am a newborn programmer still programming from the book on my Alt+Tab. One of the first programs I want to create is to help my mom in her work. I need to know if I can use Python to create it.\nIt needs to:\n\nGo on-line and log-in with account \/ pass.\nDo a search with specific criteria (use the site's search engine)\nView all the results and pick only the newest ones.\nSort them out.\nNotify me so that the newest adds are noticed the moment they are posted on the website.\n\nFrom what I see the site says : .cgi in the end.\nI know python can connect, download the text from a page and sort the wanted info, but can it log in, use the search engine and pick the options I need?\nI don't want to skip my learning process, but I am so serious about this project I am ready to put Python on hold and start learning some language that can do it!\nI will very much appreciate your guidance!\nThank you for your time!\nAJ","AnswerCount":7,"Available Count":2,"Score":0.0285636566,"is_accepted":false,"ViewCount":10966,"Q_Id":9945206,"Users Score":1,"Answer":"If I understand well, the idea of your program is to do an automated browsing session.\nSo yes, it's possible. It's not important in what the website is programmed (cgi, php etc). All you need is to send data through post\/get (like a real browser) and process the return (regexp and so on).\nGood luck","Q_Score":4,"Tags":"python,automation,notifications","A_Id":9945337,"CreationDate":"2012-03-30T14:45:00.000","Title":"Can web automation be done 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":1},{"Question":"I am a newborn programmer still programming from the book on my Alt+Tab. One of the first programs I want to create is to help my mom in her work. I need to know if I can use Python to create it.\nIt needs to:\n\nGo on-line and log-in with account \/ pass.\nDo a search with specific criteria (use the site's search engine)\nView all the results and pick only the newest ones.\nSort them out.\nNotify me so that the newest adds are noticed the moment they are posted on the website.\n\nFrom what I see the site says : .cgi in the end.\nI know python can connect, download the text from a page and sort the wanted info, but can it log in, use the search engine and pick the options I need?\nI don't want to skip my learning process, but I am so serious about this project I am ready to put Python on hold and start learning some language that can do it!\nI will very much appreciate your guidance!\nThank you for your time!\nAJ","AnswerCount":7,"Available Count":2,"Score":0.0285636566,"is_accepted":false,"ViewCount":10966,"Q_Id":9945206,"Users Score":1,"Answer":"I would point out that depending upon what site you are on, there may be a more efficient way (perhaps an exposed web service) than scraping data from the page and working with mechanize\/selenium to do what you want. If you are on the web, browser driver tools are the hammers, and they will get the screws in the wood, but sometimes another tool will work better.","Q_Score":4,"Tags":"python,automation,notifications","A_Id":9945530,"CreationDate":"2012-03-30T14:45:00.000","Title":"Can web automation be done 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":1},{"Question":"I'm writing a python program to get rsa public key. Is there a way to get it via paramiko or I just read it like plain text and with the assumption from id_rsa.pub?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":215,"Q_Id":9946744,"Users Score":1,"Answer":"If you don't know where the public key file is located, Paramiko can't help you either - it also needs you to specify where it is. You can of course try the usual places (starting by parsing ~\/.ssh\/config if available), but you don't need Paramiko for that.","Q_Score":0,"Tags":"python,ssh,paramiko","A_Id":9947158,"CreationDate":"2012-03-30T16:18:00.000","Title":"Can we get public key using Paramiko? Or just read it like plain text?","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},{"Question":"I'm developing a system, and I have build a code generator that emits a bunch of classes based on a configuration file. \nI would like to configure PyDev to invoke the generator for me whenever the configuration file (or the generator source) changes. I know that this is possible \"in theory\" because e.g., the ANTLR plugin for Eclipse does this in Java.\nIs there any kind of support in PyDev for doing this? If not, is there some other Eclipse hackery that I can use to get this working?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":339,"Q_Id":9952327,"Users Score":1,"Answer":"It should be possible to do what you want using an external builder inside Eclipse... \nRight click project > properties > builders > new > program, then configure the program as python having as a parameter the module to run and receiving as arguments also the ${build_files} variable (if it's a python script, you have to put your Python.exe as the executable, your main file as an argument and then the ${build_files} variable).","Q_Score":0,"Tags":"eclipse,python-3.x,pydev,generated-code","A_Id":9998578,"CreationDate":"2012-03-31T01:49:00.000","Title":"How do I generate code under Eclipse+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},{"Question":"I am currently using gaeunit to perform automated test on my google app engine application. I am wondering whether it's possible to simulate the user login action using his\/her google account using gaeunit? \nThank you very much.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":401,"Q_Id":9952873,"Users Score":0,"Answer":"Two situations:\n\nLocal Dev server: login is mocked via a simple web form. You can do a http POST to log in.\nProduction server: login goes through the Google auth infrastructure. No way to mock this. To make this work you'd need to code around it.","Q_Score":0,"Tags":"python,google-app-engine,google-apps,google-signin,gaeunit","A_Id":9953084,"CreationDate":"2012-03-31T03:50:00.000","Title":"How to simulate Google login using gaeunit","Data Science and Machine Learning":0,"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},{"Question":"I've recently started using eclipse for my class over IDLE. So far I have no problems writing new code and creating new projects in eclipse.\nHowever, when I open older code that was not originally written in my current project, eclipse seems to only open it as a text file. \nFor example, when I want to run a piece of code, I get a popup asking for an ANT build instead of running it using pydev. Also the code will not show up in the pydev package explorer.\nHow do I go about importing the source code into my project so eclipse will treat it as such.","AnswerCount":1,"Available Count":1,"Score":0.761594156,"is_accepted":false,"ViewCount":5598,"Q_Id":9961190,"Users Score":5,"Answer":"File > Import > \"General\" Folder > \"File System\" Folder > \"Browse\" button","Q_Score":3,"Tags":"python,eclipse,pydev","A_Id":9961465,"CreationDate":"2012-04-01T01:28:00.000","Title":"Python: Import Source Code into 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},{"Question":"I have a zmq directory in cwd . when i import zmq from a python file running under apache it gives me import error. but when i import zmq using console from current directory it imports.\nHow to make this import possible from anywhere in my server?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":2387,"Q_Id":9974611,"Users Score":1,"Answer":"Are you sure that zmq is installed on computer?\nIf not then try installing it. In ubuntu it is quite easy \nsudo apt-get install python-zmq","Q_Score":0,"Tags":"python,zeromq,pyzmq","A_Id":9975162,"CreationDate":"2012-04-02T10:18:00.000","Title":"python import error when importing zmq","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a program (not written by me) that I would like to use. It authenticates to an online service using a username and password that I would like to keep private. The authentication information may be passed to the program in two ways: either directly as command-line arguments or via a plaintext configuration file, neither of which seem particularly secure.\nI would like to write a Python script to manage the launching of this program and keep my credentials away from the prying eyes of other users of the machine. I am running in a Linux environment. My concerns with the command-line approach are that the command line used to run the program is visible to other users via the \/proc filesystem. Likewise, a plaintext configuration file could be vulnerable to reading by someone with the appropriate permissions, like a sysadmin. \nDoes anyone have any suggestions as to a good way to do this? If I had some way of obscuring the arguments used at the command line from the rest of the system, or a way to generate a configuration file that could be read just once (conceptually, if I could pipe the configuration data from the script to the program), I would avoid the situation where my credentials are sitting around potentially readable by someone else on the system.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":1344,"Q_Id":9986059,"Users Score":0,"Answer":"Tough problem. If you have access to source code of the program in question, you can change argv[0] after startup. On most flavors of *nix, this will work.\nThe config file approach may be better from a security perspective.\nIf the config file can be specified at run time, you could generate a temp file (see mkstemp), write password there, and invoke subprocess. You could even add a small delay (to give subprocess time to do its thing) and possibly even remove the config file.\nOf course the best solution is to change the program in question to read password from stdin (but it sounds like you already knew that)","Q_Score":0,"Tags":"python,security,passwords,pipe","A_Id":9986152,"CreationDate":"2012-04-03T01:38:00.000","Title":"Securely passing credentials to a program via plaintext file or 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},{"Question":"I have a program (not written by me) that I would like to use. It authenticates to an online service using a username and password that I would like to keep private. The authentication information may be passed to the program in two ways: either directly as command-line arguments or via a plaintext configuration file, neither of which seem particularly secure.\nI would like to write a Python script to manage the launching of this program and keep my credentials away from the prying eyes of other users of the machine. I am running in a Linux environment. My concerns with the command-line approach are that the command line used to run the program is visible to other users via the \/proc filesystem. Likewise, a plaintext configuration file could be vulnerable to reading by someone with the appropriate permissions, like a sysadmin. \nDoes anyone have any suggestions as to a good way to do this? If I had some way of obscuring the arguments used at the command line from the rest of the system, or a way to generate a configuration file that could be read just once (conceptually, if I could pipe the configuration data from the script to the program), I would avoid the situation where my credentials are sitting around potentially readable by someone else on the system.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":1344,"Q_Id":9986059,"Users Score":0,"Answer":"About the only thing you can do in this situation is store the credentials in a text file and then deny all other users of the machine permissions to read or write it. Create a user just for this script, in fact. Encrypting doesn't do much because you still have to have the key in the script, or somewhere the script can read it, so it's the same basic attack.","Q_Score":0,"Tags":"python,security,passwords,pipe","A_Id":9986183,"CreationDate":"2012-04-03T01:38:00.000","Title":"Securely passing credentials to a program via plaintext file or 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},{"Question":"Assuming I have a instance of class A (name it AI)\nthat has an instance of class B (name it BI).\nCan a reference to BI (somewhere else) tell me that it is part of AI?\nI don't talk about inheritance\/parent class.\nI know I can do this by implementing a reference to A\nin the constructor of B - but can mighty Python do it for me?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":429,"Q_Id":9988578,"Users Score":2,"Answer":"can mighty Python do it for me?\n\nNo, you have to do it yourself (by having every instance of B keep a reference to the corresponding instance of A).","Q_Score":1,"Tags":"python","A_Id":9988597,"CreationDate":"2012-04-03T07:01:00.000","Title":"Get containing python class from element","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I currently have a python script that runs every few minutes and picks up \"rules\", in my case python classes, within files in a directory tree. for each class it can load it runs \"execute()\" and in this way lets me do useful things like monitor log files and so on.\nI'm now revisiting the script to make it self documenting and it strikes me that perhaps there is a neater way of picking up these ad hoc classes; maybe a framework or nice example somewhere.\nCan anyone suggest a neat solution?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":134,"Q_Id":9993899,"Users Score":1,"Answer":"You can simply import the modules (use the __import__ function), and reload them when they change.\nNote that you will still have the issue that existing instances of classes will not automagically change to reflect the new class definition.","Q_Score":0,"Tags":"python,plugins,adhoc","A_Id":9993949,"CreationDate":"2012-04-03T13:06:00.000","Title":"Can someone recommend a pythonic approach to loading adhoc 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},{"Question":"What is the most efficient way in terms of speed to access the pixel data of a PIL image from a C extension? I only need read-only access to it, if that makes a difference.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":456,"Q_Id":9996105,"Users Score":0,"Answer":"C-level bindings for PIL are available, but there is very little documentation for them. You will need to consult the source for usage information.","Q_Score":4,"Tags":"python,python-imaging-library,python-c-extension","A_Id":9996422,"CreationDate":"2012-04-03T15:06:00.000","Title":"Accessing PIL image data from C extension","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},{"Question":"I am writing my own GUI with .NET (C#) and I want to use a python script to click buttons for me automatically and read from text boxes etc. I've tried the Google searches but nothing really helpful. Is there a library that I need to download for .NET or is there a module in python that will do what i\"m looking for. I'm sure it can be done, I just don't know where yo start","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":793,"Q_Id":9996435,"Users Score":1,"Answer":"It sounds like you might be looking for a test automation tool, to script GUI events. I looked into using Ranorex for that a while back, and it looked very capable, but it was too expensive and overkill for my needs.","Q_Score":0,"Tags":"c#,.net,python,user-interface","A_Id":9999447,"CreationDate":"2012-04-03T15:23:00.000","Title":"Python script to control GUI?","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},{"Question":"Are there any tools which generate a project layout for python specific projects, much similar to what maven accomplishes with mvn archetype:generate for java projects.","AnswerCount":4,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":15040,"Q_Id":9999618,"Users Score":10,"Answer":"It is the good news: you do not need any tool. You can organise your source code in any way you want. \nLet recap why we need tools in the java world:\nIn java you want to generate directories upfront because the namespace system dictates that each class must live in one file in a directory structure that reflects that package hierarchy. As a consequence you have a deep folder structure. Maven enforces an additional set of convention for file location. You want to have tools to automate this.\nSecondly, different artefacts require use of different goals and even additional maven projects (e.g. a ear project requires a few jars and war artefacts). There are so many files to create you want to have tools to automate this.\nThe complexity makes tools like mvn archetype:generate not just helpful. It is almost indispensable.\nIn python land, we just do not have these complexity in the language.\nIf my project is small, I can put all my classes and functions in a single file (if it makes sense) \nIf my project is of a bigger size (LOC or team size), it makes sense to group .py files into modules in whatever way makes sense to you and your peers. \nAt the end of the days, it is about striking a balance between ease of maintenance and readability.","Q_Score":16,"Tags":"python,maven","A_Id":9999984,"CreationDate":"2012-04-03T18:59:00.000","Title":"Project structure for python projects with maven","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I'm having a problem with my (game) application, which is using Boost.Python, when it comes to the scripting part. I have a client thread and a server thread that runs in the same process if you do not connect to an external server.\nThis is where my problems arise: It seems like the Python interpreter can't execute scripts in the client thread parallel with scripts in the server thread, as it causes the application to crash.\nSo my question is: Is there any possibility to run two (or more) scripts parallel in the Python interpreter?\nI have been searching all day and found a lot of information regarding Py_NewInterpreter, but this does not solve my problem as it uses GIL, I don't want the interpreter to lock other scripts from executing as it will cause lag on the client and\/or the server side.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":624,"Q_Id":10000524,"Users Score":1,"Answer":"As of today, you cannot avoid GIL interactions when using python threads in the same process.\nYou may want to have a look at multiprocessing module which is meant to easily spawn Python processes, thus not interacting with GIL.\nAnother option is to explicitly release the GIL when its not needed in your wrapped C\/C++ functions. This can be done using PyEval_SaveThread and PyEval_RestoreThread functions.","Q_Score":2,"Tags":"c++,parallel-processing,boost-python,cpython","A_Id":10002004,"CreationDate":"2012-04-03T20:04:00.000","Title":"Running two python scripts parallel with boost::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},{"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},{"Question":"I have a simple question. I am in the process of debugging some code. I am using Enthought Python, with the \"PyLab\" program. I edit my code using gEdit. I am using Ubuntu 10.04.4 LTS.\nI use \"run myfile.py\" to run the program. Then I test myfile(somearguments), and see where the bugs are.\nHowever, when I make changes to the code, using \"run myfile.py\" again does not properly update what Python\/PyLab on the changes to my code. The result is that I will get error messages back pointing to lines that have no errors, and don't even have the \"trouble\" text in them anymore. I tried using import and reload as well, but that didn't work.\nHow do I get Python\/PyLab to see the new changes to my code? The only option I have for now is to fix the bug and then restart PyLab to confirm the fix.\nThanks!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":233,"Q_Id":10003152,"Users Score":0,"Answer":"Did you try to remove the pyc file ?\nIt may happen as the pyc file exists that PyLab keeps reading it without reloading the file.","Q_Score":0,"Tags":"python,matplotlib","A_Id":10003436,"CreationDate":"2012-04-03T23:57:00.000","Title":"Python \"run\" and \"reload\" not showing the changes to my 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":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},{"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},{"Question":"I have a call to a python script that is sudo -u user_name python python_scipt.py and I need to schedule it to run every 30 minutes with crontab. The problem is how can I authenticate it with sudo on crontab?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":489,"Q_Id":10033057,"Users Score":1,"Answer":"Everything solved with the sudo crontab -u username -e\ncredits to 9000","Q_Score":2,"Tags":"python,crontab","A_Id":10198435,"CreationDate":"2012-04-05T17:19:00.000","Title":"Authenticate with sudo on a crontab 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},{"Question":"I need to separate natural, coherent text\/sentences in emails from lists, signatures, greetings and so on before further processing.\nexample:\n\nHi tom,\nlast monday we did bla bla, lore Lorem ipsum dolor sit amet, consectetur adipisici elit, sed eiusmod tempor incidunt ut labore et\n dolore magna aliqua.\n\nlist item 2\nlist item 3\nlist item 3\n\nUt enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquid x ea commodi consequat. Quis aute iure reprehenderit\n in voluptate velit\nregards, K.\n---line-of-funny-characters-#######\nexample inc. \n33 evil street, london\nmobile: 00 234534\/234345\n\nIdeally the algorithm would match only the bold parts. \nIs there any recommended approach - or are there even existing algorithms for that problem? Should I try approximate regular expressions or more statistical stuff based on number of punctation marks, length and so on?","AnswerCount":4,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":229,"Q_Id":10046451,"Users Score":0,"Answer":"You'll need many heuristics to get an approximation of a solution, so here's one: you can safely cut off anything after a sigdash (hyphen-hyphen-space), which standards-conforming e-mail messages use to separate the message body from the signature.\nAnother approach you can use is to store copies of e-mails from the same sender; this should allow you to extract things that are the same or similar in every message (such as salutations and signatures) and detect how their mail client does quoting.","Q_Score":2,"Tags":"python,regex,algorithm,nlp","A_Id":10047362,"CreationDate":"2012-04-06T16:44:00.000","Title":"Algorithm to match natural text in 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":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I need to separate natural, coherent text\/sentences in emails from lists, signatures, greetings and so on before further processing.\nexample:\n\nHi tom,\nlast monday we did bla bla, lore Lorem ipsum dolor sit amet, consectetur adipisici elit, sed eiusmod tempor incidunt ut labore et\n dolore magna aliqua.\n\nlist item 2\nlist item 3\nlist item 3\n\nUt enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquid x ea commodi consequat. Quis aute iure reprehenderit\n in voluptate velit\nregards, K.\n---line-of-funny-characters-#######\nexample inc. \n33 evil street, london\nmobile: 00 234534\/234345\n\nIdeally the algorithm would match only the bold parts. \nIs there any recommended approach - or are there even existing algorithms for that problem? Should I try approximate regular expressions or more statistical stuff based on number of punctation marks, length and so on?","AnswerCount":4,"Available Count":2,"Score":0.1488850336,"is_accepted":false,"ViewCount":229,"Q_Id":10046451,"Users Score":3,"Answer":"In the example you post, line length suffices. \nThere is no perfect algorithm; even human beings will classify lines differently. \nI suggest just use line length until you find a counter example, at which point revise your algorithm. Repeat until problem solved to your satisfaction.","Q_Score":2,"Tags":"python,regex,algorithm,nlp","A_Id":10046551,"CreationDate":"2012-04-06T16:44:00.000","Title":"Algorithm to match natural text in 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":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a need to identify comments in different kinds of source files in a given directory. ( For example java,XML, JavaScript, bash). I have decided to do this using Python (as an attempt to learn Python). The questions I have are\n1) What should I know about python to get this done? ( I have an idea that Regular Expressions will be useful but are there alternatives\/other modules that will be useful? Libraries that I can use to get this done?)\n2) Is Python a good choice for such a task? Will some other language make this easier to accomplish?","AnswerCount":3,"Available Count":1,"Score":0.1325487884,"is_accepted":false,"ViewCount":104,"Q_Id":10046665,"Users Score":2,"Answer":"1) What you need to know about is parsing, not regex. Additionally you will need the os module and some knowledge about pythons file handling. DiveIntoPython (http:\/\/www.diveintopython.net\/) is a good start here. I'd recommend chapter 6. (And maybe 1-5 as well :) )\n2) Python is a good start. Another language is not going to make it easier, but different. Python allready is pretty simple to start with.\nI would recommend not to use regex for your task, as it is as simple as searching for comment signs and linefeeds.","Q_Score":1,"Tags":"python,text-manipulation","A_Id":10046888,"CreationDate":"2012-04-06T17:03:00.000","Title":"What should I know about Python to identify comments in different 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},{"Question":"This is my first hack at doing any system-level programming (mostly a LAMPhp, specifically Drupal, web dev up to this point).\nBecause of availability of a library with a very specific feature, I am using Python for an upcoming project. I need to run, restart as needed, monitor and respond to the output of multiple Python script processes, controlled ideally via a HTTP API from another master program which keeps a database of processes that need to be running, and some metadata about those processes (parameters, pid, etc). I'm planning on building this master program in PHP as I have far more experience in it, hence the want for a nice HTTP API.\nIs there some best practice for this type of system? Some initial research lead me to supervisord (which has XML-RPC built in, apparently), but I thought I'd check the wisdom of the masses who've actually been down this road before moving forward with testing.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":875,"Q_Id":10056289,"Users Score":0,"Answer":"I can't say I have been down this road, but I am working to go down this road. I would look into the multiprocessing libraries for Python. There are network transparent libraries. A couple of routes you could take with those:\n1. Create a process that controls all of the other processes. Make this process a server you can control with your PHP.\n2. Determine how to get PHP to communicate to these networked Python processes. They may still need to be launched from a central Python process however.","Q_Score":3,"Tags":"python,web-services,architecture,operating-system","A_Id":10711768,"CreationDate":"2012-04-07T16:37:00.000","Title":"Best practice for Python process control","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I'm wondering if there's a speedy, Pythonic way to calculate factorials of non-integral numbers (e.g., 3.4)? Of course, the bult-in factorial() function in the Math module is available, but it only works for integrals (I don't care about negative numbers here).","AnswerCount":2,"Available Count":1,"Score":0.2913126125,"is_accepted":false,"ViewCount":7874,"Q_Id":10056797,"Users Score":3,"Answer":"In Python 2.7 or 3.2, you can use math.gamma(x + 1). In older versions, you'd need some external library like SciPy.","Q_Score":8,"Tags":"python,floating-point,factorial","A_Id":10056813,"CreationDate":"2012-04-07T17:45:00.000","Title":"Python: Calculate factorial of a non-integral number","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to build a simple email client with python and IMAPClient. The problem is that the folder names aren't uniform for all servers.\nIf i mark an e-mail as spam, it has to be moved to the spam\/junk folder from the inbox folder (?) .. but i am unable to do that because i don't know what the folder name would be (Spam or INBOX.junk or [Gmail]\/Spam )\nHow do other email clients work with varying folder names ?","AnswerCount":4,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":1797,"Q_Id":10064769,"Users Score":0,"Answer":"They try a lot of possibilities, let you choose one and\/or create one ;)","Q_Score":1,"Tags":"python,email,imap","A_Id":10064803,"CreationDate":"2012-04-08T17:24:00.000","Title":"Identifying IMAP mail folders (spam,sent...), folder names vary with 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},{"Question":"I am trying to build a simple email client with python and IMAPClient. The problem is that the folder names aren't uniform for all servers.\nIf i mark an e-mail as spam, it has to be moved to the spam\/junk folder from the inbox folder (?) .. but i am unable to do that because i don't know what the folder name would be (Spam or INBOX.junk or [Gmail]\/Spam )\nHow do other email clients work with varying folder names ?","AnswerCount":4,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":1797,"Q_Id":10064769,"Users Score":0,"Answer":"Roundcube have this in both the server and user configuration. I don't know about other mail clients, but I guess they either use heuretics, either by just looking at what folders there are or by using knowledge about the particular IMAP server.","Q_Score":1,"Tags":"python,email,imap","A_Id":10064809,"CreationDate":"2012-04-08T17:24:00.000","Title":"Identifying IMAP mail folders (spam,sent...), folder names vary with 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},{"Question":"I am trying to build a simple email client with python and IMAPClient. The problem is that the folder names aren't uniform for all servers.\nIf i mark an e-mail as spam, it has to be moved to the spam\/junk folder from the inbox folder (?) .. but i am unable to do that because i don't know what the folder name would be (Spam or INBOX.junk or [Gmail]\/Spam )\nHow do other email clients work with varying folder names ?","AnswerCount":4,"Available Count":3,"Score":1.2,"is_accepted":true,"ViewCount":1797,"Q_Id":10064769,"Users Score":2,"Answer":"I believe that for common EMail providers they have a mapping as to what that provider uses by default (gmail, hotmail, exchange etc.).\nAnother way of doing it is to let the user decide first time, persist the setting for that account and not ask again.\nMixed approach would be to try and detect all common variations and use the first valid one you encounter. If there are more then one simply allow user to choose.","Q_Score":1,"Tags":"python,email,imap","A_Id":10064811,"CreationDate":"2012-04-08T17:24:00.000","Title":"Identifying IMAP mail folders (spam,sent...), folder names vary with 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},{"Question":"I wrote a sorting algorithm in python.\nIt returns a Python Dictionary object.\nHow do i get the dictionary from Python into my PHP code as an associative arr ?\nWill I have to write the whole sorting algorithm again in PHP?","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":3027,"Q_Id":10072287,"Users Score":0,"Answer":"What you can do is save the Dictionary Object as json or xml in Python, then use json_decode or simple_xml in PHP to load it as array or object\nYou need no sorting algorithm ... PHP has a lot of them","Q_Score":0,"Tags":"php,python,python-2.7","A_Id":10072364,"CreationDate":"2012-04-09T11:06:00.000","Title":"Converting a Python Dictionary into Associative Array for 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":0},{"Question":"I have to build a web application which uses Python, php and MongoDB.\n\nPython - For offline database populating on my local home machine and then exporting db to VPS. Later I am planning to schedule this job using cron.\nPHP - For web scripting.\n\nThe VPS I wish to buy supports Python and LAMP Stack but not mongoDB (myhosting.com LAMP stack VPS) by default. Now since mongoDB isn't supported by default, I would have to install mongoDB manually on VPS. So what I want to know is that, had it been my VPS would have supported mongoDB would I have benefitted in terms of performance and scalability.\nAlso can someone please suggest a VPS suitable in my case.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":810,"Q_Id":10073934,"Users Score":1,"Answer":"If the vps you are looking at restricts the packages you can install, and you need something that they prohibit, I would look for another vps. Both rackspace and amazon a range of instances, and numerous supported os. With either of them you choose your operating system and are free to install whatever you want.","Q_Score":1,"Tags":"php,python,mongodb,vps","A_Id":10074035,"CreationDate":"2012-04-09T13:28:00.000","Title":"Performance of MongoDB on VPS or cloud service not having mongoDB installed","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},{"Question":"I am using the email module and creating a message object out of both ASCII and Unicode files that are essentially emails. \nThe emails include a secretary responding in one portion and in others the boss creating the email. These emails were extracted from pst files (i.e. from outlook or something similar). If you are familiar with company emails then you'll know what I'm talking about. \nAlso if do have multiparts and I use get_payload() on those parts and specify an index, i, how are the indices arranged? As in what is in the indices? Are they the parts of an email?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":287,"Q_Id":10082968,"Users Score":1,"Answer":"A multipart message is basically a nested e-mail message. The embedded messages are ordered in the order that the messages were attached to the containing e-mail. There isn't and index embedded in the e-mail (if I understand your question correctly) - get_payload() would return a list of the embedded e-mail messages.\nIf you saw the raw e-mail and how the MIME parts are arranged it would clarify your understanding.","Q_Score":0,"Tags":"python,email,message,multipart,smtplib","A_Id":13021872,"CreationDate":"2012-04-10T04:03:00.000","Title":"What exactly is a python sub message object if is_multipart is true and how does python organize them?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to understand few things with respect to design.\nI see a number of the code where Lazy Import features is used.By Lazy Import, I mean a facility provided by certain recipes, packages and modules which support \"LazyImport\" style. Those implementation in general aim to import the module only when it is used and provide some extra hooks for different things. I know there the error condition is delayed over here, but I am trying to understand why Lazy Import is not a default strategy in Python. \nWhat could it's (other) drawbacks be which prevent it from making a general useful case. Or are there languages which use this as a default import mechanism strategy.","AnswerCount":3,"Available Count":2,"Score":0.1973753202,"is_accepted":false,"ViewCount":5844,"Q_Id":10084487,"Users Score":3,"Answer":"Sometimes modules do important things when they are first loaded, so it might break the program to delay import of the module. For example, if a module defines command-line flags that should be parsed when the program first starts, the module must be imported before parsing the arguments. Since Python was originally designed to do imports eagerly, it's not possible to change the default behavior now without breaking some existing programs. Also, as mentioned in some of the other answers, for long-running services it's often desirable to load everything up front before serving requests so that the first few requests are not slowed down waiting for modules to be imported.","Q_Score":12,"Tags":"python","A_Id":30221189,"CreationDate":"2012-04-10T07:05:00.000","Title":"Why Lazy Import is not default 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},{"Question":"I am trying to understand few things with respect to design.\nI see a number of the code where Lazy Import features is used.By Lazy Import, I mean a facility provided by certain recipes, packages and modules which support \"LazyImport\" style. Those implementation in general aim to import the module only when it is used and provide some extra hooks for different things. I know there the error condition is delayed over here, but I am trying to understand why Lazy Import is not a default strategy in Python. \nWhat could it's (other) drawbacks be which prevent it from making a general useful case. Or are there languages which use this as a default import mechanism strategy.","AnswerCount":3,"Available Count":2,"Score":0.3215127375,"is_accepted":false,"ViewCount":5844,"Q_Id":10084487,"Users Score":5,"Answer":"Python, unlike e.g. PHP, is rarely used in a way where every request\/action\/... causes the whole application to be started again.\nSo importing everything at startup has the advantage of not having to perform imports while the application is doing something where delays are annoying.\nThe only advantage of local\/lazy imports is that you won't have problems with circular imports.","Q_Score":12,"Tags":"python","A_Id":10084940,"CreationDate":"2012-04-10T07:05:00.000","Title":"Why Lazy Import is not default 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},{"Question":"I'm building a scientific\/education application, and I need to provide power-user scripting capabilities. My choices are:\n\nEmbedding an existing language such as Python or Lua\nOr creating my own language with coco\/R, for example\n\n(Initially I'm building in C#, but will probably later port to C++ for iPad & Android reach.)\nEach approach has its advantages, but a big factor is that I don't want to be shut out of app stores. Apple apparently prohibits apps that run interpreted code. I don't really understand how this is defined - surely any app runs by interpreting its own data structures? I assume it's some sort of \"we know pornography when we see it\" definition, and you just mustn't make your system look too powerful. If this is the case, I'm thinking that if I build my own language and transmit only the active syntax tree and not the scripting source, then I'm less likely to trigger their alarm bells - it'll look like any old data structure. Anyone know if this is right?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":360,"Q_Id":10088731,"Users Score":1,"Answer":"Apple relaxed the language in their license agrement to allow Lua a few years ago. It's used in a huge number of iOS games (including Angry Birds, all EA games, etc.). In fact, there are many games on the App Store written in Lua, using Lua-based frameworks like Corona or MOAI (such as Crimson: Steam Pirates, a Bungie Aerospace funded game which was #1 on the App Store for a few weeks). There are also Apps like Codea, a Lua scripting environment that end users can use to build games\/toys right on the device. Lua is very popular on the iOS platform.\nCreating your own language would be absurd, IMO. Lua is too good, and a perfect fit for iOS: light weight, fast, hackable, user friendly, easily embedded and extended, etc. However, you may have trouble integrating it into a C# app. I don't really know how MonoTouch works, but in the desktop world, C# is managed code, compiled to byte code, but Lua's API is native code. Bridging that gap can be done, but it's more work. \nIn short, you can use Lua and you don't have to hide it. What you're not allowed to do is create a \"metaplatform\", where users can basically download entirely new applications (which have not been reviewed by Apple) through your app.\nEDIT: Regarding \"I'm building in C#, but will probably later port to C++ for iPad & Android reach\", you may want to check out MOAI. It's an open source, cross platform (PC, Mac, iPad, Android, Chrome) framework written in C++ for writing games in Lua. Might save you time to start there rather than porting later. You can do pretty much everything directly in Lua, and if you run into something where you need bare-metal performance or access to functionality not already exposed via a Lua API, you can write it in C or C++.","Q_Score":0,"Tags":"c#,python,lua","A_Id":10145095,"CreationDate":"2012-04-10T12:22:00.000","Title":"Embedded scripting on the AppStore - use Python, or snake my way 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":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm developing a framework of sorts. I'm providing a base class, that will be subclassed by other developers to add behavior to the system. The instances of those classes will have attributes that my framework doesn't necessarily expect, except by inspecting those instances' __dict__. To make things even more interesting, some of those classes can be created dynamically, at any time.\nI'd like some things to be handled by the framework, namely, I will need to persist those instances, display their attribute values to the user, and let her search\/filter instances using those values. \nI have to use a relational database. I know there are some decent python OO database out there, but unfortunately they're not an option in this case. \nI'm not looking for a full-blown ORM too... and it may not even be an option, given that some of the classes can be created dynamically.\nSo, my question is, what state of a python instance do I need to serialize to ensure that I can deserialize it later on? Is it enough to look at __dict__, or are there other private attributes that I should be using?\nPickling the instances is not enough, because I'll need to unpickle them to search\/filter the attribute values, and I'm afraid it's too much data to do it in-memory (instead of letting the database do it).","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":136,"Q_Id":10094217,"Users Score":1,"Answer":"Just use an ORM. This is what they are for. \nWhat you are proposing to do is create your own half-assed ORM on your own time. Save your time for your own code that does things, and use the effort other people put for free into solving this problem for you.\nNote that all class creation in python is \"dynamic\" - this is not an issue, for, well, anything at all. In fact, if you are assembling classes programmatically, it is probably slightly easier with an ORM, because they provide reifications of fields.\nIn the worst case, if you really do need to store your objects in a fake nosql-type schema, you will still only have to write your own backend driver if you use an existing ORM, rather than coding the whole stack yourself. (As it happens, you're not the first person to face this - solutions exist. Goole \"python orm store dynamically created models\" and \"sqlalchemy store dynamically created models\")\nCandidates include:\n\nDjango ORM\nSQLAlchemy\nSome others you can find by googling \"Python ORM\".","Q_Score":2,"Tags":"python,metaprogramming,pickle","A_Id":10094298,"CreationDate":"2012-04-10T18:18:00.000","Title":"Getting and serializing the state of dynamically created python instances to a relational model","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I have a R data.frame containing longitude, latitude which spans over the entire USA map. When X number of entries are all within a small geographic region of say a few degrees longitude & a few degrees latitude, I want to be able to detect this and then have my program then return the coordinates for the geographic bounding box. Is there a Python or R CRAN package that already does this? If not, how would I go about ascertaining this information?","AnswerCount":5,"Available Count":1,"Score":0.0399786803,"is_accepted":false,"ViewCount":5580,"Q_Id":10108368,"Users Score":1,"Answer":"A few ideas:\n\nAd-hoc & approximate: The \"2-D histogram\". Create arbitrary \"rectangular\" bins, of the degree width of your choice, assign each bin an ID. Placing a point in a bin means \"associate the point with the ID of the bin\". Upon each add to a bin, ask the bin how many points it has. Downside: doesn't correctly \"see\" a cluster of points that stradle a bin boundary; and: bins of \"constant longitudinal width\" actually are (spatially) smaller as you move north.\nUse the \"Shapely\" library for Python. Follow it's stock example for \"buffering points\", and do a cascaded union of the buffers. Look for globs over a certain area, or that \"contain\" a certain number of original points. Note that Shapely is not intrinsically \"geo-savy\", so you'll have to add corrections if you need them.\nUse a true DB with spatial processing. MySQL, Oracle, Postgres (with PostGIS), MSSQL all (I think) have \"Geometry\" and \"Geography\" datatypes, and you can do spatial queries on them (from your Python scripts). \n\nEach of these has different costs in dollars and time (in the learning curve)... and different degrees of geospatial accuracy. You have to pick what suits your budget and\/or requirements.","Q_Score":20,"Tags":"python,r,geolocation,cran","A_Id":10108983,"CreationDate":"2012-04-11T14:47:00.000","Title":"Detecting geographic clusters","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},{"Question":"If I am using a python script with mechanize to fill out forms on websites (such as login information) should I be worried about encryption? Is there anything I need\/could do to ensure that the password sent is encrypted? (Or is this even necessary? Is filling out a form with mechanize equivalent to filling out a form with a standard web browser and therefore there I am not actually \"sending\" anything (ie. its up to the website to use https)).\nThanks!\nAlex","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":215,"Q_Id":10109848,"Users Score":2,"Answer":"It's exactly the same as using a web browser -- you should use the same judgement as to whether you want to enter your username and password.","Q_Score":1,"Tags":"python,encryption,https,mechanize,mechanize-python","A_Id":10109960,"CreationDate":"2012-04-11T16:15:00.000","Title":"Python Mechanize Module Encryption","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I'm dynamically defining functions in a module and then updating the module's __all__ and the function's __name__ attribute to match the name it will have inside the module. I was wondering if it is a good idea to update the function's __module__ attribute as well to point to the module the function will reside. The docs say __module__ is:\n\nThe name of the module the function was defined in, or None if unavailable.\n\nThe code that creates the function resides in a different module which is pretty much unrelated to the module where the function resides. There is no reference to the function in this module.\nI've done some poking around on the mailing list but I'm a bit confused as to what the semantics of __module__ are and if I should set it to None or the module that the function resides or the module where the code resides that created the function. Gonna leave it be for now but am interested to see if anyone knows the answer.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":22298,"Q_Id":10113892,"Users Score":1,"Answer":"You shouldn't have to worry about __module__ usually, sometimes its used for dark magic or knowing where a function came (example) debugging from, but most of the time everyone ignores it. If your really worried set __module__ = \"dynamically_defined_function\" or something similar.","Q_Score":17,"Tags":"python","A_Id":10114026,"CreationDate":"2012-04-11T20:58:00.000","Title":"semantics of __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},{"Question":"compared to invoking a python library function that does the same thing. \nI've some legacy code that uses Popen to invoke a executable with some parameters. \nNow there a python library that supports that same function. \nI was wondering what the performance implications are.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":601,"Q_Id":10116602,"Users Score":2,"Answer":"Forking a separate process to do something is almost always much more expensive than calling a function that does the same thing. But if that Python function is very inefficient, and the OS forks new processes quickly (i.e., is a UNIX variant,) you could imagine a rare case where this is not true -- but it will definitely be rare.","Q_Score":3,"Tags":"python,native,popen","A_Id":10116621,"CreationDate":"2012-04-12T02:25:00.000","Title":"What is the performance overhead of Popen 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},{"Question":"I am reading data from a microcontroller via serial, at a baudrate of 921600. I'm reading a large amount of ASCII csv data, and since it comes in so fast, the buffer get's filled and all the rest of the data gets lost before I can read it. I know I could manually edit the pyserial source code for serialwin32 to increase the buffer size, but I was wondering if there is another way around it?\nI can only estimate the amount of data I will receive, but it is somewhere around 200kB of data.","AnswerCount":5,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":12564,"Q_Id":10125009,"Users Score":0,"Answer":"For me the problem was it was overloading the buffer when receiving data from the Arduino.\nAll I had to do was mySerialPort.flushInput() and it worked.\nI don't know why mySerialPort.flush() didn't work. flush() must only flush the outgoing data?\nAll I know is mySerialPort.flushInput() solved my problems.","Q_Score":6,"Tags":"python,serial-port,pyserial","A_Id":67317060,"CreationDate":"2012-04-12T13:53:00.000","Title":"Pyserial buffer fills faster than I can read","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I'm in the process of migrating my Google AppEngine solution from Python 2.5 to 2.7. The application migration was relatively easy, but I'm struggling with the unittests.\nIn the 2.5 version I was using the use_library function to set the django version to 1.2, but this isn't supported anymore on 2.7. Now I set the default version in the app.yaml. \nWhen I'm now running my unittests the default django version becomes 0.96 and I can't manage to set the 1.2 as the default version. \nWho knows how I can set the default libraries for the unittest, so the match the settings in the app.yaml?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":111,"Q_Id":10125860,"Users Score":0,"Answer":"app.yaml configuration is not applied when doing unit tests with webtest app and NoseGAE.\nuse_library does not work neither.\nThe right solution for this case is to provide proper python path to the preferred lib version, e.g. PYTHONPATH=..\/google_appengine\/lib\/django-1.5 when running nosetests.","Q_Score":1,"Tags":"unit-testing,google-app-engine,python-2.7","A_Id":21678252,"CreationDate":"2012-04-12T14:38:00.000","Title":"How to set the default libraries when doing unit tests under 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":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"I have a cgi script wrote in Python that is receiving some complex http request, one that could be POST or GET.\nI am looking for a simple way to log the request in some way so I can replay it later any number of times I want.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":91,"Q_Id":10131506,"Users Score":0,"Answer":"Seems you're looking to cache queries made to your site. \nAfter calculating a response, save a record with the request url, method, params, and response in a your preferred storage.\nDepending on your environment and the number of requests, your may choose a database or filesystem. \nHowever, you need to take into account that some of the result data may change, in which case you'd need to remove cached data that depend on that data.","Q_Score":0,"Tags":"python,http,cgi","A_Id":40729146,"CreationDate":"2012-04-12T20:44:00.000","Title":"How can I save a HTTP request from a python cgi scripts so I can easily repeat 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},{"Question":"I am using pydev where I have set up pylint.\nThe problem is that even inside the comments, pylint reports warnings. I was looking to disable any sort of checking inside any line or a block comment.\nAlso, I wish to follow camelCase naming convention instead of underscores for variables and arguments in my code.\nIs there any way to specify such a rule without inserting my code with any pylint: disable comments?","AnswerCount":6,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":33391,"Q_Id":10138917,"Users Score":20,"Answer":"As said by cfedermann, you can specify messages to be disabled in a ~\/.pylintrc file (notice you can generate a stub file using pylint --generate-rcfile if you don't want to use inline comments.\nYou'll also see in the generated file, in the [BASIC] section, options like \"method-rgx\", \"function-rgx\", etc. which you can configure as you like to support camel cases style rather than pep8 underscore style.","Q_Score":40,"Tags":"python,pydev,pylint","A_Id":10140373,"CreationDate":"2012-04-13T10:08:00.000","Title":"Can Pylint error checking be customized?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I stepped into python gui programming and I wanted to know what the best documented GUI builder like GLADE, which I'm using right now, however I struggle so much to find some good tutorials or documentation, mostly in the even handling area.\nI would like also to understand what's the best\/documented GUI framework.\nThanks to anyone who will answer.","AnswerCount":4,"Available Count":1,"Score":0.1488850336,"is_accepted":false,"ViewCount":6486,"Q_Id":10140560,"Users Score":3,"Answer":"There is no \"best\/documented GUI framework\". There are many GUI toolkits, all more-or-less equally powerful. Tkinter, PyQT, wxPython... all have their strengths and weaknesses. Pick any one of them and start learning. \nI recommend Tkinter for learning, mainly because you probably already have it. Once you understand the fundamentals of event based programming (and Tkinter provides a fairly gentle way to learn that), you'll be in a better position to judge which of the available toolkits fits your definition of \"best\".","Q_Score":4,"Tags":"python,user-interface,pyqt,pygtk,glade","A_Id":10141980,"CreationDate":"2012-04-13T12:11:00.000","Title":"what the best documented python friendly GUI builder like GLADE","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"Okay, so I probably shouldn't be worrying about this anyway, but I've got some code that is meant to pass a (possibly very long, possibly very short) list of possibilities through a set of filters and maps and other things, and I want to know if my implementation will perform well.\nAs an example of the type of thing I want to do, consider this chain of operations:\n\nget all numbers from 1 to 100\nkeep only the even ones\nsquare each number\ngenerate all pairs [i, j] with i in the list above and j in [1, 2, 3, 4,5]\nkeep only the pairs where i + j > 40\n\nNow, after doing all this nonsense, I want to look through this set of pairs [i, j] for a pair which satisfies a certain condition. Usually, the solution is one of the first entries, in which case I don't even look at any of the others. Sometimes, however, I have to consume the entire list, and I don't find the answer and have to throw an error.\nI want to implement my \"chain of operations\" as a sequence of generators, i.e., each operation iterates through the items generated by the previous generator and \"yields\" its own output item by item (a la SICP streams). That way, if I never look at the last 300 entries of the output, they don't even get processed. I known that itertools provides things like imap and ifilter for doing many of the types of operations I would want to perform. \nMy question is: will a series of nested generators be a major performance hit in the cases where I do have to iterate through all possibilities?","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":1253,"Q_Id":10143637,"Users Score":1,"Answer":"\"Nested\" iterators amount to the composition of the functions that the iterators implement, so in general they pose no particularly novel performance considerations. \nNote that because generators are lazy, they also tend to cut down on memory allocation as compared with repeatedly allocating one sequence to transform into another.","Q_Score":1,"Tags":"python,generator","A_Id":10144447,"CreationDate":"2012-04-13T15:19:00.000","Title":"How fast are nested python generators?","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},{"Question":"How to call a phone number using gsm & python. i have try many software in window, but i can't found it using python.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1039,"Q_Id":10152317,"Users Score":0,"Answer":"You should open a COM serial port to the gsm modem from python and use AT commands, search Wikipedia for those, they are used to communicate with gsm devices","Q_Score":0,"Tags":"python","A_Id":10152343,"CreationDate":"2012-04-14T08:55:00.000","Title":"How to call a phone number using gsm & 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},{"Question":"My python application sits behind an Nginx instance. When I upload an image, which is one of the purpose of my app, I notice that nginx first saves the image in filesystem (used 'watch ls -l \/tmp') and then hands it over to the app. Can I configure Nginx to work in-memory with image POST? My intent is to avoid touching the slow filesystem (the server runs on an embedded device).","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":673,"Q_Id":10158096,"Users Score":1,"Answer":"Yes, set the proxy_max_temp_file_size to zero, or some other reasonably small value. Another option (which might be a better choice) is to set the proxy_temp_path to faster storage so that nginx can do a slightly better job of insulating the application from buggy or malicious hosts.","Q_Score":1,"Tags":"python,image,nginx","A_Id":10165928,"CreationDate":"2012-04-14T23:05:00.000","Title":"Nginx: Speeding up Image Upload?","Data Science and Machine Learning":0,"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},{"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},{"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},{"Question":"PHP uses __construct() to set properties for a newly created object. From what I understand, it's not really a constructor, but a method. Why? \nAlso - for less .. inconsistent languages like Java or Python does the object gets instantiated before or after the constructor is called? And how is this different from the PHP way?\nThanks!","AnswerCount":3,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":244,"Q_Id":10167900,"Users Score":2,"Answer":"Both of those languages instantiate it before calling the constructor. In Java, you have access to this, in Python self. Also, in Java, it's like a method, except with no return type. In Python, the syntax is exactly that of a method (__init__).","Q_Score":1,"Tags":"java,php,python,constructor","A_Id":10167913,"CreationDate":"2012-04-16T01:57:00.000","Title":"Why is the PHP constructor a method?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"PHP uses __construct() to set properties for a newly created object. From what I understand, it's not really a constructor, but a method. Why? \nAlso - for less .. inconsistent languages like Java or Python does the object gets instantiated before or after the constructor is called? And how is this different from the PHP way?\nThanks!","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":244,"Q_Id":10167900,"Users Score":0,"Answer":"In every object-oriented language (that I know of; I'm hardly an expert in all of them), the constructor is called after the object is created, to initialise the contents of the object. No code in the constructor creates the object, or can in anyway influence the creation process[1].\n(Note I don't refer to memory; in languages like C++ and Java \"the object has been created\" means the memory its fields occupy has been allocated, whereas in Python \"the object has been created\" means there is a dictionary that will hold attributes of the object once they are assigned)\nIn most OO languages that I know of, constructors also have extremely similar syntax to methods, and I don't see any conceptual difficulty in thinking about them as methods in most senses (in Python the __init__ method is literally a method in every sense; there's just a protocol that the runtime system invokes it on new objects after they're created).\n\n[1]Python has additionally a feature that does let you control the object creation process; but you don't do it with the __init__ method (the special method that most closely corresponds with constructors from Java\/PHP), you do with with __new__.","Q_Score":1,"Tags":"java,php,python,constructor","A_Id":10169430,"CreationDate":"2012-04-16T01:57:00.000","Title":"Why is the PHP constructor a method?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm looking for a way to have a GitPoller changesource watch all branches instead of just one.\nFor now, either I specify branch='some branch' in the GitPoller constructor, or it defaults to master.\nEven better would be to be able to specify some ref pattern to watch.\nIs that something one does already? Or does it need to code another kind of GitPoller ?\nThanks.","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":2319,"Q_Id":10169290,"Users Score":1,"Answer":"Currently GitPoller can only watch a single branch at a time. However, you can have as many GitPollers as you want.","Q_Score":6,"Tags":"python,git,continuous-integration,buildbot","A_Id":10268147,"CreationDate":"2012-04-16T05:55:00.000","Title":"How to have a buildbot GitPoller change source watch all branches?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"All the forks of gevent-socketio in bitbucket and github have examples\/chat.py that do not work.\nCan anyone find me a working example of gevent-socketio?","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":7663,"Q_Id":10204230,"Users Score":1,"Answer":"what browser do you use. I saw this behavior with IE. both Mozilla and chrome were fine. there were issues with the flashscket protocol which I have fixed so ie should work but the jquery UI does not work that is the issue. don't know enough JS to fix it","Q_Score":4,"Tags":"python,websocket,socket.io,gevent","A_Id":11271531,"CreationDate":"2012-04-18T06:46:00.000","Title":"Do anyone have a working example of gevent-socketio?","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},{"Question":"I am working on a design of an application. The Core should be written in C# but i also want to use some already finished CPython modules (un-managed).\nSo I am interested in the interoperability (Call CPython method from C# and Call C# from CPython). And if there are problems, because C# runs within the .NET runtime (managed) and CPython directly un-managed.\nI already investigated this issue with Google and came out to these solutions:\n\nUse IronPython via DLR + \"CPython extension\" + maybe \"IronClad\" and call from IronPython the CPython modules and vice versa -> are these modules executed managed or unmanaged ? Are There any problems if i want to use C# classes and methods from CPython ?\nUse \"Python for .NET\" -> the same question as above.\n\nWhat do you think, which way would be better ? or do you have another solution ? \nAnd the last but maybe most important question, did I understand the above mentioned points right, or do I mess up ?\nMany thanks in advance !!","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":1191,"Q_Id":10208960,"Users Score":2,"Answer":"I think you misunderstand Python. It's an interpreted1 language. You just provide the text source files and the interpreter will execute them.\nThere is a difference between the language Python and the implementations CPython, IronPython, Jython, PyPy, what have you. Each of them attempts to implement the language Python as accurately as possible, while also adding implementation-specific functionality. This is just like how, say, the C# compiler was written in C++.\nFor example, any (pure) Python file can be executed by the IronPython interpreter. But if you know that you're going to use IronPython, you can use the special IronPython features that let you into the .NET library. \nNow, most Python doesn't use any of the implementation-specific functionality, so it doesn't matter what you use to run it. Some Python does, though.\n1Well, it's compiled into .pyc files... but then \"compile\" isn't really a well-defined term anyway.\n\nWhy does this matter to you? Well, you have a bunch of Python source code that you want to use with the .NET framework. If that code doesn't use any of the CPython-specific features -- such as using C extension modules -- then you can just run it in IronPython.","Q_Score":3,"Tags":"c#,.net,python,interop,ironpython","A_Id":10210229,"CreationDate":"2012-04-18T12:02:00.000","Title":"C# .NET interoperabillity with managed Python (CPython) -> any problems?","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},{"Question":"I am working on a design of an application. The Core should be written in C# but i also want to use some already finished CPython modules (un-managed).\nSo I am interested in the interoperability (Call CPython method from C# and Call C# from CPython). And if there are problems, because C# runs within the .NET runtime (managed) and CPython directly un-managed.\nI already investigated this issue with Google and came out to these solutions:\n\nUse IronPython via DLR + \"CPython extension\" + maybe \"IronClad\" and call from IronPython the CPython modules and vice versa -> are these modules executed managed or unmanaged ? Are There any problems if i want to use C# classes and methods from CPython ?\nUse \"Python for .NET\" -> the same question as above.\n\nWhat do you think, which way would be better ? or do you have another solution ? \nAnd the last but maybe most important question, did I understand the above mentioned points right, or do I mess up ?\nMany thanks in advance !!","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":1191,"Q_Id":10208960,"Users Score":1,"Answer":"Expose your Python code via COM and call that from C#. Used this avenue (both ways) many times.","Q_Score":3,"Tags":"c#,.net,python,interop,ironpython","A_Id":14318714,"CreationDate":"2012-04-18T12:02:00.000","Title":"C# .NET interoperabillity with managed Python (CPython) -> any problems?","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},{"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},{"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},{"Question":"I am considering of prototyping a web based point-of-sale system.\nI don't have programming skills but I'm thinking of using this project in order to learn.\nI would like to ask you the following two questions:\n\nDo you think the above task is achievable within the period of 6 months (for building a rough prototype of the basic functions of a POS)?\nIf yes, which programming language would you recommend me and why? (I was thinking of Python)\n\nYour advice is greatly appreciated!","AnswerCount":2,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":9646,"Q_Id":10236321,"Users Score":4,"Answer":"Python is a very quick and productive language to develop in, so that would be a good choice, IMO. Personally I find it the most pleasant language to develop in.\nBut I think a POS system is a terrible first programming project. A proper POS system covers too many aspects like security, authentication, data storage, client-server. Each of those has its own gotcha's and significant learning curve.\nIf you want to go through with it nonetheless, chop the project up into manageable pieces that can be built and tested separately. You could start by writing a simple program that accepts text commands from the console and stores the transactions in e.g. a text file or in a pickled Python dictionary. This would be the start of the server. Later you can add a web or GUI front-end, or have the server store transactions in a database.","Q_Score":3,"Tags":"python,point-of-sale,prototyping","A_Id":10236867,"CreationDate":"2012-04-19T20:35:00.000","Title":"Creating a web based point of sale 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},{"Question":"We are using Pylint within our build system.\nWe have a Python package within our code base that has throwaway code, and I'd like to disable all warnings for a module temporarily so I can stop bugging the other devs with these superfluous messages. Is there an easy way to pylint: disable all warnings for a module?","AnswerCount":6,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":88564,"Q_Id":10238473,"Users Score":0,"Answer":"My use case is to run pylint *.py to process all files in a directory, except that I want to skip one particular file.\nAdding # pylint: skip-file caused Pylint to fail with I: 8, 0: Ignoring entire file (file-ignored). Adding # pylint: disable=file-ignored does not fix that. Presumably, it's a global error rather than a file-specific one.\nThe solution was to include --disable=file-ignored in the Pylint command options. It took way too long to figure this out; there shouldn't be a file-ignored error when you explicitly ignore a file.","Q_Score":116,"Tags":"python,pylint","A_Id":44339590,"CreationDate":"2012-04-19T23:53:00.000","Title":"Disable all Pylint warnings for 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},{"Question":"We are using Pylint within our build system.\nWe have a Python package within our code base that has throwaway code, and I'd like to disable all warnings for a module temporarily so I can stop bugging the other devs with these superfluous messages. Is there an easy way to pylint: disable all warnings for a module?","AnswerCount":6,"Available Count":2,"Score":1.0,"is_accepted":false,"ViewCount":88564,"Q_Id":10238473,"Users Score":7,"Answer":"Another option is to use the --ignore command line option to skip analysis for some files.","Q_Score":116,"Tags":"python,pylint","A_Id":10276255,"CreationDate":"2012-04-19T23:53:00.000","Title":"Disable all Pylint warnings for 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},{"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},{"Question":"I'm new to cgi and python, so I've been making quite a few mistakes. The problem is that if something goes wrong with the script, I just get a 500 error on the webpage. The only way I can see what caused the error is by executing the page via ssh, but the page involves file uploads, so I can't test that part.\nIs there a way I can output Python errors to a file?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":2081,"Q_Id":10253898,"Users Score":3,"Answer":"there are a couple of options, use the logging module as directed, you can tail the server's error log, and you can enable cgitb with import cgitb; cgitb.enable()\nDepending on exactly where the error occurs, the error will show up in different places, so checking all three, and using print statements and exception blocks helps to debug your code.\nWith file uploads, I've found I have to explicitly state enctype=\"multipart\/form-data\" in the form tag or it breaks, often quietly.","Q_Score":0,"Tags":"python,cgi","A_Id":10254010,"CreationDate":"2012-04-20T21:37:00.000","Title":"Logging python errors on 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},{"Question":"I need to script my app (not a game) and I have a problem, choosing a script lang for this.\nLua looks fine (actually, it is ideal for my task), but it has problems with unicode strings, which will be used.\nAlso, I thought about Python, but I don't like It's syntax, and it's Dll is too big for me ( about 2.5 Mib).\nPython and other such langs have too much functions, battaries and modules which i do not need (e.g. I\/O functions) - script just need to implement logic, all other will do my app.\nSo, I'd like to know is there a scripting lang, which satisfies this conditions:\n\nunicode strings \nI can import C++ functions and then call them from\nscript\nCan be embedded to app (no dll's) without any problems\n\nReinventing the wheel is not a good idea, so I don't want to develop my own lang.\nOr there is a way to write unicode strings in Lua's source? Like in C++ L\"Unicode string\"","AnswerCount":5,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":492,"Q_Id":10262114,"Users Score":7,"Answer":"Lua strings are encoding-agnostic. So, yes, you can write unicode strings in Lua scripts. If you need pattern matching, then the standard Lua string library does not support unicode classes. But plain substring search works.","Q_Score":2,"Tags":"python,scripting,programming-languages,lua","A_Id":10262395,"CreationDate":"2012-04-21T19:10:00.000","Title":"Choosing Scripting lang","Data Science and Machine Learning":0,"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},{"Question":"I need the python moduel py4cs, but I cannot find it anywhere, it is not on pypi or anywhere else. Please Help. Thanks!","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":186,"Q_Id":10265351,"Users Score":0,"Answer":"It comes with the book \"Python Scripting for Computational Science\".","Q_Score":0,"Tags":"python","A_Id":10265367,"CreationDate":"2012-04-22T04:56:00.000","Title":"Where to find a python module, py4cs?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I need the python moduel py4cs, but I cannot find it anywhere, it is not on pypi or anywhere else. Please Help. Thanks!","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":186,"Q_Id":10265351,"Users Score":1,"Answer":"It is a set of tools useful for scientific programming in Python. Initially, it was distributed as py4cs only with purchase of the book by Hans Petter Langtangen. It is now called scitools and is widely available.","Q_Score":0,"Tags":"python","A_Id":23199828,"CreationDate":"2012-04-22T04:56:00.000","Title":"Where to find a python module, py4cs?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"When I was reading examples for testing a package in multiple pythons with tox I found about a command \"build_tests\" that would put (2to3'd) test files in build\/ directory. I could also google it in some projects' tox.ini files and some gentoo ebuilds, but I still don't know which package installs this command. I have python 3.2, last nosetests and last distribute, but \"python setup.py build_tests\" still gives error.\nSo what do I have to install to get this command?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":82,"Q_Id":10268189,"Users Score":0,"Answer":"OK, I did some more lookup and I found that at least in nose there is a custom script that adds this command. So I will probably have to copy this idea if I want to have tests for py3k.","Q_Score":0,"Tags":"python,unit-testing,nose,distribute,python-2to3","A_Id":10294908,"CreationDate":"2012-04-22T13:09:00.000","Title":"Where to find build_tests 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":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am attempting to write a script that will pull out NTLM hashes from a text file that contains about 500,000 lines of data. Not all accounts contain hashes and I only need the ones that do contain hashes. \nHere is a sample of what the data looks like:\n\nMango Chango A (a):$NT$547e2494658ca345d3847c36cf1fsef8:::\n\nThere are thousands of other lines in the file, but that particular line is what I need taken out of the file. There are about 100 lines that apply to that and I do not want to manually go through the entire file searching for that. \nIs there an easy script or something I can run in Linux to pull lines that follow that pattern out of the file?\nThank you!","AnswerCount":3,"Available Count":1,"Score":0.2605204458,"is_accepted":false,"ViewCount":575,"Q_Id":10282132,"Users Score":4,"Answer":"grep '\\$NT\\$'filename\nIf there might be other occurrences of $NT$ outside the field you're looking for, you could be more specific - this will find only lines that have it in the second colon-delimited field:\nawk -F: '$2 ~ \/\\$NT\\$\/'filename","Q_Score":0,"Tags":"python,perl,bash,sed,awk","A_Id":10282359,"CreationDate":"2012-04-23T14:05:00.000","Title":"Script to pull hashes out of large text 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},{"Question":"I am creating a module in python that can take multiple arguments. What would be the best way to pass the arguments to the definition of a method? \n\ndef abc(arg):\n ...\n\nabc({\"host\" : \"10.1.0.100\", \"protocol\" : \"http\"})\n\n\ndef abc(host, protocol):\n ...\n\nabc(\"10.1.0.100\", \"http\")\n\n\ndef abc(**kwargs):\n ...\n\nabc(host = \"10.1.0.100\", protocol = \"http\")\n\nOr something else?\nEdit\nI will actually have those arguments (username, password, protocol, host, password2) where none of them are required.","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1331,"Q_Id":10285748,"Users Score":0,"Answer":"If all the arguments are known ahead, use an explicit argument list, optionally with default values, like def abc(arg1=\"hello\", arg2=\"world\",...). This will make the code most readable.\nWhen you call the function, you can use either abd(\"hello\", \"world\") or abc(arg1=\"hello\", arg2=\"world\"). I use the longer form if there are more than 4 or 5 arguments, it's a matter of taste.","Q_Score":0,"Tags":"python","A_Id":10285800,"CreationDate":"2012-04-23T17:59:00.000","Title":"What is the best way to pass multiple parameters to class init 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},{"Question":"I'd like to develop an app that runs natively (self-contained executable) for both Mac and Windows that will detect\/poll for a USB device being inserted and send an HTTP call as a result. I'm mainly a Ruby programmer, so ideally I could do this with a combination of Macruby\/IronRuby and shared libraries, but it's looking like libusb requires a special driver to be installed on Windows (which I can't expect the clients to do). \nAre there libraries\/gems that would facilitate this? Is it possible to do what I'm describing using Python\/Ruby? It's not as important to be shared code as it is that the codebase is Python\/Ruby\/single language. libusb would be ideal if it didn't require an install of a special driver on Windows.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":528,"Q_Id":10287853,"Users Score":0,"Answer":"Well it is definitely possible; I don't know what the equivalent is in rubygems by pyUSB is a easy to use module you can leverage to do this and then there are numerous http libraries for python.\nAs for making it self contained, it is possible but not ideal. py2exe is a program that basically takes a copy of the python interpreter, all dependencies used in your programs and your script and glues it all together in a exe file, but by default py2exe will not pack it into a exe, but there are instructions on the wiki","Q_Score":1,"Tags":"python,ruby,usb,native","A_Id":10289020,"CreationDate":"2012-04-23T20:34:00.000","Title":"Cross-platform USB development for Mac\/Windows - possible with Ruby\/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},{"Question":"I have a software that uses multiple languages, which are all available as eclipse plugins (java, c++, python). The exes call each other. I was wondering if there is a way I could debug all these languages using eclipse. I have the sources for all of them, and all of them are projects in eclipse, but so far they work independently, and I was wondering whether, for example, if I added a break point in a C++ code and called a java program that calls the C++ code, the execution would pause when it reaches the C++ breakpoint. I think this is somehow similar to 'attaching to a process' in Visual Studio, though I'm not sure whether Visual Studio provides this feature either. Is it possible with eclipse or Visual Studio ?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":240,"Q_Id":10288488,"Users Score":0,"Answer":"To my knowledge, Eclipse has no support for multidebugger debugging. However, it might be possible to debug the same workspace in many Eclipse instance at the same time. Simply launch the debugger for each language separately by attaching to them as you said.","Q_Score":3,"Tags":"java,c++,python,eclipse,visual-studio","A_Id":10288556,"CreationDate":"2012-04-23T21:18:00.000","Title":"multi language IDE","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I got txt file A with 300, 000+ lines and txt file B with 600, 000+ lines. Now what I want to do is to sift through file A line by line, if that line does not appear in file B then it will be appended to file C. \nWell, the problem is if I program like what I said above, it literally takes ages to finish all the job. So is there a better way to do this?","AnswerCount":4,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":477,"Q_Id":10301687,"Users Score":0,"Answer":"Don't know anything about python, but: how about sorting the file A into a particular order? Then you can go through file B line by line and do a binary search - more efficient.","Q_Score":0,"Tags":"python,compare","A_Id":10301739,"CreationDate":"2012-04-24T16:04:00.000","Title":"What's the fastest way to find unique lines from huge file A as compared to huge file B 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},{"Question":"I'm currently using json and http to call perl functions from python, but it's slow. Based on some research, messagepack is best for serialization and zeromq is the best transport. Both have cross platform bindings, but before I dig in, I would like to know what others are using for fast cross-language RPC (preferably with persistent tcp connections)","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":523,"Q_Id":10309579,"Users Score":0,"Answer":"After studying this for a couple days I'm going with ZeroMQ + messagepack. The ZeroMQ docs show how to use messagepack, and I can implement an RPC server or client in only a few lines. The ZeroMQ modules for perl and python both have JSON serialization built in, so it's possible to implement RPC with ZeroMQ alone, but messagepack will give a nice boost to my data heavy calls. Thrift looks nice too, but it adds an extra configuration file and is fairly high level. I am sure to get max performance with ZeroMQ and it leaves a lot more options open.","Q_Score":1,"Tags":"python,perl,rpc,zeromq,msgpack","A_Id":10339941,"CreationDate":"2012-04-25T05:00:00.000","Title":"RPC between 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},{"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},{"Question":"Firstly, I should state that my current development environment is MSYS + mingw-w64 + ActivePython under Windows 7 and that on a normal day I am primarily a Linux developer. I am having no joy obtaining, or compiling, a version of the Python library with debug symbols. \nI need both 32bit and 64bit debug versions of the Python27.dll file, ideally. I want to be able to embed Python and implement Python extensions in C++, and be able to call upon a seamless debugging facility using the gdb-7.4 I have built for mingw-w64, and WingIDE for the pure Python side of things. \nBuilding Python 2.7.3 from source with my mingw-w64 toolchain is proving too problematic -- and before anyone flames me for trying: I acknowledge that this environment is unsupported, but I thought I might be able to get this working with a few judicious patches (hacks) and:\nmake OPT='-g -DMS_WIN32 -DWIN32 -DNDEBUG -D_WINDOWS -DUSE_DL_EXPORT' \nI was wrong... I gave up at posixmodule.c since the impact of my changes became uncertain; ymmv. \nI have tried building with Visual C++ 2010 Express but being primarily a Linux developer the culture-shock is too much for me to bear today; the Python project does not even import successfully. Apparently, I need Visual C++ 2008, yet I am already convinced I don't want to go down this road if at all possible... \nIt's really surprising to me that there is not a zip-file providing the requisite .dlls somewhere on the Internet. ActiveState should really provide these as an optional download with each release of ActivePython that they make -- perhaps that's where the paid support comes in ;-).\nWhat is the best way to obtain the Python debug library files given my environment?","AnswerCount":3,"Available Count":1,"Score":0.2605204458,"is_accepted":false,"ViewCount":12543,"Q_Id":10315662,"Users Score":4,"Answer":"The best way to create a debug version of Python under Windows is to use the Debug build in the Visual Studio projects that come with the Python source, using the compiler version needed for the specific Python release, i.e. VS 2008.\nThere may be other ways, but this is certainly the best way.\nIf you really need a 64-bit debug build also, the best way is to buy a copy of VS 2008 (i.e. not use the Express version). It may be possible to create an AMD64 debug build using the SDK 64-bit compiler, but again, using the officially-supported procedures is the best way.","Q_Score":12,"Tags":"python,gdb,debug-symbols,activepython,mingw-w64","A_Id":10323635,"CreationDate":"2012-04-25T12:31:00.000","Title":"How to obtain pre-built *debug* version of Python library (e.g. Python27_d.dll) for 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},{"Question":"I am building an application, which has an application based front-end in C++\/Qt and a web based front-end in Python (using Django) framework. I'm trying to migrate the architecture to services-based, as both these front-ends have business logic embedded in them, which makes it hard to maintain. \nI'm thinking of choosing Thrift to write the RPC services, which can be consumed by the other modules in the system and Python code. However, as it seems, Thrift does not work well with Windows, so I'm left with the option of converting the Thrift output to some C++ structures, which theen need to be serialized\/de-serialized again, so that the services can be consumed by Qt\/C++. Python code can consume these Thrift services easily.\nIn this process, I need to convert\/serialize the structure, first according to the Thrift IDL and then some custom code. Any suggestions to change the architecture, so as to\n\nkeep it simple \nworks with multiple languages \nquick to implement?","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":254,"Q_Id":10317632,"Users Score":1,"Answer":"you could consider:\n\nalready mentioned CORBA solution: built in marshaling, compact binary protocol\nREST http and based json server: simple, a bit chatty on the network, you need to serialize your data to json\nAMQP messaging + json or some other serializer: you need to serialize your data to json or something else like google protocol buffers, plus is that scaling if you need more servers will be simpler.","Q_Score":0,"Tags":"c++,python,architecture,thrift","A_Id":10328853,"CreationDate":"2012-04-25T14:18:00.000","Title":"migrating business logic to services: alternatives to Thrift","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I am building an application, which has an application based front-end in C++\/Qt and a web based front-end in Python (using Django) framework. I'm trying to migrate the architecture to services-based, as both these front-ends have business logic embedded in them, which makes it hard to maintain. \nI'm thinking of choosing Thrift to write the RPC services, which can be consumed by the other modules in the system and Python code. However, as it seems, Thrift does not work well with Windows, so I'm left with the option of converting the Thrift output to some C++ structures, which theen need to be serialized\/de-serialized again, so that the services can be consumed by Qt\/C++. Python code can consume these Thrift services easily.\nIn this process, I need to convert\/serialize the structure, first according to the Thrift IDL and then some custom code. Any suggestions to change the architecture, so as to\n\nkeep it simple \nworks with multiple languages \nquick to implement?","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":254,"Q_Id":10317632,"Users Score":1,"Answer":"I've implemented something similar using omniORB. It has bindings for python and for C++. It's really easy in python and performs very well.","Q_Score":0,"Tags":"c++,python,architecture,thrift","A_Id":10317981,"CreationDate":"2012-04-25T14:18:00.000","Title":"migrating business logic to services: alternatives to Thrift","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"Is python supported on Giraph and if it is, is it as well-supported as python is on Hadoop or well it lead to considerably worse performance than using raw Java?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":2017,"Q_Id":10325072,"Users Score":1,"Answer":"Streaming out to a scripting language is not yet supported but certainly would be a good addition. Patches welcome.","Q_Score":6,"Tags":"python,graph,hadoop,graph-theory","A_Id":11112245,"CreationDate":"2012-04-25T23:09:00.000","Title":"Can I use python with giraph?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I'm assuming with a call to a UNIX shell, but I was wondering if there are other options from within Python.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":2229,"Q_Id":10327804,"Users Score":1,"Answer":"os.link claims to work on all Unix platforms. Are there any OS X specific issues with it?","Q_Score":0,"Tags":"python,macos,unix,filesystems,osx-lion","A_Id":10327842,"CreationDate":"2012-04-26T05:40:00.000","Title":"How to create a hard link from within a Python script on a 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":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"After installing python on Linux, smtpd.py will be installed under \/usr\/bin directory. Why does this module exist here? How about the other one under directory \/usr\/lib\/python2.x? What's the difference?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":181,"Q_Id":10335259,"Users Score":1,"Answer":"The one in \/usr\/bin is in your PATH and can be executed by calling its filename in a shell.\nThe second one is in library directory referenced by PYTHONPATH or sys.path and can be used as a module in python scripts.\nThey are probably hard or symlinks if they have the same content.","Q_Score":0,"Tags":"python","A_Id":10335348,"CreationDate":"2012-04-26T14:12:00.000","Title":"Why two smtpd.py are installed?","Data Science and Machine Learning":0,"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},{"Question":"I am running a process on a S7-1200 plc and I need it to send a start signal to my python script, after the script is done running it needs to send something back to the plc to initiate the next phase. Oh, and it has to be done in ladder.\nIs there a quick and dirty way to send things over profibus or am I better off using just a RS232 thing?","AnswerCount":7,"Available Count":3,"Score":1.2,"is_accepted":true,"ViewCount":38421,"Q_Id":10355953,"Users Score":6,"Answer":"After failing with libnodave and OPC, I created a TCON,TSEND and TRECV communication thing. It transmits a byte over TCP and it works.","Q_Score":10,"Tags":"python,plc,siemens,s7-1200","A_Id":10782983,"CreationDate":"2012-04-27T18:30:00.000","Title":"How can I communicate between a Siemens S7-1200 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":1},{"Question":"I am running a process on a S7-1200 plc and I need it to send a start signal to my python script, after the script is done running it needs to send something back to the plc to initiate the next phase. Oh, and it has to be done in ladder.\nIs there a quick and dirty way to send things over profibus or am I better off using just a RS232 thing?","AnswerCount":7,"Available Count":3,"Score":0.057080742,"is_accepted":false,"ViewCount":38421,"Q_Id":10355953,"Users Score":2,"Answer":"There is a commercial library called \"S7connector\" by Rothenbacher GmbH (obviously it's not the \"s7connector\" on sourceforge).\nIt is for the .NET framework, so could be used with IronPython.\nIt does work with S7-1200 PLCs. You just have to make sure a DB you want to read from \/ write to is not an optimized S7-1200 style DB, but a S7-300\/400 compatible one, an option which you can set when creating a DB in TIA portal.\nThis lib also allows to read and write all I\/O ports - the \"shadow registers\" (not sure what they're called officially) and directly as well, overriding the former.","Q_Score":10,"Tags":"python,plc,siemens,s7-1200","A_Id":24056273,"CreationDate":"2012-04-27T18:30:00.000","Title":"How can I communicate between a Siemens S7-1200 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":1},{"Question":"I am running a process on a S7-1200 plc and I need it to send a start signal to my python script, after the script is done running it needs to send something back to the plc to initiate the next phase. Oh, and it has to be done in ladder.\nIs there a quick and dirty way to send things over profibus or am I better off using just a RS232 thing?","AnswerCount":7,"Available Count":3,"Score":0.0285636566,"is_accepted":false,"ViewCount":38421,"Q_Id":10355953,"Users Score":1,"Answer":"Ther best way to communicate with S7-1200 PLC cpu's is with OPC UA or Classic OPC (ommonly known as OPC DA. ) Libnodave is made for S7-300 and S7-400 not for S71200 (2.x firmware). \nIf you use a third party solution to communicate with S7-1200 (or S7-1500) you have to decrease the security level at the PLC by allowing the put and get mechanism. Put and get are pure evil to use. You open the memory of the CPU for every process. Don\u2019t use them anymore. Siemens should actually block this. \nThis applies for all firmware release for S7-1200.\nSiemens pushes people you use OPC UA as default communication from PLC. What makes sense, because OPC UA is the protocol for industry 4.0 and IIoT. \nEdit: rewrite everything. Info was heavily outdated.\nIf you use a firmware 2 or 3 1200, consider replacement or upgrade. These versions are no longer supported and contains the worm issue.","Q_Score":10,"Tags":"python,plc,siemens,s7-1200","A_Id":10773413,"CreationDate":"2012-04-27T18:30:00.000","Title":"How can I communicate between a Siemens S7-1200 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":1},{"Question":"I new to Python and to programming in general. I'm a novice, and do not work in programming, just trying to teach myself how to program as a hobby. Prior to Python, I worked with Ruby for a bit and I learned that one of the biggest challenges was actually properly setting up my computer.\nBackground: I'm on a Macbook with OSX 10.7. \nWith Ruby, you have to (or rather, you should), edit your .\/profile and add PATH info. When you install and use RVM, there are additional items you need to add to your bash_profile. \nDo you have to make similar changes with Python? What are the best practices as I'm installing\/getting started to ensure I can install modules and packages correctly?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":479,"Q_Id":10368361,"Users Score":2,"Answer":"python works out of the box on OS X (as does ruby, for that matter). The only changes I would recommend for a beginner are:\n1) Python likes to be reassured that the terminal can handle UTF-8 before it will print Unicode strings. Add export LANG=en_US.UTF-8 to .profile. (It may be that the .UTF-8 part is already present by default on Lion - I haven't checked since Snow Leopard.) Of course, this is something that will help you in debugging, but you shouldn't rely on it being set this way on other machines.\n2) Install pip by doing easy_install pip (add sudo if necessary). After that, install Python packages using pip install; this way, you can easily remove them using pip uninstall.","Q_Score":5,"Tags":"python,profile,.bash-profile","A_Id":10368402,"CreationDate":"2012-04-28T23:08:00.000","Title":"Proper Unix (.profile, .bash_profile) changes for Python usage","Data Science and Machine Learning":0,"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},{"Question":"I use the remote API for some utility tasks, and I've noticed that it is orders of magnitude slower than code running on Appengine. A simple get_by_id(list) took a couple of minutes using the remote API, and a couple of seconds running on Appengine.\nThe logs show that the remote API fetched separately taking a couple of seconds each; whereas on Appengine the whole list of objects is retrieved in about the same time.\nIs there any way to improve this situation?","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":415,"Q_Id":10393531,"Users Score":2,"Answer":"Don't forget that the remoteapi executes your code locally and only calls appengine servers for datastore\/blobstore\/etc. operations. So in essence, you're running code that's hitting a database living over the network. It's definitely slower.","Q_Score":2,"Tags":"python,google-app-engine","A_Id":10398726,"CreationDate":"2012-05-01T04:24:00.000","Title":"Remote API is extremely 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":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"I am trying to execute simple JavaScript code in a pure Python environment (Google AppEngine).\nI've tried PYJON, but it does not seem mature enough for real use(it does not handle eg forward referenced functions or do-while and it hangs on array usage).\nOne idea would be to use pynarcissus to convert JavaScript into a syntax tree and than convert this tree jnto a Python AST which could be compiled into Python bytecode.\nHas anybody done this before?\nAny problems with this idea?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":846,"Q_Id":10398315,"Users Score":0,"Answer":"To my knowledge, there are no complete and robust implementations of Javascript interpreters on Python. Your best option is probably to deploy an alternate version of your app with the Rhino interpreter in Java, and call this as a web service with the main version of your app.","Q_Score":4,"Tags":"javascript,python,google-app-engine","A_Id":10406398,"CreationDate":"2012-05-01T13:26:00.000","Title":"Converting JavaScript into Python bytecode","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I've been trying to build boost python for about two days now and am incredibly frustrated. When I build the library, it tells me that it was built successfully.\nWhen I try to run anything using the library i get errors such as;\nundefined reference to imp__ZN5boost6python6detail11init_moduleEPKcPFvvE \nIn function ZNK5boost6python9type_info4nameEv:\nundefined reference to imp__ZN5boost6python6detail12gcc_demangleEPKc\nI have absolutely no idea why this is happening, but I'd appreciate any ideas\nBTW, I'm using boost1.49.0 with python 3.0 and the other libraries seem to have been built fine. I've already used the serialization library and it works.\nLet me know if you need any more info.\nThanks.","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":362,"Q_Id":10403720,"Users Score":2,"Answer":"Ah, I got it figured out. The problems were python 3 and boost wasn't properly linking the static libraries. I switched to python2.7 and defined BOOST_PYTHON_STATIC_LIB before loading any headers. Everything works fine now.\nThanks for the help.","Q_Score":2,"Tags":"c++,python,boost,windows-7,boost-python","A_Id":10486821,"CreationDate":"2012-05-01T20:14:00.000","Title":"Building Boost Python with mingw on Windows7 64bit","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I need to convert the GPIB to USB using NI-488.2 from national instrument and I need to create a software complete with GUI using python. The old machine that my company use for measuring is Model 273A potentiostat\/galvanostat from Princeton Applied Research. Im using windows 7 and python 2.7 using wxpython. And I need to program using python. I just need to send simple command for example R to run the machine.\nConnections : from measuring machine via GPIB to NI-488.2(a card to convert GPIB to usb)\n from NI-488.2 to pc via usb\nThe questions are :\n\nHow can I send any command to the machine? From what I know, I need to send it to the driver of the NI-488.2. Is it correct? (if correct see ques. 2 if not jump to ques. 3)\nHow can I send from my own code using python to the NI-488.2 driver?\nHow to see the code of any driver? But in my case the driver for NI-488.2. (the driver can be downloaded for free in the national instrument website but registration needed)","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":2429,"Q_Id":10411605,"Users Score":1,"Answer":"Install the necessary drivers, probably NI 488.2 and NI Visa. Then use pyvisa, a python wrapper around visa, to talk to the device.","Q_Score":2,"Tags":"python,usb,driver,gpib","A_Id":14773570,"CreationDate":"2012-05-02T10:06:00.000","Title":"converting GPIB to USB using NI-488.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":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I need to convert the GPIB to USB using NI-488.2 from national instrument and I need to create a software complete with GUI using python. The old machine that my company use for measuring is Model 273A potentiostat\/galvanostat from Princeton Applied Research. Im using windows 7 and python 2.7 using wxpython. And I need to program using python. I just need to send simple command for example R to run the machine.\nConnections : from measuring machine via GPIB to NI-488.2(a card to convert GPIB to usb)\n from NI-488.2 to pc via usb\nThe questions are :\n\nHow can I send any command to the machine? From what I know, I need to send it to the driver of the NI-488.2. Is it correct? (if correct see ques. 2 if not jump to ques. 3)\nHow can I send from my own code using python to the NI-488.2 driver?\nHow to see the code of any driver? But in my case the driver for NI-488.2. (the driver can be downloaded for free in the national instrument website but registration needed)","AnswerCount":3,"Available Count":2,"Score":0.1325487884,"is_accepted":false,"ViewCount":2429,"Q_Id":10411605,"Users Score":2,"Answer":"You need to install the driver for the GPIB-USB cable, and registration process is quite simple. For the registration, basically you just need to leave a email address of yours. \nAfter you install the driver, you can find many useful information in their \"help\". Generally you need to read the user manual of your device. The idea is that you should use ctypes to interface with the GPIB-USB's dll in Python.","Q_Score":2,"Tags":"python,usb,driver,gpib","A_Id":10613554,"CreationDate":"2012-05-02T10:06:00.000","Title":"converting GPIB to USB using NI-488.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":0,"System Administration and DevOps":0,"Web Development":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},{"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},{"Question":"I have some management commands that are based on gevent. Since my management command makes thousands to requests, I can turn all socket calls into non-blocking calls using Gevent. This really speeds up my application as I can make requests simultaneously.\nCurrently the bottleneck in my application seems to be Postgres. It seems that this is because the Psycopg library that is used for connecting to Django is written in C and does not support asynchronous connections.\nI've also read that using pgBouncer can speed up Postgres by 2X. This sounds great but it would be great if someone could explain how pgBouncer works and helps?\nThanks","AnswerCount":2,"Available Count":2,"Score":1.0,"is_accepted":false,"ViewCount":41803,"Q_Id":10419665,"Users Score":11,"Answer":"PgBouncer reduces the latency in establishing connections by serving as a proxy which maintains a connection pool. This may help speed up your application if you're opening many short-lived connections to Postgres. If you only have a small number of connections, you won't see much of a win.","Q_Score":30,"Tags":"python,django,postgresql,connection-pooling,pgbouncer","A_Id":10419731,"CreationDate":"2012-05-02T18:34:00.000","Title":"How does pgBouncer help to speed up 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},{"Question":"I have some management commands that are based on gevent. Since my management command makes thousands to requests, I can turn all socket calls into non-blocking calls using Gevent. This really speeds up my application as I can make requests simultaneously.\nCurrently the bottleneck in my application seems to be Postgres. It seems that this is because the Psycopg library that is used for connecting to Django is written in C and does not support asynchronous connections.\nI've also read that using pgBouncer can speed up Postgres by 2X. This sounds great but it would be great if someone could explain how pgBouncer works and helps?\nThanks","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":41803,"Q_Id":10419665,"Users Score":105,"Answer":"Besides saving the overhead of connect & disconnect where this is otherwise done on each request, a connection pooler can funnel a large number of client connections down to a small number of actual database connections. In PostgreSQL, the optimal number of active database connections is usually somewhere around ((2 * core_count) + effective_spindle_count). Above this number, both throughput and latency get worse. NOTE: Recent versions have improved concurrency, so in 2022 I would recommend something more like ((4 * core_count) + effective_spindle_count).\nSometimes people will say \"I want to support 2000 users, with fast response time.\" It is pretty much guaranteed that if you try to do that with 2000 actual database connections, performance will be horrible. If you have a machine with four quad-core processors and the active data set is fully cached, you will see much better performance for those 2000 users by funneling the requests through about 35 database connections.\nTo understand why that is true, this thought experiment should help. Consider a hypothetical database server machine with only one resource to share -- a single core. This core will time-slice equally among all concurrent requests with no overhead. Let's say 100 requests all come in at the same moment, each of which needs one second of CPU time. The core works on all of them, time-slicing among them until they all finish 100 seconds later. Now consider what happens if you put a connection pool in front which will accept 100 client connections but make only one request at a time to the database server, putting any requests which arrive while the connection is busy into a queue. Now when 100 requests arrive at the same time, one client gets a response in 1 second; another gets a response in 2 seconds, and the last client gets a response in 100 seconds. Nobody had to wait longer to get a response, throughput is the same, but the average latency is 50.5 seconds rather than 100 seconds.\nA real database server has more resources which can be used in parallel, but the same principle holds, once they are saturated, you only hurt things by adding more concurrent database requests. It is actually worse than the example, because with more tasks you have more task switches, increased contention for locks and cache, L2 and L3 cache line contention, and many other issues which cut into both throughput and latency. On top of that, while a high work_mem setting can help a query in a number of ways, that setting is the limit per plan node for each connection, so with a large number of connections you need to leave this very small to avoid flushing cache or even leading to swapping, which leads to slower plans or such things as hash tables spilling to disk.\nSome database products effectively build a connection pool into the server, but the PostgreSQL community has taken the position that since the best connection pooling is done closer to the client software, they will leave it to the users to manage this. Most poolers will have some way to limit the database connections to a hard number, while allowing more concurrent client requests than that, queuing them as necessary. This is what you want, and it should be done on a transactional basis, not per statement or connection.","Q_Score":30,"Tags":"python,django,postgresql,connection-pooling,pgbouncer","A_Id":10420469,"CreationDate":"2012-05-02T18:34:00.000","Title":"How does pgBouncer help to speed up 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},{"Question":"I have a problem when I run a script with python. I haven't done any parallelization in python and don't call any mpi for running the script. I just execute \"python myscript.py\" and it should only use 1 cpu.\nHowever, when I look at the results of the command \"top\", I see that python is using almost 390% of my cpus. I have a quad core, so 8 threads. I don't think that this is helping my script to run faster. So, I would like to understand why python is using more than one cpu, and stop it from doing so.\nInteresting thing is when I run a second script, that one also takes up 390%. If I run a 3rd script, the cpu usage for each of them drops to 250%. I had a similar problem with matlab a while ago, and the way I solved it was to launch matlab with -singlecompthread, but I don't know what to do with python.\nIf it helps, I'm solving the Poisson equation (which is not parallelized at all) in my script.\n\nUPDATE:\nMy friend ran the code on his own computer and it only takes 100% cpu. I don't use any BLAS, MKL or any other thing. I still don't know what the cause for 400% cpu usage is.\nThere's a piece of fortran algorithm from the library SLATEC, which solves the Ax=b system. That part I think is using a lot of cpu.","AnswerCount":3,"Available Count":3,"Score":0.1325487884,"is_accepted":false,"ViewCount":1390,"Q_Id":10427900,"Users Score":2,"Answer":"Your code might be calling some functions that uses C\/C++\/etc. underneath. In that case, it is possible for multiple thread usage. \nAre you calling any libraries that are only python bindings to some more efficiently implemented functions?","Q_Score":1,"Tags":"python,multithreading,parallel-processing,cpu-usage","A_Id":10428163,"CreationDate":"2012-05-03T08:42:00.000","Title":"Stop Python from using more than one cpu","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},{"Question":"I have a problem when I run a script with python. I haven't done any parallelization in python and don't call any mpi for running the script. I just execute \"python myscript.py\" and it should only use 1 cpu.\nHowever, when I look at the results of the command \"top\", I see that python is using almost 390% of my cpus. I have a quad core, so 8 threads. I don't think that this is helping my script to run faster. So, I would like to understand why python is using more than one cpu, and stop it from doing so.\nInteresting thing is when I run a second script, that one also takes up 390%. If I run a 3rd script, the cpu usage for each of them drops to 250%. I had a similar problem with matlab a while ago, and the way I solved it was to launch matlab with -singlecompthread, but I don't know what to do with python.\nIf it helps, I'm solving the Poisson equation (which is not parallelized at all) in my script.\n\nUPDATE:\nMy friend ran the code on his own computer and it only takes 100% cpu. I don't use any BLAS, MKL or any other thing. I still don't know what the cause for 400% cpu usage is.\nThere's a piece of fortran algorithm from the library SLATEC, which solves the Ax=b system. That part I think is using a lot of cpu.","AnswerCount":3,"Available Count":3,"Score":0.0665680765,"is_accepted":false,"ViewCount":1390,"Q_Id":10427900,"Users Score":1,"Answer":"You can always set your process affinity so it run on only one cpu. Use \"taskset\" command on linux, or process explorer on windows. \nThis way, you should be able to know if your script has same performance using one cpu or more.","Q_Score":1,"Tags":"python,multithreading,parallel-processing,cpu-usage","A_Id":10429302,"CreationDate":"2012-05-03T08:42:00.000","Title":"Stop Python from using more than one cpu","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},{"Question":"I have a problem when I run a script with python. I haven't done any parallelization in python and don't call any mpi for running the script. I just execute \"python myscript.py\" and it should only use 1 cpu.\nHowever, when I look at the results of the command \"top\", I see that python is using almost 390% of my cpus. I have a quad core, so 8 threads. I don't think that this is helping my script to run faster. So, I would like to understand why python is using more than one cpu, and stop it from doing so.\nInteresting thing is when I run a second script, that one also takes up 390%. If I run a 3rd script, the cpu usage for each of them drops to 250%. I had a similar problem with matlab a while ago, and the way I solved it was to launch matlab with -singlecompthread, but I don't know what to do with python.\nIf it helps, I'm solving the Poisson equation (which is not parallelized at all) in my script.\n\nUPDATE:\nMy friend ran the code on his own computer and it only takes 100% cpu. I don't use any BLAS, MKL or any other thing. I still don't know what the cause for 400% cpu usage is.\nThere's a piece of fortran algorithm from the library SLATEC, which solves the Ax=b system. That part I think is using a lot of cpu.","AnswerCount":3,"Available Count":3,"Score":0.0665680765,"is_accepted":false,"ViewCount":1390,"Q_Id":10427900,"Users Score":1,"Answer":"Could it be that your code uses SciPy or other numeric library for Python that is linked against Intel MKL or another vendor provided library that uses OpenMP? If the underlying C\/C++ code is parallelised using OpenMP, you can limit it to a single thread by setting the environment variable OMP_NUM_THREADS to 1:\nOMP_NUM_THREADS=1 python myscript.py\nIntel MKL for sure is parallel in many places (LAPACK, BLAS and FFT functions) if linked with the corresponding parallel driver (the default link behaviour) and by default starts as many compute threads as is the number of available CPU cores.","Q_Score":1,"Tags":"python,multithreading,parallel-processing,cpu-usage","A_Id":10445816,"CreationDate":"2012-05-03T08:42:00.000","Title":"Stop Python from using more than one cpu","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},{"Question":"Is there a built in way to save the pylint report to a file? It seems it might be useful to do this in order to log progress on a project and compare elements of reports across multiple files as changes are made.","AnswerCount":2,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":11281,"Q_Id":10439481,"Users Score":12,"Answer":"You can redirect its output in your shell using > somefile.txt\nIn case it writes to stderr, use 2>&1 > somefile.txt","Q_Score":11,"Tags":"python,pylint","A_Id":10439541,"CreationDate":"2012-05-03T21:20:00.000","Title":"save pylint message to 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":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"There are a lot of questions and answers on how to parse\/create config files in python and C++ individually. In my case, I have one single config file and need to be processed (read\/write) by both python and C++. \nIn python world, ConfigParser is popular; while in C++, libconfig looks nice. But they are using different formats. What I am looking for is a stone being able to kill two birds at the same time. :)","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":404,"Q_Id":10440924,"Users Score":2,"Answer":"An obvious solution that comes to mind is to go with something along the lines of YAML or JSON which you should find support for across many languages.","Q_Score":1,"Tags":"c++,python,configuration","A_Id":10441128,"CreationDate":"2012-05-03T23:53:00.000","Title":"Config File Process in Python and 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},{"Question":"I was looking for a Whois Api, but most of them charge heavy price and not reliable enough. We can code in Python or Php.\nWe need to make a Whois lookup service, to integrate with our site. What AWS Resource we need for this? We need at least 5k lookups per day.\nAWS provides: S3 , elastic, and others. We are confused. As Amazon provides free tire. Does it allow who is lookup? As google app engine never allowed this.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":766,"Q_Id":10447970,"Users Score":0,"Answer":"The Amazon service you want to use is the server service: EC2.\nYou get full access to a server and, of course, you can performs socket connections on port 43 (the one required by the Whois protocol).","Q_Score":1,"Tags":"php,python,amazon-web-services,whois","A_Id":10679625,"CreationDate":"2012-05-04T11:30:00.000","Title":"Amazon AWS For Whois?","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},{"Question":"I have a problem where it is beneficial for me to be able to mix python code and C++ code, and I think that the task is simple enough that it could be done by simply initializing the C++ program from python, and then having the C++ program \"wait\" for python to give it some input via std in, and then have python \"wait\" for the C++ program do its computation and return it via std out etc. \nI feel like this is either trivial or extremely extremely hard. My main problem is that each time I initialize the C++ code it takes an extremely long time, but that would only need to be done once if I can get this idea implemented. Any thoughts?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":314,"Q_Id":10453841,"Users Score":0,"Answer":"Sounds like SWIG might be what you're looking for. Use it to generate an extension module for Python, then call your C++ methods from a Python script.","Q_Score":0,"Tags":"c++,python,stdout,stdin","A_Id":10453984,"CreationDate":"2012-05-04T17:58:00.000","Title":"Mixing python and C++ via std in and std out","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},{"Question":"I have a problem where it is beneficial for me to be able to mix python code and C++ code, and I think that the task is simple enough that it could be done by simply initializing the C++ program from python, and then having the C++ program \"wait\" for python to give it some input via std in, and then have python \"wait\" for the C++ program do its computation and return it via std out etc. \nI feel like this is either trivial or extremely extremely hard. My main problem is that each time I initialize the C++ code it takes an extremely long time, but that would only need to be done once if I can get this idea implemented. Any thoughts?","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":314,"Q_Id":10453841,"Users Score":0,"Answer":"Look at the the Submodule library. You can use Submodule.popen() to create a process from python, using stdin=PIPE and stdout=PIPE. You can then read from the C++ program's stdout and write to its stdin.","Q_Score":0,"Tags":"c++,python,stdout,stdin","A_Id":10454012,"CreationDate":"2012-05-04T17:58:00.000","Title":"Mixing python and C++ via std in and std out","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},{"Question":"I have some python code which runs every 10 minutes or so. It reads in data, does some processing and produces an output. I'd like to change this so the it runs continuously. \nIs python well suited for running as a server (asin running continuously) or would I be better off converting my application to use c++? If I leave it in python, are there any modules you would reccomend for achieving this? \nThanks","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":160,"Q_Id":10460601,"Users Score":1,"Answer":"Python can use as a server application. I can remember many web and ftp servers written in python. See in threading library for threads.","Q_Score":1,"Tags":"c++,python","A_Id":10460624,"CreationDate":"2012-05-05T09:37:00.000","Title":"Using python as a 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":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Twitter, Facebook and some other websites are blocked in my country.\nAnd I want to call the open API to do some hacking. I have searched but it can't solve my \nproblem. Any python libraries can help me sign the OAuth request through proxy and get \nthe access token ? \nThanks.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":771,"Q_Id":10483013,"Users Score":0,"Answer":"I am guessing you will have to set up your own proxy service for this, i.e set up your entire API and OAuth logic on a server outside your own country. If you call this proxy service from within your own country it is probably not apparent that you are actually communicating with Twitter. \nYou will need some sort of cryptographic layer between your client and your proxy\/relay service though to make it somewhat secure\/obscure. Your own request signing mechanism so to say, and your proxy\/relay endpoint should definitely talk (HTTPS\/SSL).","Q_Score":0,"Tags":"python,oauth,proxy","A_Id":10496221,"CreationDate":"2012-05-07T13:33:00.000","Title":"How can I sign OAuth with 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},{"Question":"When I import the wx module in a python interpreter it works as expect. However, when I run a script (ie. test.py) with wx in the imports list, I need to write \"python test.py\" in order to run the script. If I try to execute \"test.py\" I get an import error saying there is no module named \"wx\". Why do I need to include the word python in my command?\nPS the most helpful answer I found was \"The Python used for the REPL is not the same as the Python the script is being run in. Print sys.executable to verify.\" but I don't understand what that means.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":383,"Q_Id":10489126,"Users Score":0,"Answer":"If you start your script with something like #!\/usr\/local\/bin\/python (but using the path to your python interpreter) you can run it without including python in your command, like a bash script.","Q_Score":1,"Tags":"python,import,module,wxwidgets","A_Id":10489311,"CreationDate":"2012-05-07T21:05:00.000","Title":"importing the wx module 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},{"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},{"Question":"My actual work is to find mood of song i.e. either a sad song or a\nhappy song. I try to find frequencies of mp3 file with fft but it just\ngive the frequencies of small files, like ringtone. Can you guide me\nwhich audio feature, such as pitch, timbre, loudness, tempo, could be\nuse to find mood of a songs which are in current playlist? And is it\nneccessary for this to find frequencies?\nAnd I am working in python 2.6 with module tkinter.","AnswerCount":2,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":3877,"Q_Id":10512569,"Users Score":4,"Answer":"Here's one way - find the lyrics on the web and train a classifier to determine if the lyrics are sad or happy. Even if you wont get good enough accuracy this way you could use it as part of the solution in conjunction with the harmony\/melody analysis.","Q_Score":0,"Tags":"python,python-2.6","A_Id":10512800,"CreationDate":"2012-05-09T08:38:00.000","Title":"How to find mood from 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":0,"Web Development":0},{"Question":"I have a function(say method1) imports hashmap in a python file (say file1.py) and it invokes another method (say method2) in another py file (file2.py) not having the import but method2 uses hashmap. When method1 is invoked inside WLST.sh, no problem. But when I invoke it as $MW_HOME\/oracle_common\/bin\/wlst.sh file1.py\nNameError: HashMap\nNote: I can't modify file2.py as it already shipped to customer.\nThanks,\nAshok","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":165,"Q_Id":10512965,"Users Score":0,"Answer":"When the name of the variable used to do something like print or use in some other expression without assigning the value for the variable before it was defined then WLST\/Python will raises NameError.\nCheck that your HashMap varialbe assigned with value and then sent for other Python script.","Q_Score":0,"Tags":"python,jython,wlst","A_Id":11896984,"CreationDate":"2012-05-09T09:06:00.000","Title":"Package importing issue in jython 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},{"Question":"I have a problem when running some python scripts. I get the message 'Ran 0 tests in 0.000s'.\nThis occured out of know where. Soem scripts still do work however. I can't find any difference between the scripts as why some should run and some don't. \nI've done a bit of research and 'unittest' seems to be a common theme. As far as I know I dind't change my code and I've included import unittest.\nI don't feel there is a need to post my code as there's no difference (except for the name odf the file) between the scripts that run and the scripts that don't run.\nAny ideas?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":196,"Q_Id":10517696,"Users Score":0,"Answer":"You are running them as unittests instead of normally. Are you using Eclipse? You're probably pressing the wrong button.","Q_Score":0,"Tags":"python,selenium","A_Id":10517715,"CreationDate":"2012-05-09T14:00:00.000","Title":"Python Scripts no longer run","Data Science and Machine Learning":0,"Database and SQL":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},{"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},{"Question":"I'm running Windows 7 64bit as my Host OS and Debian AMD64 as my Guest OS. On my Windows machine a folder called www is mounted on Debian under \/home\/me\/www.\nI have no problem installing Plone on Debian (the guest OS) with the unified installer. However, when I try to change the default install path from \/home\/me\/Plone to \/home\/me\/www\/plone, the installation always fails because Python fails to install. In the install.log it says \nln: failed to create hard link 'python' => 'python2.6': Operation not permitted\nIt looks like it might have something to do with access permissions, but I have tried to run the install script either using sudo or as a normal user, none of it helps. The script installs fine elsewhere, just not in the shared folder in Virtualbox. \nAny suggestions?\nMore Information: I don't have a root account on Debian (testing, System Python version is 2.7) and always use sudo.","AnswerCount":2,"Available Count":2,"Score":0.2913126125,"is_accepted":false,"ViewCount":419,"Q_Id":10524564,"Users Score":3,"Answer":"I've done some experimenting with VirtualBox recently. It's great, but I'm pretty sure that the shared folders are going to be limited to what's supported by the host operating system. Windows doesn't have anything like hard or symbolic links.\nI suspect that you're trying to do this so that you can edit instance files out of the shared directory with host tools. You might be able to pull this off by installing to non-shared files, then copying the critical parts (like the src directory if you're doing this for development purposes) to a host directory, and then (and only then) establishing that existing host directory as a shared directory.\nIf you try it, let us know how it works!","Q_Score":2,"Tags":"python,debian,plone,virtualbox,zope","A_Id":10527263,"CreationDate":"2012-05-09T21:47:00.000","Title":"Can't Install Plone on VirtualBox Shared Folder because Python Fails to 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":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I'm running Windows 7 64bit as my Host OS and Debian AMD64 as my Guest OS. On my Windows machine a folder called www is mounted on Debian under \/home\/me\/www.\nI have no problem installing Plone on Debian (the guest OS) with the unified installer. However, when I try to change the default install path from \/home\/me\/Plone to \/home\/me\/www\/plone, the installation always fails because Python fails to install. In the install.log it says \nln: failed to create hard link 'python' => 'python2.6': Operation not permitted\nIt looks like it might have something to do with access permissions, but I have tried to run the install script either using sudo or as a normal user, none of it helps. The script installs fine elsewhere, just not in the shared folder in Virtualbox. \nAny suggestions?\nMore Information: I don't have a root account on Debian (testing, System Python version is 2.7) and always use sudo.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":419,"Q_Id":10524564,"Users Score":0,"Answer":"How about using Debian's mount --bind to mount specific Host folders to portions of the installation tree?","Q_Score":2,"Tags":"python,debian,plone,virtualbox,zope","A_Id":10543865,"CreationDate":"2012-05-09T21:47:00.000","Title":"Can't Install Plone on VirtualBox Shared Folder because Python Fails to 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":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I just started looking into ctypes and was a little curious on how they work. How does it compare speed wise to the regular C implementation? Will using ctypes in a python program speed it up or slow it down is basically what I am wondering. Thanks!","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":1191,"Q_Id":10543992,"Users Score":2,"Answer":"there is no \"regular C implementation\" in most cases. Python data structures are one to three order of magnitudes higher level.\nTo answer you question \"how fast are ctypes in python?\" - the answer is \"pretty fast\".\nlook at numpy for an idea of it.","Q_Score":1,"Tags":"python,python-2.7,ctypes","A_Id":10544224,"CreationDate":"2012-05-11T00:46:00.000","Title":"How fast are ctypes 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},{"Question":"I just started looking into ctypes and was a little curious on how they work. How does it compare speed wise to the regular C implementation? Will using ctypes in a python program speed it up or slow it down is basically what I am wondering. Thanks!","AnswerCount":2,"Available Count":2,"Score":-0.0996679946,"is_accepted":false,"ViewCount":1191,"Q_Id":10543992,"Users Score":-1,"Answer":"If speed is only concern don't use Python, PHP, Perl or other scripting language. Write whatever in C or Assembly. Since these scripting languages are fast enough to build Google, Facebook and Amazon, you will find that they are fast enough for whatever you are thinking about.","Q_Score":1,"Tags":"python,python-2.7,ctypes","A_Id":10544690,"CreationDate":"2012-05-11T00:46:00.000","Title":"How fast are ctypes 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},{"Question":"I have a python CGI script which takes form input x andy (integers) and passes it to a C++ executable using subprocess in which the program writes the sum of the two values to a text file.\nThe code works fine on my local machine. However, after much testing ,I found that whenever I run this program on my server (in \/var\/www) and attempt to write the file some kind of error occurs because I get the \"Internal Server Error\" page.\nThe server is not mine and so I do not actually have sudo privileges. But from putty, I can manually run the executable, and it indeed writes the file.\nMy guess is I have to somehow run the executable from the python script with some amount of permission, but I'm not sure. I would appreciate any suggestions!\nEDIT:\n@gnibbler: Interesting, I was able to write the file to the \/tmp directory with no problem. \nSo I think your suggestions are correct and the server simply won't allow me to write when calling the script from the browser.\nAlso, I cannot access the directory with the error logs, so I will have try to get permission for that.","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":1569,"Q_Id":10550858,"Users Score":1,"Answer":"Either the environment is different (maybe it's trying to write to the wrong dir) or more likely, the cgi isn't running as the same user that you are logging in as.\nFor example, it's fairly common for cgi scripts to be executed as \"nobody\" or \"www\" etc.\nYou could try getting the cgi to write a file into \/tmp. That should at least confirm the user the cgi is running as","Q_Score":1,"Tags":"python,linux,cgi,subprocess","A_Id":10550999,"CreationDate":"2012-05-11T11:56:00.000","Title":"Unable to write to file programmatically on linux 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":1,"Web Development":0},{"Question":"I'm writing a script, to help me do some repetitive testing of a bunch of URLs.\nI've written a python method in the script that it opens up the URL and sends a get request. I'm using Requests: HTTP for Humans -http:\/\/docs.python-requests.org\/en\/latest\/- api to handle the http calls. \nThere's the request.history that returns a list of status codes of the directs. I need to be able to access the particular redirects for those list of 301s. There doesn't seem to be a way to do this - to access and trace what my URLS are redirecting to. I want to be able to access the redirected URLS (status code 301) \nCan anyone offer any advice?\nThanks","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":1706,"Q_Id":10560005,"Users Score":1,"Answer":"Okay, I'm so silly. Here's the answer I was looking for \nr = requests.get(\"http:\/\/someurl\")\nr.history[1].url will return the URL","Q_Score":1,"Tags":"python,module,urllib2,httplib","A_Id":10569571,"CreationDate":"2012-05-12T00:10:00.000","Title":"Python trace URL get requests - 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":0,"Web Development":0},{"Question":"I wanted to change interpreter to IronPython in Visual Studio 2010 with Python Tools for Visual Studio. Last time I hadn't problems with this I got CPython and IronPython on list but now IronPython magically disappeared. After this I tried to restore it and done this:\n\nI reinstalled PTVS, this still didn't helped\nI reinstalled IronPython in system and still nothing\n\nSo I thought to add this entry manual but I don't know what should I enter there. I can still create project in IronPython and IntelliSense properly suggest me assembles.\nCould you show me how to force PTVS to rescan to look for IronPython or what should I enter to add this entry manually.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":853,"Q_Id":10567766,"Users Score":1,"Answer":"You probably are running the latest version of IronPython and re-installed PTVS. PTVS currently installs IronPython support conditionally on whether or not it detects that IronPython is installed. Something changed in the latest version of IronPython and the PTVS installer fails to detect that IronPython is installed. \nThe good news is you can manually select to install IronPython support. First un-install, then start the installer and on the very first screen there's an Advanced button. Click on that and when the feature tree comes up change IronPython support to be installed.\nWe've changed this for 1.5 so we'll always install IronPython support by default, so in the future this won't be an issue.","Q_Score":2,"Tags":"visual-studio-2010,visual-studio,ironpython,ptvs","A_Id":10568603,"CreationDate":"2012-05-12T22:09:00.000","Title":"PTVS doesn't detect IronPython installation","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Ok, I recently installed Python27 with macports, but something happened and I created a mess. So I uninstalled it with sudo port uninstall --follow-dependents python27. Then I reinstalled it, did sudo port select --set python python27. All successful up to this point. But now I go to run python, and I get an error:\nImportError: No module named site\nAny ideas? It's been driving me crazy for the past hour. \nMac OS X Lion \/ Python 2.7 \/ MacPorts","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":3480,"Q_Id":10576151,"Users Score":1,"Answer":"The proper solution for this problem was to make it sure your PYTHONHOME environment variable is set correctly. You will receive this error if PYTHONHOME is pointing to invalid location or to another Python installation you are trying to run.","Q_Score":1,"Tags":"python,macports","A_Id":12093366,"CreationDate":"2012-05-13T23:55:00.000","Title":"ImportError: No module named site - Python27 - MacPorts","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Ok, I recently installed Python27 with macports, but something happened and I created a mess. So I uninstalled it with sudo port uninstall --follow-dependents python27. Then I reinstalled it, did sudo port select --set python python27. All successful up to this point. But now I go to run python, and I get an error:\nImportError: No module named site\nAny ideas? It's been driving me crazy for the past hour. \nMac OS X Lion \/ Python 2.7 \/ MacPorts","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":3480,"Q_Id":10576151,"Users Score":0,"Answer":"I had this problem and in the end it turned out to be to do with permissions.\nStupid mac-ports did something, not quite sure what, but I applied sudo chmod -R a+x $PYTHONPATH (which basically makes all files beneath $PYTHONPATH executable by everyone).\nIt's a nasty, and perhaps dangerous fix from a security perspective, but at this stage I just want to get it to work!","Q_Score":1,"Tags":"python,macports","A_Id":25899137,"CreationDate":"2012-05-13T23:55:00.000","Title":"ImportError: No module named site - Python27 - MacPorts","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I would like to use an expect-like module in python3. As far as I know, neither pexpect nor fabric work with python3. Is there any similar package I can use? (If no, does anyone know if py3 support is on any project's roadmap?)\nA perfectly overlapping feature set isn't necessary. I don't think my use case is necessary here, but I'm basically reimplementing a Linux expect script that does a telnet with some config-supplied commands, but extending functionality.","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":1916,"Q_Id":10603596,"Users Score":2,"Answer":"Happily, pexpect now supports python 3 (as of 2013 if not earlier). \nIt appears that @ThomasK has been able to add his pexpect-u Python 3 functionality (with some API changes) back into the main project. (Thanks Thomas!)","Q_Score":10,"Tags":"python,python-3.x,expect,fabric,pexpect","A_Id":23901161,"CreationDate":"2012-05-15T15:04:00.000","Title":"Is there an implementation of 'expect' or an expect-like library that works in 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":0,"Web Development":0},{"Question":"I have made a python ladon webservice and I run is on Ubuntu with Apache2 and mod_wsgi. (I use Python 2.6).\nThe webservice connect to a postgreSQL database with psycopg2 python module.\nMy problem is that the psycopg2.connection is closed (or destroyed) automatically after a little time (after about 1 or 2 minutes). \nThe other hand if I run the server with\nladon2.6ctl testserve\ncommand (http:\/\/ladonize.org\/index.php\/Python_Configuration)\nthan the server is working and the connection is not closed automatically.\nI can't understand why the connection is closed with apache+mod_wsgi and in this case the webserver is very slowly.\nCan anyone help me?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":450,"Q_Id":10636409,"Users Score":1,"Answer":"If you are using mod_wsgi in embedded moe, especially with preform MPM for Apache, then likely that Apache is killing off the idle processes. Try using mod_wsgi daemon mode, which keeps process persistent and see if it makes a difference.","Q_Score":0,"Tags":"python,web-services,apache2,mod-wsgi,psycopg2","A_Id":10645670,"CreationDate":"2012-05-17T13:12:00.000","Title":"Python psycopg2 + mod_wsgi: connection is very slow and automatically close","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},{"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},{"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},{"Question":"I use Tornado as the web server. I write some daemons with Python, which run in the server hardware. Sometimes the web server needs to send some data to the daemon and receives some computed results. There are two working:\n1. Asynchronous mode: the server sends some data to the daemons, and it doesn't need the results soon. Can I use message queue to do it perfectly?\n2. Synchronous mode: the server sends data to the daemons, and it will wait until it get the results. Should Iuse sockets?\nSo what's the best way of communication between tornado and Python based daemon?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":732,"Q_Id":10666877,"Users Score":0,"Answer":"Depending on the scale - the simple thing is to just use HTTP and the AsyncHTTPClient in Tornado. For the request<->response case in our application we're going 300 connections\/second with such an approach. \nFor the first case Fire and forget, you could also use AsyncHTTP and just have the server close out the connection and continue working...","Q_Score":1,"Tags":"python,sockets,tornado","A_Id":10667711,"CreationDate":"2012-05-19T16:15:00.000","Title":"What's the best way of communication between tornado and Python based 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":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I'm using isotoma.buildout.autodevelop to develop eggs which I'm currently developing within my buildout.\nI would like to include these developed eggs (which are located on the filesystem next to my buildout.cfg) as namespaces in my buildout's custom interpreter. \nCan anyone provide an example of this or link to some resource ?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":143,"Q_Id":10669497,"Users Score":0,"Answer":"A) The mr.developer recipe mentioned on your recipe's page is probably a better choice. \nB) you want your eggs in bin\/python? Include them in 'eggs' in your zc.recipe.eggs part in your buildout where you generate bin\/python.","Q_Score":0,"Tags":"python,buildout","A_Id":10678298,"CreationDate":"2012-05-19T23:05:00.000","Title":"Including a locally developed python package in a buildout 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":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I'm attempting to get eclipse running as something more powerful than a colored text editor so that I can do some Maya scripting. There's literally nothing fancy about this setup, it just doesn't keep my interpreter once the prefs window is closed. \nI can open and view .py docs fine, but pydev will not keep the interpreter I give it. As soon as I save the prefs with vanilla python.exe chosen as the interpreter, eclipse loses it. Opening the prefs again will show a blank interpreter page. \nAuto config used to work before I started mucking with settings. I had the same disappearing problem even though Autoconfig could find everything. \nc:\\Python27 is set in my PYTHONPATH for user and system variables. \nI've tried 32 and 64bit python (running win7 64). I was using Aptana with pydev and it seemed to not complain for a while, but then the interpreter went awol and I tried Eclipse to fix it. I can't start an actual project due to the missing interpreter, and the large \"help\" box that pops up when I'm typing is slowing me down considerably. \nEclipse 3.7.2\nPython 2.7.2\nPydev 2.5\nThanks for your help, I'm pretty green at this.","AnswerCount":5,"Available Count":4,"Score":0.0399786803,"is_accepted":false,"ViewCount":2628,"Q_Id":10670576,"Users Score":1,"Answer":"I've been wresting with this problem all evening and just now solved it for me. My problem was with a workspace saved in Google Drive, but where Drive had created a lot of files with a (1) before the first period in the .metadata folder, presumably as a conflict resolution thing.\nUsing File Commander (the search in Windows 7 ignored the parenthesis ?!) I searched for all the files containing (1) and delted them. (It should be said I made a copy of the folder first and opened it as a workspace to experiment on, as I've never figured out how to import a project once the workspace is lost.)\nIn my case, it worked like a charm. Now I'm going to be very nervous about having Eclipse open on both coding machines at once. We'll see how it goes from here.","Q_Score":3,"Tags":"python,eclipse,installation,pydev,interpreter","A_Id":20319027,"CreationDate":"2012-05-20T03:27:00.000","Title":"Eclipse + Pydev wont keep interpreter setting within the same 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":1,"Web Development":0},{"Question":"I'm attempting to get eclipse running as something more powerful than a colored text editor so that I can do some Maya scripting. There's literally nothing fancy about this setup, it just doesn't keep my interpreter once the prefs window is closed. \nI can open and view .py docs fine, but pydev will not keep the interpreter I give it. As soon as I save the prefs with vanilla python.exe chosen as the interpreter, eclipse loses it. Opening the prefs again will show a blank interpreter page. \nAuto config used to work before I started mucking with settings. I had the same disappearing problem even though Autoconfig could find everything. \nc:\\Python27 is set in my PYTHONPATH for user and system variables. \nI've tried 32 and 64bit python (running win7 64). I was using Aptana with pydev and it seemed to not complain for a while, but then the interpreter went awol and I tried Eclipse to fix it. I can't start an actual project due to the missing interpreter, and the large \"help\" box that pops up when I'm typing is slowing me down considerably. \nEclipse 3.7.2\nPython 2.7.2\nPydev 2.5\nThanks for your help, I'm pretty green at this.","AnswerCount":5,"Available Count":4,"Score":0.0,"is_accepted":false,"ViewCount":2628,"Q_Id":10670576,"Users Score":0,"Answer":"I had the same problem in fedora, disappearing interpreter settings. The issue was Eclipse couldn't write to the folder even after granting read+write access.\nSolution: Go to terminal and type: sudo eclipse\nenter admin password to run as admin. Solved","Q_Score":3,"Tags":"python,eclipse,installation,pydev,interpreter","A_Id":24027445,"CreationDate":"2012-05-20T03:27:00.000","Title":"Eclipse + Pydev wont keep interpreter setting within the same 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":1,"Web Development":0},{"Question":"I'm attempting to get eclipse running as something more powerful than a colored text editor so that I can do some Maya scripting. There's literally nothing fancy about this setup, it just doesn't keep my interpreter once the prefs window is closed. \nI can open and view .py docs fine, but pydev will not keep the interpreter I give it. As soon as I save the prefs with vanilla python.exe chosen as the interpreter, eclipse loses it. Opening the prefs again will show a blank interpreter page. \nAuto config used to work before I started mucking with settings. I had the same disappearing problem even though Autoconfig could find everything. \nc:\\Python27 is set in my PYTHONPATH for user and system variables. \nI've tried 32 and 64bit python (running win7 64). I was using Aptana with pydev and it seemed to not complain for a while, but then the interpreter went awol and I tried Eclipse to fix it. I can't start an actual project due to the missing interpreter, and the large \"help\" box that pops up when I'm typing is slowing me down considerably. \nEclipse 3.7.2\nPython 2.7.2\nPydev 2.5\nThanks for your help, I'm pretty green at this.","AnswerCount":5,"Available Count":4,"Score":0.0399786803,"is_accepted":false,"ViewCount":2628,"Q_Id":10670576,"Users Score":1,"Answer":"I had the same issue. This is how I solved it:\n\nGo to your workspace folder.\nEdit the file \".pydevproject\".\nChange the path located after \"PYTHON_PROJECT_INTERPRETER\" pydev property.\nSave and you're good to go.","Q_Score":3,"Tags":"python,eclipse,installation,pydev,interpreter","A_Id":27167729,"CreationDate":"2012-05-20T03:27:00.000","Title":"Eclipse + Pydev wont keep interpreter setting within the same 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":1,"Web Development":0},{"Question":"I'm attempting to get eclipse running as something more powerful than a colored text editor so that I can do some Maya scripting. There's literally nothing fancy about this setup, it just doesn't keep my interpreter once the prefs window is closed. \nI can open and view .py docs fine, but pydev will not keep the interpreter I give it. As soon as I save the prefs with vanilla python.exe chosen as the interpreter, eclipse loses it. Opening the prefs again will show a blank interpreter page. \nAuto config used to work before I started mucking with settings. I had the same disappearing problem even though Autoconfig could find everything. \nc:\\Python27 is set in my PYTHONPATH for user and system variables. \nI've tried 32 and 64bit python (running win7 64). I was using Aptana with pydev and it seemed to not complain for a while, but then the interpreter went awol and I tried Eclipse to fix it. I can't start an actual project due to the missing interpreter, and the large \"help\" box that pops up when I'm typing is slowing me down considerably. \nEclipse 3.7.2\nPython 2.7.2\nPydev 2.5\nThanks for your help, I'm pretty green at this.","AnswerCount":5,"Available Count":4,"Score":0.0399786803,"is_accepted":false,"ViewCount":2628,"Q_Id":10670576,"Users Score":1,"Answer":"I encountered this problem, and the issue was that .project and .pydevproject were read only and Eclipse couldn't save the configurations.\nSolution: make .project and .pydevproject writable.","Q_Score":3,"Tags":"python,eclipse,installation,pydev,interpreter","A_Id":56161921,"CreationDate":"2012-05-20T03:27:00.000","Title":"Eclipse + Pydev wont keep interpreter setting within the same 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":1,"Web Development":0},{"Question":"I'm writing an web app. Users can post text, and I need to store them in my DB as well as sync them to a twitter account. \nThe problem is that I'd like to response to the user immediately after inserting the message to DB, and run the \"sync to twitter\" process in background. \nHow could I do that? Thanks","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":56,"Q_Id":10673245,"Users Score":0,"Answer":"either you choose zrxq's solution, or you can do that with a thread, if you take care of two things: \n\nyou don't tamper with objects from the main thread (be careful of iterators),\nyou take good care of killing your thread once the job is done.\n\nsomething that would look like :\n\n import threading\n\n class TwitterThreadQueue(threading.Thread):\n queue = []\n\n def run(self):\n while len(self.queue!=0):\n post_on_twitter(self.queue.pop()) # here is your code to post on twitter\n\n def add_to_queue(self,msg):\n self.queue.append(msg)\n\nand then you instanciate it in your code :\n\ntweetQueue = TwitterThreadQueue()\n# ...\ntweetQueue.add_to_queue(message)\ntweetQueue.start() # you can check if it's not already started\n# ...","Q_Score":1,"Tags":"python","A_Id":10674012,"CreationDate":"2012-05-20T12:06:00.000","Title":"Sync message to twitter in background in a 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},{"Question":"I have a python program I wrote that I am trying to \"compile\" with py2exe, everything goes well and the executable is created. The first time I run the program I get this error:\nTraceback (most recent call last):\n File \"IMGui.py\", line 13, in \nImportError: No module named IMCrypt2\nI found that if I manually add my custom modules to \/lib\/shared.zip and run the program again, I get THIS error:\nTraceback (most recent call last):\n File \"IMGui.py\", line 13, in \nzipimport.ZipImportError: can't find module 'IMCrypt2'\nI have been doing some extensive googling, 2 solutions I've found on the web were to delete the 'dist' and 'build' folders and try again, and to add \"includes\":\"decimal\" to my options, but neither of these solutions have worked for me D=\nI'm using python 2.5 (I was using new version, but building with those were giving me other strange runtime errors, and the version I did successfully build on Windows 7 ONLY worked on Windows 7, so I'm trying again using Python 2.5 on Windows XP in an attempt to get a more 'universal' windows executable)\nI'm completely stumped! Any help would be greatly appreciated!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":2876,"Q_Id":10680724,"Users Score":1,"Answer":"I solved my own problem (kinda), I was able to avoid this error and successfully 'compile' my code by consolidating all my modules in to a single file, so that no custom modules were imported. It resulted in some super messy code, but it worked!","Q_Score":1,"Tags":"python,py2exe","A_Id":10716585,"CreationDate":"2012-05-21T06:59:00.000","Title":"zipimport.ZipImportError: can't find module from program made with py2exe","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":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},{"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},{"Question":"When developing macros in python for LibreOffice \/ OpenOffice on Linux at least, I've read that you have to place your py scripts in a particular directory. \nIs there a preferred method among Python LibreOffice\/OOo developers for deploying these scripts, or is there another way to specify within LibreOffice\/OOo to specify where you want these scripts to be?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":733,"Q_Id":10742188,"Users Score":1,"Answer":"Maybe a nice way to go is to get familiarized with Python setup tools itself (http:\/\/packages.python.org\/an_example_pypi_project\/setuptools.html), and write a proper setup.py script which would place all needed files in the appropriate dirs.\nYour macros could them even be installable with the \"easy_install\" Python framework","Q_Score":2,"Tags":"python,openoffice.org,libreoffice","A_Id":10743591,"CreationDate":"2012-05-24T17:10:00.000","Title":"Preferred method of \"deploying\" python scripts to LibreOffice during macro 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":1,"Web Development":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},{"Question":"I basically want to read a file (could be an mp3 file or whatever). Scan the file for all the used ASCII characters of the file and put them into an dictionary, array or list. And then from there assign each character a number value.\nFor example:\nLet's say I load in the file blabla.mp3\n(Obviously this type of file is encoded so it won't be just plain english characters.)\nThis is it's contents:\n\u2564d\u00ec\u00fa\u00faH\u00bb\u2553\u2552:\u03c6\u00ba\u00baMQ\u2564\u2564\u2564\u2564\u2524i\u2194\u2194\u2190GGG\u03a6\u2320i\u2190E::2E\u2524tti\u2190\u2559\u2564\u03a6\u03a6\u2320\u00b7:::::%F\u00e6\u2564\u2564:6\u00c5\u2320tSN\u2502\u00e8\u00eb\u00e5D\u00bf\u2562\u00c4\u00c4\u00c4\u00c4\u00c4\u00c4\u00c4\u00c4\u00c5O^\u2194:::.\u00c4\u00c4\u00c4\u00c4\u00c4\u00c4\u00e8H\u03a6\u03a6\u25a0\u00ef\u00bb\u00f3\u2310\u2559-\u2194\u2192E\u2524tttttttt}\u25b2\u00ee\u2564\u2564d\u00ec\"\u00dc:::)\u00fa$tm\u203c\u00ba\u2564\u2553q\u2564\u2559\u00b7:.\u00f1\u00c7\u00b0\"V\u251c\u2561\u03a6Pa\u21a8\/\u00fa\u00fa\u00fa\u00fa\u00fa\u00fa\u03a6\u255e\u00eeH\u03a6\u2551*\u00c4\u00e8\u00fa\u00f3\u03a6\u03a6\u03a6\u03a6\u00bbD\u03a6\u03a6\u00b7t\u0398\u25cb_N\u00ef\u00fak\u00ee\u25ba\"D\u00eb\u00dc)#\u00fa\u00bb\u2192\u00b7:4\u00c4\u00ef\u00fa\u00fa\u00fa\u00fa\u00fa\u00f3\u00bf\u2551:(\u00a0\u00a0\u00b7:\u00e7\u2191PR\"$RGH\u25c4\u25d8\u00fa\u00fa\u00f3\u00bf\u03a6\u03a6\u03a6\u03a6\u250c&H\u03a6\u03a6\u250c+\u2320W\u00baGG\u00a0\u2564m\u2192GF\u2558\u00b1\"\u00bf\u03a6\u00f1\u00ef\u00fa\u00fa\u00fa\u00f3\u03a6\u00f2\u21a8F\u00e6Ttt\u2553\u00ec\u00fa\u2320\u03a6\u03a6\u03a6\u2320z:::=:::::\u2265E\u2564\u2564\u2564\u2564\u2564\u2564\u2564Tm\u2194\u2194\u25acH\u00aa\u00e8i\u2320ztz:::tt\nI want to figure out what characters are being used and assign each one a value from 0 - 255 and each value will be unique to that character.\nSo \u2564 = 0; \u03a6 = 56; \u00fa = 25 etc etc etc\nNow I've been searching the python and java docs and I'm not so sure I know what I'm searching for. And I don't know if I should be worrying about ASCII characters or HEX or the raw bytes of the file.\nI just need someone to point me in the right direction. Any help?","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":417,"Q_Id":10748021,"Users Score":1,"Answer":"Each byte is a number from 0 to 255. An array containing those numbers is, precisely, an array containing the contents of the file. I'm not at all clear on what you want to do with this array (or dictionary, etc) but making it is going to be easy.","Q_Score":0,"Tags":"java,python","A_Id":10748050,"CreationDate":"2012-05-25T03:12:00.000","Title":"How can I bring all the used ASCII characters of a file into a dictionary\/array\/list and assign each character a value?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I basically want to read a file (could be an mp3 file or whatever). Scan the file for all the used ASCII characters of the file and put them into an dictionary, array or list. And then from there assign each character a number value.\nFor example:\nLet's say I load in the file blabla.mp3\n(Obviously this type of file is encoded so it won't be just plain english characters.)\nThis is it's contents:\n\u2564d\u00ec\u00fa\u00faH\u00bb\u2553\u2552:\u03c6\u00ba\u00baMQ\u2564\u2564\u2564\u2564\u2524i\u2194\u2194\u2190GGG\u03a6\u2320i\u2190E::2E\u2524tti\u2190\u2559\u2564\u03a6\u03a6\u2320\u00b7:::::%F\u00e6\u2564\u2564:6\u00c5\u2320tSN\u2502\u00e8\u00eb\u00e5D\u00bf\u2562\u00c4\u00c4\u00c4\u00c4\u00c4\u00c4\u00c4\u00c4\u00c5O^\u2194:::.\u00c4\u00c4\u00c4\u00c4\u00c4\u00c4\u00e8H\u03a6\u03a6\u25a0\u00ef\u00bb\u00f3\u2310\u2559-\u2194\u2192E\u2524tttttttt}\u25b2\u00ee\u2564\u2564d\u00ec\"\u00dc:::)\u00fa$tm\u203c\u00ba\u2564\u2553q\u2564\u2559\u00b7:.\u00f1\u00c7\u00b0\"V\u251c\u2561\u03a6Pa\u21a8\/\u00fa\u00fa\u00fa\u00fa\u00fa\u00fa\u03a6\u255e\u00eeH\u03a6\u2551*\u00c4\u00e8\u00fa\u00f3\u03a6\u03a6\u03a6\u03a6\u00bbD\u03a6\u03a6\u00b7t\u0398\u25cb_N\u00ef\u00fak\u00ee\u25ba\"D\u00eb\u00dc)#\u00fa\u00bb\u2192\u00b7:4\u00c4\u00ef\u00fa\u00fa\u00fa\u00fa\u00fa\u00f3\u00bf\u2551:(\u00a0\u00a0\u00b7:\u00e7\u2191PR\"$RGH\u25c4\u25d8\u00fa\u00fa\u00f3\u00bf\u03a6\u03a6\u03a6\u03a6\u250c&H\u03a6\u03a6\u250c+\u2320W\u00baGG\u00a0\u2564m\u2192GF\u2558\u00b1\"\u00bf\u03a6\u00f1\u00ef\u00fa\u00fa\u00fa\u00f3\u03a6\u00f2\u21a8F\u00e6Ttt\u2553\u00ec\u00fa\u2320\u03a6\u03a6\u03a6\u2320z:::=:::::\u2265E\u2564\u2564\u2564\u2564\u2564\u2564\u2564Tm\u2194\u2194\u25acH\u00aa\u00e8i\u2320ztz:::tt\nI want to figure out what characters are being used and assign each one a value from 0 - 255 and each value will be unique to that character.\nSo \u2564 = 0; \u03a6 = 56; \u00fa = 25 etc etc etc\nNow I've been searching the python and java docs and I'm not so sure I know what I'm searching for. And I don't know if I should be worrying about ASCII characters or HEX or the raw bytes of the file.\nI just need someone to point me in the right direction. Any help?","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":417,"Q_Id":10748021,"Users Score":0,"Answer":"Each byte you read in already is a value between 0 and 255 (thus a byte). Is there a reason you can't just use that?","Q_Score":0,"Tags":"java,python","A_Id":10748060,"CreationDate":"2012-05-25T03:12:00.000","Title":"How can I bring all the used ASCII characters of a file into a dictionary\/array\/list and assign each character a value?","Data Science and Machine Learning":0,"Database and SQL":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},{"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},{"Question":"Is it possible to execute python commands passed as strings using python -c? can someone give an example.","AnswerCount":2,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":42043,"Q_Id":10768584,"Users Score":55,"Answer":"You can use -c to get Python to execute a string. For example:\npython3 -c \"print(5)\"\nHowever, there doesn't seem to be a way to use escape characters (e.g. \\n). So, if you need them, use a pipe from echo -e or printf instead. For example:\n$ printf \"import sys\\nprint(sys.path)\" | python3","Q_Score":46,"Tags":"python","A_Id":30690444,"CreationDate":"2012-05-26T18:01:00.000","Title":"Execute python commands passed as strings in command line using python -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},{"Question":"I have written cgi script for the login page in python but I am not familiar with running the CGI script?Please help me by giving the steps to run the script?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":122,"Q_Id":10781998,"Users Score":0,"Answer":"Ask your Web host:\n1) for a simple \"hello, world\" script (in Python, I assume) that will work on their server 2) where you need to store the file (in the server file system) 3) what you need to name it (ex: index.py or .py or whatever) 4) what permissions the script file needs to have (ask them for a \"setfacl\" command you can use), and 5) what the URL will be that calls it\nIf any one of those things is even slightly wrong, your script will fail to run. If you get them all right, then your CGI script will return a \"Hello, world\" web page.\nAt that point, you modify your script a little bit at a time, testing it every step of the way, until it is doing what you want it to do.","Q_Score":0,"Tags":"python-3.x","A_Id":10809754,"CreationDate":"2012-05-28T09:04:00.000","Title":"Running the 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":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"If I import a module1.py from the python command line in windows 7 I see the corresponding module1.pyc file appear in the Python32\/pycache\/ folder. My understanding was that it is this bytecode which is executed by the Python interpreter, however I can delete the module1.pyc file and my module functions (module1.func1() etc...) can still be called from the command line. What is running when the functions are called but the .pyc file is not there? When the bytecode is compiled is it also copied to runtime memory for the Python shell?","AnswerCount":2,"Available Count":1,"Score":0.4621171573,"is_accepted":false,"ViewCount":905,"Q_Id":10785105,"Users Score":5,"Answer":"The bytecode is in memory while running the interpreter. The .pyc files are a cache for the next import of the code, so that python will not have to parse the code if it has not changed.","Q_Score":1,"Tags":"python,bytecode","A_Id":10785135,"CreationDate":"2012-05-28T13:00:00.000","Title":"How does Python run module code when there's no matching .pyc 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},{"Question":"What is the difference between calling sys.exit() and throwing an exception in Python?\nLet's say I have a Python script which does the following:\n\nopen a file\nread lines\nclose it\n\nIf the file doesn't exist or an IOException gets thrown at runtime, which of the options below makes more sense?\n\nno except\/catch of the exception, if exception occurs, it fails out (which is expected behaviour anyway)\nexcept\/catch the exception, logs the error message, throw customized exception by myself, fails out.\nin an except IOException block, exit with an error message e.g. sys.exit(\"something is wrong\")\n\nDoes option 3 kill the process while 1 and 2 do not? What's the best way to handle the Python exceptions given that Python doesn't have a checked exception like Java (I am really a Java developer ^_^)?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":8832,"Q_Id":10796821,"Users Score":21,"Answer":"sys.exit raises a SystemExit itself so from a purely technical point of view there's no difference between raising that exception yourself or using sys.exit. And yes you can catch SystemExit exceptions like any other exception and ignore it.\nSo it's just a matter of documenting your intent better.\nPS: Note that this also means that sys.exit is actually a pretty bad misnomer - because if you use sys.exit in a thread only the thread is terminated and nothing else. That can be pretty annoying, yes.","Q_Score":14,"Tags":"python,exception-handling","A_Id":10796924,"CreationDate":"2012-05-29T09:56:00.000","Title":"Difference between calling sys.exit() and throwing exception","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm going to be building web pages and web interfaces. So far I have been using LAMP stack with PHP. I want to shift to python. Which of the two Python versions (2.7 or 3.1) is better for this use?","AnswerCount":3,"Available Count":1,"Score":0.1325487884,"is_accepted":false,"ViewCount":670,"Q_Id":10811112,"Users Score":2,"Answer":"mod_wsgi didn't really work with 3.x until 3.2, so I'd stick with 2.7 for now.","Q_Score":0,"Tags":"python,python-3.x,lamp,python-2.x","A_Id":10811163,"CreationDate":"2012-05-30T06:36:00.000","Title":"Python 2.7 or 3.0 for LAMP","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm running Python 3.2 on Win XP. I run a python script thru a batch file via this:\nC:\\Python32\\python.exe test.py %1\n%1 is an argument that i pass to do some processing in the python script. \nI have 2 variables in the batch file that I also want to send as arguments to the python script.\nset $1=hey_hi_hello\nset $2=hey_hi\nI want to be able to do something like this if possible:\nC:\\Python32\\python.exe test.py %1 $1 $2\nAnd then retrieve these argiments in the python script via sys.argv[2] and sys.argv[3]\nWould appreciate any help with this. Thank you.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":45693,"Q_Id":10823033,"Users Score":0,"Answer":"Another option is to write arguments right after the python script, following the example:\npython your_script.py this that\nIf you are using Linux .sh file, remember to run dos2unix XXX.sh before you run:\nbash XXX.sh.\nThe reason, in a simple version, is that dos and unix use different newline breakers.","Q_Score":10,"Tags":"python,batch-file,windows-xp","A_Id":69202173,"CreationDate":"2012-05-30T19:34:00.000","Title":"Sending arguments from Batch file to 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},{"Question":"I'm working with an application where just about every module and every class emits logging messages.\nI need a way to capture every single one of those messages without explicitly attaching a handler via .addHandler() to each logging instance (which is what I'm doing right now).\nIs there any way to attach a handler to every logging instance at once?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1549,"Q_Id":10827751,"Users Score":3,"Answer":"logging uses a hierarchy of loggers. Add a handler to the root logger and it will receive logged messages from child loggers, too.\nTo access the root logger use logging.getLogger().","Q_Score":1,"Tags":"python,logging","A_Id":10827794,"CreationDate":"2012-05-31T05:09:00.000","Title":"Intercepting all logging messages","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I currently develop an application which is written in C++. For scripting purposes I use Python 3.2, which is fine -- on my developer machine with Python installed and all the DLLs in the right place.\nI deployed \"pure\" Python applications (i.e. without native code) before using the excellent py2exe, but I don't have a first clue how to deploy this with an embedded Python.\nFrom what my gut says I suppose the following components are necessary:\n\nPython3.dll & Python32.dll\nThe .pyd files from Python's \"DLLs\" directory\nThe Python library\n\nAnd the last point is what bothers me: How do I deploy that? That are a few thousand files and I don't really want to copy that around. Py2exe packs that into a zip-file, I guess I can do something like that in my case too?\nAnd, even more important: How do I tell the Python interpreter at run-time where he finds the library?","AnswerCount":3,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":2147,"Q_Id":10836259,"Users Score":3,"Answer":"From what I recall what you need to bundle depends on what your python scripts call or make use of. If you really only make use of the core intepreter I think you only need to bundle the dll.\nHaving said that, it shouldn't be too hard to test this on your development box by disabling any paths to your installed python and putting your app and the python dlls and libs into the same test folder.","Q_Score":5,"Tags":"c++,python,deployment,scripting,packaging","A_Id":10839045,"CreationDate":"2012-05-31T15:07:00.000","Title":"Deployment of application with embedded 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},{"Question":"I'm trying to get pylint to give html output when I run Validate syntax on a python file in TextMate. I installed pycheckmate, pylint, and created a .pylintrc file in $HOME that sets the output format to html.\nIn TextMate's Advanced control panel, in the Shell Variables tab, I have TM_PYCHECKER set to \/usr\/local\/share\/python\/pylint. If I trigger Validate Syntax, it runs pylint with all the default options, and gives me the output. If I change TM_PYCHECKER to \/usr\/local\/share\/python\/pylint --rcfile \"$HOME\/.pylintrc\" and Validate Syntax again, I get:\n\nPlease install PyChecker, PyFlakes or Pylint for more extensive code\n checking.\n\nIf I run \/usr\/local\/share\/python\/pylint from the commandline, without any arguments, the output is html, so I know in that case that it's reading the rcfile. What am I missing?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1057,"Q_Id":10836517,"Users Score":0,"Answer":"A somewhat educated guess: try replacing $HOME by the absolute path to your home directory. Shell variables like $HOME are probably not available to use in TextMate's control panel.\nUPDATE: Looking at the pycheckmate.py script included with the Python.tmbundle included with the version of TextMate I have, it appears that it is not possible to include arguments , like --rcfile \/path\/to\/rcfile. The value of TM_PYCHECKER is expected to only be the path to the checker binary with no arguments. But, if you make your own copy of the Python.tmbundle, you should be able to edit pycheckmate.py to do as you wish.","Q_Score":2,"Tags":"python,textmate,pylint","A_Id":10838327,"CreationDate":"2012-05-31T15:24:00.000","Title":"pylint ignores .pylintrc when run from TextMate","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I want to display visual\/auditory stimuli inside a web browser for psychophysic experiments. I plan on using python, but I am concerned with timing. I obviously can not rely on screen refresh for timing which is common in these types of tasks. How much can I hope for in terms of accuracy for timing on the web and what are the best tools to use with Python. I am thinking of using FastCGI\nI just want to hear peoples thoughts on this.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":296,"Q_Id":10858337,"Users Score":2,"Answer":"Do your timing in JS, save current time in ms on document.ready and then when user hits a key.\nBenchmark your test with either\n\nhigh-speed camera, or\ntest rig that \"hits\" a key, e.g. screen flash -> pohototransistor -> usb device -> virtual keyboard","Q_Score":2,"Tags":"python,web,fastcgi,timing,psychtoolbox","A_Id":10999764,"CreationDate":"2012-06-01T22:58:00.000","Title":"Achieving best timing online for psychophysics experiments using Python on the web","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},{"Question":"I have an open source PHP website and I intend to modify\/translate (mostly constant strings) it so it can be used by Japanese users.\nThe original code is PHP+MySQL+Apache and written in English with charset=utf-8\nI want to change, for example, the word \"login\" into Japanese counterpart \"\u30ed\u30b0\u30a4\u30f3\" etc\nI am not sure whether I have to save the PHP code in utf-8 format (just like Python)?\nI only have experience with Python, so what other issues I should take care of?","AnswerCount":3,"Available Count":2,"Score":0.1325487884,"is_accepted":false,"ViewCount":148,"Q_Id":10868473,"Users Score":2,"Answer":"If it's in the file, then yes, you will need to save the file as UTF-8.\nIf it's is in the database, you do not need to save the PHP file as UTF-8.\nIn PHP, strings are basically just binary blobs. You will need to save the file as UTF-8 so the correct bytes are read in. In theory, if you saved the raw bytes in an ANSI file, it would still be output to the browser correctly, just your editor would not display it correctly, and you would run the risk of your editor manipulating it incorrectly.\nAlso, when handling non-ANSI strings, you'll need to be careful to use the multi-byte versions of string manipulation functions (str_replace will likely botch a utf-8 string for example).","Q_Score":2,"Tags":"php,python,mysql,apache,utf-8","A_Id":10868488,"CreationDate":"2012-06-03T06:52:00.000","Title":"PHP for Python Programmers: UTF-8 Issues","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":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have an open source PHP website and I intend to modify\/translate (mostly constant strings) it so it can be used by Japanese users.\nThe original code is PHP+MySQL+Apache and written in English with charset=utf-8\nI want to change, for example, the word \"login\" into Japanese counterpart \"\u30ed\u30b0\u30a4\u30f3\" etc\nI am not sure whether I have to save the PHP code in utf-8 format (just like Python)?\nI only have experience with Python, so what other issues I should take care of?","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":148,"Q_Id":10868473,"Users Score":0,"Answer":"If the file contains UTF-8 characters then save it with UTF-8. Otherwise you can save it in any format. One thing you should be aware of is that the PHP interpreter does not support the UTF-8 byte order mark so make sure you save it without that.","Q_Score":2,"Tags":"php,python,mysql,apache,utf-8","A_Id":10868497,"CreationDate":"2012-06-03T06:52:00.000","Title":"PHP for Python Programmers: UTF-8 Issues","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":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"What is the best solution in python, to monitor CPU, memory, and bandwidth usage per domain?\nThis solution has to also work on multiple instances.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":3733,"Q_Id":10869472,"Users Score":1,"Answer":"CPU can be monitored by CloudWatch using the built-in metrics. For memory you can use custom metrics with the AWS command line tools or write powershell\/ruby scripts with the official AWS SDK.\nYou can monitor anything that's easily quantifiable using the AWS SDK. To monitor bandwidth usage per domain I'd recommend something like ntop.","Q_Score":4,"Tags":"python,amazon-ec2,amazon-web-services,amazon-cloudwatch","A_Id":11124827,"CreationDate":"2012-06-03T10:14:00.000","Title":"Monitor bandwidth, memory, cpu per domain on EC2","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},{"Question":"I want to implement an RSA cryptosystem algorithm for a university project and I' m trying to decide which programming language to use. I am very familiar with C so it would be a convenient choice. However, the algorithm will have to deal with very large numbers (it will include a Primality subroutine), and I have heard that using Python will result in a better implementation. Is that right? \nThank you in advance.","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":1059,"Q_Id":10871163,"Users Score":1,"Answer":"I don't know if Python will result in a \"better\" implementation, since better is rather subjective here. You can find numerical libraries for both that will allow you to deal with large numbers easily. Python has the advantage (imo) of having the numpy library which is very easy to read and use and is generally more human readable which often leads to easier debugging.","Q_Score":0,"Tags":"python,c,cryptography,rsa,primality-test","A_Id":10871183,"CreationDate":"2012-06-03T14:32:00.000","Title":"Suitable Language for RSA implementation","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to implement an RSA cryptosystem algorithm for a university project and I' m trying to decide which programming language to use. I am very familiar with C so it would be a convenient choice. However, the algorithm will have to deal with very large numbers (it will include a Primality subroutine), and I have heard that using Python will result in a better implementation. Is that right? \nThank you in advance.","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":1059,"Q_Id":10871163,"Users Score":0,"Answer":"Using a scripting language or any more high level language than C (e.g. C# or Java) will most likely be easier since you don't have to deal with memory management and other tasks not really related to your project.","Q_Score":0,"Tags":"python,c,cryptography,rsa,primality-test","A_Id":10871180,"CreationDate":"2012-06-03T14:32:00.000","Title":"Suitable Language for RSA implementation","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have read the documentation for this function, however, I dont think I understand it properly. If anyone can tell me what I'm missing, or if I am correct, it would be a great help. Here is my understanding:\nusing the shutil.rmtree(path) function, it will delete only the directory specified, not the entire path. IE:\nshutil.rmtree('user\/tester\/noob')\nusing this, it would only delete the 'noob' directory correct? not the complete path?","AnswerCount":4,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":91285,"Q_Id":10873364,"Users Score":83,"Answer":"If noob is a directory, the shutil.rmtree() function will delete noob and all files and subdirectories below it. That is, noob is the root of the tree to be removed.","Q_Score":56,"Tags":"python,python-2.7,shutil","A_Id":10873516,"CreationDate":"2012-06-03T19:40:00.000","Title":"shutil.rmtree() 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":1,"System Administration and DevOps":0,"Web Development":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},{"Question":"Is it possible to make a minimalistic operating system using Python?\nI really don't want to get into low-level code like assembly, so I want to use a simple language like Perl, Python. But how?","AnswerCount":4,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":76823,"Q_Id":10904721,"Users Score":11,"Answer":"I suggest you find a good textbook on operating system design, and study that. I'm pretty sure you won't find such a book with Python source code; C is more likely. (You might find an older textbook that uses Pascal instead of C, but it's really not that different.)\nOnce you have studied operating systems design enough to actually be able to write an operating system, you will know enough to have your own opinions on what languages would be suitable.","Q_Score":38,"Tags":"python,operating-system","A_Id":10905302,"CreationDate":"2012-06-05T20:49:00.000","Title":"Is it possible to create an operating 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":1,"System Administration and DevOps":1,"Web Development":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},{"Question":"While trying to understand what problem does OSGI solve in the java ecosystem ,i find myself wondering if there is such a problem in python as well ? if yes how it is solved , if no why ?","AnswerCount":1,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":908,"Q_Id":10911789,"Users Score":6,"Answer":"The purpose of OSGi is to write (reusable) active modules that can discover each other at runtime so that these modules can decide to collaborate. The primary mechanism is the service registry that acts as a simple broker for objects. \nA similar mechanism exists in JavaScript with the exports global variable. Unlike the JavaScript module systems, however, the OSGi service registry is dynamic.\nI am not aware of anything like this in Python. I think the need for something like OSGi arises in larger programs made with larger or diversified teams. An area that Java with its static typing is more suitable for. Especially since Java has a very strong focus on interface based design; in the eco system of Java\/OSGi you find many specifications and actually multiple implementations. In this world, a broker that matches implementations to specifications is important.\nI think Python, and for that matter Ruby, and other languages would greatly benefit from a service broker like OSGi.","Q_Score":4,"Tags":"java,python,osgi","A_Id":10928722,"CreationDate":"2012-06-06T09:46:00.000","Title":"is there a requirement in python similar to what osgi tries to solve 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":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a small python script that creates a graph of data pulled from MySQL. I'm trying to figure out a way to run the script in the background all time on a regular basis. I've tried a number of things:\n\nA Cron Job that runs the script\nA loop timer\nUsing the & command to run the script in the background\n\nThese all have there pluses and minuses:\n\nThe Cron Job running more then every half hour seems to eat up more resources then it's worth.\nThe Loop timer put into the script doesn't actually put the script in the background it just keeps it running.\nThe Linux & command backgrounds the process but unlike a real Linux service I can't restart\/stop it without killing it.\n\nCan someone point me to a way to get the best out of all of these methods?","AnswerCount":2,"Available Count":1,"Score":0.2913126125,"is_accepted":false,"ViewCount":7997,"Q_Id":10924309,"Users Score":3,"Answer":"The cron job is probably a good approach in general, as the shell approach requires manual intervention to start it. \nA couple of suggestions: \nYou could use a lock file to ensure that the cron job only ever starts one instance of the python script - often problems occur when using cron for larger jobs because it starts a second instance before the first instance has actually finished. You can do this simply by checking whether the lock file exists, then, if it does not, 'touch'ing the file at the beginning of the script and 'rm'ing it as your last action at the end of the script. If the lock file exists -- simply exit the script, as there is already one instance running. (Of course, if the script dies you will have to delete the lock file before running the script again).\nAlso, if excessive resource use is a problem, you can ensure that the script does not eat too many resources by giving it a low priority (prefix with, for example, nice -n 19).","Q_Score":2,"Tags":"python,linux,service","A_Id":10924388,"CreationDate":"2012-06-07T00:51:00.000","Title":"How can I run my python script in the background on a schedule?","Data Science and Machine Learning":0,"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},{"Question":"Is there a high-level IMAP library for Python?\nWith high-level I mean, that I do not want a library where I can issue basic IMAP commands (like Python's own imaplib). What I want, is library that cares about most of the IMAP details and gives me a more generic interface with objects for folders\/mailboxes and messages. Additionally, it would be nice if it supports the disconnected mode of operation (offline mode) transparently.","AnswerCount":5,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":3078,"Q_Id":10968541,"Users Score":0,"Answer":"To answer your question: What you're looking for doesn't exist in the wild AFAIK.\nShort of that, have you considered calling context.io from Python?","Q_Score":4,"Tags":"python,imap","A_Id":12879530,"CreationDate":"2012-06-10T12:07:00.000","Title":"High-Level IMAP library 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},{"Question":"I will be running a programming competition for high school students in the near future, and was originally going to use PC^2 (Programming Contest Control System) for the automated judging of the solutions. This software is commonly used in the ACM's International Collegiate Programming Contest regionals as well as the world finals. This is an excellent system which I have used before, but one of its pitfalls is its language support (Java, C, and C++). I'm a little bit concerned, as not all high school students who may be attending will have exposure to any of these languages. However, many local high schools teach introductory programming courses in Python. Is there an equivalent system to PC^2 which has Python support?","AnswerCount":5,"Available Count":1,"Score":-0.0399786803,"is_accepted":false,"ViewCount":1041,"Q_Id":10970042,"Users Score":-1,"Answer":"It's simpler than one may think. The following is for pc2 9.2.3-2565\nAdd language as follows (python here as an example):\nDisplay Name: Python\nCompile Cmd Line: touch OK\nExecutable Filename: OK\nProgram Execution Command Line: python {:mainfile}\npython3.3 or python3.4 will work too. \npc2 could be easier, of course, but there does not seem to be much support left at CSUS. Reseting contest would be even greater feature; the current need to clone directories for test, practice, and actual contest is very awkward. Better management of the database (like the ability to remove things) would make it into a great tool. It is alright, but it could be great.","Q_Score":0,"Tags":"python","A_Id":23380402,"CreationDate":"2012-06-10T15:43:00.000","Title":"PC^2 equivalent compatible 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},{"Question":"I'm experienced in PHP and recently started studying Python, and right now I'm on creating a small web project using django. And I have a conceptual question about approach to installing modules in Python and django. \nExample: based on expected needs for my project I've googled and downloaded django_openid module. And obviously I want to install it to my project. \nHowever, when I do it the prescribed way (python setup.py install) it installs it to python dir as a python module. Thus this module becomes not project specific, but system-wide. \nSo, what is generally right approach to install project-specific modules in python? \nBased on my PHP experience it looks strange to install high level functional modules into the python itself. I'd rather expect it to be installed in the project library and included in the project on runtime. \nOr do I loose something important here?\nI've googled around, but as long as this is rather a conceptual approach question - keywords search doesnt work good in this case.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":223,"Q_Id":10992976,"Users Score":0,"Answer":"Technically for any Python module to be \"installed\" you just have to add it to the sys.path variable, so that Python can find and import it. \nSame goes with django apps, which are Python modules. As long as Python can find and import the django application, you just have to add it to INSTALLED_APPS in settings (and maybe few more steps usually described in the application, e.g. adding urls etc).","Q_Score":2,"Tags":"python,module","A_Id":10993067,"CreationDate":"2012-06-12T08:27:00.000","Title":"python project-specific modules installation approach","Data Science and Machine Learning":0,"Database and SQL":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},{"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},{"Question":"I am trying to do python documentation generation with Sphinx. The problem is that sphinx-build ends up executing the module\/evaluating anything in global scope. Is there a reason it does this? And does anyone know of a flag that can be set to disable this?\nIt seems like Sphinx is trying to do code-coverage or something equivalent, which is definitely not what I want it doing. Normally this wouldn't be an issue, but a particular set of modules are very specific to an environment.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1993,"Q_Id":11006553,"Users Score":6,"Answer":"Sphinx evaluates everything in the global scope because the autodoc plugin imports modules, and importing a module evaluates everything in the global scope.\nTo stop this, either:\n\nDisable the autodoc plugin (search for autodoc in the sphinx config file), or\nGuard the code you don't want executed with something like if __name__ == \"__main__\": do_stuff()","Q_Score":5,"Tags":"python,python-sphinx","A_Id":11006581,"CreationDate":"2012-06-13T00:07:00.000","Title":"Prevent Sphinx from executing the 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},{"Question":"I am currently parsing large text files with Python 2.7, some of which were originally encoded in Unicode or UTF-8.\nFor modules containing functions which directly interact with strings in UTF-8, I included # -*- coding: utf-8 -*- at the top of the file, but for functions which work with only ascii, I did not bother.\nEventually, these modules lead to larger modules, and all the parsed strings gets mixed together. Is it good practice to include # -*- coding: utf-8 -*- at top of every file? \nIs there a benefit to this?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":2205,"Q_Id":11029721,"Users Score":1,"Answer":"Every ASCII file is also a valid UTF-8. Don't worry about treating your ASCII files as UTF-8 files, no conversion necessary, no increase in size.","Q_Score":1,"Tags":"python,parsing,unicode,utf-8,ascii","A_Id":11029801,"CreationDate":"2012-06-14T08:52:00.000","Title":"Mixed usage of UTF-8 and ASCII 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},{"Question":"I cannot compile python in pydev in eclipse. I get the following error:\n\"unable to make launch because launch configuration is not valid\nReason:\nInterpreter: Python32 not found\"\nI am actually runnning Python26 and have configured Python26 as the interpreter in \"Windows->Preferences\"\nI have deleted and replaced my copy of eclipse and this persists. Any help would be appreciated. I think that at one time I had Python32 running and then switched to Python26.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":820,"Q_Id":11034733,"Users Score":3,"Answer":"You probably still have that selected in your project or launch configuration... You can try to delete your existing launch configurations (run > run configurations) so that they get recreated on a new run and if that's not it, take a look at your project properties > pydev - interpreter\/grammar and see if an old interpreter was selected.","Q_Score":2,"Tags":"python,eclipse","A_Id":11192462,"CreationDate":"2012-06-14T13:59:00.000","Title":"Eclipse and pyddev: Error can't find Python32","Data Science and Machine Learning":0,"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},{"Question":"I'm a liberal arts major and have a few ideas for some web apps. I've saved up enough money to hire someone to do the coding for me, but I want to pick up at least basic coding skills on my own. I'd rather not be the clueless founder.\nI've started off with Python. So far, so good. Despite my liberal arts background, I've always been pretty mathematically inclined, even taking some advanced calculus classes in college.\nMy question is: if my goal is to make web apps and not actually land a job, is it really necessary to learn more than one programming language? I'm starting off with Python and I've found it flexible and powerful enough to meet most of my needs. Do I need to expand my oeuvre to PHP, Ruby, Java, etc.?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":96,"Q_Id":11070805,"Users Score":1,"Answer":"I'd stick with one server side language for now - and Python (or any of the other languages you listed) is a perfectly good choice for that.\nBasic notions of what Javascript would be important I think, and how and what Ajax type technology can do.\nHowever, stretching the definition of \"language\" a little, I think you develop a reasonable understanding of html and css as these are integral to web-development.","Q_Score":0,"Tags":"python","A_Id":11070833,"CreationDate":"2012-06-17T11:02:00.000","Title":"Do I really need to know more than one language if i want to make webapps?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I am accessing the twitter streaming API. I generate a map using Basemap in python. \nI want only certain parts of the map to change with time (for eg. every second). Is it hard to do? \nDo I need to leave Basemap and look for something else? Please help!","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":215,"Q_Id":11076404,"Users Score":1,"Answer":"You can send an ajax request and update the html contents dynamically.","Q_Score":1,"Tags":"python,django,dynamic,web,matplotlib","A_Id":11076420,"CreationDate":"2012-06-18T02:42:00.000","Title":"Dynamically updating images on 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":0},{"Question":"I am accessing the twitter streaming API. I generate a map using Basemap in python. \nI want only certain parts of the map to change with time (for eg. every second). Is it hard to do? \nDo I need to leave Basemap and look for something else? Please help!","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":215,"Q_Id":11076404,"Users Score":1,"Answer":"A possible approach: divide the map into tiles, and treat each one separately; use Basemap to generate just the map-tile that contains new data, then update just that tile on your webpage using Ajax. \nOf course, depending on the nature of changes to the data on your map, this approach may or may not work for you -- gerrymandering is not really possible. \nYou would need to write logic to understand which tile the new data belongs to, then use basemap to create a new image for that time, then intelligently update the tiled image. You will also have to play with margins and padding (both in matplotlib and in CSS) to cleanly piece the tiles together. \n...\nWhen the approach gets this complicated, one should re-evaluate whether better tools are available. Basemap doesn't sound like a good fit for what you need to do.","Q_Score":1,"Tags":"python,django,dynamic,web,matplotlib","A_Id":11093825,"CreationDate":"2012-06-18T02:42:00.000","Title":"Dynamically updating images on 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":0},{"Question":"How to install python module openFlashChart? I am really having trouble installing it. If you have installed it before kindly post how.\nThe error was module openFlashChart not found. I actually cant find the module to install.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":147,"Q_Id":11095247,"Users Score":0,"Answer":"Correct me if I'm wrong but flash chart is a flash not python. There is no python module dedicated to flash chart. In fact flash chart need some data from server which can be implemented in python.","Q_Score":0,"Tags":"python,open-flash-chart,openflashchart2","A_Id":11095835,"CreationDate":"2012-06-19T06:03:00.000","Title":"installing python module openFlashChart","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm currently building Python regression tests using Jenkins. For some reason, each individual test in the test suite is taking approx. 15 minutes to run (and there are about 70\/80 tests total) in Jenkins, but when I run the tests from the command line on the same windows box, each individual tests takes only about 30seconds to 1minute to run. I even put print statements in some of the files and none of them show up on the jenkins command line output. \nHas anyone else faced this problem or have any suggestions?\nThanks\nAlso, I'm not doing a sync every time I build, only syncing once!","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":2535,"Q_Id":11105304,"Users Score":0,"Answer":"Check load on the machine and ensure you set Jenkins with enough memory to run those tests.\nIt is not clear if you are working with Jenkins-slaves or directly on the master -\nThis may also have an affect on performance.","Q_Score":2,"Tags":"python,windows,selenium,build,jenkins","A_Id":11126510,"CreationDate":"2012-06-19T16:28:00.000","Title":"Jenkins takes too long to execute","Data Science and Machine Learning":0,"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},{"Question":"I'm currently building Python regression tests using Jenkins. For some reason, each individual test in the test suite is taking approx. 15 minutes to run (and there are about 70\/80 tests total) in Jenkins, but when I run the tests from the command line on the same windows box, each individual tests takes only about 30seconds to 1minute to run. I even put print statements in some of the files and none of them show up on the jenkins command line output. \nHas anyone else faced this problem or have any suggestions?\nThanks\nAlso, I'm not doing a sync every time I build, only syncing once!","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":2535,"Q_Id":11105304,"Users Score":1,"Answer":"This may have to do with running Jenkins in the background (and\/or as a service). Try running it in the foreground with java -jar jenkins.war an see if it helps.","Q_Score":2,"Tags":"python,windows,selenium,build,jenkins","A_Id":11109668,"CreationDate":"2012-06-19T16:28:00.000","Title":"Jenkins takes too long to execute","Data Science and Machine Learning":0,"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},{"Question":"I have been asked to write a script that pulls the latest code from Git, makes a build, and performs some automated unit tests.\nI found that there are two built-in Python modules for interacting with Git that are readily available: GitPython and libgit2.\nWhat approach\/module should I use?","AnswerCount":6,"Available Count":1,"Score":0.0333209931,"is_accepted":false,"ViewCount":45496,"Q_Id":11113896,"Users Score":1,"Answer":"If GitPython package doesn't work for you there are also the PyGit and Dulwich packages. These can be easily installed through pip. \nBut, I have personally just used the subprocess calls. Works perfect for what I needed, which was just basic git calls. For something more advanced, I'd recommend a git package.","Q_Score":25,"Tags":"python,git","A_Id":58983005,"CreationDate":"2012-06-20T06:23:00.000","Title":"Use Git commands within 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},{"Question":"I'm currently using FileStorage class for storing matrices XML\/YAML using OpenCV C++ API.\nHowever, I have to write a Python Script that reads those XML\/YAML files.\nI'm looking for existing OpenCV Python API that can read the XML\/YAML files generated by OpenCV C++ API","AnswerCount":6,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":16840,"Q_Id":11141336,"Users Score":0,"Answer":"pip install opencv-contrib-python for video support to install specific version use pip install opencv-contrib-python","Q_Score":21,"Tags":"c++,python,image-processing,opencv","A_Id":60879363,"CreationDate":"2012-06-21T15:18:00.000","Title":"FileStorage for OpenCV Python API","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},{"Question":"other than not encrypting, i have no choice but to have the RSA private key on the same system as the data encrypted asymetrically. (my system has no access to remote servers, etc) so i figured using seahorse (ubuntu) or keychain access (apple) might be useful?\nis it possible to access the private key stored in one of these from python?\nare there other approaches to this besides not storing the private key locally?\ni need a reversible crypt so hashing is not an option.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1455,"Q_Id":11142044,"Users Score":0,"Answer":"On Mac OS X, the keychain can be accessed from the shell using the security program. You can search for a specific private key using security find-identity -s , and export it to a file using security export (more information on those commands can be obtained from security -h ). I have not seen python bindings yet, but it should be easy to wrap the functionality you need in a subprocess.call call.","Q_Score":1,"Tags":"python,django,encryption,keystore,keychain","A_Id":11146119,"CreationDate":"2012-06-21T15:56:00.000","Title":"can python access an RSA private key stored locally in a keystore like seahorse \/ Apple Keychain","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"A python program opens a new process of the C++ program and is reading the processes stdout.\nNo problem so far. \nBut is it possible to have multiple streams like this for communication? I can get two if I misuse stderr too, but not more. Easy way to hack this would be using temporary files. Is there something more elegant that does not need a detour to the filesystem?\nPS: *nix specific solutions are welcome too","AnswerCount":4,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":270,"Q_Id":11164176,"Users Score":2,"Answer":"On unix systems; the usual way to open a subprocess is with fork(), which will leave any open file descriptors (small integers representing open files or sockets) available in both the child, and the parent, and then exec(), which also allows the new executable to use the file descriptors that were open in the old process. This functionality is preserved in the subprocess.Popen() call (adjustable with the close_fds argument). Thus, what you probably want to do is use os.pipe() to create pairs of sockets to communicate on, then use Popen() to launch the other process, with arguments for each of fd's returned by the previous call to pipe() to tell it which fd's it should use.","Q_Score":0,"Tags":"python,process,communication,iostream","A_Id":11164681,"CreationDate":"2012-06-22T21:10:00.000","Title":"C++ to python communication. Multiple io streams?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"A python program opens a new process of the C++ program and is reading the processes stdout.\nNo problem so far. \nBut is it possible to have multiple streams like this for communication? I can get two if I misuse stderr too, but not more. Easy way to hack this would be using temporary files. Is there something more elegant that does not need a detour to the filesystem?\nPS: *nix specific solutions are welcome too","AnswerCount":4,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":270,"Q_Id":11164176,"Users Score":0,"Answer":"assuming windows machine.\nyou could try using the clipboard for exchanging information between python processes and C++.\nassign some unique process id followed by your information and write it to clipboard on python side.....now just parse the string on C++ side.\nits akin to using temporary files but all done in memory..... but the drawback being you cannot use clipboard for any other application.\nhope it helps","Q_Score":0,"Tags":"python,process,communication,iostream","A_Id":11165324,"CreationDate":"2012-06-22T21:10:00.000","Title":"C++ to python communication. Multiple io streams?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I am using heliohost's free service to test my django apps. But Heliohost does not provide me shell access. Is there anyway to install python libraries on the host machine?","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":1172,"Q_Id":11168747,"Users Score":1,"Answer":"You could try to put them in your PYTHONPATH. Usually, your current working directory is in your PYTHONPATH. If that changes, you might need to add a path to it (maybe in each file, you should check, or one common file which is always included), and put the libraries there. You can do this with import sys;sys.path.append(the_path)\nI'm not sure all of the libraries will work, but those which are pure-python, you should be able to copy\/paste the source in a directory, and they will work I think.","Q_Score":0,"Tags":"python,django,web-hosting,cpanel","A_Id":11169154,"CreationDate":"2012-06-23T10:23:00.000","Title":"python libraries in cpanel","Data Science and Machine Learning":0,"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},{"Question":"I am using heliohost's free service to test my django apps. But Heliohost does not provide me shell access. Is there anyway to install python libraries on the host machine?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":1172,"Q_Id":11168747,"Users Score":0,"Answer":"You should inform the support of heliohost.this server has very good support that help you or install any package you want","Q_Score":0,"Tags":"python,django,web-hosting,cpanel","A_Id":45138203,"CreationDate":"2012-06-23T10:23:00.000","Title":"python libraries in cpanel","Data Science and Machine Learning":0,"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},{"Question":"I'd like to invoke PySocketModule_ImportModuleAndAPI function defined in socketmodule.h in my Python C-extension.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":142,"Q_Id":11172215,"Users Score":0,"Answer":"I had a similar problem and resolved it by:\n\nAdding the Modules\\ directory (from your Python source) to the C\/C++ Additional Include Directories.\n#include \"socketmodule.h\"\n\nDon't know if this is the best solution, but it worked for me!","Q_Score":1,"Tags":"python-c-extension,python-extensions","A_Id":20085116,"CreationDate":"2012-06-23T19:07:00.000","Title":"Is it possible to include socketmodule.h in Python C extensions?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"What is the most efficient way to sort a list, [0,0,1,0,1,1,0] whose elements are only 0 & 1, without using any builtin sort() or sorted() or count() function. O(n) or less than that","AnswerCount":10,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1534,"Q_Id":11175645,"Users Score":0,"Answer":"You have only two values, so you know in advance the precise structure of the output: it will be divided into two regions of varying lengths.","Q_Score":2,"Tags":"python","A_Id":11175666,"CreationDate":"2012-06-24T07:14:00.000","Title":"Sort a list efficiently which contains only 0 and 1 without using any builtin python sort 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":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I know this question has been asked many times and it's also covered in official memcached FAQ. But my case is - I want to use it just for admin panel purposes. I want to see keys with values in my admin page so it doesn't matter if it's slow and against the best practices. Please advise, if it's possible.","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":839,"Q_Id":11176273,"Users Score":2,"Answer":"There's no way to do it that's guaranteed to work. The only way I found is the way you'll find on google, but there's a restriction: Only 1 MB will be returned - it may not be all keys. And it will probably be quite slow..\nIf you really, really has to have all those keys you'd probably have to hack the source code.\nI would say: no, you can't.\nWhy do you need all those key? I would consider redesigning your application to not make your admin panel dependent of the internals of a caching server","Q_Score":2,"Tags":"python,caching,memcached","A_Id":11176318,"CreationDate":"2012-06-24T09:15:00.000","Title":"List all memcached keys\/values","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I'm trying to understand whether and under what circs one should use Python classes and\/or Java ones. \nIf making a specialist dictionary\/Map kind of class, should one subclass from Python's dict, or from Java's HashMap or TreeMap, etc.?\nIt is tempting to use the Python ones just because they are simpler and sexier. But one reason that Jython runs relatively slowly (so it appears to me to do) seems to have something to do with the dynamic typing. I'd better say I'm not that clear about all this, and haven't spent nocturnal hours poring over the Python\/Jython interpreter code, to my shame.\nAnyway it just occurs to me that the Java classes might possibly run faster because the code might have to do less work. OTOH maybe it has to do more. Or maybe there's nothing in it. Anyone know?","AnswerCount":2,"Available Count":2,"Score":0.4621171573,"is_accepted":false,"ViewCount":418,"Q_Id":11178243,"Users Score":5,"Answer":"The point of using Jython is that you can write Python code and have it run on the JVM. Don't ruin that by making your Python into Java. \nIf -- if -- it turns out that your data structure is too slow, you can drop-in replace it with a Java version. But that's for the optimisation stage of programming, which comes later.\n\nI guess I should try to answer your question. I would guess that using native Java structures will be faster (because the JVM can infer more about them than the Python interpreter can), but that might be counterbalanced by the extra processing needed to interface with Jython. Only tests will tell!","Q_Score":6,"Tags":"java,python,jython","A_Id":11178285,"CreationDate":"2012-06-24T14:24:00.000","Title":"Jython - is it faster to use Python data structures or Java 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":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm trying to understand whether and under what circs one should use Python classes and\/or Java ones. \nIf making a specialist dictionary\/Map kind of class, should one subclass from Python's dict, or from Java's HashMap or TreeMap, etc.?\nIt is tempting to use the Python ones just because they are simpler and sexier. But one reason that Jython runs relatively slowly (so it appears to me to do) seems to have something to do with the dynamic typing. I'd better say I'm not that clear about all this, and haven't spent nocturnal hours poring over the Python\/Jython interpreter code, to my shame.\nAnyway it just occurs to me that the Java classes might possibly run faster because the code might have to do less work. OTOH maybe it has to do more. Or maybe there's nothing in it. Anyone know?","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":418,"Q_Id":11178243,"Users Score":4,"Answer":"Generally, the decision shouldn't be one of speed - the Python classes will be implemented in terms of Java classes anyway, even if they don't inherit from them. So, the speed should be roughly comparable, and at most you would save a couple of method calls per operation. \nThe bigger question is what you plan on doing with your class. If you're using it with Python APIs, you'll want to use the Python types, or something that behaves like them so that you don't have to do the work of implementing the entire Mapping protocol (only the bits your class changes). If you're using Java APIs, you will certainly need to meet the static type checks - which means you'll need to inherit from Java's classes. \nIf this isn't easy to answer in your situation, start with the Python ones, since you (correctly ;-) find them \"simpler and sexier\". If your class doesn't pass outside the boundaries of your project, then this should be trivial to change later if the speed really becomes an issue - and at that point, you might also be thinking about questions like \"could it help to implement it entirely at the Java level?\" which you've hopefully recognised would be premature optimisation to think about now.","Q_Score":6,"Tags":"java,python,jython","A_Id":11179152,"CreationDate":"2012-06-24T14:24:00.000","Title":"Jython - is it faster to use Python data structures or Java 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":1,"System Administration and DevOps":0,"Web Development":1},{"Question":"I need a url for using that for a template. Now there are two ways of storing the url and use that again in python I guess...\nOne is using session to store that URL and get it later whenever we need it...\nor \nSecond is using cookies to store that URL and get it later..\nSo which method is more appropriate in terms of security ?\nIs there any other method in python which is more better for storing the url and use that later, which is more secure..?\nWhile using cookies somebody can easily change the information I guess, in sessions also somebody can hijack it and make the changes....","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":276,"Q_Id":11188725,"Users Score":0,"Answer":"In terms of security, you should store it in session. If it's in cookie, the client can modify your url to whatever he wants.","Q_Score":0,"Tags":"python,django,http","A_Id":11188777,"CreationDate":"2012-06-25T11:43:00.000","Title":"Storing URL into cookies or session?","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},{"Question":"I need a url for using that for a template. Now there are two ways of storing the url and use that again in python I guess...\nOne is using session to store that URL and get it later whenever we need it...\nor \nSecond is using cookies to store that URL and get it later..\nSo which method is more appropriate in terms of security ?\nIs there any other method in python which is more better for storing the url and use that later, which is more secure..?\nWhile using cookies somebody can easily change the information I guess, in sessions also somebody can hijack it and make the changes....","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":276,"Q_Id":11188725,"Users Score":0,"Answer":"I don't think \"session hijacking\" means what you think it means. The only thing someone can do with session hijacking is impersonate a user. The actual session data is stored on the back end (eg in the database), so if you don't give the user access to that particular data then they can't change it, whether they're the actual intended user or someone impersonating that user.\nSo, the upshot of this is, store it in the session.\nEdit after comment Well, you'd better not allow any information to be sent to your server then, and make your website browse-only. \nSeriously, I don't see why \"session data\" is any less secure than anything else. You are being unreasonably paranoid. If you want to store data, you need to get that data from somewhere, either from a calculation on the server side, or from user submissions. If you can't calculate this specific URL on the server side, it needs to come from the user. And then you need to store it on the server against the particular user. I don't see what else you want to do.","Q_Score":0,"Tags":"python,django,http","A_Id":11188963,"CreationDate":"2012-06-25T11:43:00.000","Title":"Storing URL into cookies or session?","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},{"Question":"And if it doesn't, is there anyway to speed up my python code for accessing pytables on a 64-bit system (so no psyco)?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":589,"Q_Id":11196258,"Users Score":4,"Answer":"There is some support numpy. Running pypy 1.9 I get the following message on importing numpy:\n\nImportError: The 'numpy' module of PyPy is in-development and not\n complete. To try it out anyway, you can either import from 'numpypy',\n or just write 'import numpypy' first in your program and then import\n from 'numpy' as usual.","Q_Score":1,"Tags":"python,cython,pypy,pytables,psyco","A_Id":11196841,"CreationDate":"2012-06-25T19:44:00.000","Title":"Does Pypy Support PyTables and Numpy?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I am working on a multi threaded server application for processing serial\/USB ports.\nThe issue is that if a cable gets unplugged, pyserial keeps reporting that the port is open and available. When reading I only receive Empty exceptions (due to read timeout).\nHow do I find out that a port has been disconnected so that I can handle this case?\nEdit: OS is Ubuntu 12.04\nEdit 2: Clarification - I am connecting to serial port devices via Serial to USB connector, thus the device being disconnected is an USB device.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":2182,"Q_Id":11202713,"Users Score":3,"Answer":"A Serial port has no real concept of \"cable connected\" or not connected.\nDepending on the equipment you are using you could try to poll the DSR or CTS lines, and decide there is no device connected when those stay low over a certain time.\nFrom wikipedia:\n\nDTR and DSR are usually on all the time and, per the RS-232 standard\n and its successors, are used to signal from each end that the other\n equipment is actually present and powered-up\n\nSo if you've got a conforming device, the DSR line could be the thing you need.\nEdit:\nAs you seem to use an USB2Serial converter, you can try to check whether the device node still exists - you don't need to try to open it.\nso os.path.exists(devNode) could suffice.","Q_Score":1,"Tags":"python,pyserial","A_Id":11202829,"CreationDate":"2012-06-26T07:37:00.000","Title":"How to find out if serial port is 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":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a GPIB device that I'm communicating with using a National Instruments USB to GPIB. the USB to GPIB works great. \nI am wondering what can cause a GPIB device to be unresponsive? If I Turn off the device and turn it back on it will respond, but when I run my program it will respond at first. It then cuts off I can't even communicate with the GPIB device it just times out. \nDid I fill up the buffer?\nSome specifics from another questioner\nI'm controlling a National Instruments GPIB card (not USB) with PyVisa. The instrument on the GPIB bus is a Newport ESP300 motion controller. During a session of several hours (all the while sending commands to and reading from the ESP300) the ESP300 will sometimes stop listening and become unresponsive. All reads time out, and not even *idn? produces a response.\nIs there something I can do that is likely to clear this state? e.g. drive the IFC line?","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":2223,"Q_Id":11216401,"Users Score":1,"Answer":"There should be a clear command (something like \"*CLS?\", but dont quote me on that). I always run that when i first connect to a device. Then make sure you have a good timeout duration. I found for my device around 1 second works. Less then 1 second makes it so I miss the read after a write. Most of the time, a timeout is because you just missed it or you are reading after a command without a return. Make sure you are also checking for errors in the error queue in between write to make sure the write actually properly when through.","Q_Score":2,"Tags":"c#,python,visa,gpib","A_Id":15514499,"CreationDate":"2012-06-26T21:43:00.000","Title":"What can cause a GPIB to be unresponsive","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I have a CentOS 5.8 server and am planning to install a later version of python (presumably 2.7). I have heard a lot of mention that CentOS relies quite heavily on 2.4 for many admin features etc. I'm trying to determine exactly what these features are (and whether I would actually be using them) so that I can decide whether to update python through yum or build from source.\nCan anyone give me some more detailed information on what CentOS features have dependencies on Python 2.4.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1419,"Q_Id":11224517,"Users Score":1,"Answer":"If python2.7 is available on Yum, you should use that: the package management on large distros (redhat, ubuntu, debian, fedora ) takes care of maintaining parallel Python installs for you which won't conflict with each other.\nThis option should keep your system \"\/usr\/bin\/python\u00ac file pointing to Python2.4 and give you another python2.7 binary.\nOtherwise, if you choose to build it from source, pick another prefix - \/opt - (not even \/usr\/local will be quite safe) for building it. \nYou don't need to know exactly which system parts depend on Python 2.4 - just rest assured it will crash very hard and unpredictably if you try to modify the system Python itself.","Q_Score":0,"Tags":"python,centos","A_Id":11251911,"CreationDate":"2012-06-27T10:49:00.000","Title":"CentOS 5.8 dependencies on Python 2.4?","Data Science and Machine Learning":0,"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},{"Question":"How do you get Jenkins to execute python unittest cases?\nIs it possible to JUnit style XML output from the builtin unittest package?","AnswerCount":6,"Available Count":2,"Score":1.0,"is_accepted":false,"ViewCount":104678,"Q_Id":11241781,"Users Score":20,"Answer":"I would second using nose. Basic XML reporting is now built in. Just use the --with-xunit command line option and it will produce a nosetests.xml file. For example:\n\nnosetests --with-xunit\n\nThen add a \"Publish JUnit test result report\" post build action, and fill in the \"Test report XMLs\" field with nosetests.xml (assuming that you ran nosetests in $WORKSPACE).","Q_Score":150,"Tags":"python,unit-testing,jenkins,junit,xunit","A_Id":11463624,"CreationDate":"2012-06-28T09:33:00.000","Title":"Python unittests 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":0},{"Question":"How do you get Jenkins to execute python unittest cases?\nIs it possible to JUnit style XML output from the builtin unittest package?","AnswerCount":6,"Available Count":2,"Score":0.1325487884,"is_accepted":false,"ViewCount":104678,"Q_Id":11241781,"Users Score":4,"Answer":"I used nosetests. There are addons to output the XML for Jenkins","Q_Score":150,"Tags":"python,unit-testing,jenkins,junit,xunit","A_Id":11241965,"CreationDate":"2012-06-28T09:33:00.000","Title":"Python unittests 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":0},{"Question":"I want to create a UI which invokes my python script. Can i do it using JSP? If so, can you please explain how ? Or can i do it using some other language. I have gone through many posts related to it but could not find much? please help me out? Explanations using examples would be more helpful.\nThanks In Advance..","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":8657,"Q_Id":11244049,"Users Score":1,"Answer":"It would be neater to expose your python API as RESTful services, that JSP can access using Ajax and display data in the page. I'm specifically suggesting this because you said 'JSP' not 'Java'.","Q_Score":1,"Tags":"java,python,jsp","A_Id":11244145,"CreationDate":"2012-06-28T11:53:00.000","Title":"Is it possible to invoke a python script from jsp?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I am starting an open source Python library that my company expects will be used by all of our customers. Since I am a sucker for proper presentation and practices, I have a question about file modes as saved by git. However, I want to avoid turning this into a best-practice type of discussion discouraged by StackOverflow, so here the is question in a form seeking a concrete answer:\nIs there a reason why I shouldn't set Python examples in my library to be executable? I tend to set the executable flag on Python that I need to run and would prefer to do so (simply because it's generally slightly easier to type .\/ than python), but I have noticed that most open source libraries differ from that in practice. I don't feel that such security should be manifested that way, but I want to make sure. I would not be setting library files to be executable, just example files or tests that I feel should be executable.\nAs a related question, should library files that are never meant to be executed directly omit the hashbang (#!\/usr\/bin\/env python) on the first line?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":95,"Q_Id":11252864,"Users Score":2,"Answer":"Personally, I only set files I intend to be executed as scripts as executable. Using a least permissive model is a smart, if not ideal, design choice when it comes to security. If you don't need the permissions, don't use them. \nI don't see any reason why omitting the shebang is a bad idea, other than if someone else want's to make the file executable they have two steps instead of one.","Q_Score":0,"Tags":"python,git,packaging","A_Id":11253601,"CreationDate":"2012-06-28T21:04:00.000","Title":"Is there a reason to not set Python files' modes as executable in an open source git 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},{"Question":"Is there a way to measure audio output level in Python? I'd like to measure the volume of a 30 second audio file every 1\/10th of a second, then export the data into something like Excel. Is this possible?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":799,"Q_Id":11269631,"Users Score":0,"Answer":"I know that this is a long shot, but maybe there are some libavcodec\/FFMpeg ports to python. It's always worth a shot to see if there is something that exists out there along these lines...","Q_Score":1,"Tags":"python,excel,audio,measure","A_Id":11269704,"CreationDate":"2012-06-29T22:15:00.000","Title":"Using Python to measure audio output 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},{"Question":"Sorry about the nooby question, but, when I download and unzip a third-party python package, and then python setup.py install it thereby making an egg directory in site-packages, what do I do with the original unzipped directory in the Download folder? Should I sudo copy & paste all the test\/docs\/README files along with the rest of the corresponding site-packages files? I've typically deleted them but don't think that's a smart thing to do..","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":55,"Q_Id":11271883,"Users Score":1,"Answer":"If all you want is to use the installed Python package, then you don't need the downloaded directory at all. You can delete it if you like. If you want to use it for its docs, then you can keep it, or move it somewhere else. There's no connection between the installed package and the original unzipped directory you installed from, so you are free to do what you like with it.","Q_Score":1,"Tags":"python,macos,packages,egg,file-management","A_Id":11273716,"CreationDate":"2012-06-30T06:05:00.000","Title":"What to do with the test\/docs\/readme files after the downloaded python package is built?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":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},{"Question":"I am trying to have the bus loads in PSS\/E to change by using python program. So I am trying to write a script in python where I could change loads to different values between two buses in PSS\/E.","AnswerCount":4,"Available Count":1,"Score":0.049958375,"is_accepted":false,"ViewCount":5345,"Q_Id":11316694,"Users Score":1,"Answer":"You can use API routine called \"LOAD_CHNG_4\" (search for this routin in API.pdf documentation). This routine belongs to the set of load data specification functions. It can be used to modify the data of an existing load in the working case.","Q_Score":1,"Tags":"python,psse","A_Id":26021216,"CreationDate":"2012-07-03T18:10:00.000","Title":"Python and PSS\/E","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to find out a way in python to redirect the script execution log to a file as well as stdout in a pythonic way. Is there any easy way of achieving this?","AnswerCount":8,"Available Count":1,"Score":0.0748596907,"is_accepted":false,"ViewCount":174224,"Q_Id":11325019,"Users Score":3,"Answer":"You should use the logging library, which has this capability built in. You simply add handlers to a logger to determine where to send the output.","Q_Score":61,"Tags":"python","A_Id":11325504,"CreationDate":"2012-07-04T08:13:00.000","Title":"How to output to the console and 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},{"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},{"Question":"I'm using python 2.7 and paramiko library. client app running on window sends ssh commands to server app running on linux.\n when I send vi command, I get the response\n<-[0m<-[24;2H<-[K<-[24;1H<-[1m~<-[0m<-[25;2H....\n I don't know what these characters mean and how I process it. I'm struggling for hours, please help me.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":223,"Q_Id":11342314,"Users Score":0,"Answer":"Reviewing my SO activity this week, saw this opportunity to whore for rep:\nThose look like ANSI\/VT100 terminal control codes, which suggests that something which thinks it is attached to a terminal is sending them but they are being received by something which doesn't know what to do with them.\nNow you can Google for 'VT100 control codes' and learn what you want.","Q_Score":3,"Tags":"python,linux,paramiko","A_Id":11360629,"CreationDate":"2012-07-05T10:21:00.000","Title":"vi command returns error format data?","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},{"Question":"I'm interested in what pitfalls can be (except Python is not installed in target system) when using Python for deb package flow control scripts (preinst, postinst, etc.). Will it be practical to implement those scripts in Python, not in sh?\nAs I understand it's at least possible.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":912,"Q_Id":11347613,"Users Score":8,"Answer":"The only reason this isn't commonly done, afaik, is that it's not convention, and Python isn't usually more useful or straightforward than plain shell script for the sorts of things that maintainer scripts do. When it is more useful, you can often break out the Python-needing functionality into a separate Python script which is called by the maintainer scripts.\nIt can help to follow convention in this sort of situation, since there are a lot of helpful tools and scripts (e.g., Lintian, Debhelper) which generally assume that maintainer scripts use bash. If they don't, it's ok, but those tools may not be as useful as they would be otherwise. The only other issue I think you need to be aware of is that if your preinst or postrm scripts need Python, then Python needs to be a pre-dependency (Pre-Depends) of your package instead of just a Depends.\nThat said, I've found it useful to use Python in a maintainer script before.","Q_Score":9,"Tags":"python,debian,packaging,deb","A_Id":11350615,"CreationDate":"2012-07-05T15:28:00.000","Title":"Will it be practical to implement deb preinst, postint, etc. scripts in Python, not in sh","Data Science and Machine Learning":0,"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},{"Question":"I'm looking to add simple repeating tasks to my current application and I'm looking at the uwsgi signals api and there are two decorators @timer and @rbtimer. I've tried looking through the doc and even the python source at least but it appears it's probably more low level than that somewhere in the c implementation.\nI'm familiar with the concept of a red-black tree but I'm not sure how that would relate to timers. If someone could clear things up or point me to the doc I might have missed I'd appreciate it.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":826,"Q_Id":11350907,"Users Score":11,"Answer":"@timer uses kernel-level facilities, so they are limited in the maximum number of timers you can create.\n@rbtimer is completely userspace so you can create an unlimited number of timers at the cost of less precision","Q_Score":5,"Tags":"python,timer,uwsgi","A_Id":11353126,"CreationDate":"2012-07-05T19:06:00.000","Title":"What's the difference between timer and rbtimer in uWSGI?","Data Science and Machine Learning":0,"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},{"Question":"I read an article about a regular expression to detect base64 but when I try it in \"yara python\" it gives an error of \"unterminated regular expression\"\nthe regular expression is: \n\n(?:[A-Za-z0-9+\/]{4}){2,}(?:[A-Za-z0-9+\/]{2}[AEIMQUYcgkosw048]=|[A-Za-z0-9+\/][AQgw]==)\n\ncould anyone throw a suggestion please?\nthanks","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":5830,"Q_Id":11357851,"Users Score":0,"Answer":"I would suggest escaping \/ character in the [A-Za-z0-9+\/] block, because while unescaped it defines regular expression start\/end.","Q_Score":1,"Tags":"python,regex,base64","A_Id":11357972,"CreationDate":"2012-07-06T07:38:00.000","Title":"regular Expression to detect base64","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":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},{"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},{"Question":"I was using ubuntu.\nI found that many Python libraries installed went in both \/usr\/lib\/python and \/usr\/lib64\/python.\nWhen I print a module object, the module path showed that the module lived in \/usr\/lib\/python.\nWhy do we need the \/usr\/lib64\/python directory then?\nWhat's the difference between these two directories?\nBTW\nSome package management script and egg-info that lived in both directories are actually links to packages in \/usr\/share.\nMost Python modules are just links, but the so files are not.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":10916,"Q_Id":11370877,"Users Score":4,"Answer":"The 64-bit version of the libraries?\nWhat version of Python are you running? If you are running the 32-bit version, then you probably won't need those files.","Q_Score":10,"Tags":"python","A_Id":11370887,"CreationDate":"2012-07-06T23:24:00.000","Title":"What's the difference between \/usr\/lib\/python and \/usr\/lib64\/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},{"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},{"Question":"I currently am developing a website in the Symfony2 framework, and i have written a Command that is run every 5 minutes that needs to read a tonne of RSS news feeds, get new items from it and put them into our database.\nNow at the moment the command takes about 45 seconds to run, and during those 45 seconds it also takes about 50% to up to 90% of the CPU, even though i have already optimized it a lot.\nSo my question is, would it be a good idea to rewrite the same command in something else, for example python? Are the RSS\/Atom libraries available for python faster and more optimized than the ones available for PHP?\nThanks in advance,\nJaap","AnswerCount":3,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":269,"Q_Id":11382163,"Users Score":0,"Answer":"Is solved this by adding a usleep() function at the end of each iteration of a feed. This drastically lowered cpu and memory consumption. The process used to take about 20 minutes, and now only takes around and about 5!","Q_Score":0,"Tags":"php,python,symfony","A_Id":15361568,"CreationDate":"2012-07-08T09:43:00.000","Title":"Reading RSS feeds in php or python\/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":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I currently am developing a website in the Symfony2 framework, and i have written a Command that is run every 5 minutes that needs to read a tonne of RSS news feeds, get new items from it and put them into our database.\nNow at the moment the command takes about 45 seconds to run, and during those 45 seconds it also takes about 50% to up to 90% of the CPU, even though i have already optimized it a lot.\nSo my question is, would it be a good idea to rewrite the same command in something else, for example python? Are the RSS\/Atom libraries available for python faster and more optimized than the ones available for PHP?\nThanks in advance,\nJaap","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":269,"Q_Id":11382163,"Users Score":0,"Answer":"You could try to check Cache-Headers of the feeds first before parsing them.\nThis way you can save the expensive parsing operations on probably a lot of feeds.\nStore a last_updated date in your db for the source and then check against possible cache headers. There are several, so see what fits best or is served the most or check against all.\nHeaders could be: \n\nExpires \nLast-Modified \nCache-Control \nPragma \nETag\n\nBut beware: you have to trust your feed sources.\nNot every feed provides such headers or provides them correctly.\nBut i am sure a lot of them do.","Q_Score":0,"Tags":"php,python,symfony","A_Id":11393069,"CreationDate":"2012-07-08T09:43:00.000","Title":"Reading RSS feeds in php or python\/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":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have emacs 24.1.1, which comes with GNU's python.el in byte-compiled form at emacs\/24.1\/lisp\/progmodes.\nI downloaded Fabian Gallina's python.el (note the same name) and placed it at emacs\/site-lisp, which is part of emacs' load-path.\nWhen I edit a Python file, it is Gallina's mode which is loaded, NOT GNU's. However, I have not put (require 'python) in my .emacs file, despite what Gallina's documentation suggests.\nWhy is this? Why does Gallina's python.el take precedence over GNU's? Why does it get loaded without (require 'python)?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":828,"Q_Id":11388125,"Users Score":0,"Answer":"To load an already loaded library from new place, write in your Emacs init-file something like\n(unload-feature...\n(load FROM-NEW-PLACE...","Q_Score":0,"Tags":"python,emacs,python-mode","A_Id":15865420,"CreationDate":"2012-07-09T01:22:00.000","Title":"Understanding which python mode is loaded by emacs \/ Aquamacs and why","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"What is the degree of source code dependency that can be resolved by examining at the source code for the following programming languages -- Java, Python and Lisp.\nFor example, can I say for sure by looking at a collection of Python files that examining all the \"import\" statements in every file are the only dependencies (source dependencies)?\nIn Lisp, I'm aware of the (load \"filename\") command that allows including function defined in other files.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":87,"Q_Id":11407544,"Users Score":1,"Answer":"Even if you find an \"import\" statement of whatever kind it is not shure that the code will use it.\nIn Java you can import a name space, but also use the full qualified name of the class without any import statement \njavax.swing.JButton but = new javax.swing.JButton(\"MyButton\");\nAnd last but not least all of them supports some kind of symbolic programming. You may use a plain string to get code loaded or executed:\nObject x = Class.forName(\"javax.swing.\"+compName);\nreturn x.toString();","Q_Score":0,"Tags":"java,python,lisp","A_Id":11407713,"CreationDate":"2012-07-10T06:07:00.000","Title":"Listing source 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":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm writing a script to be run as a cron and I was wondering, is there any difference in speed between the Ruby MySQL or Python MySQL in terms of speed\/efficiency? Would I be better of just using PHP for this task?\nThe script will get data from a mysql database with 20+ fields and store them in another table every X amount of minutes. Not much processing of the data will be necessary.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":254,"Q_Id":11431679,"Users Score":7,"Answer":"Just pick the language you feel most comfortable with. It shouldn't make a noticeable difference. \nAfter writing the application, you can search for bottlenecks and optimize that","Q_Score":0,"Tags":"python,mysql,ruby","A_Id":11431795,"CreationDate":"2012-07-11T11:28:00.000","Title":"Python MySQL vs Ruby MySQL","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},{"Question":"I would like to protect my python source code, I know there is no absolute protection possible, but still there should be some means to make it difficult enough to do or quite time-consuming. I want\n1) to remove all documentation, comments automatically and\n2) to systematically change the names of variables and functions within a module (obfuscation?), so that I can keep an external interface (with meaningful names) while the internal names of variables and functions are impossible to pronounce.\nPerhaps the best solution, which would make 1) and 2) redundant, is the following:\n3) Is there a simple way to compile python modules to .so libraries, with a clear interface and which can be used by other python modules? It would be similar as building C and C++ extensions with distutils, except that the source code is python itself rather than C\/C++. The idea is to organize all \"secret code\" into modules, compile them, and then import them in the rest of the python code which is not considered secret.\nAgain, I am aware that everything can be reverse-engineered, I think in pragmatic terms, most of the average developers would not be able to reverse-engineer code and even if they would be able, ethical\/legal\/timing reasons would make them think twice if they really want to work on this.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":11732,"Q_Id":11436484,"Users Score":6,"Answer":"As mgilson mentioned in the comments, Cython is probably your best bet here. Generally speaking, you can use it to convert your pure-python source code into compiled extension modules. While the primary intent of Cython is for enhanced performance, there shouldn't be any barriers for using it for source-code protection. The extension modules it outputs aren't limited in any special ways so anything you were able to do from within Python before, you should be able to do from the Cython-generated extension modules. Cython does have a few known limitations in terms of supported features that may need to be worked around but, overall, it looks well suited to serving your purpose.","Q_Score":6,"Tags":"python,compilation,source-code-protection","A_Id":11438657,"CreationDate":"2012-07-11T15:48:00.000","Title":"How to protect and compile python source code into a .so 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},{"Question":"I am looking for help debugging Mechanize. When I navigate to a page and attempt to call .read(), I get non-unicode result about 1 out of every 5 or so attempts. The non-unicode result looks like the following:\n\n\u00faRW!\u00a4c\u00eaL\u00d20T\u00b8\u00b2\u00d6\u00feF\\<\u00e4s +\u20ac\u00b2\u00dc@9\u201a\u00c8\u00f8Mq1;=\u00ae}\u00ff\u00bd8\u00b9WP[\u00eb\u00e6\u00e5\u00f1\u00b1\u00f8\u00fe\u00fb\u00dac!\u02c6\u00cdz\u00f2\u00d8\u00e5\u0178\u00bf\u00feU\u00fc\u00fef>\u00e0S\u00d5\u2039\u201a~\u00e9\u00f7b\u00c6\u00aa}\u00c3p#',\u00ae\u02c6\u00e2\u00cb\u00fd\u00ca\u00e6\u00da\u00b3\u00ad\u00f5\u00b5\u00caZ\u00f1My\u00f4\u2018;\u2013s\u00e4\u201eIW\u00cd\u00de\u00b7mwx\u00a8|\u00fdH\u00e5\u00c0\u00bdA \u00ba\u00d2\u00f2\u00c0\u00f6 QNq\u00d24O{\u017d\u00eb+\u00f3Zu\"\u00fa\u00d2\u00b8\u00bdv\u00ba\u00b3\u00d4P\u201d\u00ba\u2018c\u00c7\u2014\u00ca\u00e2#<31{Hi\u00baF4N\u00a8\u00c2\u00c0\"\u00db\u00b4>\u2022\u0160\u00dc\u00c5\u00f2\u20acU\u00b1\u00a7\u00b68\u00d1WE\u00fa(\u0192\u2018c\u00c0W\u00c4~\u2021 \u2021\u2014\u00afJ$\u00c1vQ\u00ecfj\u00b2a$Dd\u00aa\u00d0\u0160\u00d05[\u00fc(4`\u00ad \u0152\u00db\"\u2013<\u2039e\u00f1\u0192(\u201a\u00b9=[U\u00a4#\u00edQh\u00c9\u00d4\u00f46(\u00ee$M \u00b2-\u00d5\u00a3\u203a\u0152nd\u00fb8m\u00d8\u00ef\u00f57;\"\u00a8z\u00d2\u20acF\u00b0\u00ac@X\u02c6\u20ac*\u00f5\u00e4\u0160\u02c6x\u0178\u00ca%\u00fa\u00c5\u00f2= k\u00f4c\u00a1\u00a2\u00d8y\u0153\u00d1y\u00b3\u00ed>\u00cb\u00dc-\u00a5m+\u00df\u00ea\u00b8\u00efm\u00ec Yc\u00e3a\u00ae-\u00d8\u2022\u2020\u00ea\u00b8\u00eemq\u00abx} i\u00a5GE\u017dj]\u00cf\u00ebU\u00c6\u00cbGS\u00b0\u00ea\u00f5\u00bdAxw\u00d5\u00b5\u00ea\u00faR\u00b6\u00e0|\u00f4O\u00b9\u00fd\u00fc\u00e0:S\u00b8S\u2021\u00aeU%}\u2022C\u00ee3\u00e3g\u00ad~Q\u00db\u00f3\u00b4\u00d3]\u00efn[FwuCm6\u017e\u0161[\u00abJ\u00ae\u2122\u203a\u00dd-\u00a3A\u02dc\u00d6\u20acs\u00b51kh\u00ed\"\u201d\/\\S~u\u00a3C7\u00b2\u00cd#w\u00d1\u00bb@\u00e7@s\u00f4,\u00c6Q\u00e8\u00ca\u00f4\u00f3\u00ae.\u00e4(\u00e5*\u00e6\u2021#\u00f7\u00bb'\u00f5\u00b5\u00ad{\u00e0\u02dc\u00d5\u201eS\u00d2%@\u02c6tL \u2020\u00b8\u00b1\u00b9\u00e5I{\u201e\u00d5v#\u00b3\u00eb\u0160UG\u2026s\u2021\u2022\u00b7A\u00ed\u00ed\u00bb8\u00a1\u00d2|\u00d6\u00ab\u00e04\u20ac\u00bcd\u02c6\u00b8\u2014\u00e1\u00d0\u00e5qA\u00ad\u2018\u00ef $\u00d5[N\u00d8\u00d6\u00a3o\\s\u00a3Z_\u00be^ \u00c4\u00f3o~?<\u00da\u00bf\u00d9\u00ff]\u00c0@@b\u00c8%\u00b6\u00c1$\u00a6G o\u00cb\u00b7\u00f2}[\u00b5+>\u00f0\u00b5\u00b0\u00cd\u00f6\u00d0\u00b5?R1\u00faQ\u2013&P\u00e3\u00fdT\u00a5\u00a2\u00f0i+|\u00f3f\u00ab\u00fa,\u00e2,\u00dbQ\u00e3\u00a4\u0161\u00d3\u00a2\u00cf\u00ec\u00ad\u00d9T\u00a3\u0161\u00daA\u00e4\u00a1\u00b3\u00a3 \n\nI have tried the normal Mechanize parser (mechanize.Browser()) as well as the commonly suggested alternative (factory=mechanize.RobustFactory()).\nAny suggestions for next steps?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":155,"Q_Id":11436837,"Users Score":0,"Answer":"Problem solved:\nIf you are getting similar output, check the page headers as it is probably gzipped after instantiating the browser set set_handle_gzip(True)","Q_Score":0,"Tags":"python,mechanize","A_Id":11458357,"CreationDate":"2012-07-11T16:09:00.000","Title":"python mechanize odd .read() 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":1},{"Question":"So I'm writing a set of C++ classes that run Python scripts. I've gotten code working to run any script I want from a specified directory, and I can pass and return values just fine.\nBut the one issue I have is I can't seem to find out how to set Python doubles up. \nFor example, when I was using long values, I could use \"PyLong_AsLong([whatever value I'm trying to convert to a long from a PyObject])\" -- but is there a PyDouble_Something in the Python\/C API I can use for that?\nMy google searching has so far turned up nothing.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":73,"Q_Id":11444173,"Users Score":0,"Answer":"I found out the answer.\nI was mistaken, and I thought there were doubles in Python, but there aren't.\nI got it to work using a \"PyFloat\" object, and just converted the double like this:\n\"PyFloat_FromDouble([the double I wanted as a PyObject])\"","Q_Score":1,"Tags":"python,python-c-api","A_Id":11444316,"CreationDate":"2012-07-12T02:15:00.000","Title":"doubles in embedded 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},{"Question":"I want to write a program that ssh's into remote boxes and runs jobs there if the remote computer is not actively being used. I'll be logging in as clusterJobRunner@remoteBox, and the other user will be logged in as someLocalUser@remoteBox. \nIs there a way to see if a remote user is actively using the box using either Python or Java?","AnswerCount":5,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":1087,"Q_Id":11510032,"Users Score":0,"Answer":"I second the answer by @Eero Aaltonen -- you should run your stuff under nice. A Linux computer can run at 100% CPU busy, yet feel nice and fast for the user, if the extra tasks are all under nice; the scheduler will only run the nice tasks when the main user's tasks are idle.\nBut if you want to figure out if the machine is being used, I suggest you look into the w command. Try man w at your prompt. The w command prints the load average for the machine, and a list of users and how much time they have been using (a combined time that includes any background tasks they are running, plus a time for their main task).","Q_Score":2,"Tags":"java,python","A_Id":11511519,"CreationDate":"2012-07-16T18:10:00.000","Title":"How can I find out if someone is actively using a Linux computer in Python or 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":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I want to write a program that ssh's into remote boxes and runs jobs there if the remote computer is not actively being used. I'll be logging in as clusterJobRunner@remoteBox, and the other user will be logged in as someLocalUser@remoteBox. \nIs there a way to see if a remote user is actively using the box using either Python or Java?","AnswerCount":5,"Available Count":2,"Score":0.0399786803,"is_accepted":false,"ViewCount":1087,"Q_Id":11510032,"Users Score":1,"Answer":"In Java you can execute the users Linux command using Runtime.exec(), grab the standard output and get it into a parsable String. I don't think there are any OS-independent ways to do this.","Q_Score":2,"Tags":"java,python","A_Id":11510091,"CreationDate":"2012-07-16T18:10:00.000","Title":"How can I find out if someone is actively using a Linux computer in Python or 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":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"[Using Python 3.2]\nIf I don't provide encoding argument to open, the file is opened using locale.getpreferredencoding(). So for example, on my Windows machine, any time I use open('abc.txt'), it would be decoded using cp1252.\nI would like to switch all my input files to utf-8. Obviously, I can add encoding = 'utf-8' to all my open function calls. Or, better, encoding = MY_PROJECT_DEFAULT_ENCODING, where the constant is defined at the global level somewhere.\nBut I was wondering if there is a clean way to avoid editing all my open calls, by changing the \"default\" encoding. Is it something I can change by changing the locale? Or by changing a parameter inside the locale? I tried to follow the Python manual but failed to understand how this is supposed to be used.\nThanks!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":3877,"Q_Id":11514414,"Users Score":3,"Answer":"In Windows, with Python 3.3+, execute chcp 65001 in the console or a batch file before running Python in order to change the locale encoding to UTF-8.","Q_Score":8,"Tags":"python,character-encoding,python-3.x,locale","A_Id":11516682,"CreationDate":"2012-07-17T00:13:00.000","Title":"Changing the \"locale preferred encoding\"","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"We've got a number of perl and python scripts we want to expose to some of our teammates for casual usage; and we really don't want ot deal with getting them setup with git, perl, python, dependencies, etc.\nOne idea we had was to write a descriptor for each script as to what arguments it needed; and then let a simple HTML page call a CGI script with the appropriate arguments, wait and return stdout to the user. \nThis seems such a simple need that I'm amazed that I can't find anything like it existing out there. No framework that renders out the form, that puts out a virtual console screen... \nThere are, of course, major security concerns. Can anyone recommend a solution that does the above, or something else similar?","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":132,"Q_Id":11514608,"Users Score":2,"Answer":"Are the teammates developers or comfortable with the command line? If so, I would propose SSH.\nRun SSHD on the box with the scripts. On Windows, this is easy with cygwin, otherwise it's there by default on Mac and Linux\nThe client logs in (ssh user@host) and runs the script. Set up security with certificates and you won't even have to type your password.\nIf there are problems, I would much rather be at the command line and able to debug the script than at the end of an opaque web page.\nMaintenance will be a lot easier too.","Q_Score":0,"Tags":"python,http,command-line,cgi","A_Id":11515334,"CreationDate":"2012-07-17T00:44:00.000","Title":"Exposing commandline tools remotely to users","Data Science and Machine Learning":0,"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},{"Question":"I am reading a ASCII file from LINUX(Debian) into Python CGI script where it is edited via a web page and then saved, \nIf I use a graphical text editor the edited and un-edited file appear the same and are corectly formatted. \nUsing vi the edited file contains ctrl M as the EOL marker and all lines rolled into one but the unedited file is correctly formatted. Using :set List in vi to see control characters the edited file remains as described above, but in the unedited file $ appears as EOL marker.\nI know LINUX EOL is ctrl 0x0D but what is the $?\nWhy does $ format correctly and ctrl M does not?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":409,"Q_Id":11520713,"Users Score":1,"Answer":"The $ is displayed by vi (in certain modes). It is not in the file contents. You could use od -cx yourfile to check that.","Q_Score":0,"Tags":"python,linux,ascii,vi","A_Id":11520748,"CreationDate":"2012-07-17T10:34:00.000","Title":"LINUX End of 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":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"So I made a game in PHP that worked fairly well, a simple game fairly similar to tic-tac-toe, I didn't really want to go much further with PHP improving the game. With that in mind I decided to learn Python; I'm familiar with the basics now. I used simple math, dictionaries and conditional statements to create a mock-up of my game. However it is turn based and I'd prefer the two players not be on the same computer physically taking turns with the computer.\nSo what I envision my final product to be is a stand-alone app which each user has on their computer, they execute the app and enter a username then are brought to a screen where other users are, who have logged in as described, from there two users could mutually agree to start a round of the game, after completion they will be brought back to the 'waiting room'\nNow for something like this would I need (or be greatly helped by) a framework? If so which one(s)?\nWould this need a database on a server, or could all data be stored on the user's computers?\nWould I be dealing with CGI or Sockets or both in creating something like this?\nWould making this game into a web-app be easier? (similar to something I would create if I used PHP and ran the game off of a website)\nI would appreciate reading material on the subject. A link to an example source-code that solves a problem similar to what I have gets a gold star =)\nThank you all for you time, I greatly appreciate everything.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1912,"Q_Id":11534826,"Users Score":2,"Answer":"General Response\nEspecially if you include a \"waiting room\" and such things\/ want this to be widely usable, this is a rather big project (definitely not a bad thing, but you may want to do some small projects first to get your feet wet with python programming for the web). However, it is relatively easy to have a simple terminal-based, turn-based game that transmits data over the network between its players; I'd focus on making the simple version first to get a feel for what is involved. That being said, here are some answers to the specific questions you asked; unfortunately they can't be too detailed, because there is so much to learn about these topics.\nSpecific Answers\n\nNow for something like this would I need (or be greatly helped by) a framework? If so which one(s)?\n\nThere are frameworks that would help with several different parts of this project, but you have some big design decisions to make before you start looking into frameworks to help with the implementation.\n\nWould this need a database on a server, or could all data be stored on the user's computers?\n\nHaving a \"waiting room\" implies that there is some kind of server set up to facilitate making connections between players. Whether a database is necessary depends entirely on the scale of the application. If you want to keep track of users\/enable repeat logins, there's almost certainly a database involved.\n\nWould I be dealing with CGI or Sockets or both in creating something like this?\n\nRead more about what CGI and sockets are and think about this one.\n\nWould making this game into a web-app be easier? (similar to something I would create if I used PHP and ran the game off of a website)\n\nThere seem to be more resources to help making a web app version, but there are a whole new set of challenges and perhaps even more new things to learn about. It depends partly on what you are already comfortable with. Making a web app and making a standalone app that uses the internet are, perhaps surprisingly, very different, but both will involve a lot of new learning. \nConclusion\nWell, I hope that was helpful in some way. Best of luck!","Q_Score":0,"Tags":"php,python,network-programming","A_Id":11535406,"CreationDate":"2012-07-18T05:32:00.000","Title":"Wanting to make a turn-based python game. Where do I go from here?","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},{"Question":"I would like to use html5 validator from LiipFunctionalTestBundle in my Symfony2 project.\nSo, I followed instructions on bundle's github page, but I got this error during python build:\n\nIOError: [Errno 2] No such file or directory: '.\/syntax\/relaxng\/datatype\/java\/dist\/html5-datatypes.jar'\n\nindeed, there is a \"dist\" folder under that path, but it's empty (no files inside).\nI also tried to download file from daisy-pipeline, but it's deleted after running python build again\nI'm using Java 1.7.0_04 on Ubuntu x64","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":218,"Q_Id":11540645,"Users Score":0,"Answer":"As noted above:\n\nYou need to install JDK, not only JRE. That is because you need java compiler.","Q_Score":3,"Tags":"java,python,html,symfony,liipfunctionaltestbundle","A_Id":26174556,"CreationDate":"2012-07-18T11:48:00.000","Title":"html5 checker compilation","Data Science and Machine Learning":0,"Database and SQL":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},{"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},{"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},{"Question":"I have a python module packaged by distutils into a zipped egg installed in a custom prefix. If I set PYTHONPATH to contain that prefix's site-packages directory, the egg is added to sys.path and the module can be imported. If I instead from within the script run site.addsitedir with the prefix's site-packages directory, however, the egg is not added to sys.path and the module import fails. In both cases, the module's site-packages directory ends up in sys.path.\nIs this expected behavior? If so, is there any way to tell Python to process the .pth files in a given directory without setting an env var?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":3434,"Q_Id":11562721,"Users Score":2,"Answer":"If I set PYTHONPATH to contain that prefix's site-packages directory, the egg is added to sys.path and the module can be imported. \n\nAdding some directory to PYTHONPATH doesn't trigger processing of .pth-files in it. Therefore your zipped egg won't be in sys.path. You can import a module from the egg only if the egg itself is in sys.path (parent directory is not enough).\n\nIf I instead from within the script run site.addsitedir with the prefix's site-packages directory, however, the egg is not added to sys.path and the module import fails.\n\nsite.addsitedir() triggers processing of .pth-files if the directory hasn't been seen yet so it should work.\nThe behavior you described is the opposite of what should happen.\nAs a workaround you could add the egg to sys.path manually: sys.path.insert(0, '\/path\/to\/the.egg')","Q_Score":0,"Tags":"python,pythonpath","A_Id":11576705,"CreationDate":"2012-07-19T14:11:00.000","Title":"site.addsitedir doesn't add egg to sys.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":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I am using Python 2.7, beanstalkd server with beanstalkc as the client library.\nIt takes about 500 to 1500 ms to process each job, depending on the size of the job.\nI have a cron job that will keep adding jobs to the beanstalkd queue and a \"worker\" that will run in an infinite loop getting jobs and processing them.\neg:\ndef get_job(self):\n while True:\n job = self.beanstalk.reserve(timeout=0)\n if job is None:\n timeout = 10 #seconds\n continue\n else:\n timeout = 0 #seconds\n self.process_job(job)\n\nThis results in \"timed out\" exception.\nIs this the best practice to pull a job from the queue?\nCould someone please help me out here?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1433,"Q_Id":11567431,"Users Score":4,"Answer":"Calling beanstalk.reserve(timeout=0) means to wait 0 seconds for a job to become available,\nso it'll time out immediately unless a job is already\nin the queue when it's called. If you want it never to time out,\nuse timeout=None (or omit the timeout parameter, since None is the default).","Q_Score":0,"Tags":"python,timeout,jobs,beanstalkd,beanstalkc","A_Id":11570528,"CreationDate":"2012-07-19T18:53:00.000","Title":"Getting jobs from beanstalkd - timed out exception","Data Science and Machine Learning":0,"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},{"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},{"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},{"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},{"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},{"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},{"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},{"Question":"I have a script which will log into a STMP server (GMail's) to send an email notification. How can I do this without distributing the password in plain text?","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":168,"Q_Id":11576502,"Users Score":1,"Answer":"Have the script request the password when running.\nNote, I wouldn't advise that it accept the password as a command line argument as this isn't very secure because it will be logged in the command history etc.","Q_Score":2,"Tags":"python,gmail,password-protection","A_Id":11576535,"CreationDate":"2012-07-20T09:21:00.000","Title":"Distribute a script, but protect the password","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I have a script which will log into a STMP server (GMail's) to send an email notification. How can I do this without distributing the password in plain text?","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":168,"Q_Id":11576502,"Users Score":0,"Answer":"check if your provider offers an smtp server that doesn't require authentication and use that instead.","Q_Score":2,"Tags":"python,gmail,password-protection","A_Id":11576594,"CreationDate":"2012-07-20T09:21:00.000","Title":"Distribute a script, but protect the password","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I'm looking for a language or library to allow me to simulate key strokes at the maximum level possible, without physically pressing the key. \n(My specific measure of the level of the keystroke is whether or not it will produce the same output as a physical Key Press when my computer is already running key listeners (such as MouseKeys and StickyKeys)).\nI've tried many methods of keystroke emulation;\nThe java AWT library, Java win32api, python win32com sendKeys, python ctypes Key press, and many more libraries for python and Java, but none of them simulate the key stroke at a close enough level to actual hardware.\n(When Windows MouseKeys is active, sending a key stroke of a colon, semi colon or numpad ADD key just produces those characters, where as a physical press performs the MouseKeys click)\nI believe such methods must involve sending the strokes straight to an application, rather than passing them just to the OS.\nI'm coming to the idea that no library for these high (above OS code) level languages will produce anything adequate. I fear I might have to stoop to some kind of BIOS programming.\nDoes anybody have any useful information on the matter whatsoever?\nHow would I go about emulating key presses in lower level languages?\nShould I be looking for a my-hardware-specific solution (some kind of Fujitsu hardware API)?\nI almost feel it would be easier to program a robot to simply sit by the hardware and press the keys.\nThanks!","AnswerCount":4,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":14658,"Q_Id":11597892,"Users Score":0,"Answer":"I'm not on a Windows box to test it against MouseKeys, so no guarantees that it will work, but have you tried AutoHotkey?","Q_Score":11,"Tags":"java,python,hardware,keystroke,simulate","A_Id":11598099,"CreationDate":"2012-07-22T05:08:00.000","Title":"Simulate Key Press at hardware level - 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},{"Question":"I am getting ready to start a little Android development and need to choose a language. I know Python but would have to learn Java. I'd like to know from those of you who are using Python on Android what the limitations are. Also, are there any benefits over Java?","AnswerCount":3,"Available Count":1,"Score":0.2605204458,"is_accepted":false,"ViewCount":20495,"Q_Id":11600364,"Users Score":4,"Answer":"I have developed Android Apps on the market, coded in Python. Downsides: \n\nThus far my users must download the interpreter as well, but they are immediately prompted to do so. (UPDATE: See comment below.)\nThe script does not exit properly, so I include a webView page that asks them to goto:Settings:Apps:ForceClose if this issue occurs.","Q_Score":28,"Tags":"java,android,python,sl4a","A_Id":12758628,"CreationDate":"2012-07-22T12:38:00.000","Title":"What are the limitations of Python 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":0,"Web Development":0},{"Question":"I have quite a few static files used in my Google App Engine application (CSS, robots.txt, etc.) They are all defined in app.yaml.\nI want to have some automated tests that check whether those definitions in app.yaml are valid and my latest changes didn't brake anything. E.g. check that specific URLs return correct responses. Ideally, it should be a part of my app unit tests.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":120,"Q_Id":11600374,"Users Score":1,"Answer":"I have a post deploy script for the staging environment that just does curl on the urls to validate they are all there. If this script passes (among other things) I will deploy from staging to production.","Q_Score":1,"Tags":"python,unit-testing,google-app-engine","A_Id":11600406,"CreationDate":"2012-07-22T12:39:00.000","Title":"How to write tests for static routes defined in app.yaml?","Data Science and Machine Learning":0,"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},{"Question":"for the most part I work in Python, and as such I have developed a great appreciation for the repr() function which when passed a string of arbitrary bytes will print out it's human readable hex format. Recently I have been doing some work in C and I am starting to miss the python repr function. I have been searching on the internet for something similar to it, preferably something like void buffrepr(const char * buff, const int size, char * result, const int resultSize) But I have ha no luck, is anyone aware of a simple way to do this?","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1147,"Q_Id":11601703,"Users Score":0,"Answer":"The most simple way would be printf()\/sprintf() with the %x and %X format specifiers.","Q_Score":5,"Tags":"python,c,repr","A_Id":11601779,"CreationDate":"2012-07-22T15:51:00.000","Title":"Python style repr for char * buffer 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":0,"Web Development":0},{"Question":"I have Sage 4.7.1 installed and have run into an odd problem. Many of my older scripts that use functions like deepcopy() and uniq() no longer recognize them as global names. I have been able to fix this by importing the python modules one by one, but this is quite tedious. But when I start the command-line Sage interface, I can type \"list2=deepcopy(list1)\" without importing the copy module, and this works fine. How is it possible that the command line Sage can recognize global name 'deepcopy' but if I load my script that uses the same name it doesn't recognize it?\noops, sorry, not familiar with stackoverflow yet. I type: 'sage_4.7.1\/sage\" to start the command line interface; then, I type \"load jbom.py\" to load up all the functions I defined in a python script. When I use one of the functions from the script, it runs for a few seconds (complex function) then hits a spot where I use some function that Sage normally has as a global name (deepcopy, uniq, etc) but for some reason the script I loaded does not know what the function is. And to reiterate, my script jbom.py used to work the last time I was working on this particular research, just as I described.\nIt also makes no difference if I use 'load jbom.py' or 'import jbom'. Both methods get the functions I defined in my script (but I have to use jbom. in the second case) and both get the same error about 'deepcopy' not being a global name.\nREPLY TO DSM: I have been sloppy about describing the problem, for which I am sorry. I have created a new script 'experiment.py' that has \"import jbom\" as its first line. Executing the function in experiment.py recognizes the functions in jbom.py but deepcopy is not recognized. I tried loading jbom.py as \"load jbom.py\" and I can use the functions just like I did months ago. So, is this all just a problem of layering scripts without proper usage of import\/load etc?\nSOLVED: I added \"from sage.all import *\" to the beginning of jbom.py and now I can load experiment.py and execute the functions calling jbom.py functions without any problems. From the Sage doc on import\/load I can't really tell what I was doing wrong exactly.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":784,"Q_Id":11602817,"Users Score":0,"Answer":"Okay, here's what's going on:\nYou can only import files ending with .py (ignoring .py[co]) These are standard Python files and aren't preparsed, so 1\/3 == int(0), not QQ(1)\/QQ(3), and you don't have the equivalent of a from sage.all import * to play with.\nYou can load and attach both .py and .sage files (as well as .pyx and .spyx and .m). Both have access to Sage definitions but the .py files aren't preparsed (so y=17 makes y a Python int) while the .sage files are (so y=17 makes y a Sage Integer).\nSo import jbom here works just like it would in Python, and you don't get the access to what Sage has put in scope. load etc. are handy but they don't scale up to larger programs so well. I've proposed improving this in the past and making .sage scripts less second-class citizens, but there hasn't yet been the mix of agreement on what to do and energy to do it. In the meantime your best bet is to import from sage.all.","Q_Score":0,"Tags":"python,module,sage","A_Id":11603378,"CreationDate":"2012-07-22T18:18:00.000","Title":"python modules missing in sage","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I'm working on a module using sockets with hundreds of test cases. Which is nice. Except now I need to test all of the cases with and without socket.setdefaulttimeout( 60 )... Please don't tell me cut and paste all the tests and set\/remove a default timeout in setup\/teardown.\nHonestly, I get that having each test case laid out on it's own is good practice, but i also don't like to repeat myself. This is really just testing in a different context not different tests.\ni see that unittest supports module level setup\/teardown fixtures, but it isn't obvious to me how to convert my one test module into testing itself twice with two different setups. \nany help would be much appreciated.","AnswerCount":5,"Available Count":1,"Score":0.1586485043,"is_accepted":false,"ViewCount":5608,"Q_Id":11604888,"Users Score":4,"Answer":"I would do it like this:\n\nMake all of your tests derive from your own TestCase class, let's call it SynapticTestCase.\nIn SynapticTestCase.setUp(), examine an environment variable to determine whether to set the socket timeout or not.\nRun your entire test suite twice, once with the environment variable set one way, then again with it set the other way.\nWrite a small shell script to invoke the test suite both ways.","Q_Score":13,"Tags":"python,unit-testing,sockets,fixtures","A_Id":11604901,"CreationDate":"2012-07-22T23:39:00.000","Title":"python unittests with multiple setups?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":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},{"Question":"I am trying to use the python ctypes library to access various functions in a COM DLL created in Visual Fox Pro (from a .prg file).\nHere is an example in fox pro (simplified from the actual code)\n\nDEFINE CLASS Testing AS CUSTOM OLEPUBLIC\n\n PROCEDURE INIT\n ON ERROR\n SET CONSOLE OFF\n SET NOTIFY OFF\n SET SAFETY OFF\n SET TALK OFF\n SET NOTIFY OFF\n ENDPROC\n\n FUNCTION get_input_out(input AS STRING) AS STRING\n output = input\n RETURN output\n ENDFUNC\n\nENDDEFINE\n\nIn python i am doing something along the lines of:\n\nimport ctypes\n\nlink = ctypes.WinDLL(\"path\\to\\com.dll\")\nprint link.get_input_out(\"someinput\")\n\n\nThe dll registers fine and is loaded but i just get the following when I try to call the function.\n\nAttributeError: function 'get_input_out' not found\n\nI can verfiy the dll does work as i was able to access the functions with a php script using the COM libary.\nI would really like to get this working in python but so far my attempts have all been in vain, will ctypes even work with VFP? Any advice would be appreciated.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":740,"Q_Id":11612663,"Users Score":0,"Answer":"Try removing the parentheses from the call to the function. Change print link.get_input_out(\"someinput\") to print link.get_input_out \"someinput\".","Q_Score":1,"Tags":"python,dll,ctypes,foxpro,visual-foxpro","A_Id":11613687,"CreationDate":"2012-07-23T12:35:00.000","Title":"Using Python ctypes to access a Visual Foxpro COM DLL","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I am currently doing some I\/O intensive load-testing using python. All my program does is to send HTTP requests as fast as possible to my target server.\nTo manage this, I use up to 20 threads as I'm essentially bound to I\/O and remote server limitations.\nAccording to 'top', CPython uses a peak of 130% CPU on my dual core computer.\nHow is that possible ? I thought the GIL prevented this ? Or is it the way Linux 'counts' the resources consumed by each applications ?","AnswerCount":3,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":1861,"Q_Id":11615449,"Users Score":0,"Answer":"If you find this irritating, set your preferences (specifically, the preferences of your System Monitor or equivalent tool) to enable \"Solaris Mode,\" which calculates CPU% as a proportion of total processing power, not the proportion of a single core's processing power.","Q_Score":3,"Tags":"python,linux,multithreading,load","A_Id":11617105,"CreationDate":"2012-07-23T15:17:00.000","Title":"Python interpreters uses up to 130% of my CPU. How is that possible?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am currently doing some I\/O intensive load-testing using python. All my program does is to send HTTP requests as fast as possible to my target server.\nTo manage this, I use up to 20 threads as I'm essentially bound to I\/O and remote server limitations.\nAccording to 'top', CPython uses a peak of 130% CPU on my dual core computer.\nHow is that possible ? I thought the GIL prevented this ? Or is it the way Linux 'counts' the resources consumed by each applications ?","AnswerCount":3,"Available Count":3,"Score":0.0665680765,"is_accepted":false,"ViewCount":1861,"Q_Id":11615449,"Users Score":1,"Answer":"That is possible in situations when used C-extension library call releases GIL and does some further processing in the background.","Q_Score":3,"Tags":"python,linux,multithreading,load","A_Id":11615563,"CreationDate":"2012-07-23T15:17:00.000","Title":"Python interpreters uses up to 130% of my CPU. How is that possible?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am currently doing some I\/O intensive load-testing using python. All my program does is to send HTTP requests as fast as possible to my target server.\nTo manage this, I use up to 20 threads as I'm essentially bound to I\/O and remote server limitations.\nAccording to 'top', CPython uses a peak of 130% CPU on my dual core computer.\nHow is that possible ? I thought the GIL prevented this ? Or is it the way Linux 'counts' the resources consumed by each applications ?","AnswerCount":3,"Available Count":3,"Score":1.2,"is_accepted":true,"ViewCount":1861,"Q_Id":11615449,"Users Score":15,"Answer":"100 percent in top refer to a single core. On a dual-core machine, you have up to 200 per cent available.\nA single single-threaded process can only make use of a single core, so it is limited to 100 percent. Since your process has several threads, nothing is stopping it from making use of both cores.\nThe GIL only prevents pure-Python code from being executed concurrently. Many library calls (including most I\/O stuff) release the GIL, so no problem here as well. Contrary to much of the FUD on the internet, the GIL rarely reduces real-world performance, and if it does, there are usually better solutions to the problem than using threads.","Q_Score":3,"Tags":"python,linux,multithreading,load","A_Id":11615490,"CreationDate":"2012-07-23T15:17:00.000","Title":"Python interpreters uses up to 130% of my CPU. How is that possible?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm debating whether to use C++ or Python for a largely math-based program. \nBoth have great math libraries, but which language is generally faster for complex math?","AnswerCount":7,"Available Count":4,"Score":1.2,"is_accepted":true,"ViewCount":3134,"Q_Id":11625450,"Users Score":7,"Answer":"I guess it is safe to say that C++ is faster. Simply because it is a compiled language which means that only your code is running, not an interpreter as with python. \nIt is possible to write very fast code with python and very slow code with C++ though. So you have to program wisely in any language!\nAnother advantage is that C++ is type safe, which will help you to program what you actually want.\nA disadvantage in some situations is that C++ is type safe, which will result in a design overhead. You have to think (maybe long and hard) about function and class interfaces, for instance.\nI like python for many reasons. So don't understand this a plea against python.","Q_Score":2,"Tags":"c++,python,math","A_Id":11625468,"CreationDate":"2012-07-24T06:41:00.000","Title":"C++ or Python for an Extensive Math 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},{"Question":"I'm debating whether to use C++ or Python for a largely math-based program. \nBoth have great math libraries, but which language is generally faster for complex math?","AnswerCount":7,"Available Count":4,"Score":1.0,"is_accepted":false,"ViewCount":3134,"Q_Id":11625450,"Users Score":8,"Answer":"You could also consider a hybrid approach. Python is generally easier and faster to develop in, specially for things like user interface, input\/output etc. \nC++ should certainly be faster for some math operations (although if your problem can be formulated in terms of vector operations or linear algebra than numpy provides a python interface to very efficient vector manipulations).\nPython is easy to extend with Cython, Swig, Boost Python etc. so one strategy is write all the bookkeeping type parts of the program in Python and just do the computational code in C++.","Q_Score":2,"Tags":"c++,python,math","A_Id":11625521,"CreationDate":"2012-07-24T06:41:00.000","Title":"C++ or Python for an Extensive Math 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},{"Question":"I'm debating whether to use C++ or Python for a largely math-based program. \nBoth have great math libraries, but which language is generally faster for complex math?","AnswerCount":7,"Available Count":4,"Score":0.1137907297,"is_accepted":false,"ViewCount":3134,"Q_Id":11625450,"Users Score":4,"Answer":"It all depends if faster is \"faster to execute\" or \"faster to develop\". Overall, python will be quicker for development, c++ faster for execution. For working with integers (arithmetic), it has full precision integers, it has a lot of external tools (numpy, pylab...) My advice would be go python first, if you have performance issue, then switch to cpp (or use external libraries written in cpp from python, in an hybrid approach) \nThere is no good answer, it all depends on what you want to do in terms of research \/ calculus","Q_Score":2,"Tags":"c++,python,math","A_Id":11625696,"CreationDate":"2012-07-24T06:41:00.000","Title":"C++ or Python for an Extensive Math 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},{"Question":"I'm debating whether to use C++ or Python for a largely math-based program. \nBoth have great math libraries, but which language is generally faster for complex math?","AnswerCount":7,"Available Count":4,"Score":0.0,"is_accepted":false,"ViewCount":3134,"Q_Id":11625450,"Users Score":0,"Answer":"I sincerely doubt that Google and Stanford don't know C++. \n\"Generally faster\" is more than just language. Algorithms can make or break a solution, regardless of what language it's written in. A poor choice written in C++ and be beaten by Java or Python if either makes a better algorithm choice.\nFor example, an in-memory, single CPU linear algebra library will have its doors blown in by a parallelized version done properly.\nAn implicit algorithm may actually be slower than an explicit one, despite time step stability restrictions, because the latter doesn't have to invert a matrix. This is often true for hyperbolic partial differential equations.\nYou shouldn't care about \"generally faster\". You ought to look deeply into the problem you're trying to solve and the algorithms used to solve it. You'll do better that way than a blind language choice.","Q_Score":2,"Tags":"c++,python,math","A_Id":11630046,"CreationDate":"2012-07-24T06:41:00.000","Title":"C++ or Python for an Extensive Math 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},{"Question":"I'm writing a 2D game in Python that has gravity as a major mechanic.\nI have some of the game engine made, but the part where I'm stuck is actually determining what to add to the X and Y velocities of each mass.\nSo say I have circle A and circle B, each with a position, a velocity, and a mass. Each should be pulled towards the other fairly realistically, simulating Newtonian gravity. How would I achieve this?\nYes, I am being very ambiguous with the units of measurement. Later I can experiment with changing the variables to fit the formula.","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":1914,"Q_Id":11641077,"Users Score":1,"Answer":"Assuming that you've got an in-game quantized unit of time, a \"tick\" of the clock, if you will, give each body a velocity vector (how much, and in which directions, it moves per \"tick\") and for each tick, have each other body change its velocity vector by some amount based on their distance (exert a force on it, divided by its mass). Then, whenever your clock ticks, the bodies move according to their velocity vectors, and then their velocity vectors changed based on the net force on them. As long as you decide which happens first - acceleration or motion - provided that your ticks are small enough, you should be fine.","Q_Score":3,"Tags":"python,physics,game-physics","A_Id":11641106,"CreationDate":"2012-07-25T00:17:00.000","Title":"Newtonian gravity simulation","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm writing a 2D game in Python that has gravity as a major mechanic.\nI have some of the game engine made, but the part where I'm stuck is actually determining what to add to the X and Y velocities of each mass.\nSo say I have circle A and circle B, each with a position, a velocity, and a mass. Each should be pulled towards the other fairly realistically, simulating Newtonian gravity. How would I achieve this?\nYes, I am being very ambiguous with the units of measurement. Later I can experiment with changing the variables to fit the formula.","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":1914,"Q_Id":11641077,"Users Score":3,"Answer":"You need to solve the equations of motion for each body. They'll be written as a set of coupled, first-order, ordinary differential equations. You'll write one equation each for the x- and y-directions, which will give you the acceleration as a function of the gravitational force between the two bodies divided by their respective masses.\nYou know the relationships between acceleration, velocity, and displacement.\nYou end up four coupled ordinary differential equations to solve. Use a time stepping solution to advance the solution in time - explicit or implicit, your choice.","Q_Score":3,"Tags":"python,physics,game-physics","A_Id":11641140,"CreationDate":"2012-07-25T00:17:00.000","Title":"Newtonian gravity simulation","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"In selenium testing, there is htmlunitdriver which you can run tests without browser with. I need to do this with windmill too. Is there a way to do this in windmill?\nThank!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":364,"Q_Id":11645451,"Users Score":0,"Answer":"If you're looking to run Windmill in headless mode (no monitor) you can do it by running\nXvfb :99 -ac &\nDISPLAY=:99 windmill firefox -e test=\/path\/to\/your\/test.py","Q_Score":1,"Tags":"python,selenium,windmill,browser-testing","A_Id":12344550,"CreationDate":"2012-07-25T08:17:00.000","Title":"Windmill-Without web browser","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},{"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},{"Question":"In a programming language that has a file object, would you rather pass this object to a function or the path to the physical file and let the function open the file itself?\nIf the language does matter for your answer, please consider c++ and python.\nThanks,\nSomebody","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":681,"Q_Id":11649744,"Users Score":0,"Answer":"That depends very much on the specific case. \nIf I were to use the file in several (sub)functions than I would rather pass the initialised file object (or function). \nIf I have one function to get the filename and path and another to do something with the data of the file, I would probably prefer to pass the path and filename and have the file opened by the function that uses the data.","Q_Score":1,"Tags":"c++,python,coding-style","A_Id":11649914,"CreationDate":"2012-07-25T12:29:00.000","Title":"pass file or filename to 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":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"In a programming language that has a file object, would you rather pass this object to a function or the path to the physical file and let the function open the file itself?\nIf the language does matter for your answer, please consider c++ and python.\nThanks,\nSomebody","AnswerCount":3,"Available Count":2,"Score":0.1973753202,"is_accepted":false,"ViewCount":681,"Q_Id":11649744,"Users Score":3,"Answer":"My understanding of good coding practices is to open the file where the information is to be used and not in a more global scope in any language.","Q_Score":1,"Tags":"c++,python,coding-style","A_Id":11649800,"CreationDate":"2012-07-25T12:29:00.000","Title":"pass file or filename to 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":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I addded the project root of my python project to the PYTHONPATH. Now the import of my modules works in the CLI of python bot NOT in a python script. \nHow can I fix that?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":72,"Q_Id":11665765,"Users Score":2,"Answer":"Call your script with -v option.\n\npython -v yourscript.py\n\nThis will trace all the import statements and look or do grep for your project name. If it's not in that, then either it's not at all added to your python path or you're running different python interpreter.","Q_Score":0,"Tags":"python,import","A_Id":11666220,"CreationDate":"2012-07-26T08:57:00.000","Title":"Relative import works on CLI but not in 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},{"Question":"Is there a way to list all my HIT types (not HITs or assignments) using the mturk api?\nI can't find any documentation on this. I'm using python, so it'd be nice if boto supported this query.","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":362,"Q_Id":11673711,"Users Score":1,"Answer":"Looking through the MTurk API (http:\/\/docs.amazonwebservices.com\/AWSMechTurk\/latest\/AWSMturkAPI\/Welcome.html) I don't see anything that returns a list of HIT types. You should post a query to the MTurk forum (https:\/\/forums.aws.amazon.com\/forum.jspa?forumID=11). It seems like a useful feature to add.","Q_Score":0,"Tags":"python,boto,mechanicalturk","A_Id":11677299,"CreationDate":"2012-07-26T16:21:00.000","Title":"List all hitTypes through the mturk 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},{"Question":"Is there a way to list all my HIT types (not HITs or assignments) using the mturk api?\nI can't find any documentation on this. I'm using python, so it'd be nice if boto supported this query.","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":362,"Q_Id":11673711,"Users Score":1,"Answer":"Unfortunately there isn't. We resort to persisting every HitType locally that we create through turk's api at houdiniapi.com which works just fine.","Q_Score":0,"Tags":"python,boto,mechanicalturk","A_Id":11678042,"CreationDate":"2012-07-26T16:21:00.000","Title":"List all hitTypes through the mturk 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},{"Question":"I'm sure this is well documented somewhere, but I can't find it! I want to make my scripts portable to machines that may not have their Python interpreters in the same location. For that reason, I thought that I could just code the first line as #!python3 rather than with the absolute path to the interpreter, like #!\/usr\/local\/bin\/python3.\nNo doubt most of you understand why this doesn't work, but I have no idea. Although my lab mates aren't complaining about having to recode my scripts to reflect the absolute path to the interpreter on their own machines, this seems like it shouldn't be necessary. I'd be perfectly happy with a response providing a link to the appropriate documentation. Thanks in advance.","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":155,"Q_Id":11674359,"Users Score":2,"Answer":"env is a program that handles these sort of things. You should pretty much always use something like #! \/usr\/bin\/env python3 as your shebang line rather than specifying an absolute path.","Q_Score":1,"Tags":"python","A_Id":11674391,"CreationDate":"2012-07-26T17:02:00.000","Title":"How to make Python script portable to machines with interpreters in different locations?","Data Science and Machine Learning":0,"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},{"Question":"I am starting on a new project at a new job. This is my first time working heavily in Python. Mocking is a whole new beast compared to the hoops I had to jump through in a statically typed language. I took it upon myself to look into the team's unit tests and hopefully upgrade some of them from using Dingus to Mock.\nEarlier today, I came across some tests that were checking a conversion class. Specifically, it converted strings of hexadecimal numbers into Mongo ObjectIds (unique identifiers). What I expected to see was a test that verified given a valid hex number, an ObjectId with same hex number would be returned -or- given a bad hex number an error would occur. Instead, all that the tests verified were that an ObjectId was created and returned. In fact, ObjectId was mocked out entirely and so was the hex number!\nNow, creating an ObjectId from a string doesn't require going out to a server or anything. Everything is run locally.\nI asked about this particular test suite with my new coworkers. Their thoughts were that the actual conversion should be verified using an integration test and being a unit test, all the unit test should do is make sure the code flows from top to bottom as expected and the ObjectId is created and returned. So, basically, the tests only verify that this class interacts with the environment in the expected way.\nI have been writing unit tests for a long time. In my experience, I wouldn't be using mocks at all and I would just verify the conversions occurred as expected. This means interacting with the ObjectId class from another module. Perhaps my idea of a unit tests is too encompassing. I have always reserved integration tests for connecting to remote servers, files and whatnot.\nThe way I look at it, working with ObjectId in this example is no different than working with str or list. Sure, I can mock out str and list, but since they are essential to what my code is doing, mocking them out doesn't make much sense in my mind. The only time I should care about interacting with a dependency is when it can change the outcome of the test.\nIs there any value in writing unit tests that simply check the flow of code? Shouldn't unit tests be the result of verifying the behavior\/correctness of the code in mind?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":355,"Q_Id":11674762,"Users Score":1,"Answer":"So, it's tough to see exactly what's going on without seeing the code, but based solely on your explanation...\nI would agree with you. The behavior is what is important, not the flow of the code.\nWhat if someone later on needs to change the flow of the code to support a different case (say, using a function with a different argument that accomplishes the same result); they can do so without breaking the existing tests.\nWhat if you upgrade the library that is being used, and now calling the function actually has a different result than what you want? Your test still works (the function is being called), but what the unit test is actually trying to test does not.\nReally, how mocks and tests are used is still a pretty young discipline. The jury is still out over whether unit testing (and the various strategies that are used in unit testing, such as mocking) are even considered \"good thing\". No doubt, however, I have found myself creating tests not to actually test behavior, but just so that I can say I have the test, and improper use of mocks is a great way to pretend you've created a test when really you've just created a false feeling of accomplishment that your code has now been more rigorously tested.","Q_Score":2,"Tags":"python,unit-testing,mocking","A_Id":11674984,"CreationDate":"2012-07-26T17:29:00.000","Title":"Python Unit Testing and when to Mock","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I was until now programming in C, which is a very basic language. But now as I am studying data structures, my online teacher actually uses some methods like leftChild(), rightChild(), etc.\nBut then I started searching whether tree ADT and such are implemented in C++, Python, Java \nby default. And mostly the answers were no.\nI just want to confirm whether any language supports tree ADT by default that means without downloading their classes separately.","AnswerCount":2,"Available Count":2,"Score":-0.0996679946,"is_accepted":false,"ViewCount":668,"Q_Id":11675707,"Users Score":-1,"Answer":"Many of the STL containers in C++ are commonly implemented using trees. Examples include std::map and std::set","Q_Score":1,"Tags":"java,c++,python,c","A_Id":11675784,"CreationDate":"2012-07-26T18:28:00.000","Title":"built in Abstract Data Types in c++\/python\/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},{"Question":"I was until now programming in C, which is a very basic language. But now as I am studying data structures, my online teacher actually uses some methods like leftChild(), rightChild(), etc.\nBut then I started searching whether tree ADT and such are implemented in C++, Python, Java \nby default. And mostly the answers were no.\nI just want to confirm whether any language supports tree ADT by default that means without downloading their classes separately.","AnswerCount":2,"Available Count":2,"Score":-0.0996679946,"is_accepted":false,"ViewCount":668,"Q_Id":11675707,"Users Score":-1,"Answer":"These are the basic ADTs. I think you should first learn and code them yourselves before jumping into any library with these inbuild features.\nThanks","Q_Score":1,"Tags":"java,c++,python,c","A_Id":11676043,"CreationDate":"2012-07-26T18:28:00.000","Title":"built in Abstract Data Types in c++\/python\/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},{"Question":"I'm currently writing a script, which at some point needs to compare numbers provided to the script by two different sources\/inputs. One source provides the numbers as integers and one source provides them as strings. I need to compare them, so I need to use either str() on the integers or int() on the strings.\nAssuming the amount of conversions would be equal, would it be more efficient to convert the strings into integers or vice versa?","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":2669,"Q_Id":11687183,"Users Score":1,"Answer":"I don't really know what you exactly mean by \"compare\", but if it is not always only strict egality you'd better work with integers. You could need to sort your data or whatever, and it will be easier this way !","Q_Score":3,"Tags":"python,string,int,type-conversion,performance","A_Id":11687359,"CreationDate":"2012-07-27T11:49:00.000","Title":"More efficient to convert string to int or inverse?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to write a test script in python which should reboot the system in between the test execution on local machine... (No remote automation server is monitoring the script). How the script execution can be made continuous even after reboot? The script covers following scenario...\n\nCreate a Volume on some disk\nCreate a filesystem and mount the file system temporary \nReboot the system \nVerify if filesystem is mounted \nMount the filesystem again.","AnswerCount":1,"Available Count":1,"Score":0.537049567,"is_accepted":false,"ViewCount":1400,"Q_Id":11700172,"Users Score":3,"Answer":"It's not about python but rather about your whole system config. In given conditions I suggest you to split your script on 2 parts. First part is doing 1..3 and storing some extra info you're required onto persistent storage other than the fs you're experimenting on. The second part is invoked on each OS os start, reads some data stored by first part and then performs checking actions 4..5. It seems to be the most obvious and simple way.","Q_Score":0,"Tags":"python,reboot","A_Id":11700297,"CreationDate":"2012-07-28T10:24:00.000","Title":"How to continue the python script execution from the point it left before reboot","Data Science and Machine Learning":0,"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},{"Question":"I need to call GET, POST, PUT, etc. requests to another URI because of search, but I cannot find a way to do that internally with pyramid. Is there any way to do it at the moment?","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":552,"Q_Id":11701920,"Users Score":1,"Answer":"Also check the response status code: response.status_int\nI use it for example, to introspect my internal URIs and see whether or not a given relative URI is really served by the framework (example to generate breadcrumbs and make intermediate paths as links only if there are pages behind)","Q_Score":5,"Tags":"python,pyramid","A_Id":13202389,"CreationDate":"2012-07-28T14:35:00.000","Title":"Pyramid subrequests","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},{"Question":"I put a simple python script inside the cgi-bin in apache2 and tried to execute it using the browser as follows,\n\"http:\/\/www.example.com\/cgi-bin\/test.py\"\nBut it gives a 500 Internal sever error.\nFollowing is the error.log in apache2.\n[Sun Jul 29 22:07:51 2012] [error] (8)Exec format error: exec of '\/usr\/lib\/cgi-bin\/test.py' failed\n[Sun Jul 29 22:07:51 2012] [error] [client ::1] Premature end of script headers: test.py\n[Sun Jul 29 22:07:51 2012] [error] [client ::1] File does not exist: \/var\/www\/favicon.ico\ncan anyone help me on this?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":2241,"Q_Id":11711060,"Users Score":1,"Answer":"BlaXpirit's answer should solve your problem with a 500 server internal error.\nIt is important to note the \"\\n\" at the end of the first print statement. You can also write it as \nprint(\"Content-Type: text\/html; charset=utf-8\")\nprint()\nI was surprised to learn that writing out these headers is necessary even if your Python program is only going to do server-side work - with no response to the browser at all.","Q_Score":2,"Tags":"python,apache","A_Id":14268807,"CreationDate":"2012-07-29T16:51:00.000","Title":"How to run a python script inside the cgi-bin of apache 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":1,"Web Development":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},{"Question":"I'm trying to develop a small script that generate a complete new pdf, mainly text and tables, file as result.\nI'm searching for the best way to do it. \nI've read about reportlab, which seems pretty good. It has only one drawback asfar as I can see. It is quiet hard to write a template without the commercial version, and the code seems to be hard to maintain.\nSo I've searched for a more sufficient way and found xhtml2pdf, but this software is quiet old, and cannot generate tables over two pages or more.\nThe last solution in my mind it to generate a tex-File with a template framework, and later call pdftex as subprocess. \nI would implement the last one, and go over LateX. Would you do so, have you better ideas?","AnswerCount":3,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":3407,"Q_Id":11725645,"Users Score":5,"Answer":"I would suggest using the LaTeX approach. It is cross-platform, works in many different languages and is easy to maintain. Plus it's non-commercial!","Q_Score":6,"Tags":"python,pdf,latex","A_Id":11725677,"CreationDate":"2012-07-30T16:29:00.000","Title":"Generate a pdf 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":1},{"Question":"I have to design a interface using PHP for a software written in python. Currently this software is used from command line by passing input, mostly the input is a text file. There are series of steps and for every step a python script is called. Every step takes a text file as input and an generates an output text file in the folder decided by the user. I am using system() of php but I can't see the output but when I use the same command from command line it generates the output. Example of command :\npython \/software\/qiime-1.4.0-release\/bin\/check_id_map.py -m \/home\/qiime\/sample\/Fasting_Map.txt -o \/home\/qiime\/sample\/mapping_output -v","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":634,"Q_Id":11733149,"Users Score":0,"Answer":"instead of system() try surrounding the code in `ticks`...\nIt has a similar functionality but behaves a little differently in the way it returns the output..","Q_Score":2,"Tags":"php,python,qiime","A_Id":11733222,"CreationDate":"2012-07-31T04:33:00.000","Title":"I need to run a python script from 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":1,"Web Development":0},{"Question":"just using python & gevent.server to server a simple login server(just check some data and do some db operation), would it be a problem when it's under ddos attack?\nwould it be better if using apache\/ngnix to server http request?","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":1332,"Q_Id":11737754,"Users Score":1,"Answer":"In my opinion, you will never get the same level of security with a pure-Python server that you could have with majors web servers, as Apache and Nginx are.\nThese are well-tested before being released, so, by using a stable build and by configuring it properly, you will be close of the maximum of security possible.\nPure-python servers are very usefull during development, but I do not know any that can claim to compete with them for security testing \/ bug report \/ quick fix.\nThis is why it is generally advisable to put one of these servers in front before the server in pure python, using, for example, options like ProxyPass.","Q_Score":2,"Tags":"python,apache,nginx,gevent,httpserver","A_Id":11740272,"CreationDate":"2012-07-31T10:08:00.000","Title":"http server using python & gevent(not using 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":0,"Web Development":1},{"Question":"just using python & gevent.server to server a simple login server(just check some data and do some db operation), would it be a problem when it's under ddos attack?\nwould it be better if using apache\/ngnix to server http request?","AnswerCount":2,"Available Count":2,"Score":0.2913126125,"is_accepted":false,"ViewCount":1332,"Q_Id":11737754,"Users Score":3,"Answer":"If you are using gevent.server to implement your own HTTP server, I advise against it, and you should use instead gevent.pywsgi, that provides a full-featured, stable and thoroughly tested HTTP server. It is not as fast as gevent.wsgi, which is backed by libevent-http, but has more features that you are likely to need, like HTTPS.\nGevent is much more likely to survive a DDOS attack than Apache, but nginx is as good as gevent on this regard, although I don't see why using it if you can do just fine with your pure Python server. It would be the case of using nginx if you had multiple backends through the same server, like your auth server together with some static file serving (what could be done entirely by nginx) and possibly other subsystem, or other virtual hosts, that all could be served through a single nginx configuration.","Q_Score":2,"Tags":"python,apache,nginx,gevent,httpserver","A_Id":11740845,"CreationDate":"2012-07-31T10:08:00.000","Title":"http server using python & gevent(not using 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":0,"Web Development":1},{"Question":"I am trying to send a python (2.6) HTML email with color coded output. My script creates an output string which I format to look like a table (using str.format). It prints okay on the screen:\nabcd 24222 xyz A\nabcd 24222 xyz B\nabcd 24222 xyz A\nabcd 24222 xyz D\nBut I also need to send it as an email message and I need to have A (say in Green color), B (in Red) etc. How could I do it? \nWhat I've tried is attach FONT COLOR = #somecolor & \/FONT tags at the front and back of A, B etc. And I wrote a method\/module which adds table, tr & td tags) at appropriate parts of the string so that the message would like an HTML table in the email. But, There is an issue with this approach:\n1) This doesn't always work properly. The emails (obtained by running the exact same script) are different and many times with misalligned members and mysterious tr's or td's appearing (at different locations each time). even though my html table creation is correct\nAny help would be appreciated.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1729,"Q_Id":11745033,"Users Score":0,"Answer":"All right. Her's what worked for me, just in case anybody bumps into the same problem. I had to enter carriage return (i.e. \\n) after my every tag in the HTML table. And everything worked fine.\nPS: One clue as to whether this will help you is that, I am creating one big string of HTML.","Q_Score":0,"Tags":"python","A_Id":11868901,"CreationDate":"2012-07-31T16:43:00.000","Title":"Python HTML email : customizing output color-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":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"we have successfully added pydev plugin on our eclipse. as a result in pydev projects it detects errors and so on.\nbut the question is that is there any way that we use pydev abilities (e.g. error detection) in non-pydev projects?(e.g. a java project).\nactually we are developing an eclipse plugin that contains some .py files and we want it to interpret them as a side feature","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":113,"Q_Id":11756207,"Users Score":0,"Answer":"PyDev should be working fine. In project properties, you can set interpreter, PYTHONPATH and other PyDev related settings.\nTo manually trigger code analysis, right-click on project, file or folder and select PyDev->Code analysis","Q_Score":1,"Tags":"python,eclipse,pydev","A_Id":11758291,"CreationDate":"2012-08-01T09:18:00.000","Title":"python interpreter on non-pydev 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":1},{"Question":"The requirement is to develop a HTML based facebook app. It would not be content based like a newspaper site,\nbut will mostly have user generated data which would be aggregated and presented from database + memcache.\nThe app would contain 4-5 pages at most, with different purposes.\nWe decided to write the app in Python instead of PHP , and tried to evaluate django.\nHowever, we found django is not as flexible as how CodeIgniter in PHP is i.e. putting less restrictions and rules, and allowing you to do what you want to do.\nPHP CodeIgnitor is minimalistic MVC framework, which we would have chosen if we were to develop in PHP.\nCan you please suggest a flexible and minimalistic python based web framework? I have heard of pylons,cheeryPy,web.py , but I am completely unaware of their usage and structure.","AnswerCount":4,"Available Count":1,"Score":0.049958375,"is_accepted":false,"ViewCount":1400,"Q_Id":11759164,"Users Score":1,"Answer":"For the fastest development you may dive into Django. But Django is probably not the fastest solution. Flask is lighter. Also you can try Pyramid.","Q_Score":0,"Tags":"python,django,pylons,cherrypy","A_Id":11760761,"CreationDate":"2012-08-01T12:25:00.000","Title":"Which Python framework is flexible and similar to CodeIgniter 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":1},{"Question":"I'm working on a bit of python code that uses mechanize to grab data from another website. Because of the complexity of the website the code takes 10-30 seconds to complete. It has to work its way through a couple pages and such.\nI plan on having this piece of code being called fairly frequently. I'm wondering the best way to implement something like this without causing a huge server load. Since I'm fairly new to python I'm not sure how the language works.\nIf the code is in the middle of processing one request and another user calls the code, can two instances of the code run at once? Is there a better way to implement something like this?\nI want to design it in a way that it can complete the hefty tasks without being too taxing on the server.","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":128,"Q_Id":11762480,"Users Score":0,"Answer":"You can run more than one python process at a time. As for causing excessive load on the server that can only be alleviated by making sure either you only have one instance running at any given time or some other number of processes, say two. To accomplish this you can look at using a lock file or some kind of system flag, mutex ect...\nBut, the best way to limit excessive use is to limit the number of tasks running concurrently.","Q_Score":4,"Tags":"php,python,mysql,cron","A_Id":11762685,"CreationDate":"2012-08-01T15:25:00.000","Title":"Best way to implement frequent calls to taxing 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":0,"Web Development":0},{"Question":"In my app i sent packet by raw socket to another computer than get packet back and write the return packet to another computer by raw socket. \nMy app is c++ application run on Ubuntu work with nfqueue.\nI want to test sent packets for both computer1 and computer2 in order to check if they are as expected.\nI need to write an automation test that check my program, this automation test need to listen to the eth load the sent packets and check if they are as expected (ip,ports, payload).\nI am looking for a simple way (tool (with simple API), code) to do this.\nI need a simple way to listen (automate) to the eth .\nI preffer that the test will check the sender , but it might be difficult to find an api to listen the eth (i sent via raw socket) , so a suggested API that will check the receivers computers is also good.\nThe test application can be written in c++, java , python.","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":1276,"Q_Id":11762812,"Users Score":0,"Answer":"The only way to check if a packet has been sent correctly is by verifying it's integrity on the receiving end.","Q_Score":0,"Tags":"c++,python,testing,networking","A_Id":11763064,"CreationDate":"2012-08-01T15:40:00.000","Title":"How to test if packet is sent correct?","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},{"Question":"In my app i sent packet by raw socket to another computer than get packet back and write the return packet to another computer by raw socket. \nMy app is c++ application run on Ubuntu work with nfqueue.\nI want to test sent packets for both computer1 and computer2 in order to check if they are as expected.\nI need to write an automation test that check my program, this automation test need to listen to the eth load the sent packets and check if they are as expected (ip,ports, payload).\nI am looking for a simple way (tool (with simple API), code) to do this.\nI need a simple way to listen (automate) to the eth .\nI preffer that the test will check the sender , but it might be difficult to find an api to listen the eth (i sent via raw socket) , so a suggested API that will check the receivers computers is also good.\nThe test application can be written in c++, java , python.","AnswerCount":3,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":1276,"Q_Id":11762812,"Users Score":0,"Answer":"I operate tcpdump on the reciver coputer and save all packet to file.\nI analysis the tcpdump with python and check that packet send as expected in the test.","Q_Score":0,"Tags":"c++,python,testing,networking","A_Id":11809920,"CreationDate":"2012-08-01T15:40:00.000","Title":"How to test if packet is sent correct?","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},{"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},{"Question":"As programmers we read more than we write. I've started working at a company that uses a couple of \"big\" Python packages; packages or package-families that have a high KLOC. Case in point: Zope.\nMy problem is that I have trouble navigating this codebase fast\/easily. My current strategy is \n\nI start reading a module I need to change\/understand\nI hit an import which I need to know more of\nI find out where the source code for that import is by placing a Python debug (pdb) statement after the imports and echoing the module, which tells me it's source file\nI navigate to it, in shell or the Vim file explorer.\nmost of the time the module itself imports more modules and before I know it I've got 10KLOC \"on my plate\"\n\nAlternatively:\n\nI see a method\/class I need to know more of\nI do a search (ack-grep) for the definition of that method\/class across the whole codebase (which can be a pain because the codebase is partly in ~\/.buildout-eggs)\nI find one or more pieces of code that define that method\/class\nI have to deduce which one of them is the one I need to read\n\nThis costs a lot of time, which is understandable for a big codebase. But I get the feeling that navigating a large and unknown Python codebase is a common enough problem.\nSo I'm looking for technical tools or strategic solutions for this problem.\n...\nI just can't imagine hardcore Python programmers using the strategies outlined above.","AnswerCount":3,"Available Count":1,"Score":0.3215127375,"is_accepted":false,"ViewCount":7153,"Q_Id":11778071,"Users Score":5,"Answer":"I use ipython's ?? command\nYou just need to figure out how to import the things you want to look for, then add ?? to the end of the module or class or function or method name to view their source code. And the command completion helps on figuring out long names as well.","Q_Score":15,"Tags":"python,vim,codebase","A_Id":11778262,"CreationDate":"2012-08-02T13:07:00.000","Title":"Navigating a big Python codebase 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":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"i have a php file calls a script and prints the output like this\n\n\n $output=shell_exec('\/usr\/bin\/python hello.py');\n echo $output;\n\n\nit prints;\n\n\n b'total 16\\ndrwx---r-x 2 oae users 4096 Jul 31 14:21 .\\ndrwxr-x--x+ 9 oae root 4096 Jul 26 13:59 ..\\n-rwx---r-x 1 oae users 90 Aug 3 11:22 hello.py\\n-rwx---r-x 1 oae users 225 Aug 3 11:22 index.php\\n'\n\n\nbut it should be like this;\n\n\n total 16K\n drwx---r-x 2 oae users 4.0K Jul 31 14:21 .\/\n drwxr-x--x+ 9 oae root 4.0K Jul 26 13:59 ..\/\n -rwx---r-x 1 oae users 90 Aug 3 11:22 hello.py*\n -rwx---r-x 1 oae users 225 Aug 3 11:22 index.php*\n\n\n\\n characters shouldn't be shown.How can i solve this?","AnswerCount":4,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":10514,"Q_Id":11792129,"Users Score":0,"Answer":"An alternative would be wrapping the string between

...<\/pre> tags.","Q_Score":3,"Tags":"php,python","A_Id":11792313,"CreationDate":"2012-08-03T08:32:00.000","Title":"Print python script output correctly 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":1,"Web Development":0},{"Question":"I currently run my own server \"in the cloud\" with PHP using mod_fastcgi and mod_vhost_alias.  My mod_vhost_alias config uses a VirtualDocumentRoot of \/var\/www\/%0\/htdocs so that I can serve any domain that routes to my server's IP address out of a directory with that name.\nI'd like to begin writing and serving some Python projects from my server, but I'm unsure how to configure things so that each site has access to the appropriate script processor.\nFor example, for my blog, dead-parrot.com, I'm running a PHP blog platform (Habari, not WordPress).  But I'd like to run an app I've written in Flask on not-dead-yet.com.  \nI would like to enable Python execution with as little disruption to my mod_vhost_alias configuration as possible, so that I can continue to host new domains on this server simply by adding an appropriate directory.  I'm willing to alter the directory structure, if necessary, but would prefer not to add additional, specific vhost config files for every new Python-running domain, since apart from being less convenient than my current setup with just PHP, it seems kind of hacky to have to name these earlier alphabetically to get Apache to pick them up before the single mod_vhost_alias vhost config.\nDo you know of a way that I can set this up to run Python and PHP side-by-side as conveniently  as I do just PHP?  Thanks!","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":6266,"Q_Id":11796126,"Users Score":0,"Answer":"Even I faced the same situation, and initially I was wondering in google but later realised and fixed it, I'm using EC2 service in aws with ubuntu and I created alias to php and python individually and now I can access both.","Q_Score":3,"Tags":"php,python,apache,mod-vhost-alias","A_Id":36646397,"CreationDate":"2012-08-03T12:53:00.000","Title":"Can I run PHP and Python on the same Apache server using mod_vhost_alias and mod_wsgi?","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},{"Question":"We develop a distributed system built from components implemented in different programming languages (C++, C# and Python) and communicating one with another across a network.\nAll the components in the system operate with the same business concepts and communicate one with another also in terms of these concepts.\nAs a results we heavily struggle with the following two challenges:\n\n\nKeeping the representation of our business concepts in these three languages in sync\nSerialization \/ deserialization of our business concepts across these languages\n\nA naive solution for this problem would be just to define the same data structures (and the serialization code) three times (for C++, C# and Python). \nUnfortunately, this solution has serious drawbacks:\n\nIt creates a lot of \u201ccode duplication\u201d\nIt requires a huge amount of cross-language integration tests to keep everything in sync \n\nAnother solution we considered is based on the frameworks like ProtoBufs or Thrift. These frameworks have an internal language, in which the business concepts are defined, and then the representation of these concepts in C++, C# and Python (together with the serialization logic) is auto-generated by these frameworks.\nWhile this solution doesn\u2019t have the above problems, it has another drawback: the code generated by these frameworks couples together the data structures representing the underlying business concepts and the code needed to serialize\/deserialize these data-structures.\nWe feel that this pollutes our code base \u2013 any code in our system that uses these auto-generated classes is now \u201cfamiliar\u201d with this serialization\/deserialization logic (a serious abstraction leak). \nWe can work around it by wrapping the auto-generated code by our classes \/ interfaces, but this returns us back to the drawbacks of the naive solution.\nCan anyone recommend a solution that gets around the described problems?","AnswerCount":7,"Available Count":4,"Score":0.0,"is_accepted":false,"ViewCount":1432,"Q_Id":11802505,"Users Score":0,"Answer":"You can wrap your business logic as a web service and call it from all three languages - just a single implementation.","Q_Score":17,"Tags":"c#,c++,python,serialization,cross-language","A_Id":11803274,"CreationDate":"2012-08-03T20:01:00.000","Title":"How to share business concepts across different 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":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"We develop a distributed system built from components implemented in different programming languages (C++, C# and Python) and communicating one with another across a network.\nAll the components in the system operate with the same business concepts and communicate one with another also in terms of these concepts.\nAs a results we heavily struggle with the following two challenges:\n\n\nKeeping the representation of our business concepts in these three languages in sync\nSerialization \/ deserialization of our business concepts across these languages\n\nA naive solution for this problem would be just to define the same data structures (and the serialization code) three times (for C++, C# and Python). \nUnfortunately, this solution has serious drawbacks:\n\nIt creates a lot of \u201ccode duplication\u201d\nIt requires a huge amount of cross-language integration tests to keep everything in sync \n\nAnother solution we considered is based on the frameworks like ProtoBufs or Thrift. These frameworks have an internal language, in which the business concepts are defined, and then the representation of these concepts in C++, C# and Python (together with the serialization logic) is auto-generated by these frameworks.\nWhile this solution doesn\u2019t have the above problems, it has another drawback: the code generated by these frameworks couples together the data structures representing the underlying business concepts and the code needed to serialize\/deserialize these data-structures.\nWe feel that this pollutes our code base \u2013 any code in our system that uses these auto-generated classes is now \u201cfamiliar\u201d with this serialization\/deserialization logic (a serious abstraction leak). \nWe can work around it by wrapping the auto-generated code by our classes \/ interfaces, but this returns us back to the drawbacks of the naive solution.\nCan anyone recommend a solution that gets around the described problems?","AnswerCount":7,"Available Count":4,"Score":0.057080742,"is_accepted":false,"ViewCount":1432,"Q_Id":11802505,"Users Score":2,"Answer":"All the components in the system operate with the same business concepts and communicate \n  one with another also in terms of these concepts.\n\nWhen I got you right, you have split up your system in different parts communicating by well-defined interfaces. But your interfaces share data structures you call \"business concepts\" (hard to understand without seeing an example), and since those interfaces have to build for all of your three languages, you have problems keeping them \"in-sync\".\nWhen keeping interfaces in sync gets a problem, then it seems obvious that your interfaces are too broad. There are different possible reasons for that, with different solutions.\nPossible Reason 1 - you overgeneralized your interface concept. If that's the case, redesign here: throw generalization over board and create interfaces which are only as broad as they have to be.\nPossible reason 2: parts written in different languages are not dealing with separate business cases, you may have a \"horizontal\" partition between them, but not a vertical. If that's the case, you cannot avoid the broadness of your interfaces. \nCode generation may be the right approach here if reason 2 is your problem. If existing code generators don't suffer your needs, why don't you just write your own? Define the interfaces for example as classes in C#, introduce some meta attributes and use reflection in your code generator to extract the information again when generating the according C++, Python and also the \"real-to-be-used\" C# code. If you need different variants with or without serialization, generate them too. A working generator should not be more effort than a couple of days (YMMV depending on your requirements).","Q_Score":17,"Tags":"c#,c++,python,serialization,cross-language","A_Id":11807691,"CreationDate":"2012-08-03T20:01:00.000","Title":"How to share business concepts across different 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":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"We develop a distributed system built from components implemented in different programming languages (C++, C# and Python) and communicating one with another across a network.\nAll the components in the system operate with the same business concepts and communicate one with another also in terms of these concepts.\nAs a results we heavily struggle with the following two challenges:\n\n\nKeeping the representation of our business concepts in these three languages in sync\nSerialization \/ deserialization of our business concepts across these languages\n\nA naive solution for this problem would be just to define the same data structures (and the serialization code) three times (for C++, C# and Python). \nUnfortunately, this solution has serious drawbacks:\n\nIt creates a lot of \u201ccode duplication\u201d\nIt requires a huge amount of cross-language integration tests to keep everything in sync \n\nAnother solution we considered is based on the frameworks like ProtoBufs or Thrift. These frameworks have an internal language, in which the business concepts are defined, and then the representation of these concepts in C++, C# and Python (together with the serialization logic) is auto-generated by these frameworks.\nWhile this solution doesn\u2019t have the above problems, it has another drawback: the code generated by these frameworks couples together the data structures representing the underlying business concepts and the code needed to serialize\/deserialize these data-structures.\nWe feel that this pollutes our code base \u2013 any code in our system that uses these auto-generated classes is now \u201cfamiliar\u201d with this serialization\/deserialization logic (a serious abstraction leak). \nWe can work around it by wrapping the auto-generated code by our classes \/ interfaces, but this returns us back to the drawbacks of the naive solution.\nCan anyone recommend a solution that gets around the described problems?","AnswerCount":7,"Available Count":4,"Score":0.0,"is_accepted":false,"ViewCount":1432,"Q_Id":11802505,"Users Score":0,"Answer":"I would accomplish that by using some kind of meta-information about your domain entities (either XML or DSL, depending on complexity) and then go for code generation for each language. That would reduce (manual) code duplication.","Q_Score":17,"Tags":"c#,c++,python,serialization,cross-language","A_Id":11807498,"CreationDate":"2012-08-03T20:01:00.000","Title":"How to share business concepts across different 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":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"We develop a distributed system built from components implemented in different programming languages (C++, C# and Python) and communicating one with another across a network.\nAll the components in the system operate with the same business concepts and communicate one with another also in terms of these concepts.\nAs a results we heavily struggle with the following two challenges:\n\n\nKeeping the representation of our business concepts in these three languages in sync\nSerialization \/ deserialization of our business concepts across these languages\n\nA naive solution for this problem would be just to define the same data structures (and the serialization code) three times (for C++, C# and Python). \nUnfortunately, this solution has serious drawbacks:\n\nIt creates a lot of \u201ccode duplication\u201d\nIt requires a huge amount of cross-language integration tests to keep everything in sync \n\nAnother solution we considered is based on the frameworks like ProtoBufs or Thrift. These frameworks have an internal language, in which the business concepts are defined, and then the representation of these concepts in C++, C# and Python (together with the serialization logic) is auto-generated by these frameworks.\nWhile this solution doesn\u2019t have the above problems, it has another drawback: the code generated by these frameworks couples together the data structures representing the underlying business concepts and the code needed to serialize\/deserialize these data-structures.\nWe feel that this pollutes our code base \u2013 any code in our system that uses these auto-generated classes is now \u201cfamiliar\u201d with this serialization\/deserialization logic (a serious abstraction leak). \nWe can work around it by wrapping the auto-generated code by our classes \/ interfaces, but this returns us back to the drawbacks of the naive solution.\nCan anyone recommend a solution that gets around the described problems?","AnswerCount":7,"Available Count":4,"Score":0.0,"is_accepted":false,"ViewCount":1432,"Q_Id":11802505,"Users Score":0,"Answer":"You could model these data structures using tools like a UML modeler (Enterprise Architect comes to mind as it can generate code for all 3.) and then generate code for each language directly from the model. \nThough I would look closely at a previous comment about using XSD.","Q_Score":17,"Tags":"c#,c++,python,serialization,cross-language","A_Id":11804524,"CreationDate":"2012-08-03T20:01:00.000","Title":"How to share business concepts across different 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":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am working on a project in Python, using Git for version control, and I've decided it's time to add a couple of unit tests. However, I'm not sure about the best way to go about this.\nI have two main questions: which framework should I use and how should I arrange my tests? For the first, I'm planning to use unittest since it is built in to Python, but if there is a compelling reason to prefer something else I'm open to suggestions. The second is a tougher question, because my code is already somewhat disorganized, with lots of submodules and relative imports. I'm not sure where to fit the testing code. Also, I'd prefer to keep the testing code seperate from everything else if possible. Lastly, I want the tests to be easy to run, preferably with a single commandline command and minimal path setup. \nHow do large Python projects handle testing? I understand that there is typically an automated system to run tests on all new checkins. How do they do it? What are the best practices for setting up a testing system?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":489,"Q_Id":11822790,"Users Score":1,"Answer":"The Python unittest is fine, but it may be difficult to add unit testing to a large project. The reason is that unit testing is related to the testing of the functionality of the tiniest blocks.\nUnit testing means to use a lot of small tests that are separated each from the other. They should be independent on anything but the tested part of the code.\nWhen unittests are added to the existing code, it is usually added only to test the isolated cases that was proved to cause the error. The added unittest should be written with uncorrected functionality to disclose the error. Then the error should be fixed so that the unittest passes. This is the first extreme -- to add unit tests only to the code that fails. This is a must. You should always add unit test for the code that fails, and you should do it before you fix the error.\nNow, it is a question how to add unit tests to the large project that did not use them. The quantity of code of unit tests may be comparable with the size of the project itself. This way the other extreme could be to add unit test to everything. However, this is too much work, and you usually have to reverse engineer your own code to find the building blocks to be tested.\nI suggest to find the most important parts of the code and add unit tests to them.","Q_Score":2,"Tags":"python,unit-testing","A_Id":11823239,"CreationDate":"2012-08-06T05:05:00.000","Title":"How to arrange and set up unit testing 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},{"Question":"I am working on Web application, which allows users to create their own webapp in turn. For each new webapp created by my application I Assign a new Subdomain.\ne.g. subdomain1.xyzdomain.com, subdomain2.xyzdomain.com etc.\nAll these Webapps are stored in Database and are served by a python script (say \ndefault_script.py) kept in \/var\/www\/. \nTill now, I have blocked Search Engine indexing for directory ( \/var\/www\/ ) using robots.txt. Which essentially blocks indexing of my all scripts including default_script.py as well as content served for multiple webapps using that default_script.py script. \nBut now I want that some of those subdomains should be indexed. \nAfter searching for a while I was able to figure out a way to block indexing of my scripts by explicitly specifing them in robots.txt\nBut I am still doubtful about the following:\n\nWill blocking the my default_script.py from indexing also block indexing of all content that are served from default_script.py. If yes then if I let it index, will default_script.py start showing up in search results also.\nHow can I allow indexing of some of the Subdomains seletively.\nEx:  Index subdomain1.xyzdomain.com but NOT subdomain2.xyzdomain.com","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":134,"Q_Id":11829360,"Users Score":1,"Answer":"No. The search engine should not care what script generates the pages. Just so long as the pages generated by the webapps are indexed you should be fine.\nSecond question:\nYou should create a separate robots.txt per subdomain. That is when robots.txt is fetched from a particular subdomain, return a robots.txt file that pertains to that sudomain only. So if you want the subdomain indexed, has that robots file allow all. If you don't want it indexed, have the robots file deny all.","Q_Score":0,"Tags":"python,seo,indexing,robots.txt,googlebot","A_Id":11829421,"CreationDate":"2012-08-06T13:34:00.000","Title":"Selectively indexing subdomains","Data Science and Machine Learning":0,"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},{"Question":"I'm running a python file every minute using a cron job. It queries a site and gather's information, but it has to load through 4-5 pages before it gets to the data I need.\nThe execution time is around 5-10s per query.\nI'm wondering if there's a difference in server load if the file is being run congruently multiple times verses having 3 different files assigned to load sections.\nExample:\ntest1.py loads information between A-H\ntest2.py loads information between I-Q\ntest3.py loads information between R-Z\nIf someone requests information about a \"B\", \"M\", and \"S\" topic each file would run and return the results, verses one file test.py running a loop to return all three results.\nP.S. I'm asking because I'm expecting in the future that people will request information about 2-6 topics, and that's just one person. So I don't want one file running for 60 seconds straight. I'm wondering if it'll alleviate load to spread it across multiple files.\nP.P.S. Also I'm wondering the implications of using python vs php.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":57,"Q_Id":11860036,"Users Score":0,"Answer":"Using multiple files to fetch smaller parts probably won't make a difference in server load (well, in fact it'd make the load x times bigger for x times shorter period of time, but the overall result is the same), but it should fetch the data faster (thanks to multithreading and paralleling the requests) therefore reducing your response times.","Q_Score":1,"Tags":"php,python,load,cron","A_Id":11860120,"CreationDate":"2012-08-08T07:51:00.000","Title":"Server load comparison","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I am not a native English speaker. When I code with Python, I often make spelling mistakes and get 'NameError' Exceptions. Unit test can solve some problems but not all. Because one can hardly construct test cases which cover all logic. So I think a tool that detect such errors would help me a lot but I searched Google and cannot find it.","AnswerCount":4,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":130,"Q_Id":11878554,"Users Score":0,"Answer":"You could get an IDE which helps a bit with autocompletion of names, though not in all situations. PyDev is one such IDE with autocompletion; PyCharm is another (not free).\nUsing autocomplete is probably your best bet to solve your problem in the long term. Even if you find a tool which attempts to correct such spelling errors, that will not solve the initial problem and will probably just cause new ones.","Q_Score":1,"Tags":"python,nameerror","A_Id":11878657,"CreationDate":"2012-08-09T07:21:00.000","Title":"Does there  a tool exists which can help programmer avoid Python NameError?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm guessing my question is pretty basic, but after 15-20 minutes on Google and YouTube, I am still a little fuzzy. I am relatively new to both Linux and Python, so I am having some difficulty comprehending the file system tree (coming from Windows).\nFrom what I've found digging around the directories in Ubuntu (which is version 12.04, I believe, which I am running in VBox), I have ID'd the following two directories related to Python:\n\n\/usr\/local\/lib\/python2.7 which contains these two subdirectories:\ndist-packages\nsite-packages \nboth of which do not show anything when I type \"ls\" to get a list of the files therein, but show \". ..\" when I type \"ls -a\".\n\/usr\/lib\/python2.7 which has no site-packages directory but does have a dist-packages directory that contains many files and subdirectories.\n\nSo if I want to install a 3rd party Python module, like, say, Mechanize, in which one of the above directories (and which subdirectory), am I supposed to install it in? \nFurthermore, I am unclear on the steps to take even after I know where to install it; so far, I have the following planned:\n\nDownload the tar.gz (or whatever kind of file the module comes in) from whatever site or server has it\nDirect the file to be unzipped in the appropriate subdirectory (one of the 2 listed above)\nTest to make sure it works via import mechanize in interactive mode.\n\nLastly, if I want to replace step number 1 above with a terminal command (something like sudo apt-get), what command would that be, i.e., what command via the terminal would equate to clicking on a download link from a browser to download the desired file?","AnswerCount":5,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":63583,"Q_Id":11893311,"Users Score":0,"Answer":"To install nay python package in ubuntu, first run \nsudo apt-get update\nThen type \"sudo apt-get install python-\" and press tab twice repeatedly. \npress y or yes and it will display all the packages available for python. Then again type\nsudo apt-get install python-package\nIt will install the package from the internet.","Q_Score":13,"Tags":"python,module","A_Id":31068954,"CreationDate":"2012-08-09T23:11:00.000","Title":"Installing 3rd party Python modules on an Ubuntu Linux machine?","Data Science and Machine Learning":0,"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},{"Question":"I'm guessing my question is pretty basic, but after 15-20 minutes on Google and YouTube, I am still a little fuzzy. I am relatively new to both Linux and Python, so I am having some difficulty comprehending the file system tree (coming from Windows).\nFrom what I've found digging around the directories in Ubuntu (which is version 12.04, I believe, which I am running in VBox), I have ID'd the following two directories related to Python:\n\n\/usr\/local\/lib\/python2.7 which contains these two subdirectories:\ndist-packages\nsite-packages \nboth of which do not show anything when I type \"ls\" to get a list of the files therein, but show \". ..\" when I type \"ls -a\".\n\/usr\/lib\/python2.7 which has no site-packages directory but does have a dist-packages directory that contains many files and subdirectories.\n\nSo if I want to install a 3rd party Python module, like, say, Mechanize, in which one of the above directories (and which subdirectory), am I supposed to install it in? \nFurthermore, I am unclear on the steps to take even after I know where to install it; so far, I have the following planned:\n\nDownload the tar.gz (or whatever kind of file the module comes in) from whatever site or server has it\nDirect the file to be unzipped in the appropriate subdirectory (one of the 2 listed above)\nTest to make sure it works via import mechanize in interactive mode.\n\nLastly, if I want to replace step number 1 above with a terminal command (something like sudo apt-get), what command would that be, i.e., what command via the terminal would equate to clicking on a download link from a browser to download the desired file?","AnswerCount":5,"Available Count":2,"Score":1.0,"is_accepted":false,"ViewCount":63583,"Q_Id":11893311,"Users Score":11,"Answer":"You aren't supposed to manually install anything.\nThere are three ways to install Python libraries:\n\nUse apt-get, aptitude or similar utilities.\nUse easy_install or pip (install pip first, its not available by default)\nIf you download some .tar.gz file, unzip it and then type sudo python setup.py install\n\nManually messing with paths and moving files around is the first step to headaches later. Do not do it.\nFor completeness I should mention the portable, isolated way; that is to create your own virtual environment for Python.\n\nRun sudo apt-get install python-virtualenv\nvirtualenv myenv (this creates a new virtual environment. You can freely install packages in here without polluting your system-wide Python libraries. It will add (myenv) to your prompt.)\nsource myenv\/bin\/activate (this activates your environment; making sure your shell is pointing to the right place for Python)\npip install _____ (replace __ with whatever you want to install)\nOnce you are done type deactivate to reset your shell and environment to the default system Python.","Q_Score":13,"Tags":"python,module","A_Id":11893356,"CreationDate":"2012-08-09T23:11:00.000","Title":"Installing 3rd party Python modules on an Ubuntu Linux machine?","Data Science and Machine Learning":0,"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},{"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},{"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},{"Question":"I am working on a task to back up (copy) about 100 Gb of data (including a thousand files and sub folders in a directory) to another server. Normally, for the smaller scale, I can use scp or rsync instead. However, as the other server is not on the same LAN network, it could easily take hours, even days, to complete the task. I can't just leave my computer there with the terminal running. I don't think that's the best choice, and again, I have another good reason to use Python :) \nIs there any library, or best practice for me to start with? As, it's just for in-house project,  we don't need any fancy features, just some fundamental things such as logging, error tolerance, etc.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":723,"Q_Id":11895298,"Users Score":3,"Answer":"I think your best bet is to use scp or rsync from within screen. That way you can detach the screen session and logout and the transfer will keep going.\nman screen","Q_Score":1,"Tags":"python,networking,file-transfer","A_Id":11895345,"CreationDate":"2012-08-10T04:00:00.000","Title":"How can we transfer large amounts of data over a network, 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},{"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},{"Question":"I started a project where you can \"log in\" on a terminal (basically a Raspberry Pi with a touchscreen attached) with a wireless token (for time tracking).\nWhat will be the best and fastest solution to display the status (basically a background picture and 2-3 texts changing depending on the status of the token) on the screen (fullscreen)? I tried it web-based with chromium, which is -very- slow...\nIt has to be easy to do http request and en-\/decoding JSON - and please no C\/C++.\nMaybe python + wxwidgets?","AnswerCount":3,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":3021,"Q_Id":11907027,"Users Score":3,"Answer":"You could use Python for this easily with just the standard library (python 2.7.3).\nFor the GUI you can use Tkinter or Pygame (not standard library) which both support images and text placement (and full screen). It is notable that Tkinter is not thread safe, so that may be a problem if your planning on threading this program.\nFor the http request you can use httplib.\nFor the Json related things you can use the json library.","Q_Score":3,"Tags":"python,user-interface,raspberry-pi","A_Id":11907139,"CreationDate":"2012-08-10T18:09:00.000","Title":"fast gui on raspberry","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},{"Question":"It seems to me that languages that are quite simple to use (i.e. Python) often have slower execution times than languages that are deemed more complex to learn (i.e. C++ or Java).  Why?  I understand that part of the problem arises from the fact that Python is interpreted rather than compiled, but what prevents Python (or another high-level language) from being compiled efficiently?  Is there any programming language that you feel does not have this trade off?","AnswerCount":4,"Available Count":2,"Score":0.2449186624,"is_accepted":false,"ViewCount":375,"Q_Id":11909078,"Users Score":5,"Answer":"The problem with efficiency in high-level languages (or, at least, the dynamic ones) stems from the fact that it's usually not known WHAT operations needs to be performed until the actual types of objects are resolved in runtime. As a consequence, these languages don't compile to straightforward machine code and have to do all the heavy lifting behind the covers.","Q_Score":4,"Tags":"c++,python,compilation,interpreter,execution","A_Id":11909155,"CreationDate":"2012-08-10T20:52:00.000","Title":"Why does there seem to be tension between the simplicity of a language and execution 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},{"Question":"It seems to me that languages that are quite simple to use (i.e. Python) often have slower execution times than languages that are deemed more complex to learn (i.e. C++ or Java).  Why?  I understand that part of the problem arises from the fact that Python is interpreted rather than compiled, but what prevents Python (or another high-level language) from being compiled efficiently?  Is there any programming language that you feel does not have this trade off?","AnswerCount":4,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":375,"Q_Id":11909078,"Users Score":5,"Answer":"Lets compare C and Python. By most accounts C is more \"complex\" to program in than say, Python. This is because Python automates a lot of work which C doesn't. For example, garbage collection is automated in Python, but is the programmer's responsibility in C. \nThe price of this automation is that these \"high level features\" need to be generic enough to \"fit\" the needs of every program. For example, the Python garbage collector has a predefined schedule\/garbage collection algorithm, which may not be the optimal for every application. On the other hand, C gives the programmer complete flexibility  to define the GC schedule and algorithm as she wants it to be.\nSo there you have it, ease versus performance.","Q_Score":4,"Tags":"c++,python,compilation,interpreter,execution","A_Id":11909183,"CreationDate":"2012-08-10T20:52:00.000","Title":"Why does there seem to be tension between the simplicity of a language and execution 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},{"Question":"I am writing an application in Qt that I want to extend with plugins.\nMy application also has a library that the plugins will use. So, I need a 2 way communication. Basically, the plugins can call the library, and my application which loads the plugins will call them.\nRight now, I have my library written in C++, so it has some classes. The plugins can include the header files, link to it and use it. I also have a header file with my interface, which is abstract base class that the plugins must have implemented. They should also export a function that will return a pointer to that class, and uses C linkage.\nUp to this point I believe that everything is clear, a standard plugin interface. However, there are 3 main problems, or subtasks:\n\nHow to use the library from other languages?\nI tried this with Python only. I used SIP to generate a Python component that I successfully imported in a test.py file, and called functions from a class in the library. I haven't tried with any other language.\nHow to generate the appropriate declaration, or stub, for my abstract class in other languages? Since the plugins must implement this class, I should be able to somehow generate an equivalent to a header in the other languages, like .py files for Python, .class files for Java, etc.\nI didn't try this yet, but I suppose there are generators for other languages.\nHow am I going to make instances of the objects in the plugins? If I got to this point the class would be implemented in the plugins. Now I will need to call the function that returns the instance of the implemented abstract class, and get a pointer to it.\nBased on my research, in order to make this work I will have to get a handle to the Python interpreter, JVM, etc., and then communicate with the plugin from there.\n\nIt doesn't look too complex, but when I started my research even for the simplest case it took a good amount of work. And I successfully got only to the 1st point, and only in Python. That made me wonder if I am taking the right approach? What are your thoughts on this.. maybe I should not have used Qt in my library and the abstract base class, but only pure C++. It could probably make the things a bit easier. Or maybe I should have used only C in my library, and make the plugins return a C struct instead of a class. That I believe would make the things much easier, since calling the library would be a trivial thing. And I believe the implementation of a C struct would be much easier that implementing C++ class, and even easier that implementing a C++ class that uses Qt objects.\nPlease point me to the right direction, and share your expertise on this. Also, if you know of any book on the subject, I'd be more than happy to purchase it. Or some links that deal with this would do.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":308,"Q_Id":11914614,"Users Score":1,"Answer":"C++ mangles its symbols, and has special magic to define classes, which is sort of hacked on top of standard (C) object files. You don't want your files from other languages to understand that magic. So I would certainly follow your own suggestion, to do everything in pure C.\nHowever, that doesn't mean you can't use C++. Only the interface has to be C, not the implementation. Or more strictly speaking, the object file that is produced must not use special features that other languages don't use.\nWhile it is possible for a plugin to link to your program and thus use functions from it, I personally find it more readable (and thus maintainable) to call a plugin function after loading it, passing an array of function pointers which can be used by the plugin.\n\nEvery language has support for opening shared object (SO or DLL) files. Use that.\nYour interface will consist of functions which have several arguments and return types, which probably have special needs in how they are passed in or retrieved. There probably are automated systems for this, but personally I would just write the interface file by hand. The most important is that you properly document the interface, so people can use any language they want, as long as they know how to load object files from their language.\nDifferent languages have very different ways of storing objects. I would recommend to make the creator of the data also the owner of the memory. So if your program has a class with a constructor (which is wrapped in C functions for the plugin interface), the class is the one creating the data, and your program, not the plugin, should own it. This means that the plugin will need to notify your program when it's done with it and at that point your program can destroy it (unless it is still needed, of course). In languages which support it, such as Python and C++, this can be done automatically when their interface object is destroyed. (I'm assuming here that the plugin will create an object for the purpose of communicating with the actual object; this object behaves like the real object, but in the target language instead of C.)\n\nKeep any libraries (such as Qt) out of the interface. You can allow functions like \"Put resource #x at this position on the screen\", but not \"Put this Qt object at this position on the screen\". The reason is that when you require the plugin to pass Qt objects around, they will need to understand Qt, which makes it a lot harder to write a plugin.\nIf plugins are completely trusted, you can allow them to pass (opaque) pointers to those objects, but for the interface that isn't any different from using other number types. Just don't require them to do things with the objects, other than calling functions in your program.","Q_Score":3,"Tags":"java,c++,python,qt,plugins","A_Id":13563225,"CreationDate":"2012-08-11T12:15:00.000","Title":"How to write Qt plugin system with bindings in other languages?","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},{"Question":"I am successfully running a cron job every hour on Google Appengine. However I would like it to start when I launch the app. Now it does the first cron job 1 hour after the start.\nI am using Python.","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":211,"Q_Id":11917869,"Users Score":2,"Answer":"There is no \"launch\" the app in production as such.  You deploy the app for the first time and crontab is now present and crontab scheduling is started. So I assume you really mean you would like to run the cron job every time you deploy a new version of your application in addition to the cron schedule.\nThe cron handler is callable by you, so why not just wrap appcfg in a script that calls the cron handler after you do the deploy. Use wget\/curl etc.....","Q_Score":0,"Tags":"python,google-app-engine,cron","A_Id":11918536,"CreationDate":"2012-08-11T21:37:00.000","Title":"Cron job on Appengine - first time on 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":0,"System Administration and DevOps":1,"Web Development":1},{"Question":"I was working on a project using windows in Aptana. I changed my OS and installed ubuntu on unpartitioned space. I again downloaded Aptana for ubuntu and run it. I specified same workspace that I was using during windows as my that project partition is still there. \nThe problem I am having is that I am unable to use Aptana intelligence so should I change some paths e.t.c. or is there a way to remove data from workspace(data that tells info to aptana) and recreate project so that it take new info. I tried to see that data but didn't see data that aptana use from workspace or project directory.\nPlease tell what should be done in this sitaution. thanks in advance guys.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":124,"Q_Id":11919437,"Users Score":0,"Answer":"I just changed the workspace and it works fine now. After doing so it asked for some paths for interpreter and I gave that and it works fine now.","Q_Score":0,"Tags":"aptana,ubuntu-10.04,pythonpath","A_Id":12043683,"CreationDate":"2012-08-12T03:11:00.000","Title":"Aptana getting path of Windows python interpreter instead of 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},{"Question":"First of all, this question has no malicious purposes. I had asked the same question yesterday in stackoverflow but it was removed. I would like to learn if I have to log into an account when sending emails with attachments using python smtplib module. The reason I don't want to log in to an account is that because there is no account that I can use in my company. Or I can ask my company's IT department to set up an account, but until that I want to write the program code and test it. Please don't remove this question.\nBest Regards","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":95,"Q_Id":11920330,"Users Score":1,"Answer":"You don't have to have an account (ie. authenticate to your SMTP server) if your company's server is configured to accept mail from certain trusted networks.\nTypically SMTP servers consider the internal network as trusted and may accept mail from it\nwithout authentication.","Q_Score":0,"Tags":"python,email,anonymous,smtplib","A_Id":11920368,"CreationDate":"2012-08-12T07:00:00.000","Title":"Do I have to log into an email account when sending emails using python smtplib?","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},{"Question":"I'm looking for a way to take gads of inbound SMTP messages and drop them onto an AMQP broker for further routing and processing. The messages won't actually end up in a mailbox, but instead SMTP is used as a message gateway.\nI've written a Postfix After-Queue Content Filter in Python that drops the inbound SMTP message onto a RabbitMQ broker. That works well - I get the raw message over a queue and it gets picked up nicely by a consumer. The issue is that the AMQP connection is created and torn down with each message... the Content Filter script gets re-executed from scratch each time. I imagine that will end up being a performance issue.\nIf I could leverage something re-entrant I could reuse the connection. Or maybe I'm just approaching the whole thing incorrectly...","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":1843,"Q_Id":11927409,"Users Score":1,"Answer":"Making an AMQP connection over plain TCP is pretty quick.  Perhaps if you're using SSL then it's another story but you sure that enqueueing the raw message onto the AMQP exchange is going to be the bottleneck?  My guess would be that actually delivering the message via SMTP is going to be much slower so how fast you can queue things up isn't going to affect the throughput of the system.\nIf this piece does turn out to be a bottleneck I rather like creating little web servers using Sinatra, or Rack but it sounds like you might prefer a Python based solution.  Have the postfix content filter perform a HTTP POST using curl to a webserver, which maintains a persistent connection to the AMQP server.\nOf course now you have an extra moving part for which you need to think about monitoring, error handling and security.","Q_Score":4,"Tags":"python,smtp,rabbitmq,postfix-mta,amqp","A_Id":11927486,"CreationDate":"2012-08-13T02:04:00.000","Title":"Sending raw SMTP messages to an AMQP broker","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},{"Question":"If someone now studies the basics of the Python what should he do after that? Are there specific books he must read? Or, what exactly?\nIn other words, what is the pathway to mastering Python?\nThanks","AnswerCount":3,"Available Count":1,"Score":0.1325487884,"is_accepted":false,"ViewCount":6353,"Q_Id":11972592,"Users Score":2,"Answer":"Get a project you are interested in, start hacking (i.e. extend it, fix small bugs you encounter). There are a lot of opensource projects out there you can checkout.\nYou need experience, and experience comes from failing, failing is a result of trying. That's your way to go.\nIf you get stuck somewhere, always check back to SO or google - that will aid you fixing 99.9% of your issues.","Q_Score":0,"Tags":"python","A_Id":11972623,"CreationDate":"2012-08-15T15:46:00.000","Title":"What do I do after studying the basics 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":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a series of tests in Django that are categorised into various \"types\", such as \"unit\", \"functional\", \"slow\", \"performance\", ...\nCurrently I'm annotating them with a decorator that is used to only run tests of a certain type (similar to @skipIf(...)), but this doesn't seem like an optimal approach.\nI'm wondering if there is a better way to do separation of tests into types?  I'm open to using different test runners, extending the existing django testing framework, building suites or even using another test framework if that doesn't sacrifice other benefits.\nThe underlying reason for wanting to do this is to run an efficient build pipeline, and as such my priorities are to:\n\nensure that my continuous integration runs check the unit tests first,\npossibly parallelise some test runs\nskip some classes of test altogether","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":545,"Q_Id":11982638,"Users Score":1,"Answer":"The way my company organises tests is to split them into two broad categories. Unit and functional. The unit tests live inside the Django test discovery. manage.py test will run them. The functional tests live outside of that directory. They are run either manually or by the CI. Buildbot in this case. They are still run with the unittest textrunner. We also have a subcategory of functional tests called stress tests. These are tests that can't be run in parallel because they are doing rough things to the servers. Like switching off the database and seeing what happens. \nThe CI can then run each test type as a different step. Tests can be decorated with skipif. \nIt's not a perfect solution but it is quite clear and easy to understand.","Q_Score":1,"Tags":"python,django,unit-testing,testing,django-testing","A_Id":11982939,"CreationDate":"2012-08-16T07:37:00.000","Title":"How to separate test types using 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},{"Question":"I do run parallel write requests on my ZODB. I do have multiple BTree instances inside my ZODB. Once the server accesses the same objects inside such a BTree, I get a ConflictError for the IOBucket class. For all my Django bases classes I do have _p_resolveconflict set up, but can't implement it for IOBucket 'cause its a C based class.\nI did a deeper analysis, but still don't understand why it complains about the IOBucket class and what it writes into it. Additionally, what would be the right strategy to resolve it?\nThousand thanks for any help!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":565,"Q_Id":11991114,"Users Score":1,"Answer":"IOBucket is part of the persistence structure of a BTree; it exists to try and reduce conflict errors, and it does try and resolve conflicts where possible.\nThat said, conflicts are not always avoidable, and you should restart your transaction. In Zope, for example, the whole request is re-run up to 5 times if a ConflictError is raised. Conflicts are ZODB's way of handling the (hopefully rare) occasion where two different requests tried to change the exact same data structure.\nRestarting your transaction means calling transaction.begin() and applying the same changes again. The .begin() will fetch any changes made by the other process and your commit will be based on the fresh data.","Q_Score":2,"Tags":"python,django,zodb","A_Id":11996422,"CreationDate":"2012-08-16T15:56:00.000","Title":"Conflict resolution in ZODB","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I need to generate a PDF with dynamic text and I'm using ReportLab.  Since the text is dynamic, is there anyway to have it resized to fit within a specific area of the PDF?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":6481,"Q_Id":12014573,"Users Score":1,"Answer":"Yes. Take a look at the ReportLab manual. Based on your (short) description of what you want to do it sounds like you need to look at using Frames within your page layout (assuming you use Platypus, which I would highly recommend).","Q_Score":10,"Tags":"python,pdf,reportlab","A_Id":12021221,"CreationDate":"2012-08-17T23:56:00.000","Title":"ReportLab: How to auto resize text to fit block","Data Science and Machine Learning":0,"Database and SQL":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},{"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},{"Question":"Occasionally, I have come across programming techniques that involve creating application frameworks or websites in Java, PHP or Python, but when complex algorithms are needed, writing those out in C or C++ and running them as API-like function calls within your Java\/PHP\/Python code.\nI have been googling and searching around the net for this, and unless I don't know the name of the practice, I can't seem to find anything on it.\nTo put simply, how can I:\n\nCreate functions or classes in C or C++\nCompile them into a DLL\/binary\/some form\nRun the functions from - \n\nJava\nPHP\nPython\n\nI suspect JSON\/XML like output and input must be created between the Java\/PHP\/Python and the C\/C++ function so the data can be easily bridged, but that is okay.\n\nI'm just not sure how to approach this technique, but it seems like a very smart way to take advantage of the great features of Java, PHP, and Python while at the same time utilizing the very fast programming languages for large, complex tasks.\nThe other thought going through my head is if I am creating functions using only literals in Java\/PHP\/Python, will it go nearly as fast as C anyway?\nThe specific tasks I'm looking to work with C\/C++ on is massive loops, pinging a database, and analyzing maps. No work has started yet, its all theory now.","AnswerCount":4,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":419,"Q_Id":12028908,"Users Score":0,"Answer":"For Java, you can search JNI (Java Native Interface), there're a lot of guides telling how to use it.","Q_Score":2,"Tags":"java,php,c++,python,c","A_Id":12033703,"CreationDate":"2012-08-19T18:27:00.000","Title":"Running algorithms in compiled C\/C++ code within a Java\/PHP\/Python 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},{"Question":"Is there any way to get the total amount of time that \"unittest.TextTestRunner().run()\" has taken to run a specific unit test.\nI'm using a for loop to test modules against certain scenarios (some having to be used and some not, so they run a few times), and I would like to print the total time it has taken to run all the tests.\nAny help would be greatly appreciated.","AnswerCount":5,"Available Count":1,"Score":0.1586485043,"is_accepted":false,"ViewCount":8385,"Q_Id":12034755,"Users Score":4,"Answer":"You could record start time in the setup function and then print elapsed time in cleanup.","Q_Score":11,"Tags":"python,unit-testing,time","A_Id":12034788,"CreationDate":"2012-08-20T08:55:00.000","Title":"Get python unit test duration in seconds","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":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},{"Question":"I've been using Paramiko today to work with a Python SSH connection, and it is useful.\nHowever one thing I'd really like to be able to do over the SSH is to utilise some Pythonic sugar. As far as I can tell I can only use the inbuilt Paramiko functions, and if I want to anything using Python on the remote side I would need to use a script which I have placed on there, and call it. \nIs there a way I can send Python commands over the SSH connection rather than having to make do only with the limitations of the Paramiko SSH connection? Since I am running the SSH connection through Paramiko within a Python script, it would only seem right that I could, but I can't see a way to do so.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":705,"Q_Id":12044262,"Users Score":0,"Answer":"Well, that is what SSH created for - to be a secure shell, and the commands are executed on the remote machine (you can think of it as if you were sitting at a remote computer itself, and that either doesn't mean you can execute Python commands in a shell, though you're physically interact with a machine).\nYou can't send Python commands simply because Python do not have commands, it executes Python scripts.\nSo everything you can do is a \"thing\" that will make next steps:\n\nWrap a piece of Python code into file.\nscp it to the remote machine.\nExecute it there.\nRemove the script (or cache it for further execution).\n\nBasically shell commands are remote machine's programs themselves, so you can think of those scripts like shell extensions (python programs with command-line parameters, e.g.).","Q_Score":0,"Tags":"python,ssh,paramiko","A_Id":12044350,"CreationDate":"2012-08-20T19:57:00.000","Title":"using python commands within paramiko","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},{"Question":"folks,\nI am wondering if such a package exists? Or is there a good reference for implementing it?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":461,"Q_Id":12048181,"Users Score":0,"Answer":"scipy ,  pyANN , and pyevolve are some packages that come to mind that may have some tools to help with this... Im not entirely sure what multistart optimization is but I have a rough idea ...","Q_Score":0,"Tags":"python,optimization","A_Id":12048523,"CreationDate":"2012-08-21T03:46:00.000","Title":"is there a package for multi-start optimization written 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},{"Question":"I really like the PY2EXE module, it really helps me share scripts with other co-workers that are super easy for them to use.\nMy question is: when the PY2EXE module compiles the code into an executable, does the resulting executable process faster?\nThanks for any replies!","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":2575,"Q_Id":12056702,"Users Score":1,"Answer":"Partly, it bundles the python environment with the 'precompiled' pyc files. These are already \nparsed into python byte code but they aren't native speed executables","Q_Score":2,"Tags":"python,exe,py2exe","A_Id":12056785,"CreationDate":"2012-08-21T14:08:00.000","Title":"Does PY2EXE Compile a Python Code to run 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":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I really like the PY2EXE module, it really helps me share scripts with other co-workers that are super easy for them to use.\nMy question is: when the PY2EXE module compiles the code into an executable, does the resulting executable process faster?\nThanks for any replies!","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":2575,"Q_Id":12056702,"Users Score":6,"Answer":"py2exe just bundles the Python interpreter and all the needed libraries into the executable and a few library files. When you run the executable, it uses the bundled interpreter to run your script.\nSince it doesn't actually generate native code, the speed of execution should be about the same, possibly slower because of the overhead of everything being packaged up.","Q_Score":2,"Tags":"python,exe,py2exe","A_Id":12056778,"CreationDate":"2012-08-21T14:08:00.000","Title":"Does PY2EXE Compile a Python Code to run 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":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"The gunicorn documentation talks about editing the config files, but I have no idea where it is.\nProbably a simple answer :) I'm on Amazon Linux AMI.","AnswerCount":5,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":65764,"Q_Id":12063463,"Users Score":0,"Answer":"I did this after reading the docs:\n\n\nwhen deploying my app through gunicorn, usually there is a file called Procfile\nopen this file, add --timeout 600\n\nfinally, my Procfile would be like:\nweb: gunicorn app:app --timeout 600","Q_Score":53,"Tags":"python,flask,gunicorn","A_Id":54821323,"CreationDate":"2012-08-21T21:39:00.000","Title":"Where is the Gunicorn config 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":1},{"Question":"Is there any add-on which will activate while uploading files into the Plone site automatically? It should compress the files and then upload into the files. These can be image files like CAD drawings or any other types. Irrespective of the file type, beyond a specific size, they should get compressed and stored, rather than manually compressing the files and storing them.I am using plone 4.1. I am aware of the css, javascript files which get compressed, but not of uploaded files. I am also aware of the 'image handling' in the 'Site Setup'","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":258,"Q_Id":12066923,"Users Score":2,"Answer":"As Maulwurfn says, there is no such add-on, but this would be fairly straightforward for an experienced developer to implementing using a custom content type.  You will want to be pretty sure that the specific file types you're hoping to store will actually benefit from compression (many modern file formats already include some compression, and so simply zipping them won't shrink them much).\nAlso, unless you implement something complex like a client-side Flash uploader with built-in compression, Plone can only compress files after they've been uploaded, not before, so if you're hoping to make uploads quicker for users, rather than to minimize storage space, you're facing a somewhat more difficult challenge.","Q_Score":0,"Tags":"python,plone","A_Id":12079431,"CreationDate":"2012-08-22T05:42:00.000","Title":"Is there an add-on to auto compress files while uploading into Plone?","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},{"Question":"I'm building an Android IM chat app for fun. I can develop the Android stuff well but i'm not so good with the networking side so I am looking at using XMPP on AWS servers to run the actual IM side. I've looked at OpenFire and ejabberd which i could use. Does anyone have any experience with them or know a better one? I'm mostly looking for sending direct IM between friends and group IM with friends.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":365,"Q_Id":12095507,"Users Score":0,"Answer":"As an employee of ProcessOne, the makers of ejabberd, I can tell you we run a lot of services over AWS, including mobile chat apps. We have industrialized our procedures.","Q_Score":0,"Tags":"python,ruby,amazon-ec2,amazon-web-services,xmpp","A_Id":12095630,"CreationDate":"2012-08-23T15:48:00.000","Title":"Running XMPP on Amazon for a chat 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":1},{"Question":"I'm building an Android IM chat app for fun. I can develop the Android stuff well but i'm not so good with the networking side so I am looking at using XMPP on AWS servers to run the actual IM side. I've looked at OpenFire and ejabberd which i could use. Does anyone have any experience with them or know a better one? I'm mostly looking for sending direct IM between friends and group IM with friends.","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":365,"Q_Id":12095507,"Users Score":1,"Answer":"Try to explore more about Amazon SQS( Simple Queuing Service) . It might come handy for your requirement.","Q_Score":0,"Tags":"python,ruby,amazon-ec2,amazon-web-services,xmpp","A_Id":12095743,"CreationDate":"2012-08-23T15:48:00.000","Title":"Running XMPP on Amazon for a chat 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":1},{"Question":"My question is a little bit stupid but I decided to ask advanced programmers like some of you. So I want to make a \"dynamic\" C++ program. My idea is to compile it and after compilation (maybe with scripting language like python)  to change some how the code of the program. I know you will tell me that after the compilation I can not change the code but is there a way of doing that. Thank you!","AnswerCount":3,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":315,"Q_Id":12105775,"Users Score":3,"Answer":"The only way to do that in C++ is to unload the DLL with the code to be\nmodified, modify the sources, invoke the compiler to regenerate the DLL,\nand reload the DLL.  It's very, very heavy weight, and it only works if\nthe compiler is present on the machines where the code is to be run.\n(Usually the case under Unix, rarely the case with Windows.)\nInterpreted languages like Python are considerably more dynamic; Python\nhas a built-in function to execute a string as Python code, for example.\nIf you need dynamically modifiable code, I'd suggest embedding Python in\nyour application, and using it for the dynamic parts.","Q_Score":2,"Tags":"c++,python,compilation","A_Id":12105989,"CreationDate":"2012-08-24T08:32:00.000","Title":"Using scripting language 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},{"Question":"I'm doing TDD using Python and the unittest module. In NUnit you can Assert.Inconclusive(\"This test hasn't been written yet\").\nSo far I haven't been able to find anything similar in Python to indicate that \"These tests are just placeholders, I need to come back and actually put the code in them.\"\nIs there a Pythonic pattern for this?","AnswerCount":3,"Available Count":1,"Score":0.2605204458,"is_accepted":false,"ViewCount":984,"Q_Id":12110610,"Users Score":4,"Answer":"I would not let them pass or show OK, because you will not find them easily back.\nMaybe just let them fail and the reason (not written yet), which seems logical because you have a test that is not finished.","Q_Score":5,"Tags":"python,unit-testing,tdd","A_Id":12110670,"CreationDate":"2012-08-24T13:41:00.000","Title":"How should I indicate that a test hasn't been written yet 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},{"Question":"I'm writing a linux application which uses PyQt4 for GUI and which will only be used during remote sessions (ssh -XY \/ vnc).\nSo sometimes it may occur that a user will forget to run ssh with X forwarding parameters or X forwarding will be unavailable for some reason. In this case the application crashes badly (unfortunately I am force to use an old C++ library wrapped into python and it completely messes user's current session if the application crashes).\nI cannot use something else so my idea is to check if X forwarding is available before loading that library. However I have no idea how to do that.\nI usually use xclock to check if my session has X forwarding enabled, but using xclock sounds like a big workaround.\nADDED\nIf possible I would like to use another way than creating an empty PyQt window and catching an exception.","AnswerCount":4,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":8184,"Q_Id":12122671,"Users Score":2,"Answer":"Similar to your xclock solution, I like to run xdpyinfo and see if it returns an error.","Q_Score":8,"Tags":"python,ssh,pyqt4,xserver","A_Id":12123998,"CreationDate":"2012-08-25T14:05:00.000","Title":"How to determine from a python application if X server\/X forwarding is running?","Data Science and Machine Learning":0,"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},{"Question":"I'm writing a linux application which uses PyQt4 for GUI and which will only be used during remote sessions (ssh -XY \/ vnc).\nSo sometimes it may occur that a user will forget to run ssh with X forwarding parameters or X forwarding will be unavailable for some reason. In this case the application crashes badly (unfortunately I am force to use an old C++ library wrapped into python and it completely messes user's current session if the application crashes).\nI cannot use something else so my idea is to check if X forwarding is available before loading that library. However I have no idea how to do that.\nI usually use xclock to check if my session has X forwarding enabled, but using xclock sounds like a big workaround.\nADDED\nIf possible I would like to use another way than creating an empty PyQt window and catching an exception.","AnswerCount":4,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":8184,"Q_Id":12122671,"Users Score":8,"Answer":"Check to see that the $DISPLAY environment variable is set - if they didn't use ssh -X, it will be empty (instead of containing something like localhost:10).","Q_Score":8,"Tags":"python,ssh,pyqt4,xserver","A_Id":12123396,"CreationDate":"2012-08-25T14:05:00.000","Title":"How to determine from a python application if X server\/X forwarding is running?","Data Science and Machine Learning":0,"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},{"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},{"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},{"Question":"I am running some shell test scripts from a python script under Windows. The shell scripts are testing the functionality of various modules.\nThe problem that I faced is that some scripts can hang. For this I added a timeout for each script. This timeout has a default value. But this timeout value can be changed by the bash script - from a bash function ( SetMaxTime ) - I can modify SetMaxTime.\nWhen the default value is used I wait for that period of time in python and if the bash script is not done I will consider that test as failed due to timeout.\nThe problem is when the default value of timeout is changed from bash. Is there a way to communicate with a bash script (ran with mingw) from python?\nNOTE: The scripts are ran under Windows.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":479,"Q_Id":12140608,"Users Score":1,"Answer":"Sure you can communicate between them, just read\/write from a file or pair of files (one for Python to write to and the bash script to read from, and the other for the visa-versa situation).","Q_Score":0,"Tags":"python,windows,bash,mingw","A_Id":12141142,"CreationDate":"2012-08-27T10:52:00.000","Title":"Communicating with bash scripts 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},{"Question":"I am using pyramids framework for large project and I find it messy to have all my tests in one tests.py file. So I have decided to create directory that would contain files with my tests. Problem is, I have no idea, how to tell pyramids, to run my tests from this directory.\nI am running the tests using python setup.py test -q.\nBut this of course do not work, after I have moved my tests into tests directory. What to do, to make it work?","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":4414,"Q_Id":12145688,"Users Score":1,"Answer":"I have finally found the way to do it. I have just created directory named tests, put my tests inside it and created empty file __init__.py. I needed to fix relative imports, or it make strange errors like:\nAttributeError: 'module' object has no attribute 'tests'\nI do not really understand what is going on, and what is the nosetest role here, but it works.\nIf someone is able to explain this problematics deeper, it would be nice.","Q_Score":4,"Tags":"python,testing,pyramid","A_Id":12145889,"CreationDate":"2012-08-27T16:17:00.000","Title":"Having tests in multiple 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},{"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},{"Question":"I want to learn Python for Web Programming. As of now I work on PHP and want to try Python and its object oriented features. I have basic knowledge of python and its syntax and data strucures.\nI want to start with making basic web pages - forms, file upload and then move on to more dynamic websites using MYSQl.\nAs of now I do not want to try Django or for that matter any other frameworks.\nIs python with cgi and MySQLdb modules a good start?\nThanks","AnswerCount":6,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":350,"Q_Id":12156293,"Users Score":0,"Answer":"If nothing else it will show you why you want to use a framework, should be a really valuable learning experience. I say go for it.","Q_Score":0,"Tags":"python,html,web,cgi,mysql-python","A_Id":12156338,"CreationDate":"2012-08-28T09:22:00.000","Title":"Python Web Programming - Not Using 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},{"Question":"I want to learn Python for Web Programming. As of now I work on PHP and want to try Python and its object oriented features. I have basic knowledge of python and its syntax and data strucures.\nI want to start with making basic web pages - forms, file upload and then move on to more dynamic websites using MYSQl.\nAs of now I do not want to try Django or for that matter any other frameworks.\nIs python with cgi and MySQLdb modules a good start?\nThanks","AnswerCount":6,"Available Count":3,"Score":0.0333209931,"is_accepted":false,"ViewCount":350,"Q_Id":12156293,"Users Score":1,"Answer":"Having used both Flask and Django for a bit now, I must say that I much prefer Flask for most things. I would recommend giving it a try. Flask-Uploads and WTForms are two nice extensions for the Flask framework that make it easy to do the things you mentioned. Lots of other extensions available. \nIf you go on to work with dynamic site attached to a database, Flask + SQL Alchemy make a very powerful combination. I much prefer the SQLAlchemy ORM to the django model ORM.","Q_Score":0,"Tags":"python,html,web,cgi,mysql-python","A_Id":12160352,"CreationDate":"2012-08-28T09:22:00.000","Title":"Python Web Programming - Not Using 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},{"Question":"I want to learn Python for Web Programming. As of now I work on PHP and want to try Python and its object oriented features. I have basic knowledge of python and its syntax and data strucures.\nI want to start with making basic web pages - forms, file upload and then move on to more dynamic websites using MYSQl.\nAs of now I do not want to try Django or for that matter any other frameworks.\nIs python with cgi and MySQLdb modules a good start?\nThanks","AnswerCount":6,"Available Count":3,"Score":0.0665680765,"is_accepted":false,"ViewCount":350,"Q_Id":12156293,"Users Score":2,"Answer":"I recommend Pyramid Framework!","Q_Score":0,"Tags":"python,html,web,cgi,mysql-python","A_Id":12268540,"CreationDate":"2012-08-28T09:22:00.000","Title":"Python Web Programming - Not Using 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},{"Question":"I'm looking for the fastest algorithm\/package i could use to compute the null space of an extremely large (millions of elements, and not necessarily square) matrix. Any language would be alright, preferably something in Python\/C\/C++\/Java. Your help would be greatly appreciated!","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":766,"Q_Id":12161182,"Users Score":2,"Answer":"The manner to avoid trashing CPU caches greatly depends on how the matrix is stored\/loaded\/transmitted, a point that you did not address.\nThere are a few generic recommendations:\n\ndivide the problem into worker threads addressing contiguous rows per threads\nincrement pointers (in C) to traverse rows and keep the count on a per-thread basis\nconsolidate the per-thread results at the end of all worker threads.\n\nIf your matrix cells are made of bits (instead of bytes, ints, or arrays) then you can read words (either 4-byte or 8-byte on 32-bit\/64-bit platforms) to speedup the count.\nThere are too many questions left unanswered in the problem description to give you any further guidance.","Q_Score":0,"Tags":"c++,python,c,algorithm,matrix","A_Id":12161433,"CreationDate":"2012-08-28T14:12:00.000","Title":"Computing the null space of a large matrix","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},{"Question":"I'm looking for the fastest algorithm\/package i could use to compute the null space of an extremely large (millions of elements, and not necessarily square) matrix. Any language would be alright, preferably something in Python\/C\/C++\/Java. Your help would be greatly appreciated!","AnswerCount":2,"Available Count":2,"Score":-0.0996679946,"is_accepted":false,"ViewCount":766,"Q_Id":12161182,"Users Score":-1,"Answer":"In what kind of data structure is your matrix represented? \nIf you use an element list to represent the matrix, i.e. \"column, row, value\" tuple for one matrix element, then the solution would be just count the number of the tuples (subtracted by the matrix size)","Q_Score":0,"Tags":"c++,python,c,algorithm,matrix","A_Id":12161500,"CreationDate":"2012-08-28T14:12:00.000","Title":"Computing the null space of a large matrix","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},{"Question":"I have a gcc 4.3.3 toolchain for my embedded device but I have no python (and don't need it).\nI'am looking for a way to configure boostbuild without python (compilation and cross-compilation).\nIs python mandatory ?\nMust I compile every single parts but boost-python ? (I hope not).\nThanks in advance.\nWhat I did thanks to Jupiter\n.\/bootstrap.sh --without-libraries=python\n.\/b2\nand I got\nComponent configuration:\n\n    - chrono                   : building\n    - context                  : building\n    - date_time                : building\n    - exception                : building\n    - filesystem               : building\n    - graph                    : building\n    - graph_parallel           : building\n    - iostreams                : building\n    - locale                   : building\n    - math                     : building\n    - mpi                      : building\n    - program_options          : building\n    - python                   : not building\n    - random                   : building\n    - regex                    : building\n    - serialization            : building\n    - signals                  : building\n    - system                   : building\n    - test                     : building\n    - thread                   : building\n    - timer                    : building\n    - wave                     : building","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":7027,"Q_Id":12162793,"Users Score":20,"Answer":"Look at --without-* bjam option e.g. --without-python","Q_Score":21,"Tags":"python,boost,cross-compiling","A_Id":12168033,"CreationDate":"2012-08-28T15:39:00.000","Title":"How to (cross-)compile boost WITHOUT 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},{"Question":"The problem that I am facing is whenever I make changes to my Python code, like in __init__.py or views.py file, they are not reflected on the server immediately. I am running the server using Apache+mod_wsgi, so all the Daemon process and virtual host are configured properly.\nI find that I have to run setup.py each time for new changes to take place. Is this how Pyramid works or I am missing something. Shouldn't the updated files be served instead of the old ones.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1229,"Q_Id":12190125,"Users Score":4,"Answer":"It's usually a lot easier to use something other than mod_wsgi to develop your Python WSGI application (mod_wsgi captures stdout and stderr, which makes it tricky to use things like pdb).\nThe Pyramid scaffolding generates code that allows you to do something like \"pserve development.ini\" to start a server.  If you use this instead of mod_wsgi to do your development, you can do \"pserve development.ini --reload\" and your changes to Python source will be reflected immediately.\nThis doesn't mean you can't use mod_wsgi to serve your application in production.  After you get done developing, you can then put your application into mod_wsgi for its productiony goodness.","Q_Score":1,"Tags":"python,apache,mod-wsgi,pyramid","A_Id":12203642,"CreationDate":"2012-08-30T04:55:00.000","Title":"File changes not reflecting immediately","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"Let us have some simple page that allows logged users to edit articles. Imagine following situation:\nUser Bob is logged into the system and is editing long article. As it takes really long to edit such article, his authentication becomes expired. After that, he clicks submit button and because of expired authentication, he is redirected to login page.\nIt is really desirable to finish the action (saving article) after his successful login. So we shall restore the request that was done while Bob was unauthenticated and repeat it now, after successful login. How could this be done with pyramids?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":227,"Q_Id":12196442,"Users Score":3,"Answer":"there are three parts you need;  \n\nThe page that handles the authenticated form submission should check to see if the request  is properly authenticated, perform the action, but if it isn't, store all of the data in a server side session and redirect the use to a login page.\nThe login page should look for a \"was trying to do X\" sort of query param (eg, ...?fromurl=\/post\/a\/comment.  After the user successfully logs in, the login page should redirect the user to that page instead of the site's front page.\nThe url the user was redirected to should be the same form they used to originally fill out the unauthenticated request.  In this case, though, the server should recognize that there are field values stored in the server side session for this user; and so it should populate all of the form fields with those values.  The user could then hit submit immediately and complete the post.  This could work in a similar way that fields are repopulated when a request contains some invalid form values.\n\nIt's important that step 3 should not perform the post directly;  The original data and request came from a user who was not authenticated.","Q_Score":0,"Tags":"python,login,pyramid","A_Id":12196884,"CreationDate":"2012-08-30T12:04:00.000","Title":"Request restoration after login 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},{"Question":"I am running a web app on python2.7 with mod_wsgi\/apache. Everything is fine but I can't find any .pyc files. Do they not get generated with mod_wsgi?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1616,"Q_Id":12204330,"Users Score":1,"Answer":"By default apache probably doesn't have any write access to your django app directory which is a good thing security wise.\nNow Python will byte recompile your code once every apache restart then cache it in memory.\nAs it is a longlive process it is ok.\nNote: if you really really want to have those pyc, give a write access to your apache user to the source directory.\nNote2: This can create a hell lot of confusion when you start with manage.py a test instance shared by apache as this will create those pyc as root and will keep them if you then run apache despite a source code change.","Q_Score":1,"Tags":"python,django,mod-wsgi,pyc","A_Id":12204524,"CreationDate":"2012-08-30T19:46:00.000","Title":"Cannot find .pyc files for django\/apache\/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},{"Question":"I want to run a java program on a remote machine, and intercept its logs-- also I want to be able to know if the program has completed execution, and also whether it was successful execution or if execution was halted due to an error.\nIs there any ready-made java library available for this purpose? Also, I would like to be able to use this program for obtaining logs\/execution completion for remote programs in different languages-- like Java\/Ruby\/Python etc--","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":142,"Q_Id":12206879,"Users Score":1,"Answer":"If you're only looking to determine when it has completed (and not looking to really capture all the output, as in your other question) you can simply check for the existence of the process id and, when you fail to find the process id, phone home. You really don't need the logs for that.","Q_Score":0,"Tags":"java,python,ruby,remote-debugging","A_Id":12206913,"CreationDate":"2012-08-30T23:10:00.000","Title":"java- how to code a process to intercept the output streams of program running on remote machine\/know when remote program has halted\/completed","Data Science and Machine Learning":0,"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},{"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},{"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},{"Question":"I'm kinda new to scripting for IDA - nevertheless, I've written a complex script I need to debug, as it is not working properly. \nIt is composed of a few different files containing a few different classes.\nWriting line-by-line in the commandline is not effective for obvious reasons.\nRunning a whole script from the File doesn't allow debugging.\nIs there a way of using the idc, idautils, idaapi not from within IDA?\nI've written the script on PyDev for Eclipse, I'm hoping for a way to run the scripts from within it. \nA similar question is, can the api classes I have mentioned work on idb files without IDA having them loaded?\nThanks.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2173,"Q_Id":12229101,"Users Score":0,"Answer":"We've just got a notice from one of our users that the latest version of WingIDE supports debugging of IDAPython scripts. I think there are a couple of other programs using the same approach (import a module to do RPC debugging) that might work.","Q_Score":0,"Tags":"python,debugging,reverse-engineering,ida","A_Id":12314987,"CreationDate":"2012-09-01T15:36:00.000","Title":"Debugging IDAPython Scripts outside of IDAPro","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using phpseclib to ssh to my server and run a python script. The python script is an infinite loop, so it runs until you stop it. When I execute python script.py via ssh with phpseclib, it works, but the page just loads for ever. It does this because phpseclib does not think it is \"done\" running the line of code that runs the infinite loop script so it hangs on that line. I have tried using exit and die after that line, but of course, it didnt work because it hangs on the line before, the one that executes the command. Does any one have any ideas on how I can fix this without modifying the python file? Thanks.","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":486,"Q_Id":12231412,"Users Score":0,"Answer":"If you put an & on the end of any shell command it will run in the background and return immediately, that's all you really need.","Q_Score":4,"Tags":"php,python","A_Id":12231539,"CreationDate":"2012-09-01T21:06:00.000","Title":"PHP \"Cancel\" line of 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":0},{"Question":"I am die hard fan of Artificial intelligence and machine learning. I don't know much about them but i am ready to learn. I am currently a web programmer in PHP , and  I am learning python\/django for a website.\nNow as this AI field is very wide and there are countless algorithms I don't know where to start.\nBut eventually my main target is to use whichever algorithms; like Genetic Algorithms , Neural networks , optimization which can be programmed in web application to show some stuff.\nFor Example : Recommendation of items in amazon.com\nNow what I want is that in my personal site I have the demo of each algorithm where if I click run and I can show someone what this algorithm can do.\nSo can anyone please guide which algorithms should I study for web based applications.\nI see lot of example in sci-kit python library but they are very calculation and graph based.\nI don't think I can use them from web point of view.\nAny ideas how should I go?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1093,"Q_Id":12242054,"Users Score":1,"Answer":"I assume you are mostly concerned with a general approach to implementing AI in a web context, and not in the details of the AI algorithms themselves. Any computable algorithm can be implemented in any turing complete language (i.e.all modern programming languages). There's no special limitations for what you can do on the web, it's just a matter of representation, and keeping track of session-specific data, and shared data. Also, there is no need to shy away from \"calculation\" and \"graph based\" algorithms; most AI-algorithms will be either one or the other  (or indeed both) - and that's part of the fun.\nFor example, as an overall approach for a neural net, you could:\n\nImplement a standard neural network using python classes\nPossibly train the set with historical data\nLoad the state of the net on each request (i.e. from a pickle)\nFeed a part of the request string (i.e. a product-ID) to the net, and output the result (i.e. a weighted set of other products, like \"users who clicked this, also clicked this\")\nAlso, store the relevant part of the request (i.e. the product-ID) in a session variable (i.e. \"previousProduct\"). When a new request (i.e. for another product) comes in from the same user, strengthen\/create the connection between the first product and the next.\nSave the state of the net between each request (i.e. back to pickle)\n\nThat's just one, very general example. But keep in mind - there is nothing special about web-programming in this context, except keeping track of session-specific data, and shared data.","Q_Score":0,"Tags":"python,web,machine-learning,artificial-intelligence","A_Id":12243670,"CreationDate":"2012-09-03T04:37:00.000","Title":"What algorithms i can use from machine learning or Artificial intelligence which i can show via web site","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":1},{"Question":"I have a system that sends different types of messages (HTTP, SMTP, POP, IMAP, and regular TCP) to different systems, and I need to queue all of those messages in my system, in case of other systems in-availability.\nI'm a bit new to the message queueing concept. so I don't know the best python library that I shall go for.\nIs Django-celery (and the underling components - RabbitMQ, MySql, django, apache) is the best choice for me? Will this library cover all my needs?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":169,"Q_Id":12253063,"Users Score":1,"Answer":"Try the Pika client or the Kombu client.  Celery is a whole framework for job queues, which you may not need - but it's worth taking a look if you want to understand a queue use case.","Q_Score":0,"Tags":"python,rabbitmq,message-queue,django-celery","A_Id":12258879,"CreationDate":"2012-09-03T19:23:00.000","Title":"Queueing HTTP, emails, and TCP messages 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},{"Question":"I am pretty new to Python. Currently I am trying out PyCharm and I am encountering some weird behavior that I can't explain when I run tests.\nThe project I am currently working on is located in a folder called PythonPlayground. This folder contains some subdirectories. Every folder contains a init.py file. Some of the folders contain nosetest tests.\nWhen I run the tests with the nosetest runner from the command line inside the project directory, I have to put \"PythonPlayground\" in front of all my local imports. E.g. when importing the module called \"model\" in the folder \"ui\" I have to import it like this:\n\nfrom PythonPlayground.ui.model import *\n\nBut when I run the tests from inside Pycharm, I have to remove the leading \"PythonPlayground\" again, otherwise the tests don't work. Like this:\n\nfrom ui.model import *\n\nI am also trying out the mock framework, and for some reason this framework always needs the complete name of the module (including \"PythonPlayground\"). It doesn't matter whether I run the tests from command line or from inside PyCharm:\n\nwith patch('PythonPlayground.ui.models.User') as mock:\n\nCould somebody explain the difference in behavior to me? And what is the correct behavior?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":514,"Q_Id":12260983,"Users Score":1,"Answer":"I think it happens because PyCharm have its own \"copy\" of interpreter which have its own version of sys paths where you project's root set to one level lower the PythonPlayground dir.\nAnd you could find preferences of interpreter in PyCharm fro your project and set proper top level.\nps. I have same problems but in Eclipse + pydev","Q_Score":0,"Tags":"python,pycharm,nose","A_Id":12261280,"CreationDate":"2012-09-04T09:56:00.000","Title":"Nosetest & import","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"My problem is the following:\nI have an undirected graph. Each edge has a cost (or weight). One of the nodes is labelled S. I want to start from S and visit every node at least once. Visiting a node multiple times is allowed. Travelling along an edge multiple times is allowed, although that would make the solution more expensive -- travelling an edge with cost of 3 twice will add 6 to the cost of the total path. The graph has some \"dead-end\" nodes, so sometimes we have to travel an edge more than once.\nWhat is a fast algorithm to do this? Is this a well known problem? \nWhat I'm looking for:\nReasonably fast -- The relative size of the graph we are talking about here is order of 40 - 50 nodes. So the algorithm hopefully won't take longer than 10 - 15 seconds.\nReasonably optimal -- I'm not looking for absolute optimality. Any interesting heuristic to guide the search so that the solution will be near optimal is good enough.\nI will be writing this in python. So if you know of any python implementation of the algorithm, that's best.\nThanks for any help.","AnswerCount":5,"Available Count":1,"Score":0.0399786803,"is_accepted":false,"ViewCount":4388,"Q_Id":12285858,"Users Score":1,"Answer":"A simple approach is to build the minimum spanning tree for your graph and do a (depth-first) walk over it, skipping nodes already visited.\nThis is proven to be no more than twice as long as the optimal TSP path. You can definitely do better with heuristics, but it's a starter (and easy to implement too).","Q_Score":4,"Tags":"python,search,artificial-intelligence,computer-science,heuristics","A_Id":12287399,"CreationDate":"2012-09-05T16:27:00.000","Title":"What's a fast algorithm that can find a short path to traverse each node of a weighted undirected graph at least once?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I have some class-based unit tests running in python's unittest2 framework. We're using Selenium WebDriver, which has a convenient save_screenshot() method. I'd like to grab a screenshot in tearDown() for every test failure, to reduce the time spent debugging why a test failed.\nHowever, I can't find any way to run code on test failures only. tearDown() is called regardless of whether the test succeeds, and I don't want to clutter our filesystem with hundreds of browser screenshots for tests that succeeded.\nHow would you approach this?","AnswerCount":5,"Available Count":1,"Score":0.0798297691,"is_accepted":false,"ViewCount":1958,"Q_Id":12290336,"Users Score":2,"Answer":"Override fail() to generate the screenshot and then call TestCase.fail(self)?","Q_Score":12,"Tags":"python,unit-testing,selenium-webdriver","A_Id":12290574,"CreationDate":"2012-09-05T21:53:00.000","Title":"How to execute code only on test failures with python unittest2?","Data Science and Machine Learning":0,"Database and SQL":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},{"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},{"Question":"I want to communicate with the phone via serial port. After writing some command to phone, I used ser.read(ser.inWaiting()) to get its return value, but I always got total 1020 bytes of characters, and actually, the desired returns is supposed to be over 50KB.\nI have tried to set ser.read(50000), but the interpreter will hang on.\nHow would I expand the input buffer to get all of the returns at once?","AnswerCount":4,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":21578,"Q_Id":12302155,"Users Score":0,"Answer":"pySerial uses the native OS drivers for serial receiving.  In the case of Windows, the size of the input driver is based on the device driver.  \nYou may be able to increase the size in your Device Manager settings if it is possible, but ultimately you just need to read the data in fast enough.","Q_Score":10,"Tags":"python,buffer,pyserial","A_Id":45513398,"CreationDate":"2012-09-06T14:16:00.000","Title":"How to expand input buffer size of 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":1},{"Question":"I want to communicate with the phone via serial port. After writing some command to phone, I used ser.read(ser.inWaiting()) to get its return value, but I always got total 1020 bytes of characters, and actually, the desired returns is supposed to be over 50KB.\nI have tried to set ser.read(50000), but the interpreter will hang on.\nHow would I expand the input buffer to get all of the returns at once?","AnswerCount":4,"Available Count":2,"Score":0.049958375,"is_accepted":false,"ViewCount":21578,"Q_Id":12302155,"Users Score":1,"Answer":"I'm guessing that you are reading 1020 bytes because that is all there is in the buffer, which is what ser.inWaiting() is returning. Depending on the baud rate 50 KB may take a while to transfer, or the phone is expecting something different from you. Handshaking?\nInspect the value of ser.inWaiting, and then the contents of what you are receiving for hints.","Q_Score":10,"Tags":"python,buffer,pyserial","A_Id":12920183,"CreationDate":"2012-09-06T14:16:00.000","Title":"How to expand input buffer size of 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":1},{"Question":"I am unsure which of the two I should go for. Flup or modwsgi. \nFlup seems to have very little documentation and even less people adding to the code. modwsgi on the other hand seems to be widely supported. \nI just want to start running my webpy environmental so that I can utilize Python scripts online. But this thing stops me from moving ahead. Any suggestions?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":813,"Q_Id":12305146,"Users Score":0,"Answer":"I use nginx and uwsgi to deploy my own web.py apps, seems faster and consumes less ram than apache+mod_wsgi, the setup is not as easy though. I have to run supervisord to ensure that all uwsgi processes are on.\nDon't use flup, I think its considered to be a bit outdated way of deploying python web apps.","Q_Score":1,"Tags":"python,python-2.7,mod-wsgi,web.py,flup","A_Id":12314167,"CreationDate":"2012-09-06T17:14:00.000","Title":"Python 2.7 with Webpy - flup or modwsgi?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"Here's a data flow:\nhttp <--> nginx <--> uWSGI <--> python webapp\nI guess there's http2uwsgi transfer in nginx, and uwsgi2http in uWSGI.\nWhat if I want to directly call uWSGI to test an API in a webapp?\nactually i'm using pyramid. just config [uwsgi] in .ini and run uWSGI. but i want to test if uWSGI hold webapp function normally, the uWSGI socket is not directly reachable by http.","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":5693,"Q_Id":12314245,"Users Score":1,"Answer":"First, consider those questions:\n\nOn which port is uWSGI running?\nIs uWSGI running on your or on a remote machine?\nIf it's running on a remote machine, is the port accessible from your computer? (iptables rules might forbid external access)\n\nIf you made sure you have access, you can just call http:\/\/hostname:port\/path\/to\/uWSGI for direct API access.","Q_Score":3,"Tags":"python,nginx,uwsgi","A_Id":12314652,"CreationDate":"2012-09-07T08:13:00.000","Title":"Can I use the uwsgi protocol to call http?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"Is there a good way to check if a string is encoded in base64 using Python?","AnswerCount":11,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":50919,"Q_Id":12315398,"Users Score":18,"Answer":"This isn't possible. The best you could do would be to verify that a string might be valid Base 64, although many strings consisting of only ASCII text can be decoded as if they were Base 64.","Q_Score":47,"Tags":"python,base64","A_Id":12317005,"CreationDate":"2012-09-07T09:30:00.000","Title":"Check if a string is encoded in base64 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},{"Question":"I have read this example from AutobahnPython: https:\/\/github.com\/tavendo\/AutobahnPython\/tree\/master\/examples\/websocket\/broadcast\nIt looks pretty easy to understand and practice. But I want to add a little more. Members who submit the correct secret string can send the messages, anyone else can only view the information transmitted. Any idea?\nThanks!","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":1310,"Q_Id":12321301,"Users Score":1,"Answer":"Well it is purely your logic in the code. When you receive the message you are simply broadcasting it, what you have to do is to pass this onto a custom function, and there, do a check:  \nCreate a temporary array that contains list of active authenticated users. when user logs on, it should send this special string, match it, if OK, add this user to this active user list array, if not don't add it. Later, call the bradcast function but rather then taking all online users, use this custom array instead.  \nThat is all that you have to do.\nMake sure when someone logs out, remove him from this array.","Q_Score":1,"Tags":"python,websocket,broadcasting,autobahn","A_Id":14835403,"CreationDate":"2012-09-07T15:39:00.000","Title":"Python - Broadcasting with WebSocket using AutobahnPython","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},{"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},{"Question":"Is there a command in Eclipse Pydev which allows me to only run a few selected (highlighted) lines of code within a larger script?\nIf not, is it possible to run multiple lines of code in the PyDev console at once?","AnswerCount":2,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":11174,"Q_Id":12335424,"Users Score":19,"Answer":"press CTRL+ALT+ENTER to send the selected lines to the interactive console","Q_Score":19,"Tags":"python,eclipse,pydev","A_Id":12774197,"CreationDate":"2012-09-08T23:53:00.000","Title":"Eclipse Pydev: Run selected lines of 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":1,"Web Development":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},{"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},{"Question":"I have installed psutil module.\nIt works well if run by the python interpreter but when I try to import the module in a monkeyrunner script,it gives \n\nNo such module.\n\nIs there any way through which i use psutil module in monkeyrunner?\nNote-i am using the monkeyrunner with the android ics-x86 version","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":258,"Q_Id":12346337,"Users Score":0,"Answer":"Try to name your script something.py. This way you have a python script where you can import the modules. When you run the script with monkeyrunner, some python modules are not recognized. Monkeyrunner does not equal python 100%. It does not have all the power and functionality.","Q_Score":1,"Tags":"python-module,monkeyrunner","A_Id":12348061,"CreationDate":"2012-09-10T06:26:00.000","Title":"Monkeyrunner doesnt find my 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":0},{"Question":"I'd like to test my WSGI library with gevent's WSGI Servers to ensure that request parameters aren't leaked\/overwritten with those from another request\/greenlet - in my library request is \"global\", though it should be thread-safe... which is what I'd like to test using gevent.\nWhat approaches can I use? Are there any open-source projects which already have unittests which achieve this from which I could learn?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":563,"Q_Id":12348500,"Users Score":1,"Answer":"If your library uses threading.local to provide thread-isolated \"global\" request variable then all you need is to call gevent.monkey.patch_thread BEFORE you use threading.local. That should turn all threading.local objects into \"greenlet.local\" ones.","Q_Score":1,"Tags":"python,wsgi,gevent","A_Id":15670806,"CreationDate":"2012-09-10T09:09:00.000","Title":"How can I unittest wsgi code which uses 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},{"Question":"My python script does some heavy computation. To boost performance, it caches the computed data on the disk so that next time I'll run it, it doesn't waste time in computing the same thing. However, before extracting data from the cache, it needs to do some checking to make sure that the cache is not stale. This is the part where I am stuck.\nMy first idea was to compare the creation time of cache and modification time of python script and if the later is larger (ie more recent) than the former, I would consider the cache as stale, else not. However, since linux kernel does not store creation times of files, I am stuck at this point.\nSimilar situation:\nWhen python interpreter creates .pyc files from .py files, it does something similar --> creates a new .pyc file if I'll modify my .py file after the .pyc file was created, else it does not. How does it do that? I wish to know the algorithm. Thank you.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":591,"Q_Id":12349970,"Users Score":0,"Answer":"You can have a metadata file that will hold a list of all cached entities together with their creation times","Q_Score":4,"Tags":"python,algorithm,caching","A_Id":12350058,"CreationDate":"2012-09-10T10:39:00.000","Title":"Algorithm to check if cache is stale","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"My python script does some heavy computation. To boost performance, it caches the computed data on the disk so that next time I'll run it, it doesn't waste time in computing the same thing. However, before extracting data from the cache, it needs to do some checking to make sure that the cache is not stale. This is the part where I am stuck.\nMy first idea was to compare the creation time of cache and modification time of python script and if the later is larger (ie more recent) than the former, I would consider the cache as stale, else not. However, since linux kernel does not store creation times of files, I am stuck at this point.\nSimilar situation:\nWhen python interpreter creates .pyc files from .py files, it does something similar --> creates a new .pyc file if I'll modify my .py file after the .pyc file was created, else it does not. How does it do that? I wish to know the algorithm. Thank you.","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":591,"Q_Id":12349970,"Users Score":2,"Answer":"Just check the last-modified time of your cache file instead.\nEven better, that's what you really want to check in any case, because when you update your cache to store the new computed value, you want to know when that was done last, not when that was done the first time. :-)","Q_Score":4,"Tags":"python,algorithm,caching","A_Id":12356214,"CreationDate":"2012-09-10T10:39:00.000","Title":"Algorithm to check if cache is stale","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am having a hierarchy of directories and inside every directory there is one 'test\/' directory which has all the test files. nosetests is not able to collect these test files somehow. \nI have followed naming convention used for filenames and class names as well. All the classes defined in those files are subclass of unittest:TestCase. Still no luck. What must be the problem ?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":379,"Q_Id":12367009,"Users Score":0,"Answer":"I am only answering my question. It is really very strange. I found that the test files previously were in executable mode. And as soon as i changed there modes, it started working like a charm. :-) chmod -x *_test.py worked for me. Can anybody explain this behaviour of nosetests ???","Q_Score":0,"Tags":"python,nose,nosetests","A_Id":12367042,"CreationDate":"2012-09-11T09:48:00.000","Title":"'nosetests' was unable to collect test files from 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},{"Question":"I am having a hierarchy of directories and inside every directory there is one 'test\/' directory which has all the test files. nosetests is not able to collect these test files somehow. \nI have followed naming convention used for filenames and class names as well. All the classes defined in those files are subclass of unittest:TestCase. Still no luck. What must be the problem ?","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":379,"Q_Id":12367009,"Users Score":1,"Answer":"If you carefully see the python nose usage, you will get it\n--exe                 Look for tests in python modules that are executable.\n                        Normal behavior is to exclude executable modules,\nThanks.","Q_Score":0,"Tags":"python,nose,nosetests","A_Id":12418833,"CreationDate":"2012-09-11T09:48:00.000","Title":"'nosetests' was unable to collect test files from 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},{"Question":"Is it possible to determine the type of a file-like object in Python?\nFor instance, if I were to read the contents of a file into a StringIO container and store it in a database, could I later work-out the original file-\/content-\/mime-type from the data? Eg. are there any common headers I could search for? \nIf not, are there any ways to determine \"common\" files (images, office docs, etc)?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":584,"Q_Id":12367891,"Users Score":0,"Answer":"Yes, you should evaluate the hex signature.","Q_Score":2,"Tags":"python,mime-types,content-type","A_Id":55849444,"CreationDate":"2012-09-11T10:40:00.000","Title":"Determine file-\/content-\/mime-type from file-like?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":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},{"Question":"I have installed rabbitmq, use pika in python and rabbitmq-c in C for testing.\nI have done nothing to rabbitmq except that i modify the listener port to my own one.\nThe producer works the whole night to put enough messages into rabbitmq, about 1000K durable messages.\nThe customer is written both in C and python, but its qps is just 80 per queue.\nThe articles on internet says that their single queue can reach 15000 qps, so what's wrong with mine? Do i need to configure some essential things about rabbitmq?\nEach message is about 100 Btyes long, I use consume ack, and the queue and message are both durable.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":319,"Q_Id":12383270,"Users Score":0,"Answer":"To get a good throughput one should monitor:\n\nflow control : memory based, ensure alert levels are set correctly to avoid connections blocking. Connection based ,check publisher and consumer rates are appropriate to avoid flow control)\nSetting appropriate Qos values for consumers.","Q_Score":0,"Tags":"python,c,rabbitmq","A_Id":20113247,"CreationDate":"2012-09-12T07:36:00.000","Title":"My rabbitmq's qps is only 80 in piki 1000 in rabbitmq-c, what's wrong with 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":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a consumer which listens for messages, if the flow of messages is more than the consumer can handle I want to start another instance of this consumer.\nBut I also want to be able to poll for information from the consumer(s), my thought was that I could use RPC to request this information from the producers by using a fanout exchange so all the producers gets the RPC-call.\nMy question is first of all is this possible and secondly is it reasonable?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":2271,"Q_Id":12407485,"Users Score":1,"Answer":"After some researching it seems that this is not possible. If you look at the tutorial on RabbitMQ.com you see that there is an id for the call which, as far as I understand gets consumed. \nI've choosen to go another way, which is reading the log-files and aggregating the data.","Q_Score":3,"Tags":"python,rabbitmq,messaging,pika","A_Id":12478098,"CreationDate":"2012-09-13T13:31:00.000","Title":"RPC calls to multiple consumers","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},{"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},{"Question":"I am running python on linux and am currently using vim for my single-file programs, and gedit for multi-file programs. I have seen development environments like eclipse and was basically wondering if there's a similar thing on ubuntu designed for python.","AnswerCount":4,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":210,"Q_Id":12425407,"Users Score":0,"Answer":"Komodo is a good commercial IDE.And Eric is a free python IDE which is written with python.","Q_Score":0,"Tags":"python,ide,text-editor","A_Id":12425441,"CreationDate":"2012-09-14T13:17:00.000","Title":"development environment for 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":1,"Web Development":0},{"Question":"I am using PyDev via eclipse and have used easy_install to get jsonpickle.  No matter what I do I can't seem to get the import to work.  \nWhat I have tried thus far:\n\nI have removed it from easy_install.pth and deleted the egg and installed again.\nAdd my python lib, dll, etc folders to a  PYTHONPATH system variable\nRestarted eclipse\n\nOther imports are working fine.  Not sure what I am doing wrong?\nEDIT:\nSorry should have included OS \/ Python version.\nOS: Windows 7\nPython: 2.7\nAny suggestions greatly appreciated","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":800,"Q_Id":12425433,"Users Score":1,"Answer":"OS and python version?\n\nPlease use pip.  Always.\npydev seems to ignore your package.  It should be in \/usr\/share\/pythonX.Y\/site-packages\/jsonpickle, or, if on Windows, c:\\pythonxx[...].\nIf using Linux, please try to find a distro package for jsonpickle.","Q_Score":0,"Tags":"python,jsonpickle","A_Id":12426079,"CreationDate":"2012-09-14T13:20:00.000","Title":"Can't get import to be recognized - jsonpickle","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Developing in Python using mod-python mod-wsgi on Apache 2.\nAll running fine, but if I do any change on my PY file, the changes are not propagated until I restart Apache \/etc\/init.d\/apache2 restart.\nThis is annoying since I can't SSH and restart Apache service everytime in development.\nIs there any way to disable Apache caching?\nThank you.","AnswerCount":2,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":1461,"Q_Id":12432130,"Users Score":4,"Answer":"Its a very bad setting from a performance point of view, but what I do in my http.conf is set MaxRequestsPerChild to 1.  This has the effect of each apache process handles a single request before dying.  It kills throughput (so don't run benchmarks with that setting, or use it on a production site), but it has the effect of giving python a clean environment for every request.","Q_Score":2,"Tags":"python,apache,caching,wsgi","A_Id":12432255,"CreationDate":"2012-09-14T21:18:00.000","Title":"Disable caching in Apache 2 for Python 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":1},{"Question":"From time to time I suddenly have a need to connect to a device's console via its serial port. The problem is, I never remember what port settings (baud rate, data bits, stop bits, etc...) to use with each particular device, and documentation never seems to be lying around when it's really needed.\nI wrote a Python script, which uses a simple brute-force method (i.e. iterates over all possible settings, sends some test input and displays the response for a human to decide if it makes sense ), but:\n\nit takes a long time to complete\ndoes not always work (perhaps port reset\/timeout issues)\njust does not seem like a proper way to do this :)\n\nSo the question is: does anyone know of a procedure to auto-detect what port settings the remote device is using?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":2135,"Q_Id":12435923,"Users Score":1,"Answer":"Although part 1 is no direct answer to your question: \nThere are devices, which just have a autodetection (called Auto-bauding) method included, that means: Send a character using your current settings (9k6, 115k2, ..) to the device and chances are high that the device will answer with your (!) settings. I've seen this on HP switches.\nSecond approach: try to re-order the connection possibilities. E.g. chances are high that the other end uses 9k6 with no hardware handshake, but less that it uses 38k4 with software Xon\/Xoff.\nIf you break down your tries into just a few, the \"brute force\" method will be much more efficient.","Q_Score":4,"Tags":"python,serial-port,communication","A_Id":12436940,"CreationDate":"2012-09-15T08:46:00.000","Title":"Detecting serial port settings","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"Can this be done?\nNo idea if the Cython .so extension can be dynamic loaded from a php script or does it needs any extra manage?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":320,"Q_Id":12462227,"Users Score":1,"Answer":"The short answer is no. Cython extensions use the Python C API, so they can't be loaded and called directly from PHP. They will typically take and return PyObject structs as arguments (Python objects). You'll need a Python <-> PHP binding to load the .so and do object conversion.","Q_Score":0,"Tags":"php,python,cython","A_Id":12462519,"CreationDate":"2012-09-17T15:13:00.000","Title":"Use a Cython extension from a compiled python 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},{"Question":"What its the best game-engine 3D to Python 3.x and easy to install on Linux (Debian 7 \"wheezy\")?","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":1505,"Q_Id":12487889,"Users Score":1,"Answer":"If you want a game engine in python, I would recommend these:\n\nKivy (multiplatform)\nPyGame (multiplatform)\nBlender (graphical game engine made in python, multiplatform, also used for modeling)\nPyOpenGL (multiplatform, 3d game engine like blender)\n\nThese are some game engines I know. You also might want to try Unity3d.","Q_Score":2,"Tags":"python,python-3.x,game-engine","A_Id":31010631,"CreationDate":"2012-09-19T02:46:00.000","Title":"Game Engine 3D to Python3.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},{"Question":"What its the best game-engine 3D to Python 3.x and easy to install on Linux (Debian 7 \"wheezy\")?","AnswerCount":2,"Available Count":2,"Score":0.1973753202,"is_accepted":false,"ViewCount":1505,"Q_Id":12487889,"Users Score":2,"Answer":"Not sure if it is the \"best\" - but not working on the field I am aware of few others than Blender 3D 's  game engine. Blender moved to Python 3 scripting at version 2.5, so any newer version than that will use Python 3 for BGE (Blender Game Engine) scripts.\nPygame is also available for Python 3.x, and it does feature a somewhat low-level interface to OpenGL - -sou you could do 3d with it.\nBoth should not have any major problems running in Debian, but maybe you will have to configure some sort of PPA to get packages being installed for Python 3.\nAlso, be sure that your Debian's python3 is 3.2 - this distribution is known to have surprisingly obsolete packages even when one is running the most recent one.","Q_Score":2,"Tags":"python,python-3.x,game-engine","A_Id":12488430,"CreationDate":"2012-09-19T02:46:00.000","Title":"Game Engine 3D to Python3.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},{"Question":"I want to execute the Python scripts(that displays a toast and notification) in Android using sl4a. Can I show a toast message and a notification simultaneously? I m using an emulator for testing.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":694,"Q_Id":12490468,"Users Score":0,"Answer":"Yes, it is possible to use a toast and a notification at the same time.\nAlthough it may be not the best user experience in my opinion. \nToast is a way to let the user know of something while he'she is looking at the screen and is low priority. It goes away in a while.\nNotification is a way to let the user know about something which is higher priority than a toast. It may be at a time where user's primary focus is not your app, or the device is sleeping as well. User can go to the notification drawer and see what's new with your app with this.\nIn most use cases, one of them does the job. I'm not sure why you need both.. at the same time. Doesn't a single notification cut it ?","Q_Score":0,"Tags":"android,python,sl4a","A_Id":12490713,"CreationDate":"2012-09-19T07:45:00.000","Title":"Toast, notification simultaneously in 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":0},{"Question":"How would I be able to find which module is overriding the Python root logger?\nMy Django project imports from quite a few external packages, and I have tried searching for all instances of logging.basicConfig and logging.root setups, however most of them are in tests and should not be overriding it unless specifically called.\nDjango's logging config does not specify a root logger.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":205,"Q_Id":12522080,"Users Score":0,"Answer":"I'm assuming you mean import logging imports a different logging module?  In this case, there are many special attributes of modules\/packages that can help, such as __path__.  Printing logging.__path__ should tell you where python is importing it from.","Q_Score":4,"Tags":"python,logging","A_Id":12523536,"CreationDate":"2012-09-20T22:53:00.000","Title":"Finding out which module is setting the root logger","Data Science and Machine Learning":0,"Database and SQL":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},{"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},{"Question":"Is there any way to read GSM modem port number programmatically using Python, when I connect mobile to Windows XP machine?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":894,"Q_Id":12527309,"Users Score":0,"Answer":"Sorry I donot know the python syntaxes, just an idea to follow. You can use SerialPort.GetPortNames(); to get the list of available ports in your system. \nAnd then send an AT command to each port. Which ever port responds with an OK , it means that your modem is connected to that port.","Q_Score":0,"Tags":"python,port,gsm","A_Id":12527528,"CreationDate":"2012-09-21T08:57:00.000","Title":"Programmatically read GSM modem port number","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"It is a django project. I am using pydev 2.6. How do I make it to use the Django test runner?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":234,"Q_Id":12532465,"Users Score":1,"Answer":"The Django test runner can be accessed by creating a new (Run or Debug) configuration for your project using the Django template. Set your main module as manage.py and under the Arguments tab enter \"test\" (or any other manage.py arguments you need).","Q_Score":0,"Tags":"python,django,pydev","A_Id":12535217,"CreationDate":"2012-09-21T14:24:00.000","Title":"pydev with eclipse does create test database when running test","Data Science and Machine Learning":0,"Database and SQL":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},{"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},{"Question":"I need to run a monkeyrunner script in a remote machine. I'm using python to to automate it and RPyC so that I could connect to other machines, everything is running in CentOS.\nwritten below is the command that I used:\n\nimport rpyc\nimport subprocess\nconn = rpyc.classic.connect(\"192.XXX.XXX.XXX\",XXXXX)\nconn.execute (\"print 'Hello'\")\nsubprocess.Popen(\"\/opt\/android-sdk\/tools\/monkeyrunner -v ALL\n\/opt\/android-sdk\/tools\/MYSCRIPT.py\", shell=True)\n\nand this is the result:\n\ncan't open specified script file\nUsage : monkeyrunner [option] script_file\n-s MonkeyServer IP Address\n-p MonkeyServer TCP Port\n-v MonkeyServer Logging level\n\nAnd then I realized that if you use the command below, it is running the command in your machine. (example: the command inside the Popen is \"ls\" the result that it will give you is the list of files and directories in the current directory of the LOCALHOST) hence, the command is wrong.\n\nsubprocess.Popen(\"\/opt\/android-sdk\/tools\/monkeyrunner -v ALL\n\/opt\/android-sdk\/tools\/MYSCRIPT.py\", shell=True)\n\nand so I replaced the code with this\n\nconn.modules.subprocess.Popen(\"\/opt\/android-sdk\/tools\/monkeyrunner -v ALL\n\/opt\/android-sdk\/tools\/MYSCRIPT.py\", shell=True)\n\nAnd give me this error message \n\n======= Remote traceback ======= Traceback (most recent call last):   File\n  \"\/usr\/lib\/python2.4\/site-packages\/rpyc-3.2.2-py2.4.egg\/rpyc\/core\/protocol.py\",\n  line 300, in _dispatch_request\n      res = self._HANDLERS[handler](self, *args)   File \"\/usr\/lib\/python2.4\/site-packages\/rpyc-3.2.2-py2.4.egg\/rpyc\/core\/protocol.py\",\n  line 532, in _handle_call\n      return self._local_objects[oid](*args, **dict(kwargs))   File \"\/usr\/lib\/python2.4\/subprocess.py\", line 542, in init\n      errread, errwrite)   File \"\/usr\/lib\/python2.4\/subprocess.py\", line 975, in _execute_child\n      raise child_exception OSError: [Errno 2] No such file or directory\n======= Local exception ======== Traceback (most recent call last):   File \"\", line 1, in ?   File\n  \"\/usr\/lib\/python2.4\/site-packages\/rpyc-3.2.2-py2.4.egg\/rpyc\/core\/netref.py\",\n  line 196, in call\n      return syncreq(_self, consts.HANDLE_CALL, args, kwargs)   File \"\/usr\/lib\/python2.4\/site-packages\/rpyc-3.2.2-py2.4.egg\/rpyc\/core\/netref.py\",\n  line 71, in syncreq\n      return conn.sync_request(handler, oid, *args)   File \"\/usr\/lib\/python2.4\/site-packages\/rpyc-3.2.2-py2.4.egg\/rpyc\/core\/protocol.py\",\n  line 438, in sync_request\n      raise obj OSError: [Errno 2] No such file or directory\n\nI am thinking that it cannot run the file because I don't have administrator access (since I didn't supply the username and password of the remote machine)?\nHelp!","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1078,"Q_Id":12578021,"Users Score":0,"Answer":"Using this function to run monekyrunner doesn't work although running ls, pwd works fine.\n\nconn.modules.subprocess.Popen(\"\/opt\/android-sdk\/tools\/monkeyrunner -v\n  ALL\n  \/opt\/android-sdk\/tools\/MYSCRIPT.py\", shell=True)\n\nThe chunk of code below solved my problem : \n\nimport rpyc\nimport subprocess , os\nconn = rpyc.classic.connect(\"192.XXX.XXX.XXX\",XXXXX)\nconn.execute (\"print 'Hello'\")\nconn.modules.os.popen(\"monkeyrunner -v ALL MYSCRIPT.py\",)\n\nHope this helps to those who are experiencing the same problem as mine.","Q_Score":2,"Tags":"android,python,centos,monkeyrunner,rpyc","A_Id":12593620,"CreationDate":"2012-09-25T07:20:00.000","Title":"why is monkeyrunner not working when run from a remote machine?","Data Science and Machine Learning":0,"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},{"Question":"When working on a project my scripts often have some boiler-plate code, like adding paths to sys.path and importing my project's modules. It gets tedious to run this boiler-plate code every time I start up the interactive interpreter to quickly check something, so I'm wondering if it's possible to pass a script to the interpreter that it will run before it becomes \"interactive\".","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":422,"Q_Id":12581638,"Users Score":6,"Answer":"That can be done using the -i option. Quoting the interpreter help text:\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\nSo the interpreter runs the script, then makes the interactive prompt available after execution.\nExample:\n\n$ python -i boilerplate.py\n>>> print mymodule.__doc__\nI'm a module!\n>>>\n\n\nThis can also be done using the environment variable PYTHONSTARTUP. Example:\n\n$ PYTHONSTARTUP=boilerplate.py python\nPython 2.7.3 (default, Sep  4 2012, 10:30:34) \n[GCC 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.11.00)] on darwin\nType \"help\", \"copyright\", \"credits\" or \"license\" for more information.\n>>> print mymodule.__doc__\nI'm a module!\n>>>\n\nI personally prefer the former method since it doesn't show the three lines of information, but either will get the job done.","Q_Score":6,"Tags":"python,python-interactive","A_Id":12581642,"CreationDate":"2012-09-25T11:03:00.000","Title":"Is it possible to get the Python Interactive Interpreter to run a script on load?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm working with a framework and the source code is raising exceptions using the Exception class (and not a subclass, either framework specific or from the stdlib) in a few places, which is is not a good idea in my opinion. \nThe main argument against this idiom is that it forces the caller to use except Exception: which can catch more than what is meant, and therefore hide problems at lower stack levels. \nHowever, a quick search in the Python documentation did not come up with arguments against this practice, and there are even examples of this in the tutorial (although things which are OK in Python scripts may not be OK at all in a Python framework in my opinion). \nSo is raise Exception considered pythonic?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":89,"Q_Id":12596557,"Users Score":1,"Answer":"No, it is not.  At the very minimum the framework should provide its own exception class, and probably should have several (depending on the variety of things that could go wrong).\nAs you said, except Exception will catch way too much and is not good practice.","Q_Score":2,"Tags":"python,coding-style","A_Id":12596686,"CreationDate":"2012-09-26T07:20:00.000","Title":"arguments for \/ against `raise Exception(message)` 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},{"Question":"What is the best way to communicate between a Python 3.x and a Python 2.x program?\nWe're writing a web app whose front end servers will be written in Python 3 (CherryPy + uWSGI) primarily because it is unicode heavy app and Python 3.x has a cleaner support for unicode.\nBut we need to use systems like Redis and Boto (AWS client) which don't yet have Python 3 support.\nHence we need to create a system in which we can communicate between Python 3.x and 2.x programs.\nWhat do you think is the best way to do this?","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":1491,"Q_Id":12597394,"Users Score":2,"Answer":"The best way? Write everything in Python 2.x. It's a simple question: can I do everything in Python 2.x? Yes! Can I do everything in Python 3.x? No. What's your problem then?\nBut if you really, really have to use two different Python versions ( why not two different languages for example? ) then you will probably have to create two different servers ( which will be clients at the same time ) which will communicate via TCP\/UDP or whatever protocol you want. This might actually be quite handy if you think about scaling the application in the future. Although let me warn you: it won't be easy at all.","Q_Score":3,"Tags":"python,python-3.x,python-2.x","A_Id":12599590,"CreationDate":"2012-09-26T08:15:00.000","Title":"communication between Python 3 and Python 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},{"Question":"Looking to improve quality of a fairly large Python project. I am happy with the types of warnings PyLint gives me. However, they are just too numerous and hard to enforce across a large organization. Also I believe that some code is more critical\/sensitive than others with respect to where the next bug may come. For example I would like to spend more time validating a library method that is used by 100 modules rather than a script that was last touched 2 years ago and may not be used in production. Also it would be interesting to know modules that are frequently updated.\nIs anyone familiar with tools for Python or otherwise that help with this type of analysis?","AnswerCount":6,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":1381,"Q_Id":12614131,"Users Score":10,"Answer":"I'm afraid you are mostly on your own.\nIf you have decent set of tests, look at code coverage and dead code.\nIf you have a decent profiling setup, use that to get a glimpse of what's used more.\nIn the end, it seems you are more interested in fan-in\/fan-out analysis, I'm not aware of any good tools for Python, primarily because static analysis is horribly unreliable against a dynamic language, and so far I didn't see any statistical analysis tools.\nI reckon that this information is sort of available in JIT compilers -- whatever (function, argument types) is in cache (compiled) those are used the most. Whether or not you can get this data out of e.g. PyPy I really don't have a clue.","Q_Score":21,"Tags":"python,code-analysis","A_Id":12663047,"CreationDate":"2012-09-27T04:32:00.000","Title":"Identifying \"sensitive\" code in your 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":1,"System Administration and DevOps":0,"Web Development":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},{"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},{"Question":"I\u2019m having a very strange issue with running a python CGI script in IIS.\nThe script is running in a custom application pool which uses a user account from the domain for identity. Impersonation is disabled for the site and Kerberos is used for authentication.\n\nWhen the account is member of the \u201cDomain Admins\u201d group, everything works like a charm\nWhen the account is not member of \u201cDomain Admins\u201d, I get an error on the very first line in the script: \u201cimport cgi\u201d. It seems like that import eventually leads to a random number being generated and it\u2019s the call to _urandom() which fails with a \u201cWindowsError: [Error 5] Access is denied\u201d.\nIf I run the same script from the command prompt, when logged in with the same user as the one from the application pool, everything works as a charm.\n\nWhen searching the web I have found out that the _urandom on windows is backed by the CryptGenRandom function in the operating system. Somehow it seems like my python CGI script does not have access to that function when running from the IIS, while it has access to that function when run from a command prompt.\nTo complicate things further, when logging in as the account running the application pool and then invoking the CGI-script from the web browser it works. It turns out I have to be logged in with the same user as the application pool for it to work. As I previously stated, impersonation is disabled, but somehow it seems like the identity is somehow passed along to the security functions in windows.\nIf I modify the random.py file that calls the _urandom() function to just return a fixed number, everything works fine, but then I have probably broken a lot of the security functions in python.\nSo have anyone experienced anything like this? Any ideas of what is going on?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":928,"Q_Id":12639930,"Users Score":0,"Answer":"I've solved the _urandom() error by changing IIS 7.5 settings to Impersonate User = yes. I'm not a Windows admin so I cannot elaborate. \nAfterwards import cgi inside python script worked just fine.","Q_Score":5,"Tags":"python,cgi,iis-7.5","A_Id":21917122,"CreationDate":"2012-09-28T12:21:00.000","Title":"Python CGI in IIS: issue with urandom 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},{"Question":"What is the best way to load a python module\/file after the whole python program is up and running. My current idea is to save the new python file to disk and call import on it. I am working with python 2.7.\nEach new python file will have pre-known functions, that will be called by the already running application.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":23,"Q_Id":12652475,"Users Score":0,"Answer":"The import statement is like any other executable statement, and can be executed at any point during execution.","Q_Score":0,"Tags":"python-2.7,runtime","A_Id":12654018,"CreationDate":"2012-09-29T11:52:00.000","Title":"loading python after the application is up and running","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Hi all~ I just be interested in embedded development, and as known to all, C is the most popular programming language in embedded development. But I prefer to use Python, does Python be adapted to do any tasks about embedded development or automatic control? And are there some books about this be worth recommended? Thanks!","AnswerCount":2,"Available Count":2,"Score":-0.1973753202,"is_accepted":false,"ViewCount":664,"Q_Id":12653026,"Users Score":-2,"Answer":"OOP is generally not suitable for embedded development. This is because embedded hardware is limited on memory and OOP is unpredictable with memory usage. It is possible, but you are forced into static objects an methods to have any kind of reliability.","Q_Score":0,"Tags":"python,embedded","A_Id":12653117,"CreationDate":"2012-09-29T13:20:00.000","Title":"Python on automatic control and embedded 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},{"Question":"Hi all~ I just be interested in embedded development, and as known to all, C is the most popular programming language in embedded development. But I prefer to use Python, does Python be adapted to do any tasks about embedded development or automatic control? And are there some books about this be worth recommended? Thanks!","AnswerCount":2,"Available Count":2,"Score":0.4621171573,"is_accepted":false,"ViewCount":664,"Q_Id":12653026,"Users Score":5,"Answer":"The reason C (and C++) are prevalent in embedded systems is that they are systems-level languages with minimal run-time environment requirements and can run stand-alone (bare metal), with an simple RTOS kernel, or within a complete OS environment.  Both are also almost ubiquitous being available for most 8, 16, 32 and 64 bit architectures.  For example, you can write bootstrap and OS code in C or C++, whereas Python needs both of those already in place just to run.\nPython on the other hand is an interpreted language (although it is possible to compile it, you would also need cross-compilation tools or an embedded target that could support self hosted development for that), and a significant amount of system level code (usually and OS) as well an the interpreter itself is required to support it.  All this precludes for example deployment on very small systems where C and even C++ can deliver.\nMoreover it Python would probably be unsuitable for hard-real-time systems due to its intrinsically slower execution and non-deterministic behaviour with respect to memory management.\nIf your embedded system happened to be running Linux it would of course be possible to use Python but the number of applications to which it was suited may be limited, and since Linux itself is somewhat resource hungry, you would probably not deploy it is the only reason was to be able to run Python.","Q_Score":0,"Tags":"python,embedded","A_Id":12654265,"CreationDate":"2012-09-29T13:20:00.000","Title":"Python on automatic control and embedded 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},{"Question":"I've to develop a server that has to make a lot of connections to receive and send small files. The question is if the increment of performance with C++ worth the time to spend on develop the code or if is better to use Python and debug the code time to time to speed it up. Maybe is a little abstract question without giving a number of connections but I don't really know. At least 10,000 connections\/minute to update clients status.","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":3596,"Q_Id":12656098,"Users Score":5,"Answer":"With that many connections, your server will be I\/O bound. The frequently cited speed differences between languages like C and C++ and languages like Python and (say) Ruby lie in the interpreter and boxing overhead which slow down computation, not in the realm of I\/O.\nNot only can use make good and reasonably use of concurrency (both via processes and threads, the GIL is released during I\/O and thus does not matter much for I\/O-bound programs), there is also a wealth of asynchronous servers. In addition, web servers in general have much better Python integration (e.g. mod_wsgi for Apache) than C and C++. This frees you from writing your own server loop, socket management, etc. which you likely won't do as well as the major servers anyway. This is assuming we're talking about a web service, and not something more arcane which Apache etc. cannot do out of the box.","Q_Score":3,"Tags":"c++,python,performance,cpu-speed","A_Id":12656127,"CreationDate":"2012-09-29T20:11:00.000","Title":"C++ vs Python server side 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":0},{"Question":"I've to develop a server that has to make a lot of connections to receive and send small files. The question is if the increment of performance with C++ worth the time to spend on develop the code or if is better to use Python and debug the code time to time to speed it up. Maybe is a little abstract question without giving a number of connections but I don't really know. At least 10,000 connections\/minute to update clients status.","AnswerCount":2,"Available Count":2,"Score":0.1973753202,"is_accepted":false,"ViewCount":3596,"Q_Id":12656098,"Users Score":2,"Answer":"I'd expect that the server time would be dominated by I\/O- network, disk, etc. You'd want to prove that the CPU consumption of the Python program is problematic and that you've grasped all the low-hanging CPU fruit before considering a change.","Q_Score":3,"Tags":"c++,python,performance,cpu-speed","A_Id":12656117,"CreationDate":"2012-09-29T20:11:00.000","Title":"C++ vs Python server side 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":0},{"Question":"python blabla.py will execute. But .\/blabla.py gives me an error of \"no such file or directory\" on CentOS6.3.\n\/usr\/bin\/env python does open up python properly.\nI am new to linux and really would like to get this working. Could someone help?\nThanks in advance!\n\nNote: thanks to all the fast replies!\nI did have the #!\/usr\/bin\/env python line at the beginning.\nwhich python gives \/usr\/bin\/python as an output.\nAnd the chmod +x was done as well.\nThe exact error was \"no such file or directory\" for .\/blabla.py, but python blabla.py runs fine.","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2334,"Q_Id":12663774,"Users Score":0,"Answer":"Add #!\/usr\/bin\/env python at the head of your script file.\nIt tell your system to search for the python interpreter and execute your script with it.","Q_Score":0,"Tags":"python,centos","A_Id":12663789,"CreationDate":"2012-09-30T18:20:00.000","Title":"\/usr\/bin\/env python opens up python, but .\/blabla.py does not execute","Data Science and Machine Learning":0,"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},{"Question":"I am using python2.7 and PDFminer for extracting text from pdf. I noticed that sometimes PDFminer gives me words with strange letters, but pdf viewers don't. Also for some pdf docs result returned by PDFminer and other pdf viewers are same (strange), but there are docs where pdf viewers can recognize text (copy-paste). Here is example of returned values:\nfrom pdf viewer: \u202b\u0641\u062a\u0640\u0640\u062d \u0628\u0640\u0640\u0640\u0627\u0628 \u0627\ufffd\u0633\u062a\u064a\u0640\u0640\u0631\u0627\u062f \u0627\u0644\u0628\u064a\u0640\u0640\ufffd\u0636 \u0648\u0627\u0644\u062f\u062c\u0640\u0640\u0640\u0640\u0627\u062c \u0627\u0644\u0645\u062c\u0645\u0640\u0640\u0640\u062f\u202c\nfrom PDFMiner: \u00f3\u00aa\u00e9\u00aadG \u00ea\u00c9````L\u00f3dGh \u00a2\u2020``\u00ab\u00d1dG OG\u00f4``\u00ab\u00e0\u00b0SG \u00dc\u00c9H \u00ed``\u00e0a\nSo my question is can I get same result as pdf viewer, and what is wrong with PDFminer. Does it missing encodings I don't know.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1267,"Q_Id":12675471,"Users Score":2,"Answer":"Yes.\nThis will happen when custom font encodings have been used e.g. identity-H,identity-V, etc. but fonts have not been embedded properly. \npdfminer gives garbage output in such cases because encoding is required to interpret the text","Q_Score":2,"Tags":"python,pdf,encoding","A_Id":13703110,"CreationDate":"2012-10-01T14:41:00.000","Title":"PDFminer gives strange letters","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I need to write program that will change bytes in file in specific addreses. I can use only python 2.2 it's game's module so... I read once about mmap but i can't find it in python 2.2","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":191,"Q_Id":12676194,"Users Score":1,"Answer":"Your best option is to manipulate the file directly; this will work regarding of Python version, i.e., 1.x, 2.x, 3.x. Here is some rough outline to get you started... if you do the actual pseudocode, it'll probably be pretty close if not exactly the correct Python:\n\nopen the file for 'r+b' (read\/write; for POSIX systems, you can also just use 'r+')\ngo to the specific byte in question (use a file's tell() method)\nwrite out the single byte you want changed (use a file's write() method)\nclose the file (use a file's close() method)","Q_Score":1,"Tags":"python,file,byte,python-2.2","A_Id":12677772,"CreationDate":"2012-10-01T15:21:00.000","Title":"How to change byte on specific addres","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"How can I add custom fields (in this case, meta codes) to a dispatch_list in Tastypie?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":883,"Q_Id":12683630,"Users Score":1,"Answer":"You can add a new field to the resource and dehydrate it with dehydrate_field_name().","Q_Score":0,"Tags":"python,django,api,rest,tastypie","A_Id":12686954,"CreationDate":"2012-10-02T02:08:00.000","Title":"Tastypie: Add meta codes to dispatch_list","Data Science and Machine Learning":0,"Database and SQL":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},{"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},{"Question":"I'm trying to track several keywords at once, with the following url: \nhttps:\/\/stream.twitter.com\/1.1\/statuses\/filter.json?track=twitter%2C%20whatever%2C%20streamingd%2C%20\nBut the stream only returns results for the first keyword?! What am I doing wrong?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":163,"Q_Id":12708573,"Users Score":0,"Answer":"Try without spaces (ie. the %20). Doh!","Q_Score":0,"Tags":"python,twitter,urlencode","A_Id":12708663,"CreationDate":"2012-10-03T12:34:00.000","Title":"Twitter Public Stream URL when several track keywords?","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},{"Question":"I am using pyramid web framework to build a website. I keep getting this warning in chrome console:\n\nResource interpreted as Font but transferred with MIME type application\/octet-stream: \"http:static\/images\/fonts\/font.woff\".\n\nHow do I get rid of this warning message?\nI have configured static files to be served using add_static_view\nI can think of a way to do this by adding a subscriber function for responses that checks if the path ends in .woff and setting the response header to application\/x-font-woff. But it does not look like a clean solution. Is there a way to tell Pyramid to do it through some setting.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":1474,"Q_Id":12723009,"Users Score":1,"Answer":"Simply add this following code where your Pyramid web app gets initialized.\n\nimport mimetypes\nmimetypes.add_type('application\/x-font-woff', '.woff')\n\nFor instance, I have added it in my webapp.py file, which gets called the first time the server gets hit with a request.","Q_Score":4,"Tags":"python,pyramid","A_Id":26917124,"CreationDate":"2012-10-04T08:13:00.000","Title":"How to set the content type header in response for a particular file type in Pyramid web 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},{"Question":"I am trying to clarify the concept of runtime dynamic binding and class inheritance in dynamic languages (Python, ruby) and static type languages (java, C++). I am not sure I am right or not.\nIn dynamic languages like Python and Ruby, runtime dynamic binding is implemented as duck typing. When the interpreter checks the type of an object, it checks whether the object has the specific method (or behaviour) rather than check the type of the object; and runtime dynamic binding does not mean class inheritence. Class inheritance just reduce code copy in Python and Ruby.\nIn static typed languages like Java and C++, runtime dynamic binding can be obtained only class inheritance. Class inheritance not only reduces code copy here, but is also used to implement runtime dynamic binding.\nIn summary, class inheritance and runtime dynamic binding are two difference concepts. In Python and Ruby, they are totally different; in Java and C++ they are mixed together.\nAm I right?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1662,"Q_Id":12729828,"Users Score":3,"Answer":"You are correct in that runtime dynamic binding is entirely different conceptually from class inheritance.\nBut as I re-read your question, I don't think I would agree that \"Java and C++, runtime dynamic binding is implemented as class inheritance.\" Class inheritance is simply the definition of broader behavior that includes existing behavior from existing classes. Further, runtime binding doesn't necessarily have anything to do with object orientation; it can refer merely to deferred method resolution.\nClass inheritance refers to the \"template\" for how an object is built, with more and more refined behavior with successive subclasses. Runtime dynamic binding is merely a way of saying that a reference to a method (for example) is deferred until execution time. In a given language, a particular class may leverage runtime dynamic binding, but have inherited classes resolved at compile time. \nIn a nutshell, Inheritance refers to the definition or blueprint of an object. Runtime dynamic binding is, at its most basic level, merely a mechanism for resolving method calls at execution time.\nEDIT I do need to clarify one point on this: Java implements dynamic binding on overridden class methods, while C++ determines a type through polymorphism at runtime, so it is not accurate for me to say that dynamic binding has \"no relationship\" to class inheritance. At a \"macro\" level, they're not inherently related, but a given language might leverage it in its inheritance mechanism.","Q_Score":6,"Tags":"java,c++,python,ruby,compiler-construction","A_Id":12730127,"CreationDate":"2012-10-04T14:41:00.000","Title":"Difference between runtime dynamic binding and class inheritance","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm unit testing a URL fetcher, and I need a test url which always causes urllib2.urlopen() (Python) to time out. I've tried making a php page with just sleep(10000) in it, but that causes 500 internal server error.\nHow would I make a resource that causes a connection timeout in the client whenever it is requested?","AnswerCount":5,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":615,"Q_Id":12753527,"Users Score":0,"Answer":"While there have been some good answers here, I found that a simple php sleep() call with an override to Apache's timeout was all I needed.\nI know that unit tests should be in isolation, but the server this endpoint is hosted on is no going anywhere.","Q_Score":3,"Tags":"php,python,apache,url,timeout","A_Id":12941867,"CreationDate":"2012-10-05T20:22:00.000","Title":"How should I create a test resource which always times out","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},{"Question":"I'm unit testing a URL fetcher, and I need a test url which always causes urllib2.urlopen() (Python) to time out. I've tried making a php page with just sleep(10000) in it, but that causes 500 internal server error.\nHow would I make a resource that causes a connection timeout in the client whenever it is requested?","AnswerCount":5,"Available Count":2,"Score":0.0399786803,"is_accepted":false,"ViewCount":615,"Q_Id":12753527,"Users Score":1,"Answer":"Connection timeout? Use, for example, netcat. Listen on some port (nc -l), and then try to download data from that port.. http:\/\/localhost:port\/. It will open connection, which will never reply.","Q_Score":3,"Tags":"php,python,apache,url,timeout","A_Id":12753554,"CreationDate":"2012-10-05T20:22:00.000","Title":"How should I create a test resource which always times out","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},{"Question":"I'm attempting to configure SQLAlchemy Alembic for my Pyramid project and I want to use my developement.ini (or production.ini) for the configuration settings for Alembic. Is it possible to specify the .ini file I wish to use anywhere within Alembic?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":5384,"Q_Id":12756976,"Users Score":26,"Answer":"Just specify alembic -c \/some\/path\/to\/another.ini when running alembic commands. You could even put the [alembic] section in your development.ini and production.ini files and just alembic -c production.ini upgrade head.","Q_Score":13,"Tags":"python,pyramid,alembic","A_Id":12757266,"CreationDate":"2012-10-06T05:18:00.000","Title":"Use different .ini file for alembic.ini","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"Sorry if my title is not correct. Below is the explanation of what i'm looking for.\nI've coded a small GUI game (let say a snake game) in python, and I want it to be run on Linux machine. I can run this program by just run command \"python snake.py\" in the terminal.\nHowever, I want to combine all my .py files into one file, and when I click on this file, it just run my game. I don't want to go to shell and type \"python snake.py\". I means something like manifest .jar in java.\nCould any one help me please? If my explanation is not good enough, please let me know. I'll give some more explanation.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":172,"Q_Id":12763015,"Users Score":1,"Answer":"If you only want it to run on a Linux machine, using Python eggs is the simplest way.\npython snake.egg will try to execute the main.py inside the egg.\nPython eggs are meant to be packages, and basically is a zip file with metadata files included.","Q_Score":1,"Tags":"linux,jar,python-2.7","A_Id":12763086,"CreationDate":"2012-10-06T19:16:00.000","Title":"How to make an executable for a python 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":1,"Web Development":0},{"Question":"I'm using an event loop based server in twisted python that stores files, and I'd like to be able to classify the files according to their compressibility.\nIf the probability that they'd benefit from compression is high, they would go to a directory with btrfs compression switched on, otherwise they'd go elsewhere.\nI do not need to be sure - 80% accuracy would be plenty, and would save a lot of diskspace. But since there is the CPU and fs performance issue too, I can not just save everything compressed.\nThe files are in the low megabytes. I can not test-compress them without using a huge chunk of CPU and unduly delaying the event loop or refactoring a compression algorithm to fit into the event loop.\nIs there any best practice to give a quick estimate for compressibility? What I came up with is taking a small chunk (few kB) of data from the beginning of the file, test-compress it (with a presumably tolerable delay) and base my decision on that.\nAny suggestions? Hints? Flaws in my reasoning and\/or problem?","AnswerCount":3,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":3128,"Q_Id":12769933,"Users Score":12,"Answer":"Just 10K from the middle of the file will do the trick. You don't want the beginning or the end, since they may contain header or trailer information that is not representative of the rest of the file.  10K is enough to get some amount of compression with any typical algorithm.  That will predict a relative amount of compression for the whole file, to the extent that that middle 10K is representative.  The absolute ratio you get will not be the same as for the whole file, but the amount that it differs from no compression will allow you to set a threshold.  Just experiment with many files to see where to set the threshold.\nAs noted, you can save time by doing nothing for files that are obviously already compressed, e.g. .png. .jpg., .mov, .pdf, .zip, etc.\nMeasuring entropy is not necessarily a good indicator, since it only gives the zeroth-order estimate of compressibility.  If the entropy indicates that it is compressible enough, then it is right.  If the entropy indicates that it is not compressible enough, then it may or may not be right.  Your actual compressor is a much better estimator of compressibility.  Running it on 10K won't take long.","Q_Score":9,"Tags":"python,compression,twisted","A_Id":12770967,"CreationDate":"2012-10-07T15:04:00.000","Title":"How can I estimate the compressibility of a file without compressing 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":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm using an event loop based server in twisted python that stores files, and I'd like to be able to classify the files according to their compressibility.\nIf the probability that they'd benefit from compression is high, they would go to a directory with btrfs compression switched on, otherwise they'd go elsewhere.\nI do not need to be sure - 80% accuracy would be plenty, and would save a lot of diskspace. But since there is the CPU and fs performance issue too, I can not just save everything compressed.\nThe files are in the low megabytes. I can not test-compress them without using a huge chunk of CPU and unduly delaying the event loop or refactoring a compression algorithm to fit into the event loop.\nIs there any best practice to give a quick estimate for compressibility? What I came up with is taking a small chunk (few kB) of data from the beginning of the file, test-compress it (with a presumably tolerable delay) and base my decision on that.\nAny suggestions? Hints? Flaws in my reasoning and\/or problem?","AnswerCount":3,"Available Count":2,"Score":0.3215127375,"is_accepted":false,"ViewCount":3128,"Q_Id":12769933,"Users Score":5,"Answer":"Compressed files usually don't compress well.  This means that just about any media file is not going to compress very well, since most media formats already include compression.  Clearly there are exceptions to this, such as BMP and TIFF images, but you can probably build a whitelist of well-compressed filetypes (PNGs, MPEGs, and venturing away from visual media - gzip, bzip2, etc) to skip and then assume the rest of the files you encounter will compress well.\nIf you feel like getting fancy, you could build feedback into the system (observe the results of any compression you do and associate the resulting ratio with the filetype).  If you come across a filetype that has consistently poor compression, you could add it to the whitelist.\nThese ideas depend on being able to identify a file's type, but there are standard utilities which do a pretty good job of this (generally much better than 80%) - file(1), \/etc\/mime.types, etc.","Q_Score":9,"Tags":"python,compression,twisted","A_Id":12770116,"CreationDate":"2012-10-07T15:04:00.000","Title":"How can I estimate the compressibility of a file without compressing 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":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I need to work with m2crypto library. How can I import it to my .py file? I use Eclipse.","AnswerCount":1,"Available Count":1,"Score":0.6640367703,"is_accepted":false,"ViewCount":17398,"Q_Id":12785963,"Users Score":4,"Answer":"usually just doing import m2crypto is sufficient\nyou may need to easy_install m2crypto first or maybe even pip install m2crypto\nIf you are on windows you may need the Visual Studio DLL to compile it","Q_Score":2,"Tags":"python,m2crypto","A_Id":12786065,"CreationDate":"2012-10-08T16:48:00.000","Title":"How to import m2crypto library into 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},{"Question":"I have a command-line python script that uses a configuration file.  I'm planning to put this on pypi soon.\nWhat is the best general approach for including a default version of the configuration file in the package, so that it is obvious to the end-user where to find it?\nOne example of a pypi project which includes user-editable config files is Django.  In Django, the user has to run a script to initialize a new project.  This generates a directory with a bunch of stuff, including the project configuration file.  However, this seems like a heavy approach for a simple command line utility like mine.\nAnother option is requiring the user to specify the location of the config file as a command line arg.  I guess this is okay, but it puts the onus on the user to go to the documentation and create the entire config file from scratch.\nIs there any better option?  Is there any standard practice for this?\nThanks!\n-Travis","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":426,"Q_Id":12791275,"Users Score":2,"Answer":"You could include the defaults as part of your script and then allow the user to change the defaults with either command line arguments or a config file in the user's home directory.\nI don't think the Django approach would work unless you have the concept of a project.\nIf this is on Unix I would either put the config file in \/etc if the script will be run by more than one user or in the user's home folder as a dotfile. This way the user does not have to specify the config file each time, though you could also have a command line argument that lets the user specify a different config file to use.","Q_Score":3,"Tags":"python,pypi","A_Id":12792669,"CreationDate":"2012-10-09T00:27:00.000","Title":"Best way to include a user-editable config file in a pypi 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},{"Question":"I have a command-line python script that uses a configuration file.  I'm planning to put this on pypi soon.\nWhat is the best general approach for including a default version of the configuration file in the package, so that it is obvious to the end-user where to find it?\nOne example of a pypi project which includes user-editable config files is Django.  In Django, the user has to run a script to initialize a new project.  This generates a directory with a bunch of stuff, including the project configuration file.  However, this seems like a heavy approach for a simple command line utility like mine.\nAnother option is requiring the user to specify the location of the config file as a command line arg.  I guess this is okay, but it puts the onus on the user to go to the documentation and create the entire config file from scratch.\nIs there any better option?  Is there any standard practice for this?\nThanks!\n-Travis","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":426,"Q_Id":12791275,"Users Score":0,"Answer":"I like Nathan's answer.  But in this specific case I wound up adding a command-line option to the script that would dump an example config file to standard out.","Q_Score":3,"Tags":"python,pypi","A_Id":14864557,"CreationDate":"2012-10-09T00:27:00.000","Title":"Best way to include a user-editable config file in a pypi 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},{"Question":"I am using Python Nose and would like to print the type of the test ran, like whether it is a Doctest or unittest or so? How can this be done?\nThanks.","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":502,"Q_Id":12794631,"Users Score":1,"Answer":"Using --with-doctests implies that you're running doctests. Anything outside of a doctest can be considered a unit test. AFAIK, they're not mutually exclusive, so you can't strictly tell which you're running if you've enabled --with-doctests.\nHaving said that, doctests generally are a form of unit test, so I'm not quite sure what end you're trying to achieve with this.","Q_Score":0,"Tags":"python,nose,nosetests","A_Id":12794692,"CreationDate":"2012-10-09T07:09:00.000","Title":"Print the test type in Python Nose","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am running flask\/memcached and am looking for a lean\/efficient method to prevent automated scripts from slamming me with requests and\/or submitting new posts too quickly.\nI had the thought of including a 'last_action' time in the session cookie and checking against it each request but no matter what time I set, the script could be set up to delay that long.\nI also thought to grab the IP and if too many requests from it are made in x amount of time, deny anymore for so long, but this would require something like redis to run efficiently, which I'd like to avoid having to pay for.\nI prefer a cookie-based solution unless something like redis can prove it's worth.\nWhat are the 'industry standards' for dealing with these kinds of situations? What methods come with the least amount of cost\/performance trade-offs?","AnswerCount":3,"Available Count":3,"Score":0.1325487884,"is_accepted":false,"ViewCount":1007,"Q_Id":12805732,"Users Score":2,"Answer":"You should sit down and decide what exactly your \"core\" problems in the scenario of your app are, and who your likely users will be.  That will help you guide the right solution.\nIn my experience, there are a lot of different problems and solutions in this subject - and none are a \"one size fits all\"\n\nIf you have a problem with Anonymous users , you can try to migrate as much of the functionality behind an 'account wall' as possible.  \nIf you can't use an account wall, then you'll be better off with some IP\nbased tracking, along with some other headers\/javascript stuff.  Going by IP alone can be a disaster because of corporate proxies , home routers, etc.  You'll run the risk of too many false positives.  If you add in browser info, unsavory users can still fake it - but you'll penalize fewer real users.\nYou might want an account wall to only serve as a way to enforce a cookie , or it might plug into the idea of having a site identity where experience earns privilege\nYou might want an account that can map to another trusted site's account.  For example, I generally trust a 3rd party account binding against Facebook - who are pretty decent at dealing with fake accounts.  I don't trust a 3rd party account binding against Twitter - which is largely spam.\nYou might only require site \"registration\" to need solving a captcha , or something else mildly inconvenient to weed out most unsavory visits. If the reward for bad behavior is high enough though, you won't solve anything.\n\nI could talk about this all day.  From my perspective, you have to solve the business logic and ux concepts first - and then a tech solution is much easier.","Q_Score":4,"Tags":"python,security,flask,spam-prevention","A_Id":12806423,"CreationDate":"2012-10-09T17:59:00.000","Title":"Leanest way to prevent scripted abuse of a web 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":0,"Web Development":1},{"Question":"I am running flask\/memcached and am looking for a lean\/efficient method to prevent automated scripts from slamming me with requests and\/or submitting new posts too quickly.\nI had the thought of including a 'last_action' time in the session cookie and checking against it each request but no matter what time I set, the script could be set up to delay that long.\nI also thought to grab the IP and if too many requests from it are made in x amount of time, deny anymore for so long, but this would require something like redis to run efficiently, which I'd like to avoid having to pay for.\nI prefer a cookie-based solution unless something like redis can prove it's worth.\nWhat are the 'industry standards' for dealing with these kinds of situations? What methods come with the least amount of cost\/performance trade-offs?","AnswerCount":3,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":1007,"Q_Id":12805732,"Users Score":0,"Answer":"An extremely simple method that I have used before is to have an additional input in the registration form that is hidden using CSS (i.e. has display:none). Most form bots will fill this field in whereas humans will not (because it is not visible). In your server-side code you can then just reject any POST with the input populated.","Q_Score":4,"Tags":"python,security,flask,spam-prevention","A_Id":14003551,"CreationDate":"2012-10-09T17:59:00.000","Title":"Leanest way to prevent scripted abuse of a web 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":0,"Web Development":1},{"Question":"I am running flask\/memcached and am looking for a lean\/efficient method to prevent automated scripts from slamming me with requests and\/or submitting new posts too quickly.\nI had the thought of including a 'last_action' time in the session cookie and checking against it each request but no matter what time I set, the script could be set up to delay that long.\nI also thought to grab the IP and if too many requests from it are made in x amount of time, deny anymore for so long, but this would require something like redis to run efficiently, which I'd like to avoid having to pay for.\nI prefer a cookie-based solution unless something like redis can prove it's worth.\nWhat are the 'industry standards' for dealing with these kinds of situations? What methods come with the least amount of cost\/performance trade-offs?","AnswerCount":3,"Available Count":3,"Score":0.2605204458,"is_accepted":false,"ViewCount":1007,"Q_Id":12805732,"Users Score":4,"Answer":"There is no way to achieve this with cookies, since a malicious script can just silently drop your cookie. Since you have to support the case where a user first visits (meaning without any cookies set), there is no way to distinguish between a genuine new user and a malicious script by only considering state stored on the client.\nYou will need to keep track of your users on the server-side to achieve your goals. This can be as simple as an IP-based filter that prevents fast posting by the same IP.","Q_Score":4,"Tags":"python,security,flask,spam-prevention","A_Id":12806126,"CreationDate":"2012-10-09T17:59:00.000","Title":"Leanest way to prevent scripted abuse of a web 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":0,"Web Development":1},{"Question":"I getting the below issue when firing up django or ipython notebook\n\/opt\/bitnami\/python\/bin\/.python2.7.bin: error while loading shared libraries: libreadline.so.5\nHowever libreadline.so.5 exists in my system after locating it as shown below\nroot@linux:\/opt\/bitnami\/scripts# locate libreadline.so.5\n\/opt\/bitnami\/common\/lib\/libreadline.so.5\n\/opt\/bitnami\/common\/lib\/libreadline.so.5.2\nI have also exported the path in the environment variable (where the libreadlive.so.5 is located) but still does'nt seems to be resolving my issue (see below)\nexport LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:$HOME\/opt\/bitnami\/common\/lib\nAlso there is a script which is being provided by bitnami which is located in \/opt\/bitnami\/scripts\/setenv.sh. But even after executing it still i am stuck.\nAnyone can help me with this","AnswerCount":1,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":1566,"Q_Id":12814973,"Users Score":7,"Answer":"Can you execute the following and see if it solves your issue?\n. \/opt\/bitnami\/scripts\/setenv.sh \n(notice the space between the dot and the path to the script)\nAlso what are you executing that gives you that error?","Q_Score":4,"Tags":"python,django,centos,bitnami","A_Id":12898508,"CreationDate":"2012-10-10T08:20:00.000","Title":"Bitnami - \/opt\/bitnami\/python\/bin\/.python2.7.bin: error while loading shared libraries: libreadline.so.5","Data Science and Machine Learning":0,"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},{"Question":"Is there a way to run only doctests using Python Nose (nosetests)? . I do not want to run any unittests but only and only the doctests.\nThanks.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":604,"Q_Id":12819489,"Users Score":2,"Answer":"You can achieve that effect ignoring all regular test files.\nThis can be done easily using the -I or --ignore-files options and a regex like .*\\.py.\nAn other way could be to save the doctests in a separate directory and launch nose on that.\n\nIn newer versions of nose this doesn't seem to work anymore.","Q_Score":4,"Tags":"python,nose,nosetests","A_Id":12820015,"CreationDate":"2012-10-10T12:35:00.000","Title":"run only doctests from python nose","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I am trying to extract an address automatically from a postscript document that has been intercepted by redmon and piped to a python program.  I have gotten to the point where I can capture the postscript output (and write it to a file), but I am stuck at the extraction part.  \nIs there a good\/reliable way of doing this in python, or do I need to run the postscript file through ps2ascii and hope for the best?\nIf there are tools in other languages that could do this I would be happy to evaluate them.","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":2171,"Q_Id":12837793,"Users Score":2,"Answer":"Actually, in most cases just parsing the Postscript will suffice, since a Postscript document is a normal text file.\nAs a clarification: yes, I am aware that what a Postscript document displays is a result of a program written in the beautifully reversed or reversely beautiful language called Postscript. In most of the cases, however, it is sufficient to grep the program source. In some other cases text may be encoded as a curve or bitmap and there will be no way of extracting it short of OCR'ing the rendered output.\nBottom line: it depends of the type of information you would like to extract, and on the type of the postscript file. In my view, ps2ascii is a fine tool, and one way of solving the problem, but one that (i) will not guarantee a success (maybe slightly more than greping the source) (ii) to a large extent just strips operators and (iii) might, in some cases, lead to a loss of text.","Q_Score":0,"Tags":"python,postscript","A_Id":12837843,"CreationDate":"2012-10-11T10:44:00.000","Title":"Extracting text from postscript and\/or creating overlays 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},{"Question":"How do I create a thread that continuously checks for obstacles using the ultrasonic class in nxt-python 2.2.2? I want to implement it in a way that while my robot is moving it also detects obstacles in a background process and once it detects an object it will brake and do something else","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":235,"Q_Id":12851374,"Users Score":2,"Answer":"You used the daemon thread instead of normal thread. because this is different to normal thread. I hope so daemon thread resolve your problem.","Q_Score":0,"Tags":"python,multithreading,nxt-python","A_Id":12852400,"CreationDate":"2012-10-12T02:26:00.000","Title":"Ultrasonic thread that runs in the background 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":1},{"Question":"I'm trying to use auto-doc tool to generate API doc for Tastypie REST API. I tried Tastytool, but it seems not showing the API's result parameters but the model's columns. Then I tried Sphinx seems more promising since Tastypie supports Sphinx, but I can't find an example to show where & how to put comment for the API inside the code, and generate them into the document. \nAnyone can share some info or example about correctly write comment and generate Sphinx doc for Tastypie based API? thanks.","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2869,"Q_Id":12851898,"Users Score":0,"Answer":"Perhaps I'm completely missing the point of your question but if you are just trying to build the docs that come with the source distribution there is a Makefile in the docs directory that performs the necessary actions.  You are required to specify a target output type such as html, json, latex, etc. I keep a local copy of the docs for django, tastypie, and slumber as I use all three in conjunction with each other and I use the option make html frequently.\nIf I am mistaken about what you are trying to accomplish perhaps we can come to some clarification.","Q_Score":14,"Tags":"django,python-sphinx,tastypie,documentation-generation","A_Id":12867026,"CreationDate":"2012-10-12T03:43:00.000","Title":"Tastypie documentation generation","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I am trying to run a python file from the telnet session\nSteps:\nDailyscript.py\n\nTelnetting in to montavista\nfrom the telnet session I am trying to run another python file \"python sample.py\"\n\nsample.py\n\nImporting TestLib (in this file)\n\nBut, when I run directly form my linux box, it is running fine. \nIs there any thing I need?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":581,"Q_Id":12862260,"Users Score":0,"Answer":"Most likely the problem is that TestLib.py isn't in your working directory. Make sure your Dailyscript.py sets its directory to wherever you ran it from (over SSH) before executing python sample.py.\nAlso, if you have SSH access, why aren't you just using SSH?","Q_Score":0,"Tags":"python","A_Id":12863073,"CreationDate":"2012-10-12T15:22:00.000","Title":"Import Error: No Module found named TestLIb","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},{"Question":"I am having a design problem in test automation:-\nRequirements - Need to test different servers (using unix console and not GUI) through automation framework. Tests which I'm going to run - Unit, System, Integration\nQuestion: While designing a test case, I am thinking that a Test Case should be a part of a test suite (test suite is a class), just as we have in Python's pyunit framework. But, should we keep test cases as functions for a scalable automation framework or should be keep test cases as separate classes(each having their own setup, run and teardown methods) ? From automation perspective, Is the idea of having a test case as a class more scalable, maintainable or as a function?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":1670,"Q_Id":12871388,"Users Score":0,"Answer":"Normally Test Cases are used as classes rather than functions because each test case has own setup data and initialization mechanism. Implementing test cases as a single function will not only make difficult to set up test data before running any test case, but yes you can have different test method in a test case class if you are running same test scenario.","Q_Score":0,"Tags":"java,python,testing,frameworks,automation","A_Id":12871446,"CreationDate":"2012-10-13T08:30:00.000","Title":"How to write automated tests - Test case as a function or test case as a 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},{"Question":"I am having a design problem in test automation:-\nRequirements - Need to test different servers (using unix console and not GUI) through automation framework. Tests which I'm going to run - Unit, System, Integration\nQuestion: While designing a test case, I am thinking that a Test Case should be a part of a test suite (test suite is a class), just as we have in Python's pyunit framework. But, should we keep test cases as functions for a scalable automation framework or should be keep test cases as separate classes(each having their own setup, run and teardown methods) ? From automation perspective, Is the idea of having a test case as a class more scalable, maintainable or as a function?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":1670,"Q_Id":12871388,"Users Score":0,"Answer":"The following is my opinion:\nPros of writing tests as functions:\n\nIf you need any pre-requisites for that test case, just call another function which provides the pre-requisites. Do the same thing for teardown steps\nLooks simple for a new person in the team. Easy to undertstand what is happening by looking into tests as functions\n\nCons of writing tests as functions: \n\nNot maintainable - Because if there are huge number of tests where\nsame kind of pre-requisites are required, the test case author has to\nmaintain calling each pre-requisite function in the test case. Same\nfor each teardown inside the test case\nIf there are so many calls to such a pre-requisite function inside many test cases, and if anything changes in the product functionality etc, you have to manually make efforts in many places again.\n\nPros of writing test cases as classes:\n\nSetup, run and teardown are clearly defined. the test pre-requisites are easily understood\nIf there is Test 1 which is does something and the result of Test 1 is used as a setup pre-requisite in Test 2 and 3, its easy to just inherit from Test 1, and call its setup, run a teardown methods first, and then, continue your tests. This helps make the tests independent of each other. Here, you dont need to make efforts to maintain the actual calling of your code. It will be done implicitly because of inheritance. \nSometimes, if the setup method of Test 1 and run method of Test 2 might become the pre-requisites of another Test 3. In that case, just inherit from both of Test 1 and Test 2 classes and in the Test 3's setup method, call the setup of Test 1 and run of Test 2. Again you dont need to need to maintain the calling of the actual code, because you are calling the setup and run methods, which are tried and tested from the framework perspective.\n\nCons of writing test case as classes:\n\nWhen the number of tests increase, you cant look into a particular test and say what it does, because it may have inherited so much levels that you cant back track. But, there is a solution around it - Write doc strings in each setup, run, teardown method of each test case. And, write a custom wrapper to generate doc strings for each test case. While\/After inheriting, you should provide an option to add\/Remove the docstring of a particular function (setup, run, teardown) to the inherited function. This way, you can just run that wrapper and get information about a test case from its doc-strings","Q_Score":0,"Tags":"java,python,testing,frameworks,automation","A_Id":12871619,"CreationDate":"2012-10-13T08:30:00.000","Title":"How to write automated tests - Test case as a function or test case as a 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},{"Question":"I've been testing out Mod_python and it seems that there are two ways of producing python code using:-\n\nPublisher Handler\nPSP Handler\n\nI've gotten both to work at the same time however, should I use one over the other? PSP resembles PHP a lot but Publisher seems to resemble python more. Is there an advantage over using one (speed, ease of use, etc.)?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":274,"Q_Id":12876159,"Users Score":3,"Answer":"I am not familiar with the mod_python (project was abandoned long ago) but nowadays Python applications are using wsgi (mod_wsgi or uwsgi). If you are using apache, mod_wsgi is easy to configure, for nginx use the uwsgi.","Q_Score":0,"Tags":"python,mod-python","A_Id":12876548,"CreationDate":"2012-10-13T19:19:00.000","Title":"Mod_Python: Publisher Handler vs PSP Handler","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"Python3 has a pass command that does nothing. This command is used in if-constructs because python requires the programmer to have at least one command for else. Does Ruby have an equivalent to python3's pass command?","AnswerCount":4,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":1225,"Q_Id":12878175,"Users Score":0,"Answer":"I don't think you need it in ruby ... an if doesn't require an else.","Q_Score":4,"Tags":"python,ruby,unix,scripting,python-3.x","A_Id":12878180,"CreationDate":"2012-10-14T00:09:00.000","Title":"Python3 Pass Command Equivalent in 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},{"Question":"Python3 has a pass command that does nothing. This command is used in if-constructs because python requires the programmer to have at least one command for else. Does Ruby have an equivalent to python3's pass command?","AnswerCount":4,"Available Count":2,"Score":1.0,"is_accepted":false,"ViewCount":1225,"Q_Id":12878175,"Users Score":6,"Answer":"Your statement is essentially wrong, since else statement is not obligatory in Python.\nOne of the frequent uses of the pass statement is in try\/ except construct, when exception may be ignored.\npass is also useful when you define API - and wish to postpone actual implementation of classes\/functions.\nEDIT:\nOne more frequent usage I haven't ,mentioned - defining user exception; usually you just override name to distinguish them from standard exceptions.","Q_Score":4,"Tags":"python,ruby,unix,scripting,python-3.x","A_Id":12878394,"CreationDate":"2012-10-14T00:09:00.000","Title":"Python3 Pass Command Equivalent in 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},{"Question":"Is there a way to check the size of the incoming POST in Pyramid, without saving the file to disk and using the os module?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":134,"Q_Id":12878819,"Users Score":2,"Answer":"You should be able to check the request.content_length. WSGI does not support streaming the request body so content length must be specified. If you ever access request.body, request.params or request.POST it will read the content and save it to disk.\nThe best way to handle this, however, is as close to the client as possible. Meaning if you are running behind a proxy of any sort, have that proxy reject requests that are too large. Once it gets to Python, something else may have already stored the request to disk.","Q_Score":1,"Tags":"python,pyramid","A_Id":12879591,"CreationDate":"2012-10-14T02:30:00.000","Title":"Check size of HTTP POST without saving to disk","Data Science and Machine Learning":0,"Database and SQL":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},{"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},{"Question":"Is there a built-in way in Eclipse to redirect PyUnit's output to a file (~ save the report)?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":823,"Q_Id":12897908,"Users Score":2,"Answer":"Output can be easily redirected to a file in Run Configurations > Common tab > Standard Input and Output section. Hiding just in plain sight...","Q_Score":2,"Tags":"eclipse,pydev,python-unittest","A_Id":12945643,"CreationDate":"2012-10-15T14:35:00.000","Title":"Redirecting PyUnit output to file 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":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I'm using celery and django-celery. I have defined a periodic task that I'd like to test. Is it possible to run the periodic task from the shell manually so that I view the console output?","AnswerCount":3,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":60194,"Q_Id":12900023,"Users Score":8,"Answer":"I think you'll need to open two shells: one for executing tasks from the Python\/Django shell, and one for running celery worker (python manage.py celery worker). And as the previous answer said, you can run tasks using apply() or apply_async()\nI've edited the answer so you're not using a deprecated command.","Q_Score":89,"Tags":"python,django,celery,django-celery,celery-task","A_Id":12900160,"CreationDate":"2012-10-15T16:34:00.000","Title":"How can I run a celery periodic task from the shell manually?","Data Science and Machine Learning":0,"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},{"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},{"Question":"I can find a load of information on the reverse, not so much this way around :)\nSo, the summary is that I want to write some Python code-completion stuff in C++, but I can't figure out the best way of tokenizing the Python code.\nAre there any libraries out there that will do this? \nI'm leaning towards calling Python's tokenize.tokenize directly from C++... but whenever I look at calling Python code from C++ I go cross-eyed.","AnswerCount":1,"Available Count":1,"Score":0.537049567,"is_accepted":false,"ViewCount":210,"Q_Id":12913250,"Users Score":3,"Answer":"Using regular parser-generators to generate parsers from the grammar is usually complicated with Python (for example due to its significant whitespace and difficult line-continuation rules).\nI am not sure about your experience with Python, but my recommendation would be to parse the Python file from Python, and do as much of the processing as possible in Python, then return the result to the C++ code using well-defined data types (such as the stdc++ ones) and using Boost.python for the bindings.","Q_Score":0,"Tags":"c++,python,parsing","A_Id":12913328,"CreationDate":"2012-10-16T11:01:00.000","Title":"Parsing Python code from 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":0,"Web Development":0},{"Question":"How to to send out a pwm signal from the serial port with linux? (With python or c++)\nI want to connect a motor directly to change the speed rotation.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":1468,"Q_Id":12919644,"Users Score":1,"Answer":"doubt you can do this you are using a uart interface...just get an arduino or someat and send serial commands to the arduino (serial pins) which then puts the correct pwm signal out its pins ... probably 5 lines of arduino code and another 5 of python code ...\nall that said you may be able to find some very difficult and hacky way to output a PWM signal over serial ... but you need to think about if thats really appropriate ...","Q_Score":4,"Tags":"c++,python,embedded","A_Id":12919968,"CreationDate":"2012-10-16T16:50:00.000","Title":"PWM signal out of serial port with 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},{"Question":"The project I'm working on requires me to store javascript numbers(which are doubles) as BLOB primary keys in a database table(can't use the database native float data type). So basically I need to serialize numbers to a byte array in such a way that:\n1 - The length of the byte array is 8(which is what is normally needed to serialize doubles)\n2 - the byte arrays must preserve natural order so the database will transparently sort rows in the index b-tree.\nA simple function that takes a number and returns an array of numbers representing the bytes is what I'm seeking. I prefer the function to be written in javascript but answers in java, C, C#, C++ or python will also be accepted.","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":797,"Q_Id":12932663,"Users Score":0,"Answer":"The obvious answer is to remove the restriction that you can't use the native database type. I can't see any point in it. It's still 8 bytes and it does the ordering for you without any further investigation, work, experiment, testing etc being necessary.","Q_Score":3,"Tags":"javascript,python,c,serialization,natural-sort","A_Id":12933456,"CreationDate":"2012-10-17T10:49:00.000","Title":"How to efficiently serialize 64-bit floats so that the byte arrays preserve natural numeric order?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I am trying to download only files modified in the last 30 minutes from a URL. Can you please guide me how to proceed with this. Please let me know if I should use shell scripting or python scripting for this.","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":170,"Q_Id":12940223,"Users Score":2,"Answer":"If the server supports if-modified-since, you could send the request with If-Modified-Since: (T-30 minutes) and ignore the 304 responses.","Q_Score":0,"Tags":"python,bash,shell","A_Id":12940327,"CreationDate":"2012-10-17T17:45:00.000","Title":"Download files modified in last 30 minutes from a URL","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},{"Question":"Basically I want a Java, Python, or C++ script running on a server, listening for player instances to: join, call, bet, fold, draw cards, etc and also have a timeout for when players leave or get disconnected. \nBasically I want each of these actions to be a small request, so that players could either be processes on same machine talking to a game server, or machines across network. \nSecurity of messaging is not an issue, this is for learning\/research\/fun. \nMy priorities:\n\nHave a good scheme for detecting when players disconnect, but also be able to account for network latencies, etc before booting\/causing to lose hand.\nSpeed. I'm going to be playing millions of these hands as fast as I can.\nRun on a shared server instance (I may have limited access to ports or things that need root)\n\nMy questions:\n\nListen on ports or use sockets or HTTP port 80 apache listening script? (I'm a bit hazy on the differences between these).\nAny good frameworks to work off of?\nMessage types? I'm thinking JSON or Protocol Buffers.\nHow to make it FAST?\n\nThanks guys - just looking for some pointers and suggestions. I think it is a cool problem with a lot of neat things to learn doing it.","AnswerCount":3,"Available Count":2,"Score":0.1325487884,"is_accepted":false,"ViewCount":2321,"Q_Id":12945278,"Users Score":2,"Answer":"Anything else? Maybe a cup of coffee to go with your question :-)\nAnswering your question from the ground up would require several books worth of text with topics ranging from basic TCP\/IP networking to scalable architectures, but I'll try to give you some direction nevertheless.\nQuestions:\n\nListen on ports or use sockets or HTTP port 80 apache listening script? (I'm a bit hazy on the differences between these).\n\nI would venture that if you're not clear on the definition of each of these maybe designing an implementing a service that will be \"be playing millions of these hands as fast as I can\" is a bit hmm, over-reaching? But don't let that stop you as they say \"ignorance is bliss.\"\n\nAny good frameworks to work off of?\n\nI think your project is a good candidate for Node.js. There main reason being that Node.js is relatively scaleable and it is good at hiding the complexity required for that scalability. There are downsides to Node.js, just Google search for 'Node.js scalability critisism'.\nThe main point against Node.js as opposed to using a more general purpose framework is that scalability is difficult, there is no way around it, and Node.js being so high level and specific provides less options for solving though problems.\nThe other drawback is Node.js is Javascript not Java or Phyton as you prefer.\n\nMessage types? I'm thinking JSON or Protocol Buffers.\n\nI don't think there's going to be a lot of traffic between client and server so it doesn't really matter I'd go with JSON just because it is more prevalent.\n\nHow to make it FAST?\n\nThe real question is how to make it scalable. Running human vs human card games is not computationally intensive, so you're probably going to run out of I\/O capacity before you reach any computational limit.\nOvercoming these limitations is done by spreading the load across machines. The common way to do in multi-player games is to have a list server that provides links to identical game servers with each server having a predefined number of slots available for players.\nThis is a variation of a broker-workers architecture were the broker machine assigns a worker machine to clients based on how busy they are. In gaming users want to be able to select their server so they can play with their friends.\nRelated:\n\nHave a good scheme for detecting when players disconnect, but also be able to account for network latencies, etc before booting\/causing to lose hand.\n\nSince this is in human time scales (seconds as opposed to miliseconds) the client should send keepalives say every 10 seconds with say 30 second session timeout.\nThe keepalives would be JSON messages in your application protocol not HTTP which is lower level and handled by the framework.\nThe framework itself should provide you with HTTP 1.1 connection management\/pooling which allows several http sessions (request\/response) to go through the same connection, but do not require the client to be always connected. This is a good compromise between reliability and speed and should be good enough for turn based card games.","Q_Score":2,"Tags":"java,python,optimization,webserver,multiplayer","A_Id":12946896,"CreationDate":"2012-10-18T00:04:00.000","Title":"Multiplayer card game on server using RPC","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},{"Question":"Basically I want a Java, Python, or C++ script running on a server, listening for player instances to: join, call, bet, fold, draw cards, etc and also have a timeout for when players leave or get disconnected. \nBasically I want each of these actions to be a small request, so that players could either be processes on same machine talking to a game server, or machines across network. \nSecurity of messaging is not an issue, this is for learning\/research\/fun. \nMy priorities:\n\nHave a good scheme for detecting when players disconnect, but also be able to account for network latencies, etc before booting\/causing to lose hand.\nSpeed. I'm going to be playing millions of these hands as fast as I can.\nRun on a shared server instance (I may have limited access to ports or things that need root)\n\nMy questions:\n\nListen on ports or use sockets or HTTP port 80 apache listening script? (I'm a bit hazy on the differences between these).\nAny good frameworks to work off of?\nMessage types? I'm thinking JSON or Protocol Buffers.\nHow to make it FAST?\n\nThanks guys - just looking for some pointers and suggestions. I think it is a cool problem with a lot of neat things to learn doing it.","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":2321,"Q_Id":12945278,"Users Score":1,"Answer":"Honestly, I'd start with classic LAMP. Take a stock Apache server, and a mysql database, and put your Python scripts in the cgi-bin directory. The fact that they're sending and receiving JSON instead of HTTP doesn't make much difference.\nThis is obviously not going to be the most flexible or scalable solution, of course, but it forces you to confront the actual problems as early as possible.\nThe first problem you're going to run into is game state. You claim there is no shared state, but that's not right\u2014the cards in the deck, the bets on the table, whose turn it is\u2014that's all state, shared between multiple players, managed on the server. How else could any of those commands work? So, you need some way to share state between separate instances of the CGI script. The classic solution is to store the state in the database.\nOf course you also need to deal with user sessions in the first place. The details depend on which session-management scheme you pick, but the big problem is how to propagate a disconnect\/timeout from the lower level up to the application level. What happens if someone puts $20 on the table and then disconnects? You have to think through all of the possible use cases.\nNext, you need to think about scalability. You want millions of games? Well, if there's a single database with all the game state, you can have as many web servers in front of it as you want\u2014John Doe may be on server1 while Joe Schmoe is on server2, but they can be in the same game. On the other hand, you can a separate database for each server, as long as you have some way to force people in the same game to meet on the same server. Which one makes more sense? Either way, how do you load-balance between the servers. (You not only want to keep them all busy, you want to avoid the situation where 4 players are all ready to go, but they're on 3 different servers, so they can't play each other\u2026).\nThe end result of this process is going to be a huge mess of a server that runs at 1% of the capacity you hoped for, that you have no idea how to maintain. But you'll have thought through your problem space in more detail, and you'll also have learned the basics of server development, both of which are probably more important in the long run.\nIf you've got the time, I'd next throw the whole thing out and rewrite everything from scratch by designing a custom TCP protocol, implementing a server for it in something like Twisted, keeping game state in memory, and writing a simple custom broker instead of a standard load balancer.","Q_Score":2,"Tags":"java,python,optimization,webserver,multiplayer","A_Id":12963229,"CreationDate":"2012-10-18T00:04:00.000","Title":"Multiplayer card game on server using RPC","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},{"Question":"To begin with, I am only allowed to use python 2.4.4\nI need to write a process controller in python which launches and various subprocesses monitors how they affect the environment.  Each of these subprocesses are themselves python scripts. \nWhen executed from the unix shell, the command lines look something like this:\npython myscript arg1 arg2 arg3 >output.log 2>err.log &\nI am not interested in the input or the output, python does not need to process. The python program only needs to know \n1) The pid of each process\n2) Whether each process is running. \nAnd the processes run continuously.  \nI have tried reading in the output and just sending it out a file again but then I run into issues with readline not being asynchronous, for which there are several answers many of them very complex. \nHow can I a formulate a python subprocess call that preserves the bash redirection operations?\nThanks","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":1449,"Q_Id":12960276,"Users Score":0,"Answer":"You can use existing file descriptors as the stdout\/stderr arguments to subprocess.Popen. This should be exquivalent to running from with redirection from bash. That redirection is implemented with fdup(2) after fork and the output should never touch your program. You can probably also pass fopen('\/dev\/null') as a file descriptor.\nAlternatively you can redirect the stdout\/stderr of your controller program and pass None as stdout\/stderr. Children should print to your controllers stdout\/stderr without passing through python itself. This works because the children will inherit the stdin\/stdout descriptors of the controller, which were redirected by bash at launch time.","Q_Score":0,"Tags":"python,redirect,subprocess","A_Id":12960474,"CreationDate":"2012-10-18T17:23:00.000","Title":"Preserving bash redirection in a python subprocess","Data Science and Machine Learning":0,"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},{"Question":"To begin with, I am only allowed to use python 2.4.4\nI need to write a process controller in python which launches and various subprocesses monitors how they affect the environment.  Each of these subprocesses are themselves python scripts. \nWhen executed from the unix shell, the command lines look something like this:\npython myscript arg1 arg2 arg3 >output.log 2>err.log &\nI am not interested in the input or the output, python does not need to process. The python program only needs to know \n1) The pid of each process\n2) Whether each process is running. \nAnd the processes run continuously.  \nI have tried reading in the output and just sending it out a file again but then I run into issues with readline not being asynchronous, for which there are several answers many of them very complex. \nHow can I a formulate a python subprocess call that preserves the bash redirection operations?\nThanks","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":1449,"Q_Id":12960276,"Users Score":0,"Answer":"The subprocess module is good.\nYou can also do this on *ix with os.fork() and a periodic os.wait() with a WNOHANG.","Q_Score":0,"Tags":"python,redirect,subprocess","A_Id":12961812,"CreationDate":"2012-10-18T17:23:00.000","Title":"Preserving bash redirection in a python subprocess","Data Science and Machine Learning":0,"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},{"Question":"I've been tasked with a thesis project where i have to extend the features of ArcGis. I've been asked to create a model written in Python that can run out of ArcGIS 10. This model will have a simple user interface where the user can drag\/drop a variety of shapefiles and enter the values for particular variables in order for the model to run effectively. Once the model has finished running, a new shapefile is created that lays out the most cost effective Collector Cable route for a wind turbine from point A to point B.\nI'd like to know if such a functionality\/ extension already exists in ArcGIS so i don't have to re-invent the wheel. If not then what is the best programming language to learn to extend ArcGIS for this (Python vs Visual basic vs Java). My background is Java, PHP, Jquery and Javascript. Also any pointers in the right direction i.e documentation, resources etc would be hugely appreciated","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":727,"Q_Id":12991111,"Users Score":0,"Answer":"Creating a Python AddIn is probably the quickest and easiest approach if you just want to do some geoprocessing and deploy the tool to lots of users.\nBut as soon as you need a user interface (that does more than simply select GIS data sources) you should create a .Net AddIn (using either C# or VB.net).\nI've created many AddIns over the years and they are a dramatic improvement to the old ArcGIS \"plugins\" that involved lots of complicated COM registration. AddIns are easy to build and deploy. Easy for users to install and uninstall.\n.Net has excellent, powerful features for creating rich user interfaces with the kind of drag and drop that you require. And there are great books, forums, samples to leverage.","Q_Score":0,"Tags":"java,python,visual-studio-2010,arcgis,arcobjects","A_Id":32124775,"CreationDate":"2012-10-20T17:52:00.000","Title":"Extending ArcGIS","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"eval_cli_line(\"cache_%s\" % cpu.name + \".ptime\") in my python script is constantly giving the following error \nNameError: global name 'eval_cli_line' is not defined\nAny suggestions ?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":241,"Q_Id":12995006,"Users Score":1,"Answer":"In Simics 4.x, eval_cli_line has been replaced with run_command(). Read the migration guide.","Q_Score":0,"Tags":"python,simics","A_Id":13001532,"CreationDate":"2012-10-21T04:34:00.000","Title":"Python eval_cli_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":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"My Python 2.7 script (on Raspberry Pi Debian) runs a couple of stepper motors synchronously via the GPIO port.  I currently have a signal handler in place for Ctrl-C to clean up tidily before exit.  I'd now like to extend that method such that keyboard inputs could also generate SIGUSR1 or similar as an asynchonous control mechanism.  I know this could be achieve through threading, but I'm after a KISS approach.\nTa","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":415,"Q_Id":12999970,"Users Score":0,"Answer":"Have a parent process that monitors keyboard input, and forward a signal to the child if it occurs.","Q_Score":4,"Tags":"python,keyboard,signals","A_Id":36716865,"CreationDate":"2012-10-21T16:51:00.000","Title":"Getting keyboard inputs to cause SIGUSR1\/2 akin to ctrl-C \/ SIGINT to trigger signal_handler","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"What I would like it is to run a script that automatically checks for new assets (files that aren't code) that have been submitted to a specific directory, and then every so often automatically commit those files and push them.\nI could make a script that does this through the command line, but I was mostly curious if mercurial offered any special functionality for this, specifically I'd really like some kind of return error code so that my script will know if the process breaks at any point so I can send an email with the error to specific developers. For example if for some reason the push fails because a pull is necessary first, I'd like the script to get a code so that it knows this and can handle it properly.\nI've tried researching this and can only find things like automatically doing a push after a commit, which isn't exactly what I'm looking for.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":448,"Q_Id":13018157,"Users Score":1,"Answer":"You can always check exit-code of used commands\n\nhg add (if new, unversioned files appeared in WC) \"Returns 0 if all files are successfully added\": non-zero means \"some troubles here, not all files added\"\nhg commit \"Returns 0 on success, 1 if nothing changed\": 1 means \"no commit, nothing to push\"\nhg push \"Returns 0 if push was successful, 1 if nothing to push\"","Q_Score":1,"Tags":"python,macos,mercurial,build-automation","A_Id":13667498,"CreationDate":"2012-10-22T19:13:00.000","Title":"Automating commit and push through mercurial from 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},{"Question":"I need an alternative to the shutil module in particular shutil.copyfile.\nIt is a little known bug with py2exe that makes the entire shutil module useless.","AnswerCount":3,"Available Count":1,"Score":0.1325487884,"is_accepted":false,"ViewCount":4141,"Q_Id":13042897,"Users Score":2,"Answer":"Using os.system() will be problematic for many reasons; for example, when you have spaces or Unicode in the file names.   It will also be more opaque relative to exceptions\/failures.\nIf this is on windows, using win32file.CopyFile() is probably the best approach, since that will yield the correct file attributes, dates, permissions, etc. relative to the original file (that is, it will be more similar to the results you'd get by using Explorer to copy the file).","Q_Score":4,"Tags":"python,py2exe","A_Id":16571073,"CreationDate":"2012-10-24T04:09:00.000","Title":"Alternative to shutil.copyfile","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Which of these two languages interfaces better and delivers a better performance\/toolset for working with sqlite database?  I am familiar with both languages but need to choose one for a project I'm developing and so I thought I would ask here. I don't believe this to be opinionated as performance of a language is pretty objective.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":150,"Q_Id":13059142,"Users Score":5,"Answer":"There is no good reason to choose one over the other as far as sqlite performance or usability.\nBoth languages have perfectly usable (and pythonic\/rubyriffic) sqlite3 bindings.\nIn both languages, unless you do something stupid, the performance is bounded by the sqlite3 performance, not by the bindings.\nNeither language's bindings are missing any uncommon but sometimes performance-critical functions (like an \"exec many\", manual transaction management, etc.).\nThere may be language-specific frameworks that are better or worse in how well they integrate with sqlite3, but at that point you're choosing between frameworks, not languages.","Q_Score":0,"Tags":"python,ruby,sqlite","A_Id":13059204,"CreationDate":"2012-10-24T23:00:00.000","Title":"ruby or python for use with sqlite database?","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},{"Question":"Is there a way to dynamically download and install a package like AWS API from a PHP or Python script at runtime?\nThanks.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":42,"Q_Id":13070759,"Users Score":1,"Answer":"Not at runtime - this would make no sense due to the overheads involved and the risk of the download failing.","Q_Score":0,"Tags":"php,python","A_Id":13070806,"CreationDate":"2012-10-25T14:24:00.000","Title":"Python\/PHP - Downloading and installing AWS 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},{"Question":"Is there any way with Python to directly get (only get, no modify) a single pixel (to get its RGB color) from an image (compressed format if possible) without having to load it in RAM nor processing it (to spare the CPU)?\n\nMore details:\nMy application is meant to have a huge database of images, and only of images.\nSo what I\u00a0chose is to directly store images on harddrive, this will avoid the additional workload of a DBMS.\nHowever I would like to optimize some more, and I'm wondering if there's a way to directly access a single pixel from an image (the only action on images that my application does), without having to load it in memory.\nDoes PIL pixel access allow that? Or is there another way?\nThe encoding of images is my own choice, so I\u00a0can change whenever I want. Currently I'm using PNG or JPG. I can also store in raw, but I would prefer to keep images a bit compressed if possible. But I think harddrives are cheaper than CPU and RAM, so even if images must stay RAW in order to do that, I think it's still a better bet.\nThank you.\nUPDATE\nSo, as I feared, it seems that it's impossible to do with variable compression formats such as PNG.\nI'd like to refine my question:\n\nIs there a constant compression format (not necessarily specific to an image format, I'll access it programmatically), which would allow to access any part by just reading the headers?\nTechnically, how to efficiently (read: fast and non blocking) access a byte from a file with Python?\n\nSOLUTION\nThank's to all, I have successfully implemented the functionality I described by using run-length encoding on every row, and padding every row to the same length of the maximum row.\nThis way, by prepeding a header that describes the fixed number of columns for each row, I could easily access the row using first a file.readline() to get the headers data, then file.seek(headersize + fixedsize*y, 0) where y is the row currently selected.\nFiles are compressed, and in memory I only fetch a single row, and my application doesn't even need to uncompress it because I can compute where the pixel is exactly by just iterating over every RLE values. So it is also very easy on CPU cycles.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":693,"Q_Id":13077263,"Users Score":1,"Answer":"If you want to keep a compressed file format, you can break each image up into smaller rectangles and store them separately. Using a fixed size for the rectangles will make it easier to calculate which one you need. When you need the pixel value, calculate which rectangle it's in, open that image file, and offset the coordinates to get the proper pixel.\nThis doesn't completely optimize access to a single pixel, but it can be much more efficient than opening an entire large image.","Q_Score":0,"Tags":"python,image-processing,pixel,imaging","A_Id":13078321,"CreationDate":"2012-10-25T21:04:00.000","Title":"Direct access to a single pixel 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},{"Question":"Seems like with ever increasing frequency, I am bit by pyc files running outdated code.\nThis has led to deployment scripts scrubbing *.pyc each time, otherwise deployments don't seem to take effect.\nI am wondering, what benefit (if any) is there to pyc files in a long-running WSGI application? So far as I know, the only benefit is improved startup time, but I can't imagine it's that significant--and even if it is, each time new code is deployed you can't really use the old pyc files anyways.\nThis makes me think that best practice would be to run a WSGI application with the PYTHONDONTWRITEBYTECODE environment variable set.\nAm I mistaken?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":593,"Q_Id":13081659,"Users Score":7,"Answer":"The best strategy for doing deployments is to write the deployed files into a new directory, and then use a symlink or similar to swap the codebase over in a single change. This has the side-benefit of also automatically clearing any old .pyc files.\nThat way, you get the best of both worlds - clean and atomic deployments, and the caching of .pyc if your webapp needs to restart.\nIf you keep the last N deployment directories around (naming them by date\/time is useful), you also have an easy way to \"roll back\" to a previously deployed version of the code. If you have multiple server machines, you can also deploy to all of the machines but wait to switch them over until all of them have gotten the new code.","Q_Score":2,"Tags":"python,django,wsgi,pyc","A_Id":13081746,"CreationDate":"2012-10-26T06:09:00.000","Title":"Is there any benefit to pyc files in a WSGI app where deployments happen several times per week?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"Imagine I have a script, let's say my_tools.py that I import as a module. But my_tools.py is saved twice: at C:\\Python27\\Lib \nand at the same directory from where the script is run that does the import. \nCan I change the order where python looks for my_tools.py first? That is, to check first if it exists at C:\\Python27\\Lib and if so, do the import?","AnswerCount":3,"Available Count":1,"Score":0.1325487884,"is_accepted":false,"ViewCount":2883,"Q_Id":13083026,"Users Score":2,"Answer":"if you don't want python to search builtin modules then search in current folder first,,\nyou can change sys.path\nupon program startup, the first item of this list, path[0], is the directory containing the script that was used to invoke the Python interpreter\nsys.path[0] is the empty string, which directs Python to search modules in the current directory first, you can put this at the end of the list, that way it will first search in all possible location before coming to current directory","Q_Score":5,"Tags":"python,import","A_Id":13083221,"CreationDate":"2012-10-26T07:58:00.000","Title":"Can I change the order where python looks for a module first?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm looking for an API or library that gives me access to all features of Gmail from a Django web application.\nI know I can receive and send email using IMAP or POP3. However, what I'm looking for are all the GMail features such as marking emails with star or important marker, adding or removing tags, etc.\nI know there is a Settings API that allows me to create or delete labels and filters, but I haven't found anything that actually allows me to set labels to emails, or set emails as starred, and so on.\nCan anyone give me a pointer?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1086,"Q_Id":13085946,"Users Score":0,"Answer":"I would suggest you to look at context.io, I've used it before and it works great.","Q_Score":3,"Tags":"python,django,gmail,gmail-imap","A_Id":13087381,"CreationDate":"2012-10-26T11:18:00.000","Title":"A Django library for Gmail","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I am not sure if this is the right forum to ask, but I give it a try. \nA device is sending an E-Mail to my code in which I am trying to receive the email via a socket in python, and to decode the E-Mail with  Messsage.get_payload() calls. However. I always have a \\n.\\n at the end of the message. \nIf the same device send the same message to a genuine email client (e.g. gmail), I get the correct original message without the \\n.\\n. \nI would like to know what it is with this closing set of special characters in SMTP\/E-Mail handling\/sending, and how to encode it away.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":92,"Q_Id":13108615,"Users Score":0,"Answer":"These are simply newline characters. In GMail they'll be processed and \"displayed\" so you don't see them. But they are still part of the email text message so it makes sense that get_payload() returns them.","Q_Score":0,"Tags":"python,sockets,smtp","A_Id":13108630,"CreationDate":"2012-10-28T11:56:00.000","Title":"Mysterious characters at the end of E-Mail, received with socket 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},{"Question":"There are several components involved in auth and the discovery based service api. \nHow can one test request handlers wrapped with decorators used from oauth2client (eg oauth_required, etc), httplib2, services and uploads? \nAre there any commonly available mocks or stubs?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":259,"Q_Id":13115599,"Users Score":1,"Answer":"There are the mock http and request classes that the apiclient package uses for its own testing. They are in apiclient\/http.py and you can see how to use them throughout the test suite.","Q_Score":2,"Tags":"python,google-app-engine,google-drive-api,google-api-python-client","A_Id":13125588,"CreationDate":"2012-10-29T03:42:00.000","Title":"How can one test appengine\/drive\/google api based applications?","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},{"Question":"Could I please have some ideas for a project utilising Heuristics\nThankyou in advance for your help","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":4568,"Q_Id":13133986,"Users Score":0,"Answer":"Heuristic can roughly be tranlated into 'rule of thumb'\nIt's not a programming-specific concept.","Q_Score":0,"Tags":"python,vb.net,heuristics","A_Id":13134922,"CreationDate":"2012-10-30T06:47:00.000","Title":"Programming with Heuristics?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"Is there a way to use android.py module without installing SL4A?\nI mean I have Python running on android successfully from Terminal Emulator.\nCan I use that module without installing that layer (or if I can't install it anymore)?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1256,"Q_Id":13137341,"Users Score":2,"Answer":"No, because the SL4A package provides the facade to make device API calls, acting as a middleman. Without it you might be able to import it, but you could not be able to make any API calls.","Q_Score":2,"Tags":"android,python,sl4a,android-scripting","A_Id":13215655,"CreationDate":"2012-10-30T10:46:00.000","Title":"Using Python android.py module without SL4A","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},{"Question":"Is there a way to read the excel file properties using xlrd?\nI refer not to cell presentation properties, but general workbook properties.\nThanks a lot in advance.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1896,"Q_Id":13139949,"Users Score":1,"Answer":"Apart from the username (last person to save the worksheet) the Book instance as returned by open_workbook does not seem to have any properties. \nI recursively dumped the Book ( dumping its dict if a xlrd.BaseObject) and could not find anything in that way. The test files for sure had\nan author, company and some custom metadata.\nFWIW: LibreOffice does not seem to be able to find author and company either (or does not display them), but it does show custom metadata in the properties.","Q_Score":4,"Tags":"python,xlrd","A_Id":13562703,"CreationDate":"2012-10-30T13:22:00.000","Title":"Read workbook properties using python and xlrd","Data Science and Machine Learning":0,"Database and SQL":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},{"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},{"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},{"Question":"I have a C++ project with a SWIG-generated Python front-end, which I build using CMake. I am now trying to find a convenient way to debug my mixed Python\/C++ code. I am able to get a stack-trace of errors using gdb, but I would like to have some more fancy features such as the ability to step through the code and set breakpoints, for example using Eclipse.\nUsing the Eclipse generator for CMake I am able to generate a project that I am able to import into Eclipse. This works fine and I am also able to step through the pure C++ executables. But then the problem starts. \nFirst of all, I am not able to build the Python front-end from inside Eclipse. From command line I just do \"make python\", but there is no target \"python\" in the Eclipse project.\nSecondly, once I've compiled the Python front-end, I have no clue how to step through a Python script that contains calls to my wrapped C++ classes. Eclipse has debugging both for Python and for C++, but can they be combined?","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":3277,"Q_Id":13178116,"Users Score":2,"Answer":"some more fancy features such as the ability to step through the code and set breakpoints, for example using Eclipse\n\nhow are those features \"fancy\"? You can already do those in pdb for Python, or gdb for C++.\nI'd suggest running the python code with pdb (or using pdb.set_trace() to interrupt execution at an interesting point), and attach gdb to the process in a separate terminal. Use pdb to set breakpoints in, and step through, your Python code. Use gdb to set breakpoints in, and step through, your C++ code. When pdb steps over a native call, gdb will take over. When gdb continue allows Python execution to resume, pdb will take over.\nThis should let you jump between C++ and Python breakpoints without needing to trace through the interpreter.\n\nDisclaimer: I largely think IDEs are rubbish bloatware, so if Eclipse does have a good way to integrate this, I wouldn't know about it anyway.","Q_Score":6,"Tags":"c++,python,eclipse,cmake,swig","A_Id":13178922,"CreationDate":"2012-11-01T13:29:00.000","Title":"Debugging mixed Python\/C++ 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":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a python messaging application that uses ZMQ. Each object has a PUB and a SUB queue, and they connect to each other. In some particular cases I want to wait for a particular message in the SUB queue, leaving the ones that I am not interested for later processing. \nRight now, I am getting all messages and queuing those I am not interested in a Python Queue, until I found the one I am waiting for. But his means that in each processing routing I need to check first in the Python Queue for old messages. Is there a better way?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":249,"Q_Id":13183980,"Users Score":1,"Answer":"A zmq publisher doesn't do any queueing... it drops messages when there isn't a SUB available to receive those messages. \nThe better way in your situation would be to create a generic sub who only will subscribe to certain messages of interest. That way you can spin up all of the different SUBs (even within one thread and using a zmq poller) and they will all process messages as they come from the PUB.... \nThis is what the PUB\/SUB pattern is primarily used for. Subs only subscribe to messages of interest, thus eliminating the need to cycle through a queue of messages at every loop looking for messages of interest.","Q_Score":2,"Tags":"python,filter,zeromq,pyzmq","A_Id":13200669,"CreationDate":"2012-11-01T19:16:00.000","Title":"Get a particular message from ZMQ Sub 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},{"Question":"I'm using redis for python to store and process about 4 million keys and their values. Then I found Redis writes to disk too often. It really cost time. So I change \"save 60 10000\" in redis config file to \"save 60 50000\". But it still write to disk every 10000 key changes. I've reboot Redis server.\nPS: I want to use dispy and Redis to make my application a distributed program. Is it feasible?  I use \"redis dispy distributed system\" as keyword and get nothing from Google.\nThank you very much.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":310,"Q_Id":13190253,"Users Score":0,"Answer":"I've figure it out.\nI'm using win7. Redis server doesn't load the config file each time it runs. I need to load it manually or change save frequency in redis-cli using 'save 60 50000'.","Q_Score":1,"Tags":"python,redis","A_Id":13205548,"CreationDate":"2012-11-02T06:13:00.000","Title":"Redis save time config. It operates hardisk too often","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I'm trying to automate a process that collects data on one (or more) AWS instance(s), uploads the data to S3 hourly, to be retrieved by a decoupled process for parsing and further action. As a first step, I whipped up some crontab-initiated shell script (running in Ubuntu 12.04 LTS) that calls the boto utility s3multiput.\nFor the most part, this works fine, but very occasionally (maybe once a week) the file fails to appear in the s3 bucket, and I can't see any error or exception thrown to track down why. \nI'm using the s3multiput utility included with boto 2.6.0. Python 2.7.3 is the default python on the instance.  I have an IAM Role assigned to the instance to provide AWS credentials to boto.\nI have a crontab calling a script that calls a wrapper that calls s3multiput. I included the -d 1 flag on the s3multiput call, and redirected all output on the crontab job with 2>&1 but the report for the hour that's missing data looks just like the report for the hour before and the hour after, each of which succeeded.\nSo, 99% of the time this works, but when it fails I don't know why and I'm having trouble figuring where to look.  I only find out about the failure later when the parser job tries to pull the data from the bucket and it's not there.  The data is safe and sound in the directory it should have uploaded from, so I can do it manually, but would rather not have to.\nI'm happy to post the ~30-40 lines of related code if helpful, but wondered if anybody else had run into this and it sounded familiar.\nSome grand day I'll come back to this part of the pipeline and rewrite it in python to obviate s3multiput, but we just don't have dev time for that yet.\nHow can I investigate what's going wrong here with the s3multiput upload?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":515,"Q_Id":13203745,"Users Score":1,"Answer":"First, I would try updating boto; a commit to the development branch mentions logging when a multipart upload fails. Note that doing so will require using s3put instead, as s3multiput is being folded into s3put.","Q_Score":3,"Tags":"python,crontab,boto","A_Id":13203938,"CreationDate":"2012-11-02T22:13:00.000","Title":"Silent failure of s3multiput (boto) upload to s3 from EC2 instance","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},{"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},{"Question":"Is is posible to run a python script from Cruisecontrol.Net ? Is there a CCNEt task or a nant task that can be used?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":386,"Q_Id":13228677,"Users Score":2,"Answer":"I don't think there is a built in python task, but you should be able to execute it by crafting an exec task.","Q_Score":0,"Tags":"python,cruisecontrol.net,nant","A_Id":13293387,"CreationDate":"2012-11-05T08:50:00.000","Title":"Run python script from CruiseControl.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":1,"Web Development":0},{"Question":"I have a Python program that has several slow imports.  I'd like to delay importing them until they are needed.  For instance, if a user is just trying to print a help message, it is silly to import the slow modules. What's the most Pythonic way to do this?\nI'll add a solution I was playing with as a answer. I know you all can do better, though.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":421,"Q_Id":13241827,"Users Score":5,"Answer":"Just import them where they're needed. After a module has been imported once, it is cached so that any subsequent imports will be quick. If you import the same module 20 times, only the first one will be slow.","Q_Score":1,"Tags":"python,python-import","A_Id":13241883,"CreationDate":"2012-11-05T23:05:00.000","Title":"What's the best way to do a just-in-time import of Python libraries?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am interested to build a mail service that allows you to incorporate custom logic in the your mail server.\nFor example, user A can reply to helloworld@mysite.com once and subsequent emails from user A to helloworld@mysite.com will not go through until certain actions are taken. \nI am looking for something simple and customizable, preferably open-sourced. I am fluent in most modern languages. \nWhat email servers do you guys recommend for this?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":92,"Q_Id":13243581,"Users Score":1,"Answer":"Almost every mail server has some form of extensibility where you can insert logic in the mail-flow process, it's how some spam filters were implemented before they were built directly in to the servers. Personally, I use Exchange server which has a variety of points and APIs to extend it, such as SMTP Sinks.\nHowever, this question is off-topic and shouldn't be on StackOverflow.\nI suggest you build your own server - implementing a server-side version of SMTP and IMAP can be done by a single person, or use an existing library, it shouldn't take you more than a year if you put in a couple of hours each day.","Q_Score":0,"Tags":"java,python,ruby,email,clojure","A_Id":13243729,"CreationDate":"2012-11-06T02:43:00.000","Title":"Customizable mail server - what are my options?","Data Science and Machine Learning":0,"Database and SQL":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},{"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},{"Question":"Where does boost python register from python converters for builtin types such as from PyLong_Type to double?\nI want to define a converter that can take a numpy.float128 from python and returns a long double for functions in C++. I already did it the other way round, the to_python converter. For that I tweaked builtin_converters.hpp but I didn't find how boost python does the from python conversion.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":300,"Q_Id":13267912,"Users Score":1,"Answer":"The from python conversion is in fact done in builtin_converters.cpp and not in the header part of the library. I Copied this file and deleted everything except the converter for long double, which I was then able to modify.","Q_Score":2,"Tags":"c++,python,boost-python","A_Id":13363934,"CreationDate":"2012-11-07T10:36:00.000","Title":"From python converter for builtin types","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},{"Question":"I am using eclipse for python. \n  How do I import an existing project into eclipse in the current workspace.\nThanks","AnswerCount":11,"Available Count":8,"Score":0.0181798149,"is_accepted":false,"ViewCount":46104,"Q_Id":13298630,"Users Score":1,"Answer":"First of all make sure that you have the same Python interpreter configured as the project has. You can change it under:\nWindow > Preferences > PyDev > Interpreters > Python Interpreters\nAs long the project was created using Eclipse you can use import functionality. \nGo to:\nFile > Import... > General > Existing Projects into Workspace\nChoose Select root directory: and browse to your project location. Click Finish and you are done.","Q_Score":29,"Tags":"python,eclipse","A_Id":46827826,"CreationDate":"2012-11-08T22:04:00.000","Title":"How do I import a pre-existing python project into 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},{"Question":"I am using eclipse for python. \n  How do I import an existing project into eclipse in the current workspace.\nThanks","AnswerCount":11,"Available Count":8,"Score":1.0,"is_accepted":false,"ViewCount":46104,"Q_Id":13298630,"Users Score":10,"Answer":"At time of writing none of the given answers worked.\nThis is how it's done:\n\nLocate the directory containing the Pydev project\nDelete the PyDev project files (important as Eclipse won't let you create a new project in the same location otherwise)\nIn Eclipse, File->New->Pydev Project\nName the project the same as your original project\nFor project contents, browse to location containing Pydev project\nSelect an interpreter\nFollow rest of the menu through\n\nOther answers using Eclipse project importing result in Pydev loosing track of packages, turning them all into folders only.\nThis does loose any project settings previously set, please edit this answer if it can be avoided. Hopefully Pydev devs will add project import functionality some time.","Q_Score":29,"Tags":"python,eclipse","A_Id":25244825,"CreationDate":"2012-11-08T22:04:00.000","Title":"How do I import a pre-existing python project into 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},{"Question":"I am using eclipse for python. \n  How do I import an existing project into eclipse in the current workspace.\nThanks","AnswerCount":11,"Available Count":8,"Score":0.0,"is_accepted":false,"ViewCount":46104,"Q_Id":13298630,"Users Score":0,"Answer":"I just suffered through this problem for a few hours. My issue may have been different than yours...Pydev did not show up as an import option (as opposed to C projects). My solution is to drag and drop. Just create a new project (name it the same as your old) and then drop your old project into the new project folder as displayed in eclipse...3 hours later and it's drag and drop...","Q_Score":29,"Tags":"python,eclipse","A_Id":16728953,"CreationDate":"2012-11-08T22:04:00.000","Title":"How do I import a pre-existing python project into 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},{"Question":"I am using eclipse for python. \n  How do I import an existing project into eclipse in the current workspace.\nThanks","AnswerCount":11,"Available Count":8,"Score":1.2,"is_accepted":true,"ViewCount":46104,"Q_Id":13298630,"Users Score":3,"Answer":"Following are the steps\n\nSelect pydev Perspective\nright click on the project pan and click \"import\"\nFrom the list select the existing project into workspace.\nSelect root directory by going next\nOptionally you can select to copy the project into \n\nthanks","Q_Score":29,"Tags":"python,eclipse","A_Id":13299322,"CreationDate":"2012-11-08T22:04:00.000","Title":"How do I import a pre-existing python project into 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},{"Question":"I am using eclipse for python. \n  How do I import an existing project into eclipse in the current workspace.\nThanks","AnswerCount":11,"Available Count":8,"Score":1.0,"is_accepted":false,"ViewCount":46104,"Q_Id":13298630,"Users Score":9,"Answer":"make sure pydev interpreter is added, add otherwise\nwindows->preferences->Pydev->Interpreter-Python\nthen create new pydev project,\ngive the same name\nthen don't use default location, browse to point the project location.","Q_Score":29,"Tags":"python,eclipse","A_Id":22244064,"CreationDate":"2012-11-08T22:04:00.000","Title":"How do I import a pre-existing python project into 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},{"Question":"I am using eclipse for python. \n  How do I import an existing project into eclipse in the current workspace.\nThanks","AnswerCount":11,"Available Count":8,"Score":1.0,"is_accepted":false,"ViewCount":46104,"Q_Id":13298630,"Users Score":14,"Answer":"In my case when i am trying to import my existing perforce project , it gives error no project found on windows machine. On linux i was able to import project nicely.\nFor Eclipse Kepler, i have done like below.\n\nOpen eclipse in pydev perspective.\nCreate a new pydev project in your eclipse workspace with the same name which project you want to import.\nBy now in your eclipse workspace project dir , you must be having .project and .pydevproject files.\nCopy these two files and paste it to project dir which you want to import.\nNow close and delete the pydev project you created and delete it from local disk as well.\nNow you can use import utility to import project in eclipse.","Q_Score":29,"Tags":"python,eclipse","A_Id":31423129,"CreationDate":"2012-11-08T22:04:00.000","Title":"How do I import a pre-existing python project into 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},{"Question":"I am using eclipse for python. \n  How do I import an existing project into eclipse in the current workspace.\nThanks","AnswerCount":11,"Available Count":8,"Score":1.0,"is_accepted":false,"ViewCount":46104,"Q_Id":13298630,"Users Score":15,"Answer":"New Project \nDont use default Location\nBrowse to existing project location ...\nif its an existing eclipse project with project files that have correct paths for your system you can just open the .proj file ...","Q_Score":29,"Tags":"python,eclipse","A_Id":13298723,"CreationDate":"2012-11-08T22:04:00.000","Title":"How do I import a pre-existing python project into 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},{"Question":"I am using eclipse for python. \n  How do I import an existing project into eclipse in the current workspace.\nThanks","AnswerCount":11,"Available Count":8,"Score":0.0,"is_accepted":false,"ViewCount":46104,"Q_Id":13298630,"Users Score":0,"Answer":"After following steps outlined by @Shan, if the folders under the root folder are not shown as packages, \n\nRight-click on the root folder in PyDev Package Explorer\nSelect PyDev > Set as source-folder\n\nIt will add the root folder to the PYTHONPATH and now the folders will appear as packages","Q_Score":29,"Tags":"python,eclipse","A_Id":28258101,"CreationDate":"2012-11-08T22:04:00.000","Title":"How do I import a pre-existing python project into 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},{"Question":"Our website has developed a need for real-time updates, and we are considering various comet\/long-polling solutions.  After researching, we have settled on nginx as a reverse proxy to 4 tornado instances (hosted on Amazon EC2).  We are currently using the traditional LAMP stack and have written a substantial amount of code in PHP.  We are willing to convert our PHP code to Python to better support this solution.  Here are my questions:\n\nAssuming a quad-core processor, is it ok for nginx to be running on the same server as the 4 tornado instances, or is it recommended to run two separate servers: one for nginx and one for the 4 tornado processes?\nIs there a benefit to using HAProxy in front of Nginx?  Doesn't Nginx handle load-balancing very well by itself?\nFrom my research, Nginx doesn't appear to have a great URL redirecting module.  Is it preferred to use Redis for redirects?  If so, should Redis be in front of Nginx, or behind?\nA large portion of our application code will not be involved in real-time updates.  This code contains several database queries and filesystem reads, so it clearly isn't suitable for a non-blocking app server.  From my research, I've read that the blocking issue is mitigated simply by having multiple Tornado instances, while others suggest using a separate app server (ex. Gunicorn\/Django\/Flask) for blocking calls.  What is the best way to handle blocking calls when using a non-blocking server? \nConverting our code from PHP to Python will be a lengthy process.  Is it acceptable to simultaneously run Apache\/PHP and Tornado behind Nginx, or should we just stick to on language (either tornado with gunicorn\/django\/flask or tornado by itself)?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":2544,"Q_Id":13299023,"Users Score":6,"Answer":"I'll go point by point: \n\nYes. It's ok to run tornado and nginx on one server. You can use nginx as reverse proxy for tornado also. \nHaproxy will give you benefit, if you have more than one server instances. Also it will allow you to proxy websockets directly to tornado.\nActually, nginx can be used for redirects, with no problems. I haven't heard about using redis for redirects - it's key\/value storage... may be you mean something else? \nAgain, you can write blocking part in django and non-blocking part in tornado. Also tornado has some non-blocking libs for db queries. Not sure that you need powers of django here. \nYes, it's ok to run apache behind nginx. A lot of projects use nginx in front of apache for serving static files. \n\nActually question is very basic - answer also. I can be more detailed on any of the point if you wish.","Q_Score":5,"Tags":"php,python,django,nginx,tornado","A_Id":13304821,"CreationDate":"2012-11-08T22:31:00.000","Title":"Apache\/PHP to Nginx\/Tornado\/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},{"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},{"Question":"What's the fastest way to serve static files in Python? I'm looking for something equal or close enough to Nginx's static file serving.\nI know of SimpleHTTPServer but not sure if it can handle serving multiple files efficiently and reliably.\nAlso, I don't mind it being a part of a lib\/framework of some sort as long as its lib\/framework is lightweight.","AnswerCount":4,"Available Count":2,"Score":0.049958375,"is_accepted":false,"ViewCount":3272,"Q_Id":13340080,"Users Score":1,"Answer":"I would highly recommend using a 3rd party HTTP server to serve static files.\nServers like nginx are heavily optimized for the task at hand, parallelized and written in fast languages.\nPython is tied to one processor and interpreted.","Q_Score":4,"Tags":"python","A_Id":13340136,"CreationDate":"2012-11-12T07:59:00.000","Title":"Python fast static file serving","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"What's the fastest way to serve static files in Python? I'm looking for something equal or close enough to Nginx's static file serving.\nI know of SimpleHTTPServer but not sure if it can handle serving multiple files efficiently and reliably.\nAlso, I don't mind it being a part of a lib\/framework of some sort as long as its lib\/framework is lightweight.","AnswerCount":4,"Available Count":2,"Score":0.049958375,"is_accepted":false,"ViewCount":3272,"Q_Id":13340080,"Users Score":1,"Answer":"If you look for a oneliner you can do the following:\n\n$> python -m SimpleHTTPServer\n\nThis will not fullfil all the task required but worth mentioning that this is the simplest way :-)","Q_Score":4,"Tags":"python","A_Id":13340760,"CreationDate":"2012-11-12T07:59:00.000","Title":"Python fast static file serving","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I'm using debian with usbmount. I want to check if a USB memory stick is available to write to. \nCurrently I check if a specific dir exists on the USB drive. If this is True I can then write the rest of my files - os.path.isdir('\/media\/usb0\/Test_Folder') \nI would like to create Test_Folder if it doesn't exist. However \/media\/usb0\/ exists even if no USB device is there so I can't just  os.mkdir('\/media\/usb0\/Test_Folder') As it makes the file locally.\nI need a check that there is a usb drive available on \/media\/usb0\/ to write to before creating the file. Is there a quick way of doing this?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":905,"Q_Id":13345239,"Users Score":1,"Answer":"cat \/etc\/mtab | awk '{ print $2 }'\nWill give you a list of mountpoints. You can as well read \/etc\/mtab yourself and just check if anything's mounted under \/media\/usb0 (file format: whitespace-divided, most likely single space). The second column is mount destination, the first is the source.","Q_Score":1,"Tags":"python,usb,debian","A_Id":13345336,"CreationDate":"2012-11-12T14:11:00.000","Title":"Python usbmount checking for device before writing","Data Science and Machine Learning":0,"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},{"Question":"I've written an analytical pipeline in Python that I think will be useful to other people. I'm wondering whether it is customary to publish such scripts in GitHub, whether there's a specific place to do this for Python scripts, or even if there's a more specific place for biology-related Python scripts.","AnswerCount":4,"Available Count":1,"Score":0.2449186624,"is_accepted":false,"ViewCount":521,"Q_Id":13355358,"Users Score":5,"Answer":"While there are many approaches to this, one of the customary solutions would be to indeed publish it on github and then link to it from your research institution's website.","Q_Score":4,"Tags":"python,publishing,bioinformatics,biopython","A_Id":13355383,"CreationDate":"2012-11-13T03:53:00.000","Title":"Where to deposit a Python script that performs bioinformatics analyses?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I have a python script that runs as a daemon process. I want to be able to stop and start the process via a web page. I made a PHP script that runs exec() on the python daemon. Any idea? \n\nTraceback (most recent call last):   File\n  \"\/home\/app\/public_html\/daemon\/daemon.py\", line 6, in      from\n  socketServer import ExternalSocketServer, InternalSocketServer   File\n  \"\/home\/app\/public_html\/daemon\/socketServer.py\", line 3, in \n  import json, asyncore, socket, MySQLdb, hashlib, urllib, urllib2,\n  logging, traceback, sys   File\n  \"build\/bdist.linux-x86_64\/egg\/MySQLdb\/init.py\", line 19, in\n     File \"build\/bdist.linux-x86_64\/egg\/_mysql.py\", line 7, in\n     File \"build\/bdist.linux-x86_64\/egg\/_mysql.py\", line 4, in\n  bootstrap   File \"build\/bdist.linux-i686\/egg\/pkg_resources.py\", line 882, in resource_filename   File\n  \"build\/bdist.linux-i686\/egg\/pkg_resources.py\", line 1351, in\n  get_resource_filename   File\n  \"build\/bdist.linux-i686\/egg\/pkg_resources.py\", line 1373, in\n  _extract_resource   File \"build\/bdist.linux-i686\/egg\/pkg_resources.py\", line 962, in\n  get_cache_path   File \"build\/bdist.linux-i686\/egg\/pkg_resources.py\",\n  line 928, in extraction_error pkg_resources.ExtractionError: Can't\n  extract file(s) to egg cache  The following error occurred while\n  trying to extract file(s) to the Python egg cache:    [Errno 13]\n  Permission denied: '\/\/.python-eggs'  The Python egg cache directory is\n  currently set to:    \/\/.python-eggs  Perhaps your account does not\n  have write access to this directory?  You can change the cache\n  directory by setting the PYTHON_EGG_CACHE environment variable to\n  point to an accessible directory.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":189,"Q_Id":13356024,"Users Score":0,"Answer":"Make sure whatever user php is running under has appropriate permissions. You can try opening a pipe and changing users, or just use apache's suexec.","Q_Score":0,"Tags":"php,python,caching,egg","A_Id":13356068,"CreationDate":"2012-11-13T05:33:00.000","Title":"Running Python from 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":1,"Web Development":0},{"Question":"i am facing difficulty when trying to run my tests. Here is what i did :\n\nCreate a java project with one class which has one method called hello(String name)\nExported this as a jar and kept it in the same directory where i keep my test case file.\nmy Test case looks like this.\n\nSetting *  * Value *   * Value *   * Value *   * Value *   * Value *\nLibrary    MyLibrary               \nVariable * * Value *   * Value *   * Value *   * Value *   * Value *\n\nTest Case *   * Action *  * Argument *    * Argument *    * Argument *    * Argument *\nMyTest\n          hello           World         \nKeyword * * Action *  * Argument *    * Argument *    * Argument *    * Argument *\n\n\n\nI always get the following error :\nError in file 'C:\\Users\\yahiya\\Desktop\\robot-practice\\testcase_template.tsv' in table 'Setting': Importing test library 'MyLibrary' failed: ImportError: No module named MyLibrary\nI have configured Pythopath in the system variables in my windows machine.\nPlease let me know what am i doing wrong here.\nThanks","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2367,"Q_Id":13357227,"Users Score":0,"Answer":"Try to put your Library into this folder:\n...YourPythonFolder\\Lib\\site-packages\\\nor, if this doesn't work, make in the folder \"site-packages\" folder with the name \"MyLibrary\" and put your library there. \nThis should work.","Q_Score":2,"Tags":"java,python,robotframework","A_Id":13602048,"CreationDate":"2012-11-13T07:58:00.000","Title":"Robot Framework - using User Libraries","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"How to analyse frequency of wave file in a simple way? Without extra modules.","AnswerCount":4,"Available Count":1,"Score":0.049958375,"is_accepted":false,"ViewCount":2086,"Q_Id":13377197,"Users Score":1,"Answer":"If your wave file consists of only one note, you can get the fundamental frequency (not the harmonics) simply by detecting the periodicity of the wave. Do this by looking for 0-crossings.","Q_Score":2,"Tags":"python,wave","A_Id":13378468,"CreationDate":"2012-11-14T10:38:00.000","Title":"How to analyse frequency of wave 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},{"Question":"I have the following line of code using imaplib\nM = imaplib.IMAP4('smtp.gmail.com', 587)\nI get the following error from imaplib:\nabort: unexpected response: '220 mx.google.com ESMTP o13sm12303588vde.21'\nHowever from reading elsewhere, it seems that that response is the correct response demonstrating that the connection was made to the server successfully at that port.\nWhy is imaplib giving this error?","AnswerCount":2,"Available Count":2,"Score":0.1973753202,"is_accepted":false,"ViewCount":2034,"Q_Id":13385981,"Users Score":2,"Answer":"You are connecting to the wrong port. 587 is authenticated SMTP, not IMAP; the IMAP designated port number is 143 (or 993 for IMAPS).","Q_Score":2,"Tags":"python,email,response,imaplib","A_Id":13387035,"CreationDate":"2012-11-14T19:33:00.000","Title":"python imaplib unexpected response 220","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},{"Question":"I have the following line of code using imaplib\nM = imaplib.IMAP4('smtp.gmail.com', 587)\nI get the following error from imaplib:\nabort: unexpected response: '220 mx.google.com ESMTP o13sm12303588vde.21'\nHowever from reading elsewhere, it seems that that response is the correct response demonstrating that the connection was made to the server successfully at that port.\nWhy is imaplib giving this error?","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":2034,"Q_Id":13385981,"Users Score":2,"Answer":"I realized I needed to do IMAP4_SSL() - has to be SSL for IMAP and for using IMAP I need the IMAP server for gmail which is imap.googlemail.com. I ultimately got it work without specifying a port. So, final code is:\nM = imaplib.IMAP4_SSL('imap.googlemail.com')","Q_Score":2,"Tags":"python,email,response,imaplib","A_Id":13399991,"CreationDate":"2012-11-14T19:33:00.000","Title":"python imaplib unexpected response 220","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},{"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},{"Question":"I have a Python web application in which one function that can take up to 30 seconds to complete.  \nI have been kicking off the process with a cURL request (inc. parameters) from PHP but I don't want the user staring at a blank screen the whole time the Python function is working.  \nIs there a way to have it process the data 'in the background', e.g. close the http socket and allow the user to do other things while it continues to process the data?\nThank you.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":338,"Q_Id":13403741,"Users Score":1,"Answer":"You should use an asynchronous data approach  to transfer data from a PHP script - or directly from the Python script, to an already rendered HTML page on the user side.\nCheck a javascript framework for the way that is easier for you to do that (for example, jquery). Then return an html page minus results to the user, with the javascript code to show a \"calculating\" animation, and fetch the reslts, in xml or json from the proper URL when they are done.","Q_Score":0,"Tags":"python","A_Id":13404694,"CreationDate":"2012-11-15T18:22:00.000","Title":"Python long running process","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"Is there any tool to convert the LLVM IR code to Python code?\nI know it is possible to convert it to Javascript (https:\/\/github.com\/kripken\/emscripten\/wiki), to Java (http:\/\/da.vidr.cc\/projects\/lljvm\/) and I would love to convert it to Python also.\nAdditionaly if such tool does not exist, could you provide any information, what is the best tool to base on (maybe I should extend the emscripten with other language - Javascript and Python are similar to each other in some terms ;) )","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1835,"Q_Id":13415660,"Users Score":2,"Answer":"LLVM up to 3.0 provided a C backend (see lib\/Target\/CBackend) which should be a good starting point for implementing a simple Python code generator.","Q_Score":6,"Tags":"python,compiler-construction,code-generation,llvm,converter","A_Id":13416469,"CreationDate":"2012-11-16T11:26:00.000","Title":"LLVM IR to Python Compiler","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I aim to start opencv little by little but first I need to decide which API of OpenCV is more useful. I predict that Python implementation is shorter but running time will be more dense and slow compared to the native C++ implementations. Is there any know can comment about performance and coding differences between these two perspectives?","AnswerCount":5,"Available Count":2,"Score":0.1194272985,"is_accepted":false,"ViewCount":76398,"Q_Id":13432800,"Users Score":3,"Answer":"Why choose?\nIf you know both Python and C++, use Python for research using Jupyter Notebooks and then use C++ for implementation.\nThe Python stack of Jupyter, OpenCV (cv2) and Numpy provide for fast prototyping.\nPorting the code to C++ is usually quite straight-forward.","Q_Score":92,"Tags":"c++,python,performance,opencv","A_Id":66955473,"CreationDate":"2012-11-17T17:14:00.000","Title":"Does performance differ between Python or C++ coding of OpenCV?","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},{"Question":"I aim to start opencv little by little but first I need to decide which API of OpenCV is more useful. I predict that Python implementation is shorter but running time will be more dense and slow compared to the native C++ implementations. Is there any know can comment about performance and coding differences between these two perspectives?","AnswerCount":5,"Available Count":2,"Score":1.0,"is_accepted":false,"ViewCount":76398,"Q_Id":13432800,"Users Score":6,"Answer":"You're right, Python is almost always significantly slower than C++ as it requires an interpreter, which C++ does not. However, that does require C++ to be strongly-typed, which leaves a much smaller margin for error. Some people prefer to be made to code strictly, whereas others enjoy Python's inherent leniency.\nIf you want a full discourse on Python coding styles vs. C++ coding styles, this is not the best place, try finding an article.\nEDIT:\nBecause Python is an interpreted language, while C++ is compiled down to machine code, generally speaking, you can obtain performance advantages using C++.  However, with regard to using OpenCV, the core OpenCV libraries are already compiled down to machine code, so the Python wrapper around the OpenCV library is executing compiled code.  In other words, when it comes to executing computationally expensive OpenCV algorithms from Python, you're not going to see much of a performance hit since they've already been compiled for the specific architecture you're working with.","Q_Score":92,"Tags":"c++,python,performance,opencv","A_Id":13432830,"CreationDate":"2012-11-17T17:14:00.000","Title":"Does performance differ between Python or C++ coding of OpenCV?","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},{"Question":"I am working on a repository management system for my university that will provide a gui for modifying permissions to individual folders in a subversion repository, and make it easy for professors to add directories for students and TA's, with the appropriate permissions. In order to make this work, I need to be able to retrieve the directory structure of an existing svn repository, and present it on the web. I have looked at several methods, and was wondering if anyone had other ideas, or suggestions. Some things I have looked at:\nEvery hour, run a script that runs 'svn ls -R --xml'  on all of the repositories and populates a mysql database\nPositive:\n\nFast page loads afterwards\nDoesn't take a lot of disk space\nEasy to manage permission, i.e. the website doesn't need to touch svn directly at all\n\nNegative:\n\nReally slow on some of our more complicated repositories\nNo 'live' updates\nHas to run whether there are changes or not\n\nOn page load, run 'svn ls -R --xml' and retrieve only the directory I need to render the current page\nPositive:\n\nupdates live\nno cron job to tie up the server\n\nNegative:\n\nwebsite is slow as molasses\nwebserver uses a lot more resources\n\nDirectly read svn database\nPositive:\n\nFast page loads\nlive updates\n\nNegative:\n\nDifficult?\n\nI am very curious what alternatives there are that I have not seen or thought of, because I feel like any of these would be quite awful and inelegant in one way or another. Also I don't want to reinvent the wheel if it can be avoided.\nThanks!","AnswerCount":4,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":292,"Q_Id":13444341,"Users Score":0,"Answer":"you should use direct repository access via file:\/\/ this comparable to a slow hd (if you have fast CPU and HD)\nuse the svn bindings for your respective scripting language, do not rely on xml parsing, as they are much slower\ndo not read the whole tree out, but maintain a navigational hierarchy and read directories on demand, usually if you read the whole hierarchy, you end up with hundreds\/thousands directories in the deeper levels which are usually not interesting for your application, so you can omit them and display them on demand(if user browse this deep)\nif you are doing svn access modifications use the entries in your access file to get to know your important directories beforehand","Q_Score":2,"Tags":"python,svn","A_Id":13445099,"CreationDate":"2012-11-18T20:41:00.000","Title":"Quickly retrieving svn directory trees","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I am working on a repository management system for my university that will provide a gui for modifying permissions to individual folders in a subversion repository, and make it easy for professors to add directories for students and TA's, with the appropriate permissions. In order to make this work, I need to be able to retrieve the directory structure of an existing svn repository, and present it on the web. I have looked at several methods, and was wondering if anyone had other ideas, or suggestions. Some things I have looked at:\nEvery hour, run a script that runs 'svn ls -R --xml'  on all of the repositories and populates a mysql database\nPositive:\n\nFast page loads afterwards\nDoesn't take a lot of disk space\nEasy to manage permission, i.e. the website doesn't need to touch svn directly at all\n\nNegative:\n\nReally slow on some of our more complicated repositories\nNo 'live' updates\nHas to run whether there are changes or not\n\nOn page load, run 'svn ls -R --xml' and retrieve only the directory I need to render the current page\nPositive:\n\nupdates live\nno cron job to tie up the server\n\nNegative:\n\nwebsite is slow as molasses\nwebserver uses a lot more resources\n\nDirectly read svn database\nPositive:\n\nFast page loads\nlive updates\n\nNegative:\n\nDifficult?\n\nI am very curious what alternatives there are that I have not seen or thought of, because I feel like any of these would be quite awful and inelegant in one way or another. Also I don't want to reinvent the wheel if it can be avoided.\nThanks!","AnswerCount":4,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":292,"Q_Id":13444341,"Users Score":0,"Answer":"I would refer to a database solution.\nThe problem with a repository is simultaneous access. Using the database that stores the updates the repository gives you a reliable source of information to retrieve its layout.\nI have done a fair amount of research for an internship and using a database is almost always the fastest way in which you can read the repo.\nTo put it in terms of pseudo code:\n\nread repository   \nload site\nprint layout\nperform tasks\n-- and repeat.\n\nAnother option to consider is using a database that tracks the layout of the repository independently. This way, you're sure users won't bump into eachothers updates and it keeps the repository database safe from corruption.","Q_Score":2,"Tags":"python,svn","A_Id":13444407,"CreationDate":"2012-11-18T20:41:00.000","Title":"Quickly retrieving svn directory trees","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I have opportunity to study either JAVA or PYTHON.\nBut I can't decide which to choose. I am already well versed with C++.\nCan you plz tell which one is better with our experience.","AnswerCount":5,"Available Count":5,"Score":0.0798297691,"is_accepted":false,"ViewCount":194,"Q_Id":13448232,"Users Score":2,"Answer":"If you are just learning object oriented programming language then I will suggest you to start with JAVA. Because if you don't understand the ideas behind the object oriented programming nicely, you will certainly legging behind. but if you have good experience on the ideologies (i.e. structured programming language or object oriented) then, its not a matter whether you should go with JAVA or Python. The basic concept is the main thing you need to learn.","Q_Score":0,"Tags":"java,python","A_Id":13448289,"CreationDate":"2012-11-19T05:35:00.000","Title":"Which to choose Python or 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":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have opportunity to study either JAVA or PYTHON.\nBut I can't decide which to choose. I am already well versed with C++.\nCan you plz tell which one is better with our experience.","AnswerCount":5,"Available Count":5,"Score":0.0798297691,"is_accepted":false,"ViewCount":194,"Q_Id":13448232,"Users Score":2,"Answer":"This is a really relative questions and there is no \"right\" answer. \nI personally would go with Python but I already took multiple Java classes. Python is fun and interesting but Java has been around for a while and isn't going anywhere any time soon.","Q_Score":0,"Tags":"java,python","A_Id":13448256,"CreationDate":"2012-11-19T05:35:00.000","Title":"Which to choose Python or 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":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have opportunity to study either JAVA or PYTHON.\nBut I can't decide which to choose. I am already well versed with C++.\nCan you plz tell which one is better with our experience.","AnswerCount":5,"Available Count":5,"Score":0.0399786803,"is_accepted":false,"ViewCount":194,"Q_Id":13448232,"Users Score":1,"Answer":"Start out with Python; use Python for your own hackish projects - it's great for Web Apps and rapid prototyping.\nLearn Java later on and you'll enjoy it; learn it before Python and you won't appreciate the kind of OOP Java has to offer as much.\nThis is from personal experience; again, like twodayslate mentioned, there is no \"right\" answer. I learnt both Python and Java on my own and use mainly Python for personal projects.","Q_Score":0,"Tags":"java,python","A_Id":13448303,"CreationDate":"2012-11-19T05:35:00.000","Title":"Which to choose Python or 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":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have opportunity to study either JAVA or PYTHON.\nBut I can't decide which to choose. I am already well versed with C++.\nCan you plz tell which one is better with our experience.","AnswerCount":5,"Available Count":5,"Score":0.0399786803,"is_accepted":false,"ViewCount":194,"Q_Id":13448232,"Users Score":1,"Answer":"I feel, there is not much about the language. Its just implementing the logic. You can use anything to express that. But the have to keep in mind about the drivers and libraries available for the language that you are selecting","Q_Score":0,"Tags":"java,python","A_Id":13448294,"CreationDate":"2012-11-19T05:35:00.000","Title":"Which to choose Python or 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":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have opportunity to study either JAVA or PYTHON.\nBut I can't decide which to choose. I am already well versed with C++.\nCan you plz tell which one is better with our experience.","AnswerCount":5,"Available Count":5,"Score":0.1194272985,"is_accepted":false,"ViewCount":194,"Q_Id":13448232,"Users Score":3,"Answer":"I'd say go for python.\nIts very easy to code.","Q_Score":0,"Tags":"java,python","A_Id":13448259,"CreationDate":"2012-11-19T05:35:00.000","Title":"Which to choose Python or 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":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"This is the scenario. I want to be able to backup the contents of a folder using a python script. However, I want my backups to be stored in a zipped format, possibly bz2.\nThe problem comes from the fact that I don\u2019t want to bother backing up the folder if the contents in the \u201ccurrent\u201d folder are exactly the same as what is in my most recent backup.\nMy process will be like this:\n\nInitiate backup\nCheck contents of \u201ccurrent\u201d folder against what is stored in the most recent zipped backup\nIf same \u2013 then \u201ccomplete\u201d\nIf different, then run backup, then \u201ccomplete\u201d\n\nCan anyone recomment the most reliable and simple way of completing step2? Do I have to unzip the contents of the backup and store in a temp directory to do a comparison or is there a more elegant way of doing this? Possibly to do with modified date?","AnswerCount":4,"Available Count":1,"Score":0.049958375,"is_accepted":false,"ViewCount":5546,"Q_Id":13451235,"Users Score":1,"Answer":"Rsync will automatically detect and only copy modified files, but seeing as you want to bzip the results, you still need to detect if anything has changed.\nHow about you output the directory listing (including time stamps) to a text file alongside your archive. The next time you diff the current directory structure against this stored text. You can grep differences out and pipe this file list to rsync to include those changed files.","Q_Score":7,"Tags":"python,zip,backup,unzip","A_Id":13451351,"CreationDate":"2012-11-19T09:48:00.000","Title":"How to elegantly compare zip folder contents to unzipped folder contents","Data Science and Machine Learning":0,"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},{"Question":"So I have a little script I wish to run once a week.  It will check on some variable and if its set, it continues running the script, if not, I want it to wait an hour and try again.  If it's still not set, it'll wait 2 hours, then 4, and then give up for the week.  My question is, can I do this in python?  Seems like I'd have to create and delete cron jobs in python to get this to work.","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":1865,"Q_Id":13458249,"Users Score":1,"Answer":"You can't really set standard crons directly from Python. Instead, I'd set the cron to fire every hour, and in the code determine if it needs to run again (ie last successful execution is more than 7 days ago).","Q_Score":0,"Tags":"python,cron","A_Id":13458421,"CreationDate":"2012-11-19T16:40:00.000","Title":"Creating and deleting cron jobs 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},{"Question":"I'm using pydev in eclipse.\nI was hoping that pydev would first use the python classes I develop in my source dir. but since I also install the built egg into system dir, pydev also picks up the classes from system dir.\nthe problem is that pydev uses system dir first in its python path. so after I installed a buggy version, and debug through pydev, and made the necessary changes in local sourcecode, it does not take effect, since the installed egg is not changed. or in the reverse case, as I was debugging, pydev takes me to the egg files, and I modify those egg files, so the real source code is not changed.\nso How could I let pydev rearrange pythonpath order? (just like eclipse does for java build classpath) ?\nthanks\nyang","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":464,"Q_Id":13459647,"Users Score":1,"Answer":"if you are using setuptools, you can try running sudo python setup.py develop on the egg as well as adding project dependencies between the two in Eclipse","Q_Score":3,"Tags":"python,eclipse,pydev","A_Id":14926237,"CreationDate":"2012-11-19T18:13:00.000","Title":"re-arrange pythonpath 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":1,"System Administration and DevOps":1,"Web Development":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  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},{"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},{"Question":"I'm making a search tool in Python.\nIts objective is to be able to search files by their content. (we're mostly talking about source file, text files, not images\/binary - even if searching in their METADATA would be a great improvment). For now I don't use regular expression, casual plain text.\nThis part of the algorithm works great !\nThe problem is that I realize I'm searching mostly in the same few folders, I'd like to find a way to build an index of the content of each files in a folder. And be able as fast as possible to know if the sentence I'm searching is in xxx.txt or if it can't be there.\nThe idea for now is to maintain a checksum for each file that makes me able to know if it contains a particular string.\nDo you know any algorithm close to this ?\nI don't need a 100% success rate, I prefer a little index than a big one with 100% success.\nThe idea is to provide a generic tool.\nEDIT : To be clear, I want to search a PART of the content of the file. So making a md5 hash of all its content & comparing it with the hash of what i'm searching isn't a good idea ;)","AnswerCount":4,"Available Count":1,"Score":0.049958375,"is_accepted":false,"ViewCount":3002,"Q_Id":13497607,"Users Score":1,"Answer":"The only reason anyone would want a tool that is capable of searching 'certain parts' of a file is because what they are trying to do is analyze data that has legal restrictions on which parts of it you can read. \nFor example, Apple has the capability of identifying the GPS location of your iPhone at any moment a text was sent or received. But, what they cannot legally do is associate that location data with anything that can be tied to you as an individual. \nOn a broad scale you can use obscure data like this to track and analyze patterns throughout large amounts of data. You could feasibly assign a unique 'Virtual ID' to every cell phone in the USA and log all location movement; afterward you implement a method for detecting patterns of travel. Outliers could be detected through deviations in their normal travel pattern. That 'metadeta' could then be combined with data from outside sources such as names and locations of retail locations. Think of all the situations you might be able to algorithmically detect. Like the soccer dad who for 3 years has driven the same general route between work, home, restaurants, and a little league field. Only being able to search part of a file still offers enough data to detect that Soccer Dad's phone's unique signature suddenly departed from the normal routine and entered a gun shop. The possibilities are limitless. That data could be shared with local law enforcement to increase street presence in public spaces nearby; all while maintaining anonymity of the phone's owner. \nCapabilities like the example above are not legally possible in today's environment without the method IggY is looking for.\nOn the other hand, it could just be that he is only looking for certain types of data in certain file types. If he knows where in the file he wants to search for the data he needs he can save major CPU time only reading the last half or first half of a file.","Q_Score":1,"Tags":"python,search","A_Id":35276856,"CreationDate":"2012-11-21T16:25:00.000","Title":"Create an index of the content of each file in 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},{"Question":"I am looking for some way to handle numbers that are in the tens of millions of digits and can do math at this level. I can use Java and a bit of Python. So a library for one of these would be handy, but a program that can handle these kind of numbers would also work. Does anyone have any suggestions?\nThanks","AnswerCount":5,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":207,"Q_Id":13515813,"Users Score":0,"Answer":"What kind of math operations do you need?\nJava already provides classes like java.math.BigDecimal or java.math.BigInteger you can use to do basic stuff (addition, multiplication, etc.)","Q_Score":4,"Tags":"java,python,math","A_Id":13515894,"CreationDate":"2012-11-22T15:26:00.000","Title":"Program or library to handle massive numbers","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've written a script that opens up a file, reads the content and does some operations and calculations and stores them in sets and dictionaries.\nHow would I write a unit test for such a thing? My questions specifically are:\n\nWould I test that the file opened?\nThe file is huge (it's the unix dictionary file). How would I unit test the calculations? Do I literally have to manually calculate everything and test that the result is right? I have a feeling that this defeats the whole purpose of unit testing. I'm not taking any input through stdin.","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":3162,"Q_Id":13520279,"Users Score":0,"Answer":"You haven't explained what the calculations are, but I guess your program should be able to work with a subset of the big file, as well. If this is the case, make a unit test which opens up a small file , does the calculations and produces some result, which you can verify is correct.","Q_Score":7,"Tags":"python,unit-testing","A_Id":13520332,"CreationDate":"2012-11-22T21:34:00.000","Title":"Unit testing a script that opens 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":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've written a script that opens up a file, reads the content and does some operations and calculations and stores them in sets and dictionaries.\nHow would I write a unit test for such a thing? My questions specifically are:\n\nWould I test that the file opened?\nThe file is huge (it's the unix dictionary file). How would I unit test the calculations? Do I literally have to manually calculate everything and test that the result is right? I have a feeling that this defeats the whole purpose of unit testing. I'm not taking any input through stdin.","AnswerCount":3,"Available Count":2,"Score":1.0,"is_accepted":false,"ViewCount":3162,"Q_Id":13520279,"Users Score":6,"Answer":"You should refactor your code to be unit-testable. That, on the top of my head, would say: \n\nTake the functionality of the file opening into a separate unit. Make that new unit receive the file name, and return the stream of the contents.\nMake your unit receive a stream and read it, instead of opening a file and reading it.\nWrite a unit test for your main (calculation) unit. You would need to mock a stream, e.g. from a dictionary. Write several test cases, each time provide your unit with a different stream, and make sure your unit calculates the correct data for each input.\nGet your code coverage as close to 100% as you can. Use nosetests for coverage.\nFinally, write a test for your 'stream provider'. Feed it with several files (store them in your test folder), and make sure your stream provider reads them correctly. \nGet the second unit test coverage as close to 100% as you can.\nNow, and only now, commit your code.","Q_Score":7,"Tags":"python,unit-testing","A_Id":14733487,"CreationDate":"2012-11-22T21:34:00.000","Title":"Unit testing a script that opens 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":0,"System Administration and DevOps":0,"Web Development":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},{"Question":"I have a script where I want to check if a file exists in a bucket and if it doesn't then create one.\nI tried using os.path.exists(file_path) where file_path = \"\/gs\/testbucket\", but I got a file not found error.\nI know that I can use the files.listdir() API function to list all the files located at a path and then check if the file I want is one of them. But I was wondering whether there is another way to check whether the file exists.","AnswerCount":13,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":52000,"Q_Id":13525482,"Users Score":1,"Answer":"I guess there is no function to check directly if the file exists given its path.\nI have created a function that uses the files.listdir() API function to list all the files in the bucket and match it against the file name that we want. It returns true if found and false if not.","Q_Score":40,"Tags":"python,google-cloud-storage,file-exists","A_Id":13644827,"CreationDate":"2012-11-23T08:39:00.000","Title":"How to check if file exists in Google Cloud Storage?","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},{"Question":"I want to write a script which can Shutdown remote Ubuntu system. Actually i want my VM to shutdown safely when i shutdown my main machine on which my VM is installed .\nIs there is any of doing this with the help of Sh scripts or script written in any language like Python.","AnswerCount":6,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":4767,"Q_Id":13534541,"Users Score":0,"Answer":"You can call poweroff from a script, as long as it's running with superuser privileges.","Q_Score":2,"Tags":"python,linux,bash,ubuntu,sh","A_Id":13534648,"CreationDate":"2012-11-23T19:01:00.000","Title":"Script to Shutdown 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},{"Question":"I am trying to import pythoncom, but it gives me this error: Traceback (most recent call last):\n  File \"F:\/Documents and Settings\/Emery\/Desktop\/Python 27\/Try\", line 2, in \n    import pythoncom\n  File \"F:\\Python27\\lib\\site-packages\\pythoncom.py\", line 2, in \n    import pywintypes\nImportError: No module named pywintypes\nI reinstalled Python win32, but it still doesn't fix it. Any help? Also, I am trying to access the pythoncom.PumpMessages() method, an alternative would be nice as well.","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":5795,"Q_Id":13536952,"Users Score":2,"Answer":"If you are using an IDE like I am (PyCharm), you should go the where the Python is installed e.g C:\\Users\\***\\AppData\\Local\\Programs\\Python\\Python37\\Lib\\site-packages\nIn this folder check for the folder name pywin32. Copy that folder and paste it to C:\\Users\\***\\PycharmProjects\\project\\venv\\Lib\\site-packages. After that restart your IDE, then it will import the pywin32 as it did in my case. I hope it helps.","Q_Score":3,"Tags":"python,winapi,pywin32,importerror,pythoncom","A_Id":53436989,"CreationDate":"2012-11-23T23:39:00.000","Title":"win32 Python - pythoncom error - ImportError: No module named pywintypes","Data Science and Machine Learning":0,"Database and SQL":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},{"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},{"Question":"I created a encrypted file from a text file in python with beefish.\nbeefish uses pycrypto.\nso my source text file is 33742 bytes and the encrypted version is 33752.\nthats ok so far but ...\nwhen I compress the test.enc (encrypted test file) with tar -czvf the final file is 33989 bytes. Why does the compression not work when the source file is encrypted?\nSo far the only option then seems to compress it first and then encrypt it cause then the file stays that small.","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":494,"Q_Id":13544061,"Users Score":1,"Answer":"The compression method used by tar -z relies on repeating patterns in the input file, replacing these patterns by a count of how many times the pattern repeated (grossly simplified).\nHowever, when you encrypt a file, you are basically trying to hide any repeating patterns in as much 'random'-looking noise as possible. That makes your file nearly incompressible. Combine that with the overhead of the archive and compression file format (metadata, etc.) and your file actually ends up slightly larger instead.\nYou should reverse the process; compress first, then encrypt, and you'll increase the chances you end up with a smaller payload significantly.","Q_Score":1,"Tags":"python,python-2.7,pycrypto","A_Id":13544093,"CreationDate":"2012-11-24T18:10:00.000","Title":"compressed encrypted file is bigger then 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":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I created a encrypted file from a text file in python with beefish.\nbeefish uses pycrypto.\nso my source text file is 33742 bytes and the encrypted version is 33752.\nthats ok so far but ...\nwhen I compress the test.enc (encrypted test file) with tar -czvf the final file is 33989 bytes. Why does the compression not work when the source file is encrypted?\nSo far the only option then seems to compress it first and then encrypt it cause then the file stays that small.","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":494,"Q_Id":13544061,"Users Score":7,"Answer":"Compression works by identifying patterns in the data. Since you can't identify patterns in encrypted data (that's the whole point), you can't compress it.\nFor a perfect encryption algorithm that produced a 33,742 byte output, ideally all you would be able to determine about the decrypted original data is that it can fit in 33,742 bytes, but no more than that. If you could compress it to, say, 31,400 bytes, then you would immediately know the input data was not, say, 32,000 bytes of random data since random data is patternless and thus incompressible. That would indicate a failure on the part of the encryption scheme. It's nobody's business whether the decrypted data is random or not.","Q_Score":1,"Tags":"python,python-2.7,pycrypto","A_Id":13544079,"CreationDate":"2012-11-24T18:10:00.000","Title":"compressed encrypted file is bigger then 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":0,"System Administration and DevOps":0,"Web Development":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},{"Question":"Is there any way to force python module to be installed in the following directory? \/usr\/lib\/python2.7","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":70,"Q_Id":13554241,"Users Score":0,"Answer":"Install the module:\n\nsudo pip-2.7 install guess_language\n\nValidate import and functionality:\n> Python2.7\n>>> import guess_language\n>>> print guess_language.guessLanguage(u\"\u05e9\u05dc\u05d5\u05dd \u05dc\u05db\u05dd\") \n\nhe","Q_Score":1,"Tags":"python,module,installation","A_Id":13555251,"CreationDate":"2012-11-25T18:49:00.000","Title":"Force python module to be installed in certain 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},{"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},{"Question":"I want to open a ppt file using Python on linux, (like python open a .txt file). \nI know win32com, but I am working on linux. \nSo, What do I need to do?","AnswerCount":5,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":14562,"Q_Id":13559133,"Users Score":0,"Answer":"Using catdoc\/catppt with subprocess to open doc files and ppt files.","Q_Score":3,"Tags":"python","A_Id":13568384,"CreationDate":"2012-11-26T05:28:00.000","Title":"How to open ppt file 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},{"Question":"I am a new user of  Sublime text. \nIt has been working fine for a few days until it began to refuse to compile anything and I don't know where the problem is. I wrote python programs and pressed cmd+b and nothing happened. When I try to launch repl for this file - that also doesn't work. I haven't installed any plugins and before this issue all has been working well.\nAny suggestions on how to identify\/fix the problem are greatly appreciated","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":182,"Q_Id":13571993,"Users Score":0,"Answer":"Yes, you might want to give more detail. Have you made sure you have saved the file as .py? Try something simple like Print \"Hello\" and then see if this works.","Q_Score":2,"Tags":"python,sublimetext2","A_Id":20480227,"CreationDate":"2012-11-26T19:47:00.000","Title":"Build command in sublime text has stopped functioning","Data Science and Machine Learning":0,"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},{"Question":"CMUdict works for the english language, but what if I want to count the syllables of content in another language?","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":1881,"Q_Id":13572454,"Users Score":0,"Answer":"You certainly can't do it in a general way for all languages, because different languages render sounds to text differently.\nFor example, the Hungarian word \"vagy\" looks like 2 syllables to an English speaker, but it's only one. And the English word \"bike\" would naturally be read as 2 syllables by speakers of many other languages.\nFurthermore, for English you probably can't do this very accurately without a dictionary anyway, because English has so much bizarre variation in its spelling. For example, we pronounce the \"oe\" in \"poet\" as two distinct syllables, but only one in \"does\".  This is probably true of some other languages as well.","Q_Score":3,"Tags":"python,nlp,nltk","A_Id":13572969,"CreationDate":"2012-11-26T20:17:00.000","Title":"Is there anyway in python to count syllables without the use of a 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},{"Question":"CMUdict works for the english language, but what if I want to count the syllables of content in another language?","AnswerCount":3,"Available Count":2,"Score":0.1325487884,"is_accepted":false,"ViewCount":1881,"Q_Id":13572454,"Users Score":2,"Answer":"In general, no.  For some languages there might be, but if you don't have a dictionary you'd need knowledge of those languages' linguistic structure.  How words are divided into syllables varies from language to language.","Q_Score":3,"Tags":"python,nlp,nltk","A_Id":13572478,"CreationDate":"2012-11-26T20:17:00.000","Title":"Is there anyway in python to count syllables without the use of a 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},{"Question":"I have a custom C++ Python Module that I want to build into Python that builds fine but fails when it goes to the linking stage. I have determined that the problem is that it is using the gcc to link and not g++ and this is what is causing all of the errors I am seeing when it tries to link in the std libraries. How would I get the Python build process to link with g++ instead of gcc? Do I have to manually edit the Makefile or is it something I need to set when I am configuring it. I am compiling Python 2.6 on CentOS 5.8. \nThanks in advance for the help!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":85,"Q_Id":13589075,"Users Score":0,"Answer":"I was able to solve my problem by manually editing the Makefile generated by the configure script so that the linker was using g++ instead of gcc and that solved my problems. Thanks for the possible suggestions!","Q_Score":0,"Tags":"python,linux,gcc,g++,python-2.6","A_Id":13590180,"CreationDate":"2012-11-27T16:50:00.000","Title":"C++ Python Module not being linked into Python with g++","Data Science and Machine Learning":0,"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},{"Question":"I'm coming from PHP\/Apache world where running an application is super easy. Whenever PHP application crashes Apache process running that request will stop but server will be still ruining happily and respond to other clients. Is there a way to have Python application work in a smilar way. How would I setup wsgi server like Tornado or CherryPy so it will work similarly? also, how would I run several applications from one server with different domains?","AnswerCount":2,"Available Count":1,"Score":0.2913126125,"is_accepted":false,"ViewCount":300,"Q_Id":13619021,"Users Score":3,"Answer":"What you are after would possibly happen anyway for WSGI severs. This is because any Python exception only affects the current request and the framework or WSGI server would catch the exception, log it and translate it to a HTTP 500 status page. The application would still be in memory and would continue to handle future requests.\nWhat we get down to is what exactly you mean by 'crashes Apache process'.\nIt would be rare for your code to crash, as in cause the process to completely exit due to a core dump, the whole process. So are you being confused in your terminology in equating an application language level error to a full process crash.\nEven if you did find a way to crash a process, Apache\/mod_wsgi handles that okay and the process will be replaced. The Gunicorn WSGI server will also do that. CherryPy will not unless you have a process manager running which monitors it and the process monitor restarts it. Tornado in its single process mode will have the same problem. Using Tornado as the worker in Gunicorn is one way around that plus I believe Tornado itself may have some process manager in it now for running multiple process which allow it to restart processes if they die.\nDo note that if your application bug which caused the Python exception is bad enough and it corrupts state within the process, subsequent requests may possibly have issues. This is the one difference with PHP. With PHP, after any request, whether successful or not, the application is effectively thrown away and doesn't persist. So buggy code cannot affect subsequent requests. In Python, because the process with loaded code and retained state is kept between requests, then technically you could get things in a state where you would have to restart the process to fix it. I don't know of any WSGI server though that has a mechanism to automatically restart a process if one request returned an error response.","Q_Score":1,"Tags":"python,tornado,wsgi,cherrypy","A_Id":13619836,"CreationDate":"2012-11-29T04:49:00.000","Title":"How to setup WSGI server to run similarly to 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},{"Question":"I've installed python-mode, pymacs and pycomplete+ from el-get on emacs24. But i am not able to get auto-completion for python in emacs.","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":6063,"Q_Id":13632415,"Users Score":0,"Answer":"bzr branch lp:python-mode\/components-python-mode\ni.e. the development branch of python-mode.el\ndelivering an inlined Pymacs provides auto-completion right out of the box for me\nMight conflict with an already installed Pymacs though","Q_Score":4,"Tags":"python,emacs","A_Id":13634637,"CreationDate":"2012-11-29T18:35:00.000","Title":"Emacs python 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":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm starting to use Sublime Text 2 in favor of Eclipse for developing Python code.\nIn all I'm liking the change, but one of the things I miss from Eclipse is a convenient \"problems\" window that shows a summary of all errors and warnings from files in the project. While sublimelinter helps, it only works for files that you have open and are editing. It will place a box clearly around the error as you type it, but what if there are other problems in other files that you haven't seen yet? (ie, might have been committed by a coworker, etc)\nDoes there exist something in Sublime Text 2 that will show a summary of linting output?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":813,"Q_Id":13636412,"Users Score":1,"Answer":"pylint is first and foremost a command line tool for code analysis.\nYou can simply run it on a module from the command line and it will generate a whole report with every error\/warning within the project.\nI don't know if such feature exists from within sublime text but this is not something you will use often. I simply use the command line about once a week to check if I didn't miss anything.\nI also use a SublimeTODO plugin, which basically analyses the code looking for TODO comments. Unlike sublimelint, it does generate a report for all the open files or files within a project.","Q_Score":0,"Tags":"python,sublimetext2,sublimelinter","A_Id":13636603,"CreationDate":"2012-11-29T23:04:00.000","Title":"Sublime Text 2, Sublimelint, summary of problems","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I have a Python script that scans my logs and reports all its findings. Is it possible that the script in my box (say Box A) can be executed for another box (say B) without copying it.\nDo I really need to copy my Python script to Box B and then execute it from box A or there is a method by which staying in Box A I can connect to Box B run my python program for box B there get its output to and close the same.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":119,"Q_Id":13640812,"Users Score":0,"Answer":"If your logs on box B can be accessed over the network (e.g., through a network share or FTP), then you could modify the script on box A to retrieve and process them. If they are not network accessible, then you'll need to copy either the script from box A to box B, or the logs from box B to box A.","Q_Score":0,"Tags":"python","A_Id":13640945,"CreationDate":"2012-11-30T07:31:00.000","Title":"Python : run a py program on another box","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I need a way to programmatically create Twitter Applications\/API keys. I could make something on my own, but does anyone know of a pre-made solution?","AnswerCount":2,"Available Count":2,"Score":0.2913126125,"is_accepted":false,"ViewCount":1280,"Q_Id":13652514,"Users Score":3,"Answer":"Assuming you're referring to the consumer key and consumer secret, you're not supposed to be able to create those programmatically. That's why you have to sign in to a web page with a CAPTCHA in order to create one.","Q_Score":0,"Tags":"php,python,twitter,twitter-oauth","A_Id":13652765,"CreationDate":"2012-11-30T20:16:00.000","Title":"Is there an unofficial API for creating Twitter applications\/api keys?","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},{"Question":"I need a way to programmatically create Twitter Applications\/API keys. I could make something on my own, but does anyone know of a pre-made solution?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":1280,"Q_Id":13652514,"Users Score":0,"Answer":"Not sure what you mean, but there are plenty of libraries that abstracts twitter API (https:\/\/dev.twitter.com\/docs\/twitter-libraries)","Q_Score":0,"Tags":"php,python,twitter,twitter-oauth","A_Id":13652757,"CreationDate":"2012-11-30T20:16:00.000","Title":"Is there an unofficial API for creating Twitter applications\/api keys?","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},{"Question":"I have a project where I use south migrations. Often, the migrations .py file has unused imports. This generates warnings in PyDev\/Eclipse. I want the warnings turned on in general, as they promote code discipline. However, I wish I could either turn them off on the package in Eclipse or through some directive.\nI am aware of the #@UnusedImport comment tag. Is it possible to do something like that, but on a package level? Perhaps init.py could be used?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":694,"Q_Id":13668095,"Users Score":1,"Answer":"Putting # @PydevCodeAnalysisIgnore at the top of the module will cause PyDev to skip all code analysis on a given file. While not quite on  package level, this is good enough.","Q_Score":2,"Tags":"python,eclipse,pydev","A_Id":15648517,"CreationDate":"2012-12-02T09:44:00.000","Title":"Python and PyDev unused imports - possible to disable on the package 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":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have some python file in windows, and I transfer them to my gentoo by samba.\nI check their mode is executable, and I use .\/xxx.py to run it, but get an error:\n\n: No such file or directory\n\nI am troubled that it does not prompt what file is not here.\nbut when I use python xxx.py, it can run in the right way.\nand then I check the CR character by use set ff in vim, and found it is dos, then I use set ff=unix to set it, now it can run by using .\/xxx.py\nbut I don't know why it can be use python xxx.py when ff=dos?","AnswerCount":2,"Available Count":1,"Score":0.2913126125,"is_accepted":false,"ViewCount":1281,"Q_Id":13669092,"Users Score":3,"Answer":"Windows line endings are CRLF, or \\r\\n.\nUnix uses simply \\n.\nWhen the OS reads your shebang line, it sees #!\/usr\/bin\/python\\r. It can't run this command.\nA simple way to see this behavior from a unix shell would be $(echo -e 'python\\r') (which tries to run python\\r as a command). This output will also be similar to : command not found.\nMany advanced code editors under Windows support natively saving with unix line endings.","Q_Score":0,"Tags":"python,linux","A_Id":13669170,"CreationDate":"2012-12-02T12:01:00.000","Title":"python file in dos and 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},{"Question":"I have a repository of PDF documents, and most of the text contained in these documents are formatted in Comic Sans. I would like to change this to something similar to Arial. The original font is embedded in the document. I haven't found any existing tool to do this for me (I'm on Linux), and I wonder if it's possible to do it programmaticaly. A Python library would be perfect, but a library in any programming language would do.\nIn which library will I be able to substitute fonts with the least effort? And which parts of the API would I use?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":2714,"Q_Id":13672763,"Users Score":1,"Answer":"There are commercial tools that can do this - one of which is pdfToolbox from callas software (warning - I'm affiliated with this company).\nHowever - even though this functionality exists and is sometimes used - the results are often completely undesirable and I have not seen many contexts where it is used on more than very specific files. And usually with limited success. To the point where this replacement is only available as a manual operation in the tool I mentioned - and not in automatic mode.\nDepending on how complex these files are, you would probably have better success to extract all text from the documents into something like RTF, do whatever manipulation you need to do there and regenerate PDF afterwards. Sounds like a roundabout way but I'm guessing the result will be better in most cases...","Q_Score":5,"Tags":"python,pdf,fonts","A_Id":13674330,"CreationDate":"2012-12-02T19:14:00.000","Title":"Changing the font in a PDF","Data Science and Machine Learning":0,"Database and SQL":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},{"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},{"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},{"Question":"I am using Debian and I have a python script that I would like to run during rc.local so that it will run on boot. I already have it working with a test file that is meant to run and terminate. \nThe problem is that this file should eventually run indefinitely using Scheduler. It's job is to do serial reads, a small amount of processing on those reads, and inserts into a MySQL database. However, I am nervous about then not being able to cancel the script to get to my login prompt if changes need to be made since I was unable to terminate the test script early using Ctrl+C (^C). \nMy hope is that there is some command that I am just missing that will accomplish this. Is there another key command that I'm missing that will terminate the python script and end rc.local?\nThanks.\nEDIT: Another possible solution that would help me here is if there is a way to start a python script in the background during boot. So it would start the script and then allow login while continuing to run the script in the background.\nI'm starting to think this isn't something that's possible to accomplish so other suggestions to accomplish something similar to what I'm trying to do would be helpful as well.\nThanks again.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":575,"Q_Id":13675689,"Users Score":1,"Answer":"Seems like it was just a dumb mistake on my part.\nI realized the whole point of this was to allow the python script to run as a background process during boot so I added the \" &\" to the end of the script call like you would when running it from the shell and viola I can get to my password prompt by pressing \"Enter\".\nI wanted to put this answer here just in case this would be something horribly wrong to do, but it accomplishes what I was looking for.","Q_Score":2,"Tags":"python,debian,boot","A_Id":13706652,"CreationDate":"2012-12-03T00:47:00.000","Title":"End Python Script when running it as boot 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},{"Question":"I am writing a script in python3 for Ubuntu that should be executed all X Minutes and should automatic start after logging in. Therefore I want to create a daemon (is it the right solution for that?) but I haven't found any modules \/ examples for python3, just for python 2.X. Do you know something what I can work with?\nThank you,","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":3305,"Q_Id":13721808,"Users Score":1,"Answer":"Suppose for python script name is monitor. use following steps:  \n\ncopy monitor script in \/usr\/local\/bin\/ (not necessary)\nAlso add a copy in \/etc\/init.d\/ \nThen execute following command to make it executable\nsudo -S chmod \"a+x\" \"\/etc\/init.d\/monitor\"\nAt last run update.rc command \nsudo -S update-rc.d \"monitor\"  \"defaults\" \"98\"\n\nthis will execute you monitor whenever you login for all tty.","Q_Score":2,"Tags":"python,python-3.x,daemon,launch-daemon","A_Id":13722236,"CreationDate":"2012-12-05T11:03:00.000","Title":"Daemon with 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},{"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},{"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},{"Question":"Simple question:\nIs there some code or function I can add into most scripts that would let me know its \"running\"? \nSo after you execute foo.py most people would see a blinking cursor. I currently am running a new large script and it seems to be working, but I wont know until either an error is thrown or it finish(might not finish).\nI assume you could put a simple print \"foo-bar\"at the end of each for loop in the script?\nAny other neat visual read out tricks?","AnswerCount":3,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":131,"Q_Id":13729740,"Users Score":0,"Answer":"The print \"foo-bar\" trick is basically what people do for quick&dirty scripts. However, if you have lots and lots of loops, you don't want to print a line for each one. Besides the fact that it'll fill the scrollback buffer of your terminal, on many terminals it's hard to see whether anything is happening when all it's doing is printing the same line over and over. And if your loops are quick enough, it may even mean you're spending more time printing than doing the actual work.\nSo, there are some common variations to this trick:\n\nPrint characters or short words instead of full lines.\nPrint something that's constantly changing.\nOnly print every N times through the loop.\n\nTo print a word without a newline, you just print 'foo',. To print a character with neither a newline nor a space, you have to sys.stdout.write('.'). Either way, people can see the cursor zooming along horizontally, so it's obvious how fast the feedback is.\nIf you're got a for n in \u2026 loop, you can print n. Or, if you're progressively building something, you can print len(something), or outfile.ftell(), or whatever. Even if it's not objectively meaningful, the fact that it's constantly changing means you can tell what's going on.\nThe easiest way to not print all the time is to add a counter, and do something like counter += 1; if counter % 250 == 0: print 'foo'. Variations on this include checking the time, and printing only if it's been, say, 1 or more seconds since the last print, or breaking the task into subtasks and printing at the end of each subtask.\nAnd obviously you can mix and match these.\nBut don't put too much effort into it. If this is anything but a quick&dirty aid to your own use, you probably want something that looks more professional. As long as you can expect to be on a reasonably usable terminal, you can print a \\r without a \\n and overwrite the line repeatedly, allowing you to draw nice progress bars or other feedback (ala curl, wget, scp, and other similar Unix tools). But of course you also need to detect when you're not on a terminal, or at least write this stuff to stderr instead of stdout, so if someone redirects or pipes your script they don't get a bunch of garbage. And you might want to try to detect the terminal width, and if you can detect it and it's >80, you can scale the progress bar or show more information. And so on.\nThis gets complicated, so you probably want to look for a library that does it for you. There are a bunch of choices out there, so look through PyPI and\/or the ActiveState recipes.","Q_Score":1,"Tags":"python","A_Id":13729994,"CreationDate":"2012-12-05T18:14:00.000","Title":"Code to check a scripts activity (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},{"Question":"I have a python program that uses a lot of my CPU's resources. While it is fine on my regular PC, I'm afraid it might be too much to handle for my Raspberry Pi. Speed is not an issue. I don't care if my code is executed slowly as I am implementing a real time system that executes the code only once every few hours, but my CPU needs to be freed up as I would also be running other processes simultaneously. Is there anyway I can reduce the resources that it takes from the CPU  at the cost of speed of execution? Any help would be appreciated, thank you","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":5970,"Q_Id":13748022,"Users Score":4,"Answer":"While you sure can tinker with your program and make it more optimized, the fact is that all programs are generally designed to take as much CPU as they need in order to finish in smallest time possible.\nI see two ways to achieve your goal:\n\nRaspberry pi is Linux right? So just lower process priority of the python interpreter running your script. this would make sure that other programs can have CPU if they need it\nIn your script, sleep for few milliseconds every few milliseconds.. ugly, but could do the trick\n\nBut option one is probably way to go.","Q_Score":1,"Tags":"python,performance,cpu-usage,raspberry-pi,cpu-speed","A_Id":13748368,"CreationDate":"2012-12-06T16:26:00.000","Title":"How do I reduce CPU and memory usage by 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},{"Question":"How should I implement continuous integration on my new application? Currently, this is how we're pushing to production - please bear with me, I know this is far from sane:\n\nFrom local, git push origin production (the production codebase is kept on the production branch, modifications are either written directly there and committed, or files are checked out individually from another branch. Origin is the remote production server)\nOn the remote box, sudo stop gunicorn (application is running as a process)\ncp ~\/flaskgit\/application.py ~\/flask\/applicaion.py (the git push origin from local pushes to an init -bare repo with a post-update hook that populates the files in ~\/flaskgit. ~\/flask is where the gunicorn service runs the application under a virtualenv)\nsudo start gunicorn\n\nwe do our testing with the ~\/flaskgit code running on a different port. once it looks good we do the CP\nI would love to have something more fluid. I have used jenkins in the past, and loved the experience - but didn't set it up. \nWhat resources \/ utilities should I look up in order to do this well?\nThank you!","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":1085,"Q_Id":13750417,"Users Score":1,"Answer":"buildbot, jenkins\/hudson but these give you continuous integration in the sense you can run a \"make\" equivalent with every code base change through a commit hook. You could also look at vagrant if there is something there for you for creating repeatable vm's wrt to config\/setup. Could tie it with a commit hook.","Q_Score":4,"Tags":"python,git,continuous-integration,flask,gunicorn","A_Id":13767025,"CreationDate":"2012-12-06T18:48:00.000","Title":"Continuous integration with python 2.7 \/ flask \/ mongoDB \/ 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":1},{"Question":"The situation:\nI have a python script to connect\/send signals to serial connected arduino's. I wanted to know the best way to implement a web server, so that i can query the status of the arduinos. I want that both the \"web server\" part and serial connection runs on the same script. Is it possible, or do i have to break it into a daemon and a server part?\nThanks, any comments are the most welcomed.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":544,"Q_Id":13751271,"Users Score":0,"Answer":"Have WAMP server. It is the easiest and quickest way. The web server will support php, python , http etc. \nIf you are using Linux , the easiest tool for serial communication is php. \nBut in windows php cannot read data from serial communication. Hence use python \/ perl etc. \nThanks","Q_Score":1,"Tags":"python,arduino,interprocess,python-multithreading","A_Id":16685053,"CreationDate":"2012-12-06T19:43:00.000","Title":"python daemon + interprocess communication + web server","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},{"Question":"The situation:\nI have a python script to connect\/send signals to serial connected arduino's. I wanted to know the best way to implement a web server, so that i can query the status of the arduinos. I want that both the \"web server\" part and serial connection runs on the same script. Is it possible, or do i have to break it into a daemon and a server part?\nThanks, any comments are the most welcomed.","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":544,"Q_Id":13751271,"Users Score":0,"Answer":"For those wondering what I have opted for; I have decoupled the two part:\nThe Arduino daemon\nI am using Python with a micro web framework called [Bottle][1] which handles the API calls and I have used PySerial to communicate with the Arduino's. \nThe web server\nThe canonical Apache and PHP; are used to make API calls to the Arduino daemon.","Q_Score":1,"Tags":"python,arduino,interprocess,python-multithreading","A_Id":16689821,"CreationDate":"2012-12-06T19:43:00.000","Title":"python daemon + interprocess communication + web server","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},{"Question":"I'm switching to Pyramid from Apache\/PHP\/Smarty\/Dreamweaver scheme.\nI mean the situation of having static site in Apache with menu realized via Dreamweaver template or other static tools. And then if I wanted to put some dynamic content in html I could make the following:\n\nPut smarty templates in html.  \nCreate php behind html with same name. Php takes html as template.\nChange links from html to php.\n\nAnd that was all.\nThis scheme is convenient because the site is viewable in browser and editable \nin Dreamweaver.\nHow can I reproduce this scheme in Pyramid?\nThere are separate dirs for templates and static content. Plus all this myapp:static modifiers in hrefs. Where to look up?\nThank you for your advices.","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":720,"Q_Id":13756090,"Users Score":0,"Answer":"This is somewhat a different answer than ohters but here is a completely different flow. \nWrite all your pages in html. Everything!!! and then use something like angularjs or knockoutjs to add dynamic content. Pyramid will serve dynamic content requested using ajax. \nYou can then map everything to you html templates... edit those templates wherever you want since they are simply html files. \nThe downside is that making it work altogether isn't that simple at first.","Q_Score":3,"Tags":"python,pyramid","A_Id":14030455,"CreationDate":"2012-12-07T02:32:00.000","Title":"How to make almost static site 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},{"Question":"I'm trying to improve a package written in python . The package is already installed in the system. All the source files are also present . I want to create a copy of the package source so that i can make all the changes to the copy and test so that i do not make any change to the installed package . Is there a way for me to tell python to pick my copy of code instead of the Installed version whenever a file tries to import the package , so that i can test the new code in the copy ? I'm a noob with respect to python , so please do elaborate the solution","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":65,"Q_Id":13779439,"Users Score":0,"Answer":"If you want to make change in the code; better will be; download its source code first; apply the changes; modify the setup.py file or make new one; give it a new name.. . i mean do not change directly in the installed version; do them separately .. .or do whatever you like\nbut before doing all this;  study the license agreements present in the original source by its author ; and this must be done carefully when you want to distribute your copy to others","Q_Score":0,"Tags":"python,python-2.7","A_Id":13779703,"CreationDate":"2012-12-08T16:34:00.000","Title":"Making Changes to Installed 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":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Is there anyway I can extract localised name from ttf\/otf font file?\nA solution in Python would be preferred, but I am fine with any language.\nThank you very much.","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1306,"Q_Id":13783865,"Users Score":0,"Answer":"It looks like font files may have multiple localised names.\nExample with the fontconfig tools:\n\n$ fc-query -f '%{fullname} (%{fullnamelang}): %{file}\\n' \/usr\/share\/fonts\/truetype\/unfonts-core\/UnBatang.ttf \nUn Batang,\uc740 \ubc14\ud0d5 (en,ko): \/usr\/share\/fonts\/truetype\/unfonts-core\/UnBatang.ttf\n\nI can select the korean (ko) name using the order in fullnamelang:\n\n$ fc-query -f '%{fullname[1]}\\n' \/usr\/share\/fonts\/truetype\/unfonts-core\/UnBatang.ttf \n\uc740 \ubc14\ud0d5","Q_Score":1,"Tags":"python,c,fonts","A_Id":43614842,"CreationDate":"2012-12-09T01:41:00.000","Title":"Getting ttf\/otf font localised 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},{"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},{"Question":"I'm building a database to hold a uuid generated by the python uuid4 method - however, the documentation doesn't mention how many chars the uuid is!\nI'm not overly familiar with uuids, so i don't know if all languages generate the same length for a uuid.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":10805,"Q_Id":13784859,"Users Score":23,"Answer":"There is a standard for UUIDs, so they're the same in all languages. However, there is a string representation and a binary representation. The normal string representation (str(myuuid)) looks like 42c151a8-b22b-4cd5-b103-21bdb882e489 and is 36 characters. The binary representation, myuuid.bytes (or bytes_le, but stay consistent with it when reconstructing the UUID objects), is 16 bytes. You can also get the string representation with no hyphens (32 characters) with myuuid.hex.\nYou should be aware that some databases have a specific UUID type for storing UUIDs. What kind of database are you using?","Q_Score":11,"Tags":"python,uuid","A_Id":13784879,"CreationDate":"2012-12-09T05:14:00.000","Title":"What is the number of characters in a python uuid (type 4)?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a scraper which scrape one site (Written in python). While scraping the site, that  print lines which are about to write in CSV. Scraper has been written in Python and now I want to execute it via PHP code. My question is \n\nhow can I print each line which is getting printed by python code. \n\nI have used exec function but it is none of my use and gives output after executing all the program. So;\n\nIs it possible to get python output printed while it is getting executed via PHP.","AnswerCount":7,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":3658,"Q_Id":13786926,"Users Score":0,"Answer":"I think I have a fair idea of what you are saying put I am not too sure what you mean.\nIf you mean to say that everytime the python script does a print, you want the php code to output what was print?\nIf that is the case you could pass it as a POST DATA via HTTP. That is instead of printing in Python, you could send it to the PHP Script, which on receiving the data would print it.\nI am not too sure if this is what you want though.","Q_Score":10,"Tags":"php,python,scraper","A_Id":13952344,"CreationDate":"2012-12-09T11:19:00.000","Title":"Print Python output by PHP 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":0},{"Question":"I have a scraper which scrape one site (Written in python). While scraping the site, that  print lines which are about to write in CSV. Scraper has been written in Python and now I want to execute it via PHP code. My question is \n\nhow can I print each line which is getting printed by python code. \n\nI have used exec function but it is none of my use and gives output after executing all the program. So;\n\nIs it possible to get python output printed while it is getting executed via PHP.","AnswerCount":7,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":3658,"Q_Id":13786926,"Users Score":0,"Answer":"Simply use system() instead of exec(). exec() saves all lines of stdout output of the external program into an array, but system() flushes stdout output \"as it happens\".","Q_Score":10,"Tags":"php,python,scraper","A_Id":13989869,"CreationDate":"2012-12-09T11:19:00.000","Title":"Print Python output by PHP 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":0},{"Question":"I am planning to integrate real time notifications into a web application that I am currently working on. I have decided to go with XMPP for this and selected openfire server which i thought to be suitable for my needs.\nThe front end uses strophe library to fetch the notifications using BOSH from my openfire server. However the notices are the notifications and other messages are to be posted by my application and hence I think this code needs to reside at the backend.\nInitially I thougt of going with PHP XMPP libraries like XMPHP and JAXL but then I think that this would cause much overhead as each script will have to do same steps like connection, authentication etc. and I think this would make the PHP end a little slow and unresponsive.\nNow I am thinking of creating a middle-ware application acting as a web service that the PHP will call and this application will handle the stuff with XMPP service. The benefit with this is that this app(a server if you will) will have to connect just once and the it will sit there listening on a port. also I am planning to build it in a asynchronous way such that It will first take all the requests from my PHp app and then when there are no more requests; go about doing the notification publishing stuff. I am planninng to create this service in Python using SleekXMPP.\nThis is just what I planned. I am new to XMPP and this whole web service stuff ans would like to take your comments on this regarding issues like memory and CPU usage, advantages, disadvantages, scalability issues,security etc.\nThanks in advance.\nPS:-- also if something like this already exists(although I didn't find after a lot of Googling) Please direct me there.\nEDIT ---\nThe middle-level service should be doing the following(but not limited to):\n1. Publishing notifications for different level of groups and community pages.\n2. Notification for single user on some event.\n3. User registration(can be done using user service plugin though).\nEDIT ---\nAlso it should like to create pub-sub nodes and subscribe and unsubscribe users from these pub-sub nodes.\nAlso I want to store the notifications and messages in a database(openfire doesn't). Would that be a good choice?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1049,"Q_Id":13787244,"Users Score":0,"Answer":"It seems to me like XMPP is a bit of a heavy-weight solution for what you're doing, given that communication is just one-way and you're just sending notifications (no real-time multi-user chat etc.).\nI would consider using something like Socket.io (http:\/\/socket.io) for the server<=>client channel along with Redis (http:\/\/redis.io) for persistence.","Q_Score":0,"Tags":"python,web-services,xmpp,openfire,strophe","A_Id":13797108,"CreationDate":"2012-12-09T12:07:00.000","Title":"XMPP-- openfire,PHP and python web service","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I started working on a new computer a tried to set everything as it used to be on my old one. Unfortunately switching to 64bit Windows made everything quite difficult.\nWith the current setup I can only open raw I420 videos converted with memcoder, but I can't open DivX\/XVID videos, that I used to on my old PC. I tried ffdshow and K-Lite codec pack. Opening the videos in gspot shows that the codecs are indeed installed.\nI've searched for solution all over the Internet, but I couldn't find the solution. I've tried copying the ffmpeg dll into the Python27 folder.\nThe environment is 64bits Windows 7 Pro\nEDIT:\nI tried saving a video using OpenCV:\nI passed -1 to the cv2.VideoWriter function to get the codec selection dialog. The dialog dosn't show the ffdshow codecs.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":2972,"Q_Id":13799586,"Users Score":2,"Answer":"I solved the problem finally.\nWindows7 x64 + Python 2.7 x86 + NumPy x86 + ffdshow x86 + Eclipse x64 is the way to go. Everything is working like a charm. x64 ffdshow is also required for other programs like VirtualDub though.","Q_Score":1,"Tags":"python,opencv,ffmpeg,codec","A_Id":14071725,"CreationDate":"2012-12-10T10:58:00.000","Title":"Open DivX\/XVID videos in OpenCV 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},{"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},{"Question":"I'm just curious, is it possible to dump all the variables and current state of the program to a file, and then restore it on a different computer?!\nLet's say that I have a little program in Python or Ruby, given a certain condition, it would dump all the current variables, and current state to a file.\nLater, I could load it again, in a different machine, and return to it.\nSomething like VM snapshot function.\nI've seen here a question like this, but Java related, saving the current JVM and running it again in a different JVM. Most of the people told that there was nothing like that, only Terracotta had something, still, not perfect.\nThank you.\nTo clarify what I am trying to achieve:\nGiven 2 or more Raspberry Pi's, I'm trying to run my software at Pi n\u00ba1, but then, when I need to do something different with it, I need to move the software to Pi n\u00ba2 without dataloss, only a minor break time.\nAnd so on, to an unlimited number of machines.","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":156,"Q_Id":13809013,"Users Score":1,"Answer":"Good question.\nIn Smalltalk, yes.\nActually, in Smalltalk, dumping the whole program and restarting is the only way to store and share programs. There are no source files and there is no way of starting a program from square zero. So in Smalltalk you would get your feature for free.\nThe Smalltalk VM offers a hook where each object can register to restore its externals resources after a restart, like reopening files and internet connections. But also, for example integer arrays are registered to that hook to change the endianness of their values on case the dump has been moved to a machine with different endianness.\nThis might give a hunch at how difficult (or not) it might turn our to achieve this in a language which does not support resumable dumps by design.\nAll other languages are, alas, much less live. Except for some Lisp implementation, I would not know of any language which supports resuming from a memory dump.\nWhich is a missed opportunity.","Q_Score":6,"Tags":"python,ruby,jvm,stack","A_Id":13810563,"CreationDate":"2012-12-10T20:51:00.000","Title":"Saving the stack?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I'm facing of a strange issue, and after a couple of hour of research I'm looking for help \/ explanation about the issue.\nIt's quite simple, I wrote a cgi server in python and I'm working with some libs including pynetlinux for instance.\nWhen I'm starting the script from terminal with any user, it works fine, no bug, no dependency issue. But when I'm trying to start it using a script in rc.local, the following code produce an error.\n\n   import sys, cgi, pynetlinux, logging\n\nit produce the following error :\n\n   Traceback (most recent call last):\n      File \"\/var\/simkiosk\/cgi-bin\/load_config.py\", line 3, in \n      import cgi, sys, json, pynetlinux, loggin\n   ImportError: No module named pynetlinux\n\nOther dependencies produce similar issue.I suspect some few things like user who executing the script in rc.local (root normaly) and trying some stuff found on the web without success.\nSomebody can help me ?\nThanx in advance.\nRegards.\nOllie314","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":1890,"Q_Id":13811575,"Users Score":1,"Answer":"The path where your modules are install is probably normally sourced by .bashrc or something similar. .bashrc doesn't get sourced when it's not an interactive shell. \/etc\/profile is one place that you can put system wide path changes. Depending on what Linux version\/distro it may use \/etc\/profile.d\/ in which case \/etc\/profile runs all the scripts in \/etc\/profile.d, add a new shell script there with execute permissions and a .sh extention.","Q_Score":2,"Tags":"python,dependency-management","A_Id":13811685,"CreationDate":"2012-12-11T00:13:00.000","Title":"python scripts issue (no module named ...) when starting in rc.local","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"Basically what I am trying to accomplish is have users be able to type in a certain word on one cgi script (which I currently have) and then it will save that entry in a list and display that word and the whole list on the other page.  Also I will save it into a .txt file but first I am trying to figure out how to display the whole list.  Right now it is only showing the keyword the user enters.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":59,"Q_Id":13817697,"Users Score":2,"Answer":"There's no way your code could ever accumulate a list of keywords over multiple posts. Firstly, CGI scripts have no state, so they will start from a blank list each time. And even if that wasn't true, you explicitly reset keywords to the blank list each time anyway.\nYou will need to store the list somewhere between runs. A text file will work, but only if you can guarantee that only one user will be accessing it at any one time.\nSince you're new to CGI scripts, I've no idea why you are trying to learn them. There's very little good reason to use them these days. Really, you should drop the CGI scripts, use a web framework (a micro-framework like Flask would suit you), and store the list in a database (again, an unstructure \"no-sql\" store might be good for you).","Q_Score":1,"Tags":"python,cgi","A_Id":13818037,"CreationDate":"2012-12-11T09:57:00.000","Title":"Have users enter a keyword from one cgi script and save that information in a list\/txtfile on another 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},{"Question":"I have a Python script that I'd like to be run from the browser, it seem mod_wsgi is the way to go but the method feels too heavy-weight and would require modifications to the script for the output. I guess I'd like a php approach ideally. The scripts doesn't take any input and will only be accessible on an internal network. \nI'm running apache on Linux with mod_wsgi already set up, what are the options here?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":379,"Q_Id":13841206,"Users Score":3,"Answer":"I would go the micro-framework approach just in case your requirements change - and you never know, it may end up being an app rather just a basic dump... Perhaps the simplest (and old fashioned way!?) is using CGI:\n\nDuplicate your script and include print 'Content-Type: text\/plain\\n' before any other output to sys.stdout\nPut that script somewhere apache2 can access it (your cgi-bin for instance)\nMake sure the script is executable\nMake sure .py is added to the Apache CGI handler\n\nBut - I don't see anyway this is going to be a fantastic advantage (in the long run at least)","Q_Score":1,"Tags":"python,apache,mod-wsgi","A_Id":13841885,"CreationDate":"2012-12-12T13:46:00.000","Title":"Webserver to serve 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},{"Question":"When tracing(using sys.settrace) python .egg execution by Python 2.7 interpreter frame.f_code.co_filename    instead of \/ eqauls to something like build\/bdist.linux-x86_64\/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.\/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},{"Question":"I have a python script I hope to do roughly this:\n\ncalls some particle positions into an array\nruns algorithm over all 512^3 positions to distribute them to an NxNxN matrix\nfeed that matrix back to python\nuse plotting in python to visualise matrix (i.e. mayavi)\n\nFirst I have to write it in serial but ideally I want to parrallelize step 2 to speed up computation. What tools\/strategy might get me started. I know Python and Fortran well but not much about how to connect the two for my particular problem. At the moment I am doing everything in Fortran then loading my python program - I want to do it all at once.I've heard of py2f but I want to get experienced people's opinions before I go down one particular rabbit hole. Thanks\nEdit: The thing I want to make parallel is 'embarrassingly parallel' in that is is just a loop of N particles and I want to get through that loop as quickly as possible.","AnswerCount":3,"Available Count":1,"Score":0.1325487884,"is_accepted":false,"ViewCount":929,"Q_Id":13852646,"Users Score":2,"Answer":"An alternative approach to VladimirF's suggestion, could be to set up the two parts as a client server construct, where your Python part could talk to the Fortran part using sockets. Though this comes with the burden to implement some protocol for the interaction, it has the advantage, that you get a clean separation and can even go on running them on different machines with an interaction over the network.\nIn fact, with this approach you even could do the embarrassing parallel part, by spawning as many instances of the Fortran application as needed and feed them all with different data.","Q_Score":5,"Tags":"python,arrays,parallel-processing,fortran,f2py","A_Id":13858423,"CreationDate":"2012-12-13T03:51:00.000","Title":"I want Python as front end, Fortran as back end. I also want to make fortran part parallel - best strategy?","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},{"Question":"I know this is probably a very obvious answer and that I'm exposing myself to less-than-helpful snarky comments, but I don't know the answer so here goes.\nIf Python compiles to bytecode at runtime, is it just that initial compiling step that takes longer? If that's the case wouldn't that just be a small upfront cost in the code (ie if the code is running over a long period of time, do the differences between C and python diminish?)","AnswerCount":2,"Available Count":2,"Score":1.0,"is_accepted":false,"ViewCount":7934,"Q_Id":13853053,"Users Score":8,"Answer":"Byte codes are not natural to the CPU so they need interpretation (by a CPU native code called interpreter). The advantage of byte code is that it enables optimizations, pre-computations, and saves space. C compiler produces machine code and machine code does not need interpretation, it is native to CPU.","Q_Score":8,"Tags":"python,c,compilation","A_Id":13853083,"CreationDate":"2012-12-13T04:39:00.000","Title":"What makes C faster than 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},{"Question":"I know this is probably a very obvious answer and that I'm exposing myself to less-than-helpful snarky comments, but I don't know the answer so here goes.\nIf Python compiles to bytecode at runtime, is it just that initial compiling step that takes longer? If that's the case wouldn't that just be a small upfront cost in the code (ie if the code is running over a long period of time, do the differences between C and python diminish?)","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":7934,"Q_Id":13853053,"Users Score":18,"Answer":"It's not merely the fact that Python code is interpreted which makes it slower, although that definitely sets a limit to how fast you can get.  \nIf the bytecode-centric perspective were right, then to make Python code as fast as C all you'd have to do is replace the interpreter loop with direct calls to the functions, eliminating any bytecode, and compile the resulting code.  But it doesn't work like that.  You don't have to take my word for it, either: you can test it for yourself.  Cython converts Python code to C, but a typical Python function converted and then compiled doesn't show C-level speed.  All you have to do is look at some typical C code thus produced to see why.\nThe real challenge is multiple dispatch (or whatever the right jargon is -- I can't keep it all straight), by which I mean the fact that whereas a+b if a and b are both known to be integers or floats can compile down to one op in C, in Python you have to do a lot more to compute a+b (get the objects that the names are bound to, go via __add__, etc.)\nThis is why to make Cython reach C speeds you have to specify the types in the critical path; this is how Shedskin makes Python code fast using (Cartesian product) type inference to get C++ out of it; and how PyPy can be fast -- the JIT can pay attention to how the code is behaving and specialize on things like types.  Each approach eliminates dynamism, whether at compile time or at runtime, so that it can generate code which knows what it's doing.","Q_Score":8,"Tags":"python,c,compilation","A_Id":13853280,"CreationDate":"2012-12-13T04:39:00.000","Title":"What makes C faster than 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},{"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},{"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},{"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},{"Question":"I believe this question is probably outside of the scope of SO, but I was wondering what the best practice is for testing a payment processing feature?\nFor any feature developed, it's been relatively easy to test, if not through unit testing than through a front-end walkthrough, but with this, I'm at a bit of a loss, as I have not done this before.\nWhat is suggested here?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":85,"Q_Id":13911219,"Users Score":0,"Answer":"Most payment processors have a sandbox\/developers account where you can process transactions in a test mode so you can fully test them as if you were in a live environment.","Q_Score":0,"Tags":"python,database,web,payment-processing","A_Id":13914479,"CreationDate":"2012-12-17T09:13:00.000","Title":"Testing Payment Processing Feature","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I am trying to get alerts for the data that I'm sending peers.  My code works great for incoming blocks by looking for libtorrent.block_finished_alert but I want to know when and what I am sending to peers.  I can't find an alert that will give me the equivalent for outbound transfers.  I need to know the file and offset (the peer request).\nIs there an alert for outbound block requests?\nI'm using the python bindings but C++ code is fine too.","AnswerCount":1,"Available Count":1,"Score":0.537049567,"is_accepted":false,"ViewCount":384,"Q_Id":13919367,"Users Score":3,"Answer":"The closest thing you have to alerts is probably stats_alert. It will tell you the number of payload bytes uploaded. It won't give the you granularity of a full block being sent though.\nIf you'd like to add an alert, have a look at bt_peer_connection::write_piece.\npatches are welcome!","Q_Score":2,"Tags":"python,bittorrent,libtorrent","A_Id":13938080,"CreationDate":"2012-12-17T17:51:00.000","Title":"Get alerts for upload activity with libtorrent (rasterbar)","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I am using linux mint, and to run a python file I have to type in the terminal: python [file path], so is there way to make the file executable, and make it run the python command automatically when I doublr click it?\nAnd since I stopped dealing with windows ages ago, I wonder if the .py files there are also automatically executable or do I need some steps.\nThanks","AnswerCount":7,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":290768,"Q_Id":13933169,"Users Score":8,"Answer":"yes there is. add \n#!\/usr\/bin\/env python \nto the beginning of the file and do \nchmod u+rx \nassuming your user owns the file, otherwise maybe adjust the group or world permissions.\n.py files under windows are associated with python as the program to run when opening them just like MS word is run when opening a .docx for example.","Q_Score":32,"Tags":"python,linux","A_Id":13933228,"CreationDate":"2012-12-18T12:36:00.000","Title":"How to execute python file 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},{"Question":"Im searching about services\/strategies to detect when entered names in forms are spammy, example: asdasdasd, ksfhaiodsfh, wpoeiruopwieru, zcpoiqwqwea. crazy keyboard inputs.\nI am trying akismet is not specially for names (http:\/\/kemayo.wordpress.com\/2005\/12\/02\/akismet-py\/).\nthanks in advance.","AnswerCount":4,"Available Count":4,"Score":0.049958375,"is_accepted":false,"ViewCount":361,"Q_Id":13934311,"Users Score":1,"Answer":"you could look for unusual character combinations like many consecutive vowels\/consonants, and watch your registrations and create a list of recurring patterns (like asd) in false names\ni would refrain from automatically block those inputs and rather mark them for examination","Q_Score":2,"Tags":"c#,java,php,python,api","A_Id":13934575,"CreationDate":"2012-12-18T13:42:00.000","Title":"service or strategy to detect if users enter fake names?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"Im searching about services\/strategies to detect when entered names in forms are spammy, example: asdasdasd, ksfhaiodsfh, wpoeiruopwieru, zcpoiqwqwea. crazy keyboard inputs.\nI am trying akismet is not specially for names (http:\/\/kemayo.wordpress.com\/2005\/12\/02\/akismet-py\/).\nthanks in advance.","AnswerCount":4,"Available Count":4,"Score":0.0,"is_accepted":false,"ViewCount":361,"Q_Id":13934311,"Users Score":0,"Answer":"Ask for a real email and send info to connect there. Then get info from the account.\nNo way is really safe anyway.","Q_Score":2,"Tags":"c#,java,php,python,api","A_Id":13934456,"CreationDate":"2012-12-18T13:42:00.000","Title":"service or strategy to detect if users enter fake names?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"Im searching about services\/strategies to detect when entered names in forms are spammy, example: asdasdasd, ksfhaiodsfh, wpoeiruopwieru, zcpoiqwqwea. crazy keyboard inputs.\nI am trying akismet is not specially for names (http:\/\/kemayo.wordpress.com\/2005\/12\/02\/akismet-py\/).\nthanks in advance.","AnswerCount":4,"Available Count":4,"Score":0.0,"is_accepted":false,"ViewCount":361,"Q_Id":13934311,"Users Score":0,"Answer":"If speed isn't an issue, download a list of the top 100k most common names, throw them in an O(1) lookup data structure, see if the input is there, and if not, you could always compare the input to the entries using a string similarity algorithm.\nAlthough if you do, you will probably want to bucket by starting letter to prevent having to perform that calculation on the entire list.","Q_Score":2,"Tags":"c#,java,php,python,api","A_Id":49864949,"CreationDate":"2012-12-18T13:42:00.000","Title":"service or strategy to detect if users enter fake names?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"Im searching about services\/strategies to detect when entered names in forms are spammy, example: asdasdasd, ksfhaiodsfh, wpoeiruopwieru, zcpoiqwqwea. crazy keyboard inputs.\nI am trying akismet is not specially for names (http:\/\/kemayo.wordpress.com\/2005\/12\/02\/akismet-py\/).\nthanks in advance.","AnswerCount":4,"Available Count":4,"Score":0.0996679946,"is_accepted":false,"ViewCount":361,"Q_Id":13934311,"Users Score":2,"Answer":"One strategy is having a black list with weird names and\/or a white list with normal names, to reject\/accept names. But it can be difficult to found it.","Q_Score":2,"Tags":"c#,java,php,python,api","A_Id":13934347,"CreationDate":"2012-12-18T13:42:00.000","Title":"service or strategy to detect if users enter fake names?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I am trying to find a way to rename (change email address aka group id) a google group via api.  Using the python client libraries and the provisioning api i am able to modify the group name and description, and I have used the group settings api to modify a group's settings.  Is there a way to change the email address?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":923,"Q_Id":13937326,"Users Score":1,"Answer":"There is no group rename function for groups as there is for users. With the Group Settings and Provisioning APIs though, you can capture much of the group specifics and migrate that over to a new group. You would lose:\n-Group Archive\n-Managers (show only as members)\n-Email Delivery (Immediate, Digest, No-Delivery, etc)","Q_Score":1,"Tags":"gdata-api,google-api-client,google-api-python-client,google-provisioning-api","A_Id":13938196,"CreationDate":"2012-12-18T16:28:00.000","Title":"Is it possible to change email address of a Google group via 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},{"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},{"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},{"Question":"I am using smtplib to send emails with python. I can get the email to send with the info I want in the body, but I can't find a good source to look over on how I can format the mail itself.\nAnyone know of a good resource....\nI have a list that I want to iterate over and put lines between.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2444,"Q_Id":13941436,"Users Score":0,"Answer":"This is more of an email question then a python question.  I'd refer to the RFC on email.  However to address your question in between lines of the body you should put a CRLF","Q_Score":0,"Tags":"python","A_Id":13941495,"CreationDate":"2012-12-18T21:01:00.000","Title":"smtplib email formatting","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I need to put a lot of filepaths in the form of strings in Python as part of my program. For example one of my directories is D:\\ful_automate\\dl. But Python recognizes some of the characters together as other characters and throws an error. In the example the error is IOError: [Errno 22] invalid mode ('wb') or filename: 'D:\\x0cul_automate\\\\dl. It happens a lot for me and every time I need to change the directory name to one that may not be problematic.","AnswerCount":2,"Available Count":1,"Score":0.2913126125,"is_accepted":false,"ViewCount":22129,"Q_Id":13955176,"Users Score":3,"Answer":"Use raw string instead of string ie\n    use r'filepath'\nIt fixes the problem off  blacklash \"\\\"","Q_Score":9,"Tags":"python,string,error-handling,filepath","A_Id":13955742,"CreationDate":"2012-12-19T15:03:00.000","Title":"File paths in Python in the form of string throw errors","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've wrapped a C++ class using Boost.Python. These Objects have strong references (boost::shared_ptr) on the C++-side, and there may be intermittent strong references in Python as well. So far, everything works well. However, if I create a python weak reference from one of the strong references, this weak reference is deleted as soon as the last python strong reference disappears. I'd like the weak reference to stay alive until the last strong reference on the C++ side disappears as well. Is it possible to achieve that?\nPhrased another way: Is there a way to find out from python if a particular C++ object (wrapped by Boost.Python) still exists?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":241,"Q_Id":13956055,"Users Score":1,"Answer":"How are you holding a \"C++ strong reference\" to the wrapped class ?\nI'm quite rusty on boost python, but I believe it's the boost::shared_ptr's deleter presence which ensures lifetime management.\nIf that isn't the problem, you probably need to hold the instance in C++ in a boost::python::object.","Q_Score":6,"Tags":"c++,python,boost-python","A_Id":13989547,"CreationDate":"2012-12-19T15:49:00.000","Title":"Boost.Python: Getting a python weak reference to a wrapped C++ object","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},{"Question":"Wondering if it is possible to see a history of emails that a GAE app has sent? Need to look into the history for debugging purposes.\nNote that logging when I send the email or bcc'ing a user are not options for this particular question as the period I'm curious about was in the past (since then we are bcc'ing).","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":88,"Q_Id":13956774,"Users Score":6,"Answer":"you can try one of the following way:\nLog\n\nwrite a log to datastore while each time you call sent_mail. \nwrite log with logging module and check the log in dashboard.\n\nmail\n\nwhile send the email, add a debug email address in email's \"bcc\" field. \nyou can also check the \"sent mail\" in the email account used as sender.","Q_Score":4,"Tags":"python,google-app-engine","A_Id":13957307,"CreationDate":"2012-12-19T16:27:00.000","Title":"Does a GAE app keep a log of the emails it sends?","Data Science and Machine Learning":0,"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},{"Question":"We have a suite of selenium tests that on setup and teardown open and close the browser to start a new test.\nThis approach takes a long time for tests to run as the opening and closing is slow. Is there any way to open the browser once in the constructor then reste on setup and cleanup on teardown, then on the deconstructor close the browser?\nAny example would be really appreciated.","AnswerCount":1,"Available Count":1,"Score":0.761594156,"is_accepted":false,"ViewCount":601,"Q_Id":13957413,"Users Score":5,"Answer":"You can use class or module level setup and teardown methods instead of test level setup and teardown.  Be careful with this though, as if you don't reset your test environment explicitly in each test, you have to handle cleaning everything out (cookies, history, etc) manually, and recovering the browser if it has crashed, before each test.","Q_Score":1,"Tags":"python,selenium","A_Id":13957461,"CreationDate":"2012-12-19T17:02:00.000","Title":"Selenium test suite only open browser once","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},{"Question":"Using Twitter Streaming API getting tweets from a specific query.\nHowever some tweets came with different codification (there are boxes instead of words).\nIs there any way to fix it?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":228,"Q_Id":13991387,"Users Score":1,"Answer":"Use a different font, or a better method of displaying those.\nAll tweets in the streaming API are encoded with the same codec (JSON data is fully unicode aware), but not all characters can be displayed by all fonts.","Q_Score":0,"Tags":"python,twitter","A_Id":13991409,"CreationDate":"2012-12-21T13:51:00.000","Title":"Tweets from Twitter Streaming 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},{"Question":"Is there a way to make use of AES-NI in Python? I do want to make HMAC faster by making use of my hardware support for AES-NI.\nThanks.","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":1310,"Q_Id":14007542,"Users Score":2,"Answer":"HMAC is using a secure cryptographic hash, not a symmetric cipher. You can make a \"normal\" MAC such as AES-CMAC perform better, but not a HMAC.","Q_Score":5,"Tags":"python,aes,aes-ni","A_Id":14022066,"CreationDate":"2012-12-22T23:45:00.000","Title":"Python support for AES-NI","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to create a scheduled task using the Unix at command. I wanted to run a python script, but quickly realized that at is configured to use run whatever file I give it with sh. In an attempt to circumvent this, I created a file that contained the command python mypythonscript.py and passed that to at instead.\nI have set the permissions on the python file to executable by everyone (chmod a+x), but when the at job runs, I am told python: can't open file 'mypythonscript.py': [Errno 13] Permission denied.\nIf I run source myshwrapperscript.sh, the shell script invokes the python script fine. Is there some obvious reason why I'm having permissions problems with at?\nEdit: I got frustrated with the python script, so I went ahead and made a sh script version of the thing I wanted to run. I am now finding that the sh script returns to me saying rm: cannot remove : Permission denied (this was a temporary file I was creating to store intermediate data). Is there anyway I can authorize these operations with my own credentials, despite not having sudo access? All of this works perfectly when I run it myself, but everything seems to go to shit when I have at do it.","AnswerCount":4,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":1059,"Q_Id":14007784,"Users Score":0,"Answer":"Could you try: echo 'python mypythonscript.py' | at ...","Q_Score":0,"Tags":"python,linux,shell,unix","A_Id":14033835,"CreationDate":"2012-12-23T00:37:00.000","Title":"Unix `at` scheduling with python script: Permission denied","Data Science and Machine Learning":0,"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},{"Question":"I'm trying to create a scheduled task using the Unix at command. I wanted to run a python script, but quickly realized that at is configured to use run whatever file I give it with sh. In an attempt to circumvent this, I created a file that contained the command python mypythonscript.py and passed that to at instead.\nI have set the permissions on the python file to executable by everyone (chmod a+x), but when the at job runs, I am told python: can't open file 'mypythonscript.py': [Errno 13] Permission denied.\nIf I run source myshwrapperscript.sh, the shell script invokes the python script fine. Is there some obvious reason why I'm having permissions problems with at?\nEdit: I got frustrated with the python script, so I went ahead and made a sh script version of the thing I wanted to run. I am now finding that the sh script returns to me saying rm: cannot remove : Permission denied (this was a temporary file I was creating to store intermediate data). Is there anyway I can authorize these operations with my own credentials, despite not having sudo access? All of this works perfectly when I run it myself, but everything seems to go to shit when I have at do it.","AnswerCount":4,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":1059,"Q_Id":14007784,"Users Score":0,"Answer":"Start the script using python not the actual script name, ex : python path\/to\/script.py.\nat tries to run everything as a sh script.","Q_Score":0,"Tags":"python,linux,shell,unix","A_Id":14007903,"CreationDate":"2012-12-23T00:37:00.000","Title":"Unix `at` scheduling with python script: Permission denied","Data Science and Machine Learning":0,"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},{"Question":"I am looking for pointers\/tips on how to generate a synthesized sound signal on the BeagleBone akin to watch the tone() function would return on a Arduinos. Ultimately, I'd like to connect a piezo or a speaker on a GPIO pin and hear a sound wave out of it. Any pointers?","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":4148,"Q_Id":14007965,"Users Score":1,"Answer":"The GPIO pins of the AM3359 are low-voltage and with insufficient driver strength to directly drive any kind of transducer.  You would need to build a small circuit with a op-amp, transistor or FET to do this.\nOnce you've done this, you'd simply set up a timer loop to change the state of the GPIO line at the required frequency. \nBy far the quickest and easiest way of getting audio from this board is with a USB Audio interface.","Q_Score":2,"Tags":"python,audio,beagleboard","A_Id":14008119,"CreationDate":"2012-12-23T01:28:00.000","Title":"How to generate sound signal through a GPIO pin 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":0,"Web Development":1},{"Question":"I am really bad at compiling programs, and I just want to know if my python 2.5 program would be faster if I converted it to a .exe using py2exe. I don't want to spend a lot of time trying to compile it if it will just be slower in the end. My program uses OpenCV and PyAudio, but I think that are the only non pure-python modules it uses. Thanks!\nNOTE: I do not think this question requires a snippit of code, but if it does, please say so in the comments. Thanks!","AnswerCount":3,"Available Count":2,"Score":1.0,"is_accepted":false,"ViewCount":6424,"Q_Id":14022166,"Users Score":6,"Answer":"No, not really. Since it's merely a wrapper it provides the necessary files needed to run your code. Using Cython could make your program run faster by being able to compile it using C.","Q_Score":2,"Tags":"python,windows-xp,py2exe,python-2.5","A_Id":14022239,"CreationDate":"2012-12-24T13:43:00.000","Title":"Is a python script faster when you convert it to a .exe using py2exe?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am really bad at compiling programs, and I just want to know if my python 2.5 program would be faster if I converted it to a .exe using py2exe. I don't want to spend a lot of time trying to compile it if it will just be slower in the end. My program uses OpenCV and PyAudio, but I think that are the only non pure-python modules it uses. Thanks!\nNOTE: I do not think this question requires a snippit of code, but if it does, please say so in the comments. Thanks!","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":6424,"Q_Id":14022166,"Users Score":1,"Answer":"I spent last 2 months working on Windows Python and I must say i am not very happy. \nIf you have any C modules(besides standard library), you'll have huge problems to get it working.\nSpeed is similar to Linux, but it seems a little bit slower.\nPlease note that py2exe is not the best. \nI had issues with py2exe and had to use pyinstaller. \nIt has a better debug, it worked in cases when py2exe didn't\nMy biggest dissapointment was exe size, I had a simple program which used lxml, suds and it was 7-8mb big...","Q_Score":2,"Tags":"python,windows-xp,py2exe,python-2.5","A_Id":14024396,"CreationDate":"2012-12-24T13:43:00.000","Title":"Is a python script faster when you convert it to a .exe using py2exe?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":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},{"Question":"Is there any effect of unused imports in a Python script?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":6737,"Q_Id":14038691,"Users Score":28,"Answer":"You pollute your namespace with names that could interfere with your variables and occupy some memory.\nAlso you will have a longer startup time as the program has to load the module.\nIn any case, I would not become too neurotic with this, as if you are writing code you could end up writing and deleting import os continuously as your code is modified.  Some IDE's as PyCharm detect unused imports so you can rely on them after your code is finished or nearly completed.","Q_Score":40,"Tags":"python,performance,python-import","A_Id":14038726,"CreationDate":"2012-12-26T09:44:00.000","Title":"Do unused imports in Python hamper 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},{"Question":"Is it possible to run a Python script within PHP and transferring variables from each other ?\nI have a class that scraps websites for data in a certain global way. i want to make it go a lot more specific and already have pythons scripts specific to several website.\nI am looking for a way to incorporate those inside my class.\nIs safe and reliable data transfer between the two even possible ? if so how difficult it is to get something like that going ?","AnswerCount":5,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":63592,"Q_Id":14047979,"Users Score":0,"Answer":"For me the escapeshellarg(json_encode($data)) is giving not exactly a json-formatted string, but something like { name : Carl , age : 23 }.\nSo in python i need to .replace(' ', '\"') the whitespaces to get some real json and be able to cast the json.loads(sys.argv[1]) on it.\nThe problem is, when someone enters a name with already whitespaces in it like \"Ca rl\".","Q_Score":29,"Tags":"php,python","A_Id":70877468,"CreationDate":"2012-12-27T00:30:00.000","Title":"executing Python script in PHP and exchanging data between the two","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I have written a script in python that I would like to be able to give to some less tech-savvy friends.  However, it relies on PIL and requests to function.  How can I include these modules without forcing my friends to try to install them?","AnswerCount":3,"Available Count":1,"Score":-0.0665680765,"is_accepted":false,"ViewCount":112,"Q_Id":14068303,"Users Score":-1,"Answer":"It's simple. Make them to put your script in site-packages or dist-packages. They can import the script using import module and use them.","Q_Score":2,"Tags":"python,module","A_Id":14068920,"CreationDate":"2012-12-28T10:45:00.000","Title":"Auto-including Modules 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},{"Question":"Is it possible to delete a folder from inside a file using the ZipFile module in Python?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":422,"Q_Id":14096829,"Users Score":3,"Answer":"No. Read out the rest of the archive and write it to a new zip file.","Q_Score":0,"Tags":"python,python-zipfile","A_Id":14096860,"CreationDate":"2012-12-31T02:34:00.000","Title":"Deleting a folder in a zip file using the Python zipfile 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},{"Question":"I am using pydub to mix two wav files in one file. Each wav file has about 25Mb and for me page is loaded in about 4 seconds ( so execution time would be 4 seconds ) \nDoes this execution time depend on user's internet connection speed?  \nIf it has any sense : The test.py file is on GoDaddy Deluxe Linux Hosting)","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":544,"Q_Id":14137675,"Users Score":1,"Answer":"it does not: once your script starts dubbing the wav files, it's another task. \nsee it as a 3-step (i'm guessing, very little information is provided)\n\nstep 1: you send the request --> time determined by \"internet speed\"\nstep 2: files get dubbed --> server side work, internet speed doesn't count anymore\nstep 3: you get the result back --> again internet speed related \n\nyou have to time them separately: run a benchmark only on the mixing part and see it for yourself\nFunny practical way to see this:\nConsider the dinner process: the time you spend eating your dinner doesn't depend on the time it takes for you to order or for the waiter to deliver the meal to you. \nquick edit: i just realized it may depend on internet speed, if the dubbing\/mixing part is streamed real time while being processed. but this doesn't seem your case.","Q_Score":0,"Tags":"python,execution-time,pydub","A_Id":14137744,"CreationDate":"2013-01-03T11:07:00.000","Title":"Does python script execution time depend on internet speed?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I am using pydub to mix two wav files in one file. Each wav file has about 25Mb and for me page is loaded in about 4 seconds ( so execution time would be 4 seconds ) \nDoes this execution time depend on user's internet connection speed?  \nIf it has any sense : The test.py file is on GoDaddy Deluxe Linux Hosting)","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":544,"Q_Id":14137675,"Users Score":0,"Answer":"No. The execution happens on the server and the execution time depends on the server specs and your script optimizations. The internet speed just affects when the client will receive the response after it is ready from the server and sent! \nSo in few words: \n\nServer gets request from browser (time for request to reach server depends on internet speed of the client and the host) \nServer processes the request according to your code (Execution time depends on your code)\nServer responds to client and client receives response (time for request to reach client depends on internet speed of the client and the host)","Q_Score":0,"Tags":"python,execution-time,pydub","A_Id":14137714,"CreationDate":"2013-01-03T11:07:00.000","Title":"Does python script execution time depend on internet speed?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"In my office we have about 1000 PDFs that have arbitrary title and author information. My bosses had a spreadsheet created with the PDFs filename and an appropriate title and appropriate author information.\nI would like to find a programmatic way to move the data from the Excel sheet to the PDF attributes?\nMy preferred language is Python so I looked for a Python library to do this, each library I looked at had the author and title fields as read-only.\nIf Python doesn't have a library that works I am okay using VBA, VB.NET, JavaScript... I will take this as an opportunity to learn a new language.","AnswerCount":2,"Available Count":1,"Score":-0.0996679946,"is_accepted":false,"ViewCount":834,"Q_Id":14144460,"Users Score":-1,"Answer":"Use Action Wizard in Acrobat X Pro.\nCreate New Action.\nSetup Start With, and Save To step.\nSet checkbox Overwrite existing files.\nSelect Content. Select Add Document Description.\nLeft mouse click in option. Uncheck Autor checkbox Leave As Is and enter new Autor name.\nPress Save button, set name action Your Action Name.\nRun Action:\nFile- Action Wizard - Your Action Name.\nI test it - work).","Q_Score":0,"Tags":"python,pdf","A_Id":14144813,"CreationDate":"2013-01-03T17:56:00.000","Title":"Changing a PDF author programmatically","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"Are there any IDEs for Python that support automatic error highlighting (like the Eclipse IDE for Java?) I think it would be a useful feature for a Python IDE, since it would make it easier to find syntax errors. Even if such an editor did not exist, it still might be possible to implement this by automatically running the Python script every few seconds, and then parsing the console output for error messages.","AnswerCount":4,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":203,"Q_Id":14152187,"Users Score":4,"Answer":"eclipse+pydev\npycharm\nmany others ....","Q_Score":0,"Tags":"python,ide,livecoding","A_Id":14152212,"CreationDate":"2013-01-04T06:25:00.000","Title":"Is it possible to implement automatic error highlighting 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},{"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},{"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},{"Question":"I was wondering what is the advantages of mod_wsgi. For most python web framework, I can launch (daemon) the application by python directly and serve it in a port. Then when shall I use mod_wsgi?","AnswerCount":1,"Available Count":1,"Score":0.6640367703,"is_accepted":false,"ViewCount":82,"Q_Id":14152651,"Users Score":4,"Answer":"Since I answered your other question regarding Flask, I assume you are referring to using Flask's development server.  The problem with that is it is single threaded.\nUsing mod_wsgi, you would be running behind apache, which will do process forking and allow for multiple simultaneous requests to be handled.\nThere are other options as well.  Depending on your particular use case I would consider using eventlet's wsgi server.","Q_Score":1,"Tags":"python,django,apache,mod-wsgi,wsgi","A_Id":14152716,"CreationDate":"2013-01-04T07:02:00.000","Title":"Why should I use `mod_wsgi` instead of launching by 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},{"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},{"Question":"Are there problems with sharing a single instance of RemoteWebDriver between multiple test cases?  If not, what's the best practice place to create the instance?  I'm working with Python, so I think my options are module level setup, test case class setup, test case instance setup (any others?)","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":249,"Q_Id":14161479,"Users Score":1,"Answer":"Sharing a single RemoteWebDriver can be dangerous, since your tests are no longer independently self-contained.  You have to be careful about cleaning up browser state and the like, and recovering from browser crashes in the event a previous test has crashed the browser.  You'll also probably have more problems if you ever try to do anything distributed across multiple threads, processes, or machines.  That said, the options you have for controlling this are not dependent on Selenium itself, but whatever code or framework you are using to drive it.  At least with Nose, and I think basic pyunit, you can have setup routines at the class, module, or package level, and they can be configured to run for each test, each class, each module, or each package, if memory serves.","Q_Score":0,"Tags":"python,selenium,testcase","A_Id":14161887,"CreationDate":"2013-01-04T17:03:00.000","Title":"Share single instance of selenium RemoteWebDriver between multiple test cases","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},{"Question":"I would like to build a RF transmitter\/controller for my garage. When my vehicle gets within 25', I'd like for a computer to trigger a physical relay to open my garage door. you know, like Batman.\nI like Python, so I'm hoping I can use it here.","AnswerCount":2,"Available Count":2,"Score":0.1973753202,"is_accepted":false,"ViewCount":465,"Q_Id":14164753,"Users Score":2,"Answer":"Have you looked into getting a basic arduino?  It sounds like you should pick up a cheap one at Radio Shack and get the RF devices to trigger your garage door opener remotely.  With the hardware, you can easily talk to it via python (though it'd be easy enough to just do with the Arduino language).","Q_Score":0,"Tags":"python,hardware","A_Id":14164831,"CreationDate":"2013-01-04T20:49:00.000","Title":"Can I use Python to interact with an RF transmitter\/controller?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I would like to build a RF transmitter\/controller for my garage. When my vehicle gets within 25', I'd like for a computer to trigger a physical relay to open my garage door. you know, like Batman.\nI like Python, so I'm hoping I can use it here.","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":465,"Q_Id":14164753,"Users Score":4,"Answer":"Look in to the Raspberry Pi. It's a $25 embeddable computer than supports Python. You will need to spec an RF transceiver that can interface with the on board hardware and use the documentation to determine a control method.","Q_Score":0,"Tags":"python,hardware","A_Id":14165338,"CreationDate":"2013-01-04T20:49:00.000","Title":"Can I use Python to interact with an RF transmitter\/controller?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I'm trying learn TDD in python. Unfortunately I have not found any PEPs about unittest.\n\nDoes one subclass of unittest.TestCase should contain all tests about one tested function?\nWhat are the recommendations for naming classes, methods or test-files?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":352,"Q_Id":14185831,"Users Score":1,"Answer":"I usually make one class that handles the setup and tearing down for a particular test topic and subclass it for every single test. That is, one class for every test, with a name that conveys what is being tested. Nothing fancy.","Q_Score":0,"Tags":"python,unit-testing","A_Id":14185895,"CreationDate":"2013-01-06T19:22:00.000","Title":"Python unittest - division tests into classes\/functions","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to program an alpha sign - 215r - using the alphasign python api [Alphasign] (https:\/\/alphasign.readthedocs.org\/en\/latest\/index.html). I downloaded python 2.7, pyusb, pyserial, and libusb. I got the vid and pid of the sign using libusb and added that to the devices.py file. However, when I ran the example python code [here] (https:\/\/alphasign.readthedocs.org\/en\/latest\/index.html), I still got an error that said it could not find device with vid and pid of 8765:1234 (the example numbers). Now, when I open the file (the code is copied and pasted from the link above) it crashes IDLE (totally shuts down). ...when I run the file from bash, it says core dump. suggestions please!!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":262,"Q_Id":14205744,"Users Score":0,"Answer":"I had a similar problem on a Mac (mtn lion): When I ran the sample app, I got a segment fault 11.  It was crashing in the alphasign library from the sign.connect() call.\nChanged it to sign.connect(reset=False), and it worked fine.\nFYI: The segment fault occurs in the low-level USB driver, libusb, not in python code.","Q_Score":0,"Tags":"python-2.7,sign,pyusb","A_Id":14761682,"CreationDate":"2013-01-07T23:12:00.000","Title":"Programming an Alpha electronic sign with Alphasign 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},{"Question":"I am using intellij IDEA version 11.1.5 on windows and python plugin version is 2.9.2 \nI am using grinder maven plugin to run the performance tests using grinder. It only supports python(Jython) to run tests. I am not getting any auto suggestions for the python development even though I have installed the python plugin. Python files are also getting displayed as a text files.\nIs there any other configuration to enable the auto suggestions for python development?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":711,"Q_Id":14214331,"Users Score":0,"Answer":"Your file types are not configured correctly, .py is most likely assigned to Text files instead of Python files, you can fix it in File | Settings | File Types.\nThere is no support for tests running via Maven, but you can create your own Run\/Debug configuration for Python unit tests in IDEA.","Q_Score":1,"Tags":"maven,python-3.x,intellij-idea","A_Id":14501896,"CreationDate":"2013-01-08T11:51:00.000","Title":"Python support for maven module in intellij","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"Is there a way to know which application I'm running a python script from?\nI can run python from multiple sources, like Textmate, Sublime Text 2 or Terminal (I'm on Mac OSX). How can I know, exactly which tool launched the current python app.\nI've tried looking into the os and inspect modules, but couldn't find the solution.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":99,"Q_Id":14236130,"Users Score":0,"Answer":"If you're happy to stay specific to unix and then you can get the parent PID of the process with os.getppid(). If you wanted to translate it back to a program id, you could can run a subprocess to use the relevant OS-specific PID-to-useful-data tool (odds on - ps)","Q_Score":0,"Tags":"python","A_Id":14236492,"CreationDate":"2013-01-09T13:20:00.000","Title":"How to know which application run 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":0},{"Question":"I currently have a v1 API and have updated and created new scripts for v2. The API is consumed by other developers and consists of a bunch of scripts. Before migrating and adding v2 I want to make sure I have a successful versioning strategy to go ahead with. \nCurrently, there is a bash script called before using the API, with which you can supply the version # or by default gives you the most recent version. Originally, I intended to have different subfolders for each different version, but for scripts that do not change between revisions and scripts that get content added to them, the git history will not be preserved correctly as the original file will still reside in the v1 subdir and will not be 'git mv'ed. This is obviously not the best way but I can't think of a better way currently. \nAny recommendations will be helpful but one restriction is that we cannot have a git submodule with different branches. There are no other restrictions (e.g. the bash file used for setup can be deleted) as long as the scripts are accessible. Thanks!\nEDIT: We also have scripts above the \"API\" directory that are part of the same repo that call into the API (we are consumers of our own API). The changes to these files need to be visible when using any version of the API and cannot just be seen in the latest version (related to tags in the repo)","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":605,"Q_Id":14271489,"Users Score":2,"Answer":"I think you want to use tags in your git repository. For each version of your api, use git tag vn and you don't need to maintain earlier versions of your files. You can access all files at a certain version just using git checkout vn.\nIf you use a remote repository, you need to use the flag --tags to send the tags to the remote repository, ie, git push --tags.","Q_Score":1,"Tags":"python,git,api,version","A_Id":14271577,"CreationDate":"2013-01-11T04:03:00.000","Title":"API Versioning while maintaining git history","Data Science and Machine Learning":0,"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},{"Question":"I'm working on an open source project (Master of Mana, a mod for Civilization 4) which uses Python 2.4.1 for several game mechanics. Is there a chance for a performance improvement if I try to upgrade to Python 2.7.3 or even 3.3.0?\nRelated to this, has anyone done a performance analysis on different Python versions?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":379,"Q_Id":14281308,"Users Score":0,"Answer":"Most newer Python versions bring new features.\nExisting code parts are probably updated as well, either for performance or for extended functionality.\nThe former kind of changes bring a performance benefit, but extended functionality might lead to a poorer performance.\nI don't know what is the relationship between these kinds of changes. Probably you will have to do some profiling on yourself.","Q_Score":2,"Tags":"python,performance","A_Id":14281528,"CreationDate":"2013-01-11T15:27:00.000","Title":"Upgrading to a newer Python version - performance improvements?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm a complete Noob, having studied Python 2.7 for less than four days using eclipse on a mac, and I have managed to write a \"FizzBang\" from scratch in about 20 minutes, but....I'm having one heck of a time with basic algorithms. I'm wondering if this is something I'll speed up at in time, or if there is some sort of \"logical thinking\" practice that is above me without instruction. Memorizing syntax has been no problem so far and I really enjoy the feeling when it all works out. \nMy question is, should I detour from my current beginner book and read something about basic algorithms (maybe something specific to Python algorithms)?\nIf so, what beginner text would 'yall recommend?\nI searched for this topic and didn't find anything that matched, so if this is a duplicative post, or whatever you call it, my bad.\nI'd appreciate any help I get from you Pro's. Thanks","AnswerCount":3,"Available Count":1,"Score":0.3215127375,"is_accepted":false,"ViewCount":590,"Q_Id":14287141,"Users Score":5,"Answer":"Learning the syntax of a programming language to express an algorithm is like learning the syntax of English to express a thought.\nSure, there are nuances in English that allow you to express some thoughts better than others or in other languages. However, a command of English does not automatically enable you to be able to think some thoughts.\nSimilarly, if you want to pick up an algorithms book, go for it! Your understanding of python is only very loosely connected with your ability to develop and algorithm to solve a problem.\nOnce you learn how to solve problems, you will be able to develop an algorithm to solve the specific problem at hand, and then choose the language best suited to express that algorithm\n\u2026 And as you design more and more algorithms, you'll get better at developing better algorithms; and as you write more python code, you'll get better at writing python code.\nI don't know what book you're currently reading, but beginner  books tend to orient themselves at teaching the language (it's syntax, semantics, etc) using simple algorithmic examples. If you're having a tough time understanding the algorithms that govern the solutions to these examples, you should probably do some beginner reading on algorithms. It's somewhat of a cycle, really - in order to learn algorithms, you need to be able to express them (and algorithms are most easily expressed in code). Thus to understand algorithms, you need to understand code.\nThis is not entirely true - pseudocode solves this problem quite well. But you'll need to understand at least the pseudocode.\nHope this helps","Q_Score":0,"Tags":"python,algorithm,structure","A_Id":14287198,"CreationDate":"2013-01-11T21:43:00.000","Title":"Beginning Python trouble with basic 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":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I was using PIL to do image processing, and I tried to convert a color image into a grayscale one, so I wrote a Python function to do that, meanwhile I know PIL already provides a convert function to this.\nBut the version I wrote in Python takes about 2 seconds to finish the grayscaling, while PIL's convert almost instantly. So I read the PIL code, figured out that the algorithm I wrote is pretty much the same, but\nPIL's convert is written in C or C++.\nSo is this the problem making the performance's different?","AnswerCount":2,"Available Count":2,"Score":0.2913126125,"is_accepted":false,"ViewCount":318,"Q_Id":14289657,"Users Score":3,"Answer":"Yes, coding the same algorithm in Python and in C, the C implementation will be faster.  This is definitely true for the usual Python interpreter, known as CPython.  Another implementation, PyPy, uses a JIT, and so can achieve impressive speeds, sometimes as fast as a C implementation.  But running under CPython, the Python will be slower.","Q_Score":0,"Tags":"python,c,python-imaging-library","A_Id":14289791,"CreationDate":"2013-01-12T02:41:00.000","Title":"performance concern, Python vs 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},{"Question":"I was using PIL to do image processing, and I tried to convert a color image into a grayscale one, so I wrote a Python function to do that, meanwhile I know PIL already provides a convert function to this.\nBut the version I wrote in Python takes about 2 seconds to finish the grayscaling, while PIL's convert almost instantly. So I read the PIL code, figured out that the algorithm I wrote is pretty much the same, but\nPIL's convert is written in C or C++.\nSo is this the problem making the performance's different?","AnswerCount":2,"Available Count":2,"Score":0.1973753202,"is_accepted":false,"ViewCount":318,"Q_Id":14289657,"Users Score":2,"Answer":"If you want to do image processing, you can use \nOpenCV(cv2), SimpleCV, NumPy, SciPy, Cython, Numba ...\nOpenCV, SimpleCV SciPy have many image processing routines already.\nNumPy can do operations on arrays in c speed.\nIf you want loops in Python, you can use Cython to compile your python code with static declaration into an external module. \nOr you can use Numba to do JIT convert, it can convert your python code into machine binary code, and will give you near c speed.","Q_Score":0,"Tags":"python,c,python-imaging-library","A_Id":14290456,"CreationDate":"2013-01-12T02:41:00.000","Title":"performance concern, Python vs 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},{"Question":"Both 'pypy' and 'gevent' are supposed to provide high performance. Pypy is supposedly faster than CPython, while gevent is based on co-routines and greenlets, which supposedly makes for a faster web server.\nHowever, they're not compatible with each other.\nI'm wondering which setup is more efficient (in terms of speed\/performance):\n\nThe builtin Flask server running on pypy\n\nor:\n\nThe gevent server, running on CPython","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":15866,"Q_Id":14294643,"Users Score":1,"Answer":"Builtin flask server is a BaseHTTPServer or so, never use. The best scenario is very likely tornado + pypy or something like that. Benchmark before using though. It also depends quite drastically on what you're doing. The web server + web framework benchmarks are typically hello world kind of benchmarks. Is your application really like that?\nCheers, fijal","Q_Score":25,"Tags":"python,performance,gevent,pypy","A_Id":14294862,"CreationDate":"2013-01-12T15:10:00.000","Title":"Which setup is more efficient? Flask with pypy, or Flask 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},{"Question":"I am using platypus to bundle a python applet. I am wondering if there is a way to import modules, like math from stdlib.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":773,"Q_Id":14345587,"Users Score":0,"Answer":"This is probably suboptimal, but I simply add the package (the directories which actually hold the code, not an egg or anything fancy) I want to import into the bundled files list in Platypus. \nThis works well when you only need to add a few packages.","Q_Score":4,"Tags":"python,import","A_Id":28459509,"CreationDate":"2013-01-15T19:44:00.000","Title":"How to import modules into platypus applet?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I installed OSQA Bitnami on my VPS. And I also point 3 domains to this VPS. Now I want each domain point to different web service (I have another PHP website I want to host here). \nHow can I run php service along with OSQA Bitnami (it's python stack)?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":133,"Q_Id":14350605,"Users Score":0,"Answer":"You can install BitNami modules for each one those stacks, just go to the stack download page, select the module for your platform, execute it in the command line and point to the existing installation. Then you will need to configure httpd.conf to point each domain to each app.","Q_Score":0,"Tags":"php,python,bitnami,osqa","A_Id":14351798,"CreationDate":"2013-01-16T02:45:00.000","Title":"How can I run Bitnami OSQA with other web service (wordpress, joomla)?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"Is there a way to set the optimization level from the setuptools setup.py file? Is there any way to set the optimization level within setuptools? \nI've got lots of __debug__ style logging that isn't needed on release.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1371,"Q_Id":14359644,"Users Score":0,"Answer":"You control the use of .pyc vs .pyo with the -O switch on the Python command line.  Python won't even attempt to use .pyo files without the -O switch, so compiling your .py files to .pyo files at setup time won't help: you need to invoke your program with the -O switch, or the PYTHONOPTIMIZE environment variable.","Q_Score":2,"Tags":"python,optimization,software-distribution","A_Id":14359944,"CreationDate":"2013-01-16T13:32:00.000","Title":"Python Setuptools Distribute: Optimize Option in setup.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":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to setup an internal wiki for our development team. It looks like mediawiki is the de facto means of doing this.\nWhile I'm probably capable of setting this up with PHP - I was curious if there is a python port of mediawiki or a similar framework. \nI'm very comfortable in PHP, and am more than happy to use it - but most of our developers prefer python. I think it would be neat to have a python wiki running.\nThis is just a curiosity - and not a serious issue.\nThank you for any suggestions!","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":549,"Q_Id":14366750,"Users Score":0,"Answer":"No, there is no Python port of MediaWiki.\nKeep in mind that your developers will be using the wiki, not developing for it. Chances are that none of them will never need to look at the application's internals, so the language it was written in is irrelevant.","Q_Score":2,"Tags":"php,python,mediawiki,wiki","A_Id":14366895,"CreationDate":"2013-01-16T19:59:00.000","Title":"MediaWiki python port?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I'm new to python so please excuse me if question doesn't make sense in advance. \nWe have a python messaging server which has one file server.py with main function in it. It also has a class \"*server\" and main defines a global instance of this class, \"the_server\". All other functions in same file or diff modules (in same dir) import this instance as \"from main import the_server\".\nNow, my job is to devise a mechanism which allows us to get latest message status (number of messages etc.) from the aforementioned messaging server. \nThis is the dir structure:\nsrc\/ -> all .py files only one file has main\nIn the same directory I created another status server with main function listening for connections on a different port and I'm hoping that every time a client asks me for message status I can invoke function(s) on my messaging server which returns the expected numbers. \nHow can I import the global instance, \"the_server\" in my status server or rather is it the right way to go?","AnswerCount":2,"Available Count":2,"Score":0.1973753202,"is_accepted":false,"ViewCount":128,"Q_Id":14370402,"Users Score":2,"Answer":"Unless your \"status server\" and \"real server\" are running in the same process (that is, loosely, one of them imports the other and starts it), just from main import the_server in your status server isn't going to help. That will just give you a new, completely independent instance of the_server that isn't doing anything, which you can then report status on.\nThere are a few obvious ways to solve the problem.\n\nMerge the status server into the real server completely, by expanding the existing protocol to handle status-related requests, as Peter Wooster suggestions.\nMerge the status server into the real server async I\/O implementation, but still listening on two different ports, with different protocol handlers for each.\nMerge the status server into the real server process, but with a separate async I\/O implementation.\nStore the status information in, e.g., a mmap or a multiprocessing.Array instead of directly in the Server object, so the status server can open the same mmap\/etc. and read from it. (You might be able to put the Server object itself in shared memory, but I wouldn't recommend this even if you could make it work.)\n\nI could make these more concrete if you explained how you're dealing with async I\/O in the server today. Select (or poll\/kqueue\/epoll) loop? Thread per connection? Magical greenlets? Non-magical cooperative threading (like PEP 3156\/tulip)? Even just \"All I know is that we're using twisted\/tornado\/gevent\/etc., so whatever that does\" is enough.","Q_Score":0,"Tags":"python,client-server,messaging","A_Id":14370602,"CreationDate":"2013-01-17T00:37:00.000","Title":"Python server 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":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm new to python so please excuse me if question doesn't make sense in advance. \nWe have a python messaging server which has one file server.py with main function in it. It also has a class \"*server\" and main defines a global instance of this class, \"the_server\". All other functions in same file or diff modules (in same dir) import this instance as \"from main import the_server\".\nNow, my job is to devise a mechanism which allows us to get latest message status (number of messages etc.) from the aforementioned messaging server. \nThis is the dir structure:\nsrc\/ -> all .py files only one file has main\nIn the same directory I created another status server with main function listening for connections on a different port and I'm hoping that every time a client asks me for message status I can invoke function(s) on my messaging server which returns the expected numbers. \nHow can I import the global instance, \"the_server\" in my status server or rather is it the right way to go?","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":128,"Q_Id":14370402,"Users Score":2,"Answer":"You should probably use a single server and design a protocol that supports several kinds of messages. 'send' messages get sent, 'recv' message read any existing message, 'status' messages get the server status, 'stop' messages shut it down, etc.\nYou might look at existing protocols such as REST, for ideas.","Q_Score":0,"Tags":"python,client-server,messaging","A_Id":14370495,"CreationDate":"2013-01-17T00:37:00.000","Title":"Python server 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":1,"System Administration and DevOps":0,"Web Development":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},{"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},{"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},{"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},{"Question":"I am trying to compress a huge python object ~15G, and save it on the disk. Due to requrement constraints I need to compress this file as much as possible. I am presently using zlib.compress(9). My main concern is the memory taken exceeds what I have available on the system 32g during compression, and going forward the size of the object is expected to increase. Is there a more efficient\/better way to achieve this.\nThanks.\nUpdate: Also to note the object that I want to save is a sparse numpy matrix, and that I am serializing the data before compressing, which also increases the memory consumption. Since I do not need the python object after it is serialized, would gc.collect() help?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1086,"Q_Id":14389279,"Users Score":5,"Answer":"Incremental (de)compression should be done with zlib.{de,}compressobj() so that memory consumption can be minimized. Additionally, higher compression ratios can be attained for most data by using bz2 instead.","Q_Score":1,"Tags":"python,memory,numpy,compression","A_Id":14389347,"CreationDate":"2013-01-17T22:26:00.000","Title":"Compress large python objects","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},{"Question":"I have a Python program that needs to access a Java RMI API from a third party system in order to fetch some data. \nI have no control over the third party system so it MUST be done using RMI.\nWhat should be my approach here? I have never worked with RMI using Python so I'm kind of lost as to what I should do..\nThanks in advance!","AnswerCount":2,"Available Count":2,"Score":0.1973753202,"is_accepted":false,"ViewCount":5222,"Q_Id":14403472,"Users Score":2,"Answer":"You're going to have a very hard time i would imagine.  RMI and Java serialization are very Java specific.  I don't know if anyone has already attempted to implement this in python (i'm sure google knows), but your best bet would be to find an existing library.\nThat aside, i would look at finding a way to do the RMI in some client side java shim (maybe some sort of python<->java bridge library?).  Or, maybe you could run your python in Jython and leverage the underlying jvm to handle the RMI stuff.","Q_Score":5,"Tags":"java,python,rmi","A_Id":14403624,"CreationDate":"2013-01-18T16:41:00.000","Title":"Accessing a Java RMI API from 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":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have a Python program that needs to access a Java RMI API from a third party system in order to fetch some data. \nI have no control over the third party system so it MUST be done using RMI.\nWhat should be my approach here? I have never worked with RMI using Python so I'm kind of lost as to what I should do..\nThanks in advance!","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":5222,"Q_Id":14403472,"Users Score":2,"Answer":"How about a little java middle ware piece that you can talk to via REST and the piece in turn can to the remote API?","Q_Score":5,"Tags":"java,python,rmi","A_Id":14403646,"CreationDate":"2013-01-18T16:41:00.000","Title":"Accessing a Java RMI API from 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":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Sometimes I want to just insert some print statements in my code, and see what gets printed out when I exercise it. My usual way to \"exercise\" it is with existing pytest tests. But when I run these, I don't seem able to see any standard output (at least from within PyCharm, my IDE).\nIs there a simple way to see standard output during a pytest run?","AnswerCount":14,"Available Count":2,"Score":1.0,"is_accepted":false,"ViewCount":296089,"Q_Id":14405063,"Users Score":22,"Answer":"Try   pytest -s -v test_login.py for more info in console.\n-v it's a short --verbose\n-s means 'disable all capturing'","Q_Score":669,"Tags":"python,logging,output,pytest","A_Id":47816384,"CreationDate":"2013-01-18T18:14:00.000","Title":"How can I see normal print output created during pytest run?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Sometimes I want to just insert some print statements in my code, and see what gets printed out when I exercise it. My usual way to \"exercise\" it is with existing pytest tests. But when I run these, I don't seem able to see any standard output (at least from within PyCharm, my IDE).\nIs there a simple way to see standard output during a pytest run?","AnswerCount":14,"Available Count":2,"Score":0.057080742,"is_accepted":false,"ViewCount":296089,"Q_Id":14405063,"Users Score":4,"Answer":"If you are using PyCharm IDE, then you can run that individual test or all tests using Run toolbar. The Run tool window displays output generated by your application and you can see all the print statements in there as part of test output.","Q_Score":669,"Tags":"python,logging,output,pytest","A_Id":54546338,"CreationDate":"2013-01-18T18:14:00.000","Title":"How can I see normal print output created during pytest run?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":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},{"Question":"I was playing with PyAIML. I understand how to set the bot's name. But could not figure out how to set the creator's name so that if anyone ask's \"Who created you?\" then it can reply appropriately. Please help.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":444,"Q_Id":14420413,"Users Score":1,"Answer":"It's the same way you set and get the botname. Only the variable name differs to your choice.","Q_Score":1,"Tags":"python,artificial-intelligence,chatbot,aiml","A_Id":14879572,"CreationDate":"2013-01-20T00:21:00.000","Title":"How to set the master's name of a chatbot using PyAIML?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a shell script which launches many different python scripts.\nThe shell script exports many variables, which are in turn used by the python scripts.\nThis is working perfectly when run in command line, but it does not work when executed in crontab.\nIn the cron logs, I could see the shell script working, but the python script does not seem to run.\n\nWill the python scripts be able to run from the shell script in cron?\nWill the python scripts be able to access the env variables set by the parent shell script from cron?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":147,"Q_Id":14427475,"Users Score":0,"Answer":"If you're having problems it's a good idea to use full qualified paths to commands in any script that's being called from cron, so as to avoid PATH and environment variable issues with the bare-bones environment that cron is called in.","Q_Score":1,"Tags":"python,shell,cron","A_Id":17640694,"CreationDate":"2013-01-20T18:00:00.000","Title":"Child script execution 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},{"Question":"I'm developing a distribution for the Python package I'm writing so I can post\nit on PyPI. It's my first time working with distutils, setuptools, distribute,\npip, setup.py and all that and I'm struggling a bit with a learning curve\nthat's quite a bit steeper than I anticipated :)\nI was having a little trouble getting some of my test data files to be\nincluded in the tarball by specifying them in the data_files parameter in setup.py until I came across a different post here that pointed me\ntoward the MANIFEST.in file. Just then I snapped to the notion that what you\ninclude in the tarball\/zip (using MANIFEST.in) and what gets installed in a\nuser's Python environment when they do easy_install or whatever (based on what\nyou specify in setup.py) are two very different things; in general there being\na lot more in the tarball than actually gets installed.\nThis immediately triggered a code-smell for me and the realization that there\nmust be more than one use case for a distribution; I had been fixated on the\nonly one I've really participated in, using easy_install or pip to install a\nlibrary. And then I realized I was developing work product where I had only a\npartial understanding of the end-users I was developing for.\nSo my question is this: \"What are the use cases for a Python distribution\nother than installing it in one's Python environment? Who else am I serving\nwith this distribution and what do they care most about?\"\nHere are some of the working issues I haven't figured out yet that bear on the\nanswer:\n\nIs it a sensible thing to include everything that's under source control\n(git) in the source distribution? In the age of github, does anyone download\na source distribution to get access to the full project source? Or should I\njust post a link to my github repo? Won't including everything bloat the\ndistribution and make it take longer to download for folks who just want to\ninstall it?\nI'm going to host the documentation on readthedocs.org. Does it make any\nsense for me to include HTML versions of the docs in the source\ndistribution?\nDoes anyone use python setup.py test to run tests on a source\ndistribution? If so, what role are they in and what situation are they in? I\ndon't know if I should bother with making that work and if I do, who to make\nit work for.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":476,"Q_Id":14436912,"Users Score":4,"Answer":"Some things that you might want to include in the source distribution but maybe not install include:\n\nthe package's license\na test suite\nthe documentation (possibly a processed form like HTML in addition to the source)\npossibly any additional scripts used to build the source distribution\n\nQuite often this will be the majority or all of what you are managing in version control and possibly a few generated files.\nThe main reason why you would do this when those files are available online or through version control is so that people know they have the version of the docs or tests that matches the code they're running.\nIf you only host the most recent version of the docs online, then they might not be useful to someone who has to use an older version for some reason.  And the test suite on the tip in version control may not be compatible with the version of the code in the source distribution (e.g. if it tests features added since then).  To get the right version of the docs or tests, they would need to comb through version control looking for a tag that corresponds to the source distribution (assuming the developers bothered tagging the tree).  Having the files available in the source distribution avoids this problem.\nAs for people wanting to run the test suite, I have a number of my Python modules packaged in various Linux distributions and occasionally get bug reports related to test failures in their environments.  I've also used the test suites of other people's modules when I encounter a bug and want to check whether the external code is behaving as the author expects in my environment.","Q_Score":5,"Tags":"python,pip,setuptools,distutils,distribute","A_Id":14437754,"CreationDate":"2013-01-21T10:43:00.000","Title":"What are the use cases for a Python 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":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I want to write some code to do acoustic analysis and I'm trying to determine the proper tool(s) for the job. I would normally write something like this in Python using numpy and scipy and possibly Cython for the analysis part. I've discovered that the world of Python audio libraries is a bit chaotic, with scads of very limited packages in various states of development.\nI've also come across a bunch of audio\/acoustic specific languages like SuperCollider, Faust, etc. that seem to make the audio processing easy but may be limited in terms of IO and analysis capability.\nI'm currently working on Linux with Alsa and PulseAudio installed by default. I would prefer not to involve and of the various and sundry other audio packages like Jack if possible, though that is not a hard requirement.\nMy primary interest in this question is to determine whether there is a domain specific language that will provide for quicker prototyping and testing or whether a general language like Python is more appropriate. Thanks.","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":519,"Q_Id":14469941,"Users Score":0,"Answer":"I'm not 100% sure what you want to do, but as an additional suggestion I would put forth: Spear with scripting in Common Lisp. If what you are doing involves a great deal of spectral analysis, then you can do the heavy Lifting in Spear, and script all of this using Common List with Common Music. Spear has some great tools in terms of editing out very specific partials.","Q_Score":0,"Tags":"python,audio,dsl,supercollider","A_Id":16253793,"CreationDate":"2013-01-22T23:29:00.000","Title":"Audio Domain Specific Language vs 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},{"Question":"I want to write some code to do acoustic analysis and I'm trying to determine the proper tool(s) for the job. I would normally write something like this in Python using numpy and scipy and possibly Cython for the analysis part. I've discovered that the world of Python audio libraries is a bit chaotic, with scads of very limited packages in various states of development.\nI've also come across a bunch of audio\/acoustic specific languages like SuperCollider, Faust, etc. that seem to make the audio processing easy but may be limited in terms of IO and analysis capability.\nI'm currently working on Linux with Alsa and PulseAudio installed by default. I would prefer not to involve and of the various and sundry other audio packages like Jack if possible, though that is not a hard requirement.\nMy primary interest in this question is to determine whether there is a domain specific language that will provide for quicker prototyping and testing or whether a general language like Python is more appropriate. Thanks.","AnswerCount":3,"Available Count":2,"Score":0.2605204458,"is_accepted":false,"ViewCount":519,"Q_Id":14469941,"Users Score":4,"Answer":"I've got a lot of experience with SuperCollider and Python (with and without Numpy). I do a lot of audio analysis, and I'm afraid the answer depends on what you want to do.\n\nIf you want to create systems that will input OR output audio in real time, then Python is not a good choice. The audio I\/O libraries (as you say) are a bit sketchy. There's also a fundamental issue that Python's garbage collector is not really designed for realtime stuff. You should use a system that is designed from the ground up for realtime. SuperCollider is nice for this, and as caseyanderson notes, some of the standard building-blocks for audio analysis are right there. There are other environments too.\nIf you want to do hardcore work such as applying various machine learning algorithms, not necessarily in real time (i.e. if you can get away with reading\/writing WAV files rather than live audio), then you should use a general-purpose programming language with wide support, and an ecosystem of good libraries for the extra things you want. Using Python with libs such as numpy and scikits-learn works great for this. It's good for quick prototyping, but not only does it lack solid realtime audio, it also has far fewer of the standard audio building-blocks. Those are two important things which hold you back when prototyping audio pipelines.\n\nSo, then, you're caught between these two options. Depending on your application you may be able to combine the two by manipulating the audio I\/O in a realtime environment, and using OSC messaging or shell scripts to communicate with an external Python process. The limitation there is that you can't really throw masses of data around between the two (you can't sensibly pipe all your audio across to some other process, that'd be silly).","Q_Score":0,"Tags":"python,audio,dsl,supercollider","A_Id":14707108,"CreationDate":"2013-01-22T23:29:00.000","Title":"Audio Domain Specific Language vs 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},{"Question":"I have a weather station supplying me data every 2.5 seconds. (using weewx)\nI want to show this live on my website using highcharts to plot live data.\nCurrently i can pickup the messages from the redis channel 'weather' using Predis just to test.\nThe issue is that the data is only sent every 2.5, so when a users opens the php site he sometimes has to wait 2.5 seconds for the chart to appear.\nDo you have any suggestions to get around this issue?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":238,"Q_Id":14508976,"Users Score":0,"Answer":"Store the data manually the very first time (while developing the software).\nEvery 2.5 seconds of running, use polling to check for updated data. If the data is updated, then update the data currently stored.\n\nWhen the user logs on, you plot the chart with the values in the database.","Q_Score":0,"Tags":"php,python,redis","A_Id":14511844,"CreationDate":"2013-01-24T19:15:00.000","Title":"Redis: Live data via 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},{"Question":"I have a weather station supplying me data every 2.5 seconds. (using weewx)\nI want to show this live on my website using highcharts to plot live data.\nCurrently i can pickup the messages from the redis channel 'weather' using Predis just to test.\nThe issue is that the data is only sent every 2.5, so when a users opens the php site he sometimes has to wait 2.5 seconds for the chart to appear.\nDo you have any suggestions to get around this issue?","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":238,"Q_Id":14508976,"Users Score":0,"Answer":"What you should do is have a second listener dump data into a key current_weather every time an event comes across. When you first load the page, pull from that key to build the chart, then start listening for updates.","Q_Score":0,"Tags":"php,python,redis","A_Id":14511705,"CreationDate":"2013-01-24T19:15:00.000","Title":"Redis: Live data via 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},{"Question":"I do not understand the difference between setting up a Unencrypted Session Factory in order to set cookies, as compared to using request.response.set_cookie(..) and request.cookies[key].","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":451,"Q_Id":14531396,"Users Score":8,"Answer":"The UnencryptedCookieSessionFactory manages one cookie, that is signed. This means that the client can read1 what is in the cookie, but cannot change the values in the cookie.\nIf you set cookies directly using response.set_cookie(), the client can not only read the cookie, they can change the value of the cookie and you won't be able to detect that the contents have been tampered with.\nMoreover, the UnencryptedCookieSessionFactory let's you store any python structure and it'll take care of encoding these to fit within the limitations of a cookie; you'd have to do the same work manually with .set_cookie().\n1 You'd have to base64-decode the cookie, then use the pickle module to decode the contents. Because the cookie is cryptographically signed, the usual security concerns that apply to pickle are mitigated.","Q_Score":2,"Tags":"python,python-2.7,pyramid","A_Id":14539402,"CreationDate":"2013-01-25T22:31:00.000","Title":"In Pyramid Framework what is the difference between default Unencrypted Session Factory and setting cookies manually?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I would like to take snippets of text and convert them, programmatically, to be more phonetic than traditional English spellings.  The purpose of this is for converting a bunch of text I'm working with to a version that can be read by common TTS tools in a more natural way for a scientific application.  \nMany of the terms and acronyms are common, but there are a variety that are not.  I am hoping to find a script or resource of some kind that already has much of this effort done (realizing I will have to do a bit of customization as per these terms), however so far I've found nothing that goes down this path.\nI HAVE found solutions that are truly phonetic and are for linguistic applications, however these are not desirable as they are not readable by standard off the shelf TTS solutions that I've used.\nAny ideas of a starting point for this situation?  Any examples or even libs that make this easier to chew would be fine.  Or am I bound to sit down and grind out a solution entirely of my own design?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":894,"Q_Id":14544627,"Users Score":1,"Answer":"Here is an idea that should work :\n\nUse a cunning, \"linguist\"-grade phoneticizer.\nUse a standard, small table of phonetic to English syllable  ( in the English accent of your choosing ), mappings.\nRun the resulting \"phonetically spelled\" words through a standard, OTS TTS product .\n\nSo, for example, you can have :\nFish and chips ----step 1---> phonetic linguist code ---step 2. (new Zealand accent)---> fush und chupsh ---step 3. ---> audio pleasure\nHope this assists you!","Q_Score":1,"Tags":"python,ruby,text-to-speech","A_Id":14544779,"CreationDate":"2013-01-27T05:09:00.000","Title":"Programmatically convert text to phonetic TTS readable text?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have medium amateur skills in Python and I'm beginner in asm and haven't any knowledge of C-language.\nI know that python C-extensions must follow specific interface to work fine.\nIs this possible to write python extension in pure Assembly with the right interface and full functionality? The second question is would it be efficient enough if case of doing it right?\nWhile googling I haven't found any examples of code or some articles or solutions about this question.\nAnd this ISN'T the question about running asm-code from within Python so it's not duplicate of topics on SO.","AnswerCount":3,"Available Count":2,"Score":1.0,"is_accepted":false,"ViewCount":1492,"Q_Id":14546610,"Users Score":6,"Answer":"In theory - it is possible.\nIn practice - it is highly impractical to do so. \nThere are very very few cases where there is justified usage of Assembly over C, and even if you face such a situation, it is highly unlikely you will be working with Python in that case.\nAlso note, that the compiler can optimize the C code to extremely efficient assembly. In fact it is highly unlikely that you will hand write assembly and it will be more efficient that the compiler output, unless you are have extremely potent assembly skills, or have been writing assembly all your life..","Q_Score":1,"Tags":"python,assembly,python-extensions","A_Id":14546652,"CreationDate":"2013-01-27T10:50:00.000","Title":"How to write python extensions in pure asm and would it be efficient?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have medium amateur skills in Python and I'm beginner in asm and haven't any knowledge of C-language.\nI know that python C-extensions must follow specific interface to work fine.\nIs this possible to write python extension in pure Assembly with the right interface and full functionality? The second question is would it be efficient enough if case of doing it right?\nWhile googling I haven't found any examples of code or some articles or solutions about this question.\nAnd this ISN'T the question about running asm-code from within Python so it's not duplicate of topics on SO.","AnswerCount":3,"Available Count":2,"Score":0.1325487884,"is_accepted":false,"ViewCount":1492,"Q_Id":14546610,"Users Score":2,"Answer":"You could write your asm as inline asm inside your c extention, as for efficiency... \n\nTeapot.\n\nEfficiency isn't measured by the choice of language, its measured by how well its implemented and how well its designed.","Q_Score":1,"Tags":"python,assembly,python-extensions","A_Id":14546657,"CreationDate":"2013-01-27T10:50:00.000","Title":"How to write python extensions in pure asm and would it be efficient?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Is there any way to check if object is an instance of a class? Not an instance of a concrete class, but an instance of any class.\nI can check that an object is not a class, not a module, not a traceback etc., but I am interested in a simple solution.","AnswerCount":12,"Available Count":2,"Score":0.0333209931,"is_accepted":false,"ViewCount":140863,"Q_Id":14549405,"Users Score":2,"Answer":"Yes. Accordingly, you can use hasattr(obj, '__dict__') or obj is not callable(obj).","Q_Score":116,"Tags":"python,object,instance","A_Id":55782792,"CreationDate":"2013-01-27T16:23:00.000","Title":"Python check instances of classes","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Is there any way to check if object is an instance of a class? Not an instance of a concrete class, but an instance of any class.\nI can check that an object is not a class, not a module, not a traceback etc., but I am interested in a simple solution.","AnswerCount":12,"Available Count":2,"Score":0.0333209931,"is_accepted":false,"ViewCount":140863,"Q_Id":14549405,"Users Score":2,"Answer":"It's a bit hard to tell what you want, but perhaps inspect.isclass(val) is what you are looking for?","Q_Score":116,"Tags":"python,object,instance","A_Id":14549914,"CreationDate":"2013-01-27T16:23:00.000","Title":"Python check instances of classes","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I need to make computations in a python program, and I would prefer to make some of them in R. Is it possible to embed R code in python ?","AnswerCount":3,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":13823,"Q_Id":14551472,"Users Score":3,"Answer":"When I need to do R calculations, I usually write R scripts, and run them from Python using the subprocess module. The reason I chose to do this was because the version of R I had installed (2.16 I think) wasn't compatible with RPy at the time (which wanted 2.14).\nSo if you already have your R installation \"just the way you want it\", this may be a better option.","Q_Score":13,"Tags":"python,r","A_Id":14552819,"CreationDate":"2013-01-27T19:48:00.000","Title":"Embed R code in 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":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am working on an application which uses Boost.Python to embed the Python interpreter. This is used to run user-generated \"scripts\" which interact with the main program.\nUnfortunately, one user is reporting runtime error R6034 when he tries to run a script. The main program starts up fine, but I think the problem may be occurring when python27.dll is loaded.\nI am using Visual Studio 2005, Python 2.7, and Boost.Python 1.46.1. The problem occurs only on one user's machine. I've dealt with manifest issues before, and managed to resolve them, but in this case I'm at a bit of a loss.\nHas anyone else run into a similar problem? Were you able to solve it? How?","AnswerCount":13,"Available Count":5,"Score":-0.0153834017,"is_accepted":false,"ViewCount":52195,"Q_Id":14552348,"Users Score":-1,"Answer":"Adding this answer for who is still looking for a solution. ESRI released a patch for this error. Just download the patch from their website (no login required), install it and it will solve the problem. I downloaded the patch for 10.4.1 but there are maybe patches for other versions also.","Q_Score":41,"Tags":"visual-c++,python-2.7,visual-studio-2005,manifest,boost-python","A_Id":45562941,"CreationDate":"2013-01-27T21:10:00.000","Title":"Runtime error R6034 in embedded Python 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":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am working on an application which uses Boost.Python to embed the Python interpreter. This is used to run user-generated \"scripts\" which interact with the main program.\nUnfortunately, one user is reporting runtime error R6034 when he tries to run a script. The main program starts up fine, but I think the problem may be occurring when python27.dll is loaded.\nI am using Visual Studio 2005, Python 2.7, and Boost.Python 1.46.1. The problem occurs only on one user's machine. I've dealt with manifest issues before, and managed to resolve them, but in this case I'm at a bit of a loss.\nHas anyone else run into a similar problem? Were you able to solve it? How?","AnswerCount":13,"Available Count":5,"Score":0.0,"is_accepted":false,"ViewCount":52195,"Q_Id":14552348,"Users Score":0,"Answer":"The discussion on this page involves doing things way far advanced above me. (I don't code.) Nevertheless, I ran Process Explorer as the recommended diagnostic. I found that another program uses and needs msvcr90.dll in it's program folder. Not understanding anything else being discussed here, as a wild guess I temporarily moved the dll to a neighboring program folder.\nProblem solved. End of Runtime error message.\n(I moved the dll back when I was finished with the program generating the error message.)\nThank you all for your help and ideas.","Q_Score":41,"Tags":"visual-c++,python-2.7,visual-studio-2005,manifest,boost-python","A_Id":33030097,"CreationDate":"2013-01-27T21:10:00.000","Title":"Runtime error R6034 in embedded Python 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":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am working on an application which uses Boost.Python to embed the Python interpreter. This is used to run user-generated \"scripts\" which interact with the main program.\nUnfortunately, one user is reporting runtime error R6034 when he tries to run a script. The main program starts up fine, but I think the problem may be occurring when python27.dll is loaded.\nI am using Visual Studio 2005, Python 2.7, and Boost.Python 1.46.1. The problem occurs only on one user's machine. I've dealt with manifest issues before, and managed to resolve them, but in this case I'm at a bit of a loss.\nHas anyone else run into a similar problem? Were you able to solve it? How?","AnswerCount":13,"Available Count":5,"Score":0.0614608973,"is_accepted":false,"ViewCount":52195,"Q_Id":14552348,"Users Score":4,"Answer":"(This might be better as a comment than a full answer, but my dusty SO acct. doesn't yet have enough rep for that.) \nLike the OP I was also using an embedded Python 2.7 and some other native assemblies.  \nComplicating this nicely was the fact that my application was a med-large .Net solution running on top of 64-Bit IIS Express (VS2013).  \nI tried Dependency Walker (great program, but too out of date to help with this), and Process Monitor (ProcMon -- which probably did find some hints, but even though I was using filters the problems were buried in thousands of unrelated operations, better filters may have helped).\nHowever, MANY THANKS to Michael Cooper!  Your steps and Process Explorer (procexp) got me quickly to a solution that had been dodging me all day.  \nI can add a couple of notes to Michael's excellent post.  \n\nI ignored (i.e. left unchanged) not just the \\WinSxS\\... folder but also the \\System32\\... folder.  \n\nUltimately I found msvcr90.dll being pulled in from:\n\nC:\\Program Files (x86)\\Intel\\OpenCL SDK\\2.0\\bin\\x64\n\nGoing through my Path I found the above and another, similar directory which seemed to contain 32-bit versions.  I removed both of these, restarted and... STILL had the problem.  \nSo, I followed Michael's steps once more, and, discovered another msvcr90.dll was now being loaded from: \n\nC:\\Program Files\\Intel\\iCLS Client\\\n\nGoing through my Path again, I found the above and an (x86) version of this directory as well.  So, I removed both of those, applied the changes, restarted VS2013 and...\nNo more R6034 Error! \nI can't help but feel frustrated with Intel for doing this.  I had actually found elsewhere online a tip about removing iCLS Client from the Path.  I tried that, but the symptom was the same, so, I thought that wasn't the problem.  Sadly iCLS Client and OpenCL SDK were tag-teaming my iisexpress.  If I was lucky enough to remove either one, the R6034 error remained.  I had to excise both of them in order to cure the problem.  \nThanks again to Michael Cooper and everyone else for your help!","Q_Score":41,"Tags":"visual-c++,python-2.7,visual-studio-2005,manifest,boost-python","A_Id":31012118,"CreationDate":"2013-01-27T21:10:00.000","Title":"Runtime error R6034 in embedded Python 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":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am working on an application which uses Boost.Python to embed the Python interpreter. This is used to run user-generated \"scripts\" which interact with the main program.\nUnfortunately, one user is reporting runtime error R6034 when he tries to run a script. The main program starts up fine, but I think the problem may be occurring when python27.dll is loaded.\nI am using Visual Studio 2005, Python 2.7, and Boost.Python 1.46.1. The problem occurs only on one user's machine. I've dealt with manifest issues before, and managed to resolve them, but in this case I'm at a bit of a loss.\nHas anyone else run into a similar problem? Were you able to solve it? How?","AnswerCount":13,"Available Count":5,"Score":0.0,"is_accepted":false,"ViewCount":52195,"Q_Id":14552348,"Users Score":0,"Answer":"In my case the rebuilding of linked libraries and the main project with similar \"Runtime execution libraries\" project setting helped. Hope that will be usefull for anybody.","Q_Score":41,"Tags":"visual-c++,python-2.7,visual-studio-2005,manifest,boost-python","A_Id":28445016,"CreationDate":"2013-01-27T21:10:00.000","Title":"Runtime error R6034 in embedded Python 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":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am working on an application which uses Boost.Python to embed the Python interpreter. This is used to run user-generated \"scripts\" which interact with the main program.\nUnfortunately, one user is reporting runtime error R6034 when he tries to run a script. The main program starts up fine, but I think the problem may be occurring when python27.dll is loaded.\nI am using Visual Studio 2005, Python 2.7, and Boost.Python 1.46.1. The problem occurs only on one user's machine. I've dealt with manifest issues before, and managed to resolve them, but in this case I'm at a bit of a loss.\nHas anyone else run into a similar problem? Were you able to solve it? How?","AnswerCount":13,"Available Count":5,"Score":0.0,"is_accepted":false,"ViewCount":52195,"Q_Id":14552348,"Users Score":0,"Answer":"In my case, I realised the problem was coming when, after compiling the app into an exe file, I would rename that file. So leaving the original name of the exe file doesn't show the error.","Q_Score":41,"Tags":"visual-c++,python-2.7,visual-studio-2005,manifest,boost-python","A_Id":32307577,"CreationDate":"2013-01-27T21:10:00.000","Title":"Runtime error R6034 in embedded Python 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":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Basically I have code completion working (to the best of my knowledge that it 'works') in Eclipse, but it's not nearly as good as what Visual Studio has. I have it set to call auto-complete when ( is pressed, but doing this does not show a list of the method parameters. I have to mouse over the method for that to happen, and I'd prefer for it to happen while I type, like Intellisense in VS.\nI'm using Aptana 3 with PyDev if it's relevant.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2276,"Q_Id":14563584,"Users Score":0,"Answer":"Just press Ctrl + Space, as Jonas Karlsson said.","Q_Score":5,"Tags":"python,eclipse,autocomplete","A_Id":46099882,"CreationDate":"2013-01-28T13:54:00.000","Title":"How do I get Eclipse to show me a method's signature while typing?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"Here's my problem:\nSuppose there's a course for robots to go through, and there's an overhead webcam that can see the whole of it, and which the robot can use to navigate. Now the question is, what's the best way to detect the robot (position and heading) on the image of this webcam? I was thinking about a few solutions, like putting leds on it, or two separate colored circles, but those doesn't seem to be the best way to do it.\nIs there a better solution to this, and if yes, I would really appreciate some opencv2 python code example of it, as I'm new to computer vision.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":684,"Q_Id":14571975,"Users Score":1,"Answer":"I'd do the following, and I'm pretty sure it would work:\nI assume that the background of the video stream (the robots vicinity) is pretty static, so the firs step is:\n1. background subtraction\n2. detect movement in the foreground, this is your robot and everything else that changes from the background model, you'll need some thresholding here\n3. connected-component detection to get the blobs\n4. identify the blob corresponding to the robot (biggest?)\n5. now you can get the coordinates of the blob\n6. you can compute the heading if you track your blob through multiple frames\nyou can find good examples by googling the keywords\nDistinctive color would work with color filtering and template matching and the likes, but the above method is more general.","Q_Score":0,"Tags":"python,opencv,computer-vision,robot","A_Id":14572614,"CreationDate":"2013-01-28T21:55:00.000","Title":"How can I detect my robot from an overhead webcam 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":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Is it possible to use Pyro and gevent together? How would I go about doing this?\nPyro wants to have its own event loop, which underneath probably uses epoll etc. I am having trouble reconciling the two.\nHelp would be appreciated.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":304,"Q_Id":14575161,"Users Score":1,"Answer":"I use gevent.spawn(daemon.requestLoop). I can't say more without knowing more about the specifics.","Q_Score":1,"Tags":"python,gevent,pyro","A_Id":18750345,"CreationDate":"2013-01-29T03:24:00.000","Title":"How can I use Pyro 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":0},{"Question":"I would like to achieve the following things:\nGiven file contains a job list which I need to execute one by one in a remote server using SSH APIs and store results.\nWhen I try to call the following command directly on remote server using putty it executes successfully but when I try to execute it through python SSH programming it says cant find autosys.ksh.\nautosys.ksh autorep -J JOB_NAME\nAny ideas? Please help. Thanks in advance.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1343,"Q_Id":14587135,"Users Score":0,"Answer":"After reading your comment on the first answer, you might want to create a bash script with bash path as the interpreter line and then the  autosys commands.\nThis will create a bash shell and run the commands from the script in the shell.\nAgain, if you are using autosys commands in the shell you better set autosys environment up for the user before running any autosys commands.","Q_Score":0,"Tags":"python,unix,ssh,autosys","A_Id":18859497,"CreationDate":"2013-01-29T16:08:00.000","Title":"How to call .ksh file as part of Unix command through 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},{"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},{"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},{"Question":"I cannot run any script by pressing F5 or selecting run from the menus in IDLE. It stopped working suddenly. No errors are coughed up. IDLE simply does nothing at all.\nTried reinstalling python to no effect.\nCannot run even the simplest script.\nThank you for any help or suggestions you have.\nRunning Python 2.6.5 on windows 7.\nCould not resolve the problem with idle. I have switched to using pyDev in Aptana Studio 3.","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":7570,"Q_Id":14592879,"Users Score":1,"Answer":"Your function keys are locked,I think so.\nFunction keys can be unlocked by  fn key + esc.\nThen f5 will work without any issue.","Q_Score":4,"Tags":"python,python-idle","A_Id":62436025,"CreationDate":"2013-01-29T21:44:00.000","Title":"IDLE no longer runs any script on pressing F5","Data Science and Machine Learning":0,"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},{"Question":"I cannot run any script by pressing F5 or selecting run from the menus in IDLE. It stopped working suddenly. No errors are coughed up. IDLE simply does nothing at all.\nTried reinstalling python to no effect.\nCannot run even the simplest script.\nThank you for any help or suggestions you have.\nRunning Python 2.6.5 on windows 7.\nCould not resolve the problem with idle. I have switched to using pyDev in Aptana Studio 3.","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":7570,"Q_Id":14592879,"Users Score":1,"Answer":"I am using a Dell laptop, and ran into this issue.  I found that if I pressed Function + F5, the program would run.\nOn my laptop keyboard, functions key items are in blue (main functions in white).  The Esc (escape) key has a blue lock with 'Fn' on it.  I pressed Esc + F5, and it unlocked my function keys.  I can now run a program in the editor by only pressing F5\nNote: Running Python 3 - but I do not think this is an issue with Idle or Python - I think this is a keyboard issue.","Q_Score":4,"Tags":"python,python-idle","A_Id":48695999,"CreationDate":"2013-01-29T21:44:00.000","Title":"IDLE no longer runs any script on pressing F5","Data Science and Machine Learning":0,"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},{"Question":"I have a python code (name.py) written in separate file and now I want to execute that code using sikuli.\nI have tried\n        openApp but its not working\ncould be possible I did some mistake but still looking for working logic.","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":3069,"Q_Id":14599820,"Users Score":0,"Answer":"Do you want to run the file as an executable script or use its contents?\nAs an executable script make sure that the file is a valid script and will execute something when called and then use suprocess.Popen() from another .py file to execute that file.\nTo use the module's contents make sure the file is on the PYTHONPATH and use import name and everything within name will now be available for use.","Q_Score":1,"Tags":"python,sikuli","A_Id":31121679,"CreationDate":"2013-01-30T08:44:00.000","Title":"How to execute python script file (filename.py) using sikuli","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I want to fetch the commit message to my bitbucket repository each time a user is doing any push operation.\nHow can I do that?\nI am in development version. So is there any way by which I can post to localhost\/someurl for each commit from my repository.\nElse suggest other ways by which I can achieve this.\nThanks in advance for help.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":258,"Q_Id":14624421,"Users Score":0,"Answer":"Select the administration menu for the repository (the gear symbol), then Services. There you can set up integration with external services, such as email or twitter.","Q_Score":0,"Tags":"python,post,push-notification,bitbucket,githooks","A_Id":14627911,"CreationDate":"2013-01-31T11:16:00.000","Title":"get bitbucket commit message for each push","Data Science and Machine Learning":0,"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},{"Question":"For a project I am working on I would like to use a pgcrypto compatible encryption in python. And specific the public key encryption part.\nThe problem I have is that most (all) of the implementations make use of subprocess like approaches to fork gpg, as I have to encrypt a lot of data (50.000+ entries per session) this approach will not work for me.\nCan someone give me some pointers how that this could be achieved?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":690,"Q_Id":14643282,"Users Score":1,"Answer":"Have a look at PyCrypto, it doesn't seem to use forking. pgcrypto can be configured to fit most crypto configurations.","Q_Score":4,"Tags":"python,postgresql,public-key-encryption,gnupg,pgcrypto","A_Id":14660589,"CreationDate":"2013-02-01T09:34:00.000","Title":"How to encrypt in a pgcrypto compatible way 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},{"Question":"My project requires such that my python files have to be converted to py2exe. Fair and well , my py2exe is working. Assume my binary is called as \"test.exe\". I know that my test.exe contains all pyc files of my python file. What i want to do is , protect my text.exe, so that my source is not seen, in other words i dont want it be decompiled back, what can i do for this ?","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":930,"Q_Id":14644986,"Users Score":2,"Answer":"In short: nothing. Any executable can always be reverse-engineered.\nMore in detail: do you really think your code is so valuable that people would go to spend months to do that?\nAlso keep in mind that if you import any module released under GPL, you would be doing something illegal in not having your code as GPL as well.","Q_Score":1,"Tags":"python,py2exe","A_Id":14645057,"CreationDate":"2013-02-01T11:08:00.000","Title":"protect binary generated from py2exe 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},{"Question":"Is there a module for Python to open IBM SPSS (i.e. .sav) files? It would be great if there's something up-to-date which doesn't require any additional dll files\/libraries.","AnswerCount":9,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":47105,"Q_Id":14647006,"Users Score":3,"Answer":"But the benefit of using the IBM libraries is that they get this rather complex binary file format right.  They are free, relieve you of the burden of writing code for this format, and the license permits you to redistribute them.  What more could you ask?","Q_Score":39,"Tags":"python,dataset,statistics,python-module,spss","A_Id":14669613,"CreationDate":"2013-02-01T13:07:00.000","Title":"Is there a Python module to open SPSS 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":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"We test an application developed in house using a python test suite which accomplishes web navigations\/interactions through Selenium WebDriver.  A tricky part of our web testing is in dealing with a series of pdf reports in the app.  We are testing a planned upgrade of Firefox from v3.6 to v16.0.1, and it turns out that the way we captured reports before no longer works, because of changes in the directory structure of firefox's temp folder.  I didn't write the original pdf capturing code, but I will refactor it for whatever we end up using with v16.0.1, so I was wondering if there' s a better way to save a pdf using Python's selenium webdriver bindings than what we're currently doing.\nPreviously, for Firefox v3.6, after clicking a link that generates a report, we would scan the \"C:\\Documents and Settings\\\\Local Settings\\Temp\\plugtmp\" directory for a pdf file (with a specific name convention) to be generated.  To be clear, we're not saving the report from the webpage itself, we're just using the one generated in firefox's Temp folder.\nIn Firefox 16.0.1, after clicking a link that generates a report, the file is generated in \"C:\\Documents and Settings\\ \\Local Settings\\Temp\\tmp*\\cache*\", with a random file name, not ending in \".pdf\".  This makes capturing this file somewhat more difficult, if using a technique similar to our previous one - each browser has a different tmp*** folder, which has a cache full of folders, inside of which the report is generated with a random file name.\nThe easiest solution I can see would be to directly save the pdf, but I haven't found a way to do that yet.\nTo use the same approach as we used in FF3.6 (finding the pdf in the Temp folder directory), I'm thinking we'll need to do the following:\n\nFigure out which tmp*** folder belongs to this particular browser instance (which we can do be inspecting the tmp*** folders that exist before and after the browser is instantiated)\nLook inside that browser's cache for a file generated immedaitely after the pdf report was generated (which we can by comparing timestamps)\nIn cases where multiple files are generated in the cache, we could possibly sort based on size, and take the largest file, since the pdf will almost certainly be the largest temp file (although this seems flaky and will need to be tested in practice).\n\nI'm not feeling great about this approach, and was wondering if there's a better way to capture pdf files.  Can anyone suggest a better approach?\nNote: the actual scraping of the PDF file is still working fine.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1728,"Q_Id":14651973,"Users Score":0,"Answer":"We ultimately accomplished this by clearing firefox's temporary internet files before the test, then looking for the most recently created file after the report was generated.","Q_Score":2,"Tags":"python,pdf,selenium,webdriver,selenium-webdriver","A_Id":14760698,"CreationDate":"2013-02-01T17:40:00.000","Title":"Capturing PDF files using Python Selenium Webdriver","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},{"Question":"hi i wanted to know if uploading large files like videos ( over 200 mb - 1gb) from php is a good option after setting up the server configuration like max_post_size , execution time etc. The reason i ask this question is because i read some where that when a large file is uploaded , best practice is to break that file into chunks and upload it ( I think youtube does that). Do i need to use another language like python or C++ for uploading large files or is php enough. If i need to use another language can anyone please help me with reading material for that .\nThank you.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":978,"Q_Id":14655765,"Users Score":0,"Answer":"Its not only PHP to be considered for large file uploads. Your web server also need to support that, at least in nginx. I don't know how httpd handles that, but as you said splitting in chunks are viable solution. FTP is another option.","Q_Score":1,"Tags":"php,python,web","A_Id":14655886,"CreationDate":"2013-02-01T22:02:00.000","Title":"Is php good for large file uploads such as videos","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I have 3 scripts. one is starttest.py which kicks the execution of methods called in test.py. Methods are defined in module.py.\nThere are many print statements in each of file and I want to capture each print statement in my log file from Starttest.py file itself. I tried using sys.stdout in starttest.py file but this function only takes print statements from starttest.py file. It does not have any control on test.py and module.py file print statements.\nAny suggestions to capture the print statements from all of the files in a single place only?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":109,"Q_Id":14679012,"Users Score":0,"Answer":"Maybe look at the logging module that comes with python","Q_Score":0,"Tags":"python,python-2.7","A_Id":14679195,"CreationDate":"2013-02-04T00:34:00.000","Title":"Capturing log information from bunch of python functions in single 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},{"Question":"I am looking for solutions to create a RPC client in Linux that can connect to Sun ONC RPC server.\nThe server is written in C.\nI would like to know if I can:  \n\nCreate an RPC client in Linux  \nCreate the RPC client in Python","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1821,"Q_Id":14686861,"Users Score":0,"Answer":"An ONC RPC client can be created by using the .idl file and rpcgen. The original RPC protocol precedes SOAP by several years.\nYes, you can create the RPC client in linux (see rpcgen)\nYes, you can create the RPC client in python (please see pep-0384)","Q_Score":2,"Tags":"python,c,linux,rpc","A_Id":14688041,"CreationDate":"2013-02-04T12:31:00.000","Title":"Connect to Sun ONC RPC server from 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},{"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},{"Question":"is there a posibility to make eclipse PyDev use a remote Python interpreter?\nI would like to do this, as the Linux Server I want to connect to has several optimization solvers (CPLEX, GUROBI etc.) running, that my script uses.\nCurrently I use eclipse locally to write the scripts, then copy all the files to the remote machine, log in using ssh and execute the scripts there with \"python script.py\".\nInstead I hope to click the \"run\" button and just have everything executed within my eclipse IDE.\nThanks","AnswerCount":2,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":7677,"Q_Id":14716662,"Users Score":9,"Answer":"Unfortunately no. You can remotely connect to your Linux server via Remote System Explorer (RSE). But can't use it as a remote interpreter. I use Pycharm. You can use the free Community Edition or the Professional Edition for which you have to pay for it. It is not that expensive and it has been working great for me.","Q_Score":11,"Tags":"eclipse,pydev,python","A_Id":15360958,"CreationDate":"2013-02-05T20:51:00.000","Title":"Eclipse PyDev use 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":1,"Web Development":0},{"Question":"After using cheetah and mako at their functional minimum (only for substitution) for sometime, I started asking myself whether just using string.Template wouldn't be the better and simpler approach for my use case(less deps). \nIn addition I wondered whether it would be reasonable to import these templates as .py files to avoid .open() on each call. This would make handling templates a little more complicated but other than that I'd save a lot of system calls.\nWhat do you guys think? \nI'm well aware that my present templating is speedy enough for 99.9% of the use cases I will go through.\nThank you for any Input","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":42,"Q_Id":14727628,"Users Score":0,"Answer":"After lots of trying and reading I found string.Template from the Core Library to be the fastest - I just wrapped in my own simple class to encapsulate the file-access\/reads et voil\u00e0.","Q_Score":0,"Tags":"python,performance,templating","A_Id":16305372,"CreationDate":"2013-02-06T11:12:00.000","Title":"Fastest way to do _simple_ templating 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":1},{"Question":"How can I stop, restart or start Gunicorn running within a virtualenv on a Debian system?\nI can't seem to find a solution apart from finding the PID for the gunicorn daemon and killing it.\nThank you.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":5683,"Q_Id":14736788,"Users Score":2,"Answer":"That is indeed the proper way to do it. Start it with the -p option so you don't have to guess at the PID if you have more than one instance running. You can tell gunicorn to reload your application without restarting the gunicorn process itself by sending it a SIGHUP instead of killing it.\nIf that makes you uncomfortable, you can always write a management script to put in \/etc\/init.d and start it like any other service.","Q_Score":1,"Tags":"python,python-2.7,debian,gunicorn","A_Id":14737918,"CreationDate":"2013-02-06T19:06:00.000","Title":"How can I stop, restart or start Gunicorn running within a virtualenv on a Debian 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},{"Question":"I want to display whether firewall is present or not.. if it is not enabled, the user should get an alert.. can it be done using python code?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":579,"Q_Id":14744178,"Users Score":0,"Answer":"In GNU\/linux the firewall (netfilter) is part of the kernel, so I think that if linux is on, the firewall is too.\nnext, you may ask netfilter if it is configured, and if is there any rules. for this you might parse iptables command (such as iptables -L) output.","Q_Score":0,"Tags":"python,linux","A_Id":14744411,"CreationDate":"2013-02-07T05:23:00.000","Title":"Determining presence of firewall using 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":0,"Web Development":0},{"Question":"I'm using the pyc tool to compile IronPython scripts to executables, but can they be run without IronPython installed? If so what do I have to include?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":230,"Q_Id":14746917,"Users Score":0,"Answer":"I think with py2exe and the .net framework","Q_Score":0,"Tags":"python,ironpython,exe","A_Id":14746966,"CreationDate":"2013-02-07T08:42:00.000","Title":"is it possible to run compiled iron python scripts on PCs without iron python installed?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm using the pyc tool to compile IronPython scripts to executables, but can they be run without IronPython installed? If so what do I have to include?","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":230,"Q_Id":14746917,"Users Score":2,"Answer":"Yes, you can run it on other PC's without installing IronPy or Visual Studi (ergo, off the bat).\nSometimes you'd might need the Windows runtime libraries that you compiled the application with, but other then that.. yes you can execute it on any other Windows PC equal to the one your compiled it on.\n(example, compiling on win7 will most likely run on win7 off the bat but not on a XP without the runtime libraries used on the compiling machine)","Q_Score":0,"Tags":"python,ironpython,exe","A_Id":14746941,"CreationDate":"2013-02-07T08:42:00.000","Title":"is it possible to run compiled iron python scripts on PCs without iron python installed?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have files containing compiled Python bytecode. I want to run them through my executable program without the massive overload of the Python interpreter.\nAny ideas?","AnswerCount":2,"Available Count":2,"Score":0.1973753202,"is_accepted":false,"ViewCount":457,"Q_Id":14755062,"Users Score":2,"Answer":"pyc are not compiled to machine code. Use Shedskin for that.","Q_Score":0,"Tags":"python,embed,bytecode","A_Id":14755102,"CreationDate":"2013-02-07T15:40:00.000","Title":"Is there a light version of Python that only runs .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":0,"Web Development":0},{"Question":"I have files containing compiled Python bytecode. I want to run them through my executable program without the massive overload of the Python interpreter.\nAny ideas?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":457,"Q_Id":14755062,"Users Score":0,"Answer":"You mention the massive overhead of the interpreter: do you have any evidence that the compilation step is massive overhead?  You might be misunderstanding what is in a .pyc file.  Python bytecode is not machine code, it is very high-level bytecodes that are executed by the Python interpreter.\nIn any case, no, there is not a build of Python that can run .pyc files and not .py files.","Q_Score":0,"Tags":"python,embed,bytecode","A_Id":14756123,"CreationDate":"2013-02-07T15:40:00.000","Title":"Is there a light version of Python that only runs .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":0,"Web Development":0},{"Question":"I am working on a web project with 7 developers. I setup a beta box (debian) so that we can do testing of new code before passing it to staging.\nOn the beta box, I setup Jenkins and would like to automate the merge\/testing process. We also have a test suite which I would like to tie-in somehow.\nHow should I test and run python web projects with SVN \/ Jenkins?\nI'm trying to formulate a good workflow. Right now each developer works on a feature branch, I run the code in the branch, if it looks good we merge it.\nI would love to have developers login to the beta jenkins, and tell it to build from their feature branch. Here is my plan for what Jenkins would do:\n\nMake sure the feature branch is rebased from trunk\nMake sure the beta branch is identical to trunk (overwriting any merged-in feature branches)\nMerge the feature branch into the beta branch\nKill the running server\nStart the server nohup python app.py &\nRun the test suite python test.py\nOutput the test data to the developer's view in Jenkins\nIf any of the tests fail, revert to the state before the branch was merged\n\nI'm not sure how to handle merge conflicts. Also, the above is probably bad and wrong. Any advice would be appreciated!","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":601,"Q_Id":14755065,"Users Score":3,"Answer":"The question is a bit too big to be answered in a simple post, I will therefore try to give a few hints and references as far as I see from my personal view:\nA few quick tips:\n\nI like the idea of separating the developers into branches, but I would do the testing on the feature-branch and only merge to the beta branch if the feature passes tests, this way nothing enters beta until it is tested!\nI would put the integration steps into a script outside of Jenkins. Make it part of the source code. This way you can test the script itself quickly outside of Jenkins\nUse the build-system or scripting language you feel most comfortable with, most of the steps can easily done with any programming language\nMake the script return success or failure, so Jenkins can flag the build as failed\nFor the merge-issues, you have two possibilities \n\nRequire the branch to be manually rebased before a developer can submit it for integration, check in the script and fail it if a rebase is necssary. This way merge-errors cannot happen, the build simply fails if the branch is not rebased\nIf you rather allow non-rebased merges, you need to fail the build on merge errors so the developer can manually resolve the problem (by rebasing his\/her branch before submitting again) \n\n\nHere some books that I found useful in this area:\n\nHow Google Tests Software, by James A. Whittaker, Jason Arbon, Jeff Carollo\nContinuous Delivery: Reliable Software Releases through Build, Test, and Deployment Automation by Jez Humble\n\nLet me know via comments what additional content you would like to have.","Q_Score":4,"Tags":"python,svn,jenkins,continuous-integration,release","A_Id":14828819,"CreationDate":"2013-02-07T15:40:00.000","Title":"How should our devs test python SVN branches with 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},{"Question":"I'm using twisted to get messages from internet connected sensors in order to store it to a db. I want to check these messages without interfere these process,because I need compare every message with some base values at db, if some is matched I need trigger an alert for this, and the idea is not block any process...\nMy Idea is create a new process to check and alert, but I need after the first process store the message, it will send the message to the new process in order to check and alert if is required.\nI'm need IPC for this, and I was thinking to use ZeroMQ, but also twisted have a approach to work with IPC, I think if I use ZeroMQ, but maybe it will be self-defeating...\nWhat think you about my approach? Maybe I'm completely wrong at all?\nAny advice are welcome..\nThanks\nPD:This Process will run at a dedicated server, with a expected load of 6000 msg\/hour of 1Kb each one","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1496,"Q_Id":14755187,"Users Score":3,"Answer":"All of these approaches are possible. I can only speak abstractly because I don't know the precise contours of your application.\nIf you already have a working application but it just isn't fast enough to handle the number of messages you throw at it, then identify the bottleneck. The two likely causes of your holdup are DB access or alert-triggering because either one of these are probably synchronous IO operations.\nHow you deal with this depends on your workload:\n\nIf your message rate is high and constant, then you need to make sure your database can handle this rate. If your DB can't handle it, then no amount of non-blocking message passing will help you! In this order:\n\nTry tuning your database.\nTry putting your database on a bigger comp with more memory.\nTry sharding your database across multiple machines to distribute the workload.\nOnce you know your db can handle the message rate, you can deal with other bottlenecks using other forms of parallelism.\n\nIf your message rate is bursty then you can use queueing to handle the bursts. In this order:\n\nPut a load balancer in front of a cluster of message processors. All this balancer should do is redistribute sensor messages to different machines for check-and-alert processing. The advantage of this approach is that you will probably not need to change your existing application, just run it on more machines. This works best if your load balancer does not need to wait for a response, just forward the message.\nIf your communication needs are more complex or are bidirectional, you can use a message bus (such as ZeroMQ) as the communication layer between message-processors, alert-senders, and database-checkers.  The idea is to increase parallelism by having non-blocking communication occur through the bus and having each node on the bus do one thing only. You can then alter the ratio of node types depending on how long each stage of message processing takes. (I.e. to make the queue depth equal across the entire message processing process.)","Q_Score":3,"Tags":"python,architecture,ipc,twisted,zeromq","A_Id":14763596,"CreationDate":"2013-02-07T15:46:00.000","Title":"Architecture approach with IPC, Twisted or ZeroMQ?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I'm working through Doug Hellman's \"The Python Standard Library by Example\" and came across this:\n\"1.3.2 Compiling Expressions\nre includes module-level functions for working with regular expressions as text strings, but it is more efficient to compile the expressions a program uses frequently.\"\nI couldn't follow his explanation for why this is the case.  He says that the \"module-level functions maintain a cache of compiled expressions\" and that since the \"size of the cache\" is limited, \"using compiled expressions directly avoids the cache lookup overhead.\"\nI'd greatly appreciate it if someone could please explain or direct me to an explanation that I could better understand for why it is more efficient to compile the regular expressions a program uses frequently, and how this process actually works.","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1111,"Q_Id":14755882,"Users Score":0,"Answer":"It sounds to me like the author is simply saying it's more efficient to compile a regex and save that than to count on a previously compiled version of it still being held in the module's limited-size internal cache. This is probably because to the amount of effort it takes to compile them plus the extra cache lookup overhead that must first occur being greater than the client simply storing them itself.","Q_Score":4,"Tags":"python,regex,compilation","A_Id":14756210,"CreationDate":"2013-02-07T16:22:00.000","Title":"Compiling Regular Expressions 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},{"Question":"We run a bunch of Python test scripts on a group of test stations.  The test scripts interface with hardware units on these test stations, so we're stuck running one test script at a time per station (we can't virtualize everything).  We built a tool to assign tests to different stations and report test results - this allows us to queue up thousands of tests and let these run overnight, or for any length of time.\nOccasionally, what we've found is that test stations will drop out of the cluster.  When I remotely log into them, I get a black screen, then they reboot, then upon logging in I'm notified that windows XP had a \"serious error\".  The Event Log contains a record of this error, which states Category: (102) and Event ID: 1003.\nPreviously, we found that this was caused by the creation of hundreds of temporary Firefox profiles - our tests use selenium webdriver to automate website interactions, and each time we started a new browser, a temporary Firefox profile was created.  We added a step in the cleanup between each test that empties these temporary Firefox profiles, but we're still finding that stations drop out sometime, and always with this serious error and record in the Event Log.\nI would like to find the root cause of this problem, but I don't know how to go about doing this.  I've tried searching for information about how to read event log entries, but I haven't turned up anything that helps.  I'm open to any suggestions for ways to go about debugging this issue.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":855,"Q_Id":14760751,"Users Score":0,"Answer":"I've experienced similar problems before with Firefox. The rare times that we managed to catch a machine in the act it was just not closing browser sessions. Hence the BSOD eventually. Obviously this was a bug in either webdriver, firefox, or XP (which we were also using). We solved it by aggressively killing every firefox process between each individual test. This worked for us. And because you are not running tests in parallel it would work for you as well. By agressively I mean putting an axe through it. The windows equivalent of killall -9 firefox. Because these sessions were unresponsive. \nAs to the root cause? The problem did not occur with specific versions of Firefox. But we never actually managed to debug it properly. Debugging was very difficult because it wasn't reproducible under short test runs and once the issue arose it really did cause a hard crash.","Q_Score":6,"Tags":"python,selenium,webdriver,selenium-webdriver","A_Id":21198235,"CreationDate":"2013-02-07T20:50:00.000","Title":"Python selenium webdriver tests causing \"serious error\" when run in large batches on windows XP","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},{"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},{"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},{"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},{"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},{"Question":"I am currently building a web\/desktop application. The user can create an account online and login either online or via the desktop client.\nThe client will be built in Python and exported to exe. \nI want to encrypt the password before it is sent online as the site has no https connection.\nWhat is the best way to do this so the hashed password will be the same in python and php? Or is their a better way or should I just invest in https?\nI have tried using simple hashing but php md5(\"Hello\") will return something different to python's hashlib.md5(\"Hello\").hexdigest()","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":240,"Q_Id":14799847,"Users Score":9,"Answer":"Forget this idea. Hashing the password on the client, sending the hash to the server and then compare it to the stored hash is equivalent to storing plain passwords in the database, because the hash becomes the password.\n\nOr should I just invest in https?\n\nYes!","Q_Score":0,"Tags":"php,python,passwords,password-protection,password-encryption","A_Id":14799899,"CreationDate":"2013-02-10T16:27:00.000","Title":"Password protection for Python and 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},{"Question":"Is it possible to get the user's browser width and height in Pyramid? I've searched through the response object and Googled.\nIf it's not available in Pyramid, I'll just grab it in javascript","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":118,"Q_Id":14802197,"Users Score":7,"Answer":"No, that is not possible to determine with server-side code only. Browsers do not share that information when making HTTP requests to the server.\nYou'll have to do this with JavaScript.","Q_Score":1,"Tags":"python,pyramid","A_Id":14802581,"CreationDate":"2013-02-10T20:21:00.000","Title":"Can I get the browser width and height 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},{"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},{"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},{"Question":"I am very new to linux, and i want to learn scripting. It seems like there are quite a few options to learn about scripting from bash shell scripting, python, perl lisp, and probably more that i dont know about. I am just wonder what are the  the advantage and disadvantage of all of them, and what would be a good place to start?","AnswerCount":3,"Available Count":2,"Score":0.1325487884,"is_accepted":false,"ViewCount":966,"Q_Id":14824862,"Users Score":2,"Answer":"Every programmer will have a biased answer to this, but one thing to keep in mind is what your goal is.  For instance, if you're only looking to be a successful sysadmin, then your goals might best be served by learning languages that are more conducive to sysadmin tasks (e.g. bash).  However, if you're looking to do more general programming, including data analysis, you might be better served focusing your study on more general-purpose languages like Python or Perl.  For web development, Ruby might be worth studying, etc.   It really depends on why you're interested in learning scripting.\nIf you don't really have a specific reason and are looking for general advice, it's probably wise to start with one language and get proficient at it and then expand to other languages.  The canonical path would probably be bash --> Python, these days.   Of course, this is just one person's opinion. :-)","Q_Score":0,"Tags":"python,linux,perl,scripting","A_Id":14824929,"CreationDate":"2013-02-12T03:22:00.000","Title":"different types of 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},{"Question":"I am very new to linux, and i want to learn scripting. It seems like there are quite a few options to learn about scripting from bash shell scripting, python, perl lisp, and probably more that i dont know about. I am just wonder what are the  the advantage and disadvantage of all of them, and what would be a good place to start?","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":966,"Q_Id":14824862,"Users Score":1,"Answer":"I think a lot of times, people new to programming see all the options out there and don't know where to start.  You listed a bunch of different languages in your post.  My advice would be to pick one of those languages and find a book or tutorial and work through it.\nI became interested in \"scripting\" from just trying to come up with a mIRC script that would fit my needs; however, after completing that, I changed OS from windows to Linux and mIRC scripting no longer would work for me.  So I started playing with Perl and Python to see which would work best for xChat.  \nEventually, what it all boils down with is that you'll need to experiment with a language and do some hands on learning.  I eventually completed project, and used PHP for it. While completing that, I also was working through Michael Hartl's tutorial and worked with Ruby on Rails some.  Now I'm in the process of rewriting it using Node.js (javascript). \nBest bet, just pick one language and start playing with it.","Q_Score":0,"Tags":"python,linux,perl,scripting","A_Id":14825010,"CreationDate":"2013-02-12T03:22:00.000","Title":"different types of 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},{"Question":"I am trying to connect a remote machine in python. I used telnetlib module and could connect to machine after entering login id and password as\ntn = Telnet(\"HOST IP\")\ntn.write(\"UID\")\ntn.write(\"PWD\")\nAfter entering password, the terminal connects to the remote machine which is a linux based software [having its own IP address(HOST IP).]\nThen after If I try to give a command e.g. tn.write(\"cd \/\/tmp\/media\/..) to go to its various folders then it does not work and when checked to see what the screen is showing with\ntn.read_very_eager()\nerror comes up as :\n\"\"\\r\\n\\r\\n\\r\\nBusyBox v1.19.4 (2012-07-19 22:27:43 CEST) built-in shell (ash)\\r\\n\nEnter 'help' for a list of built-in commands.\\r\\n\\r\\n~ # \"\"\nI wanted to know if there is any method in Python as we have in PERL as $telnet->cmd (\"cd \/\/tmp\/media\/..)\nAny suggestions are welcomed if you can give an example!!!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":602,"Q_Id":14825262,"Users Score":0,"Answer":"You should try to login to the machine using telnet, then you will notice you will login into BusyBox. That string you print not an error it is hte normal BusyBox prompt.\nIt might not be what you expected, I only know BusyBox from Linux boxes that were unable to properly boot.","Q_Score":0,"Tags":"python-2.7,telnetlib","A_Id":15581083,"CreationDate":"2013-02-12T04:15:00.000","Title":"How to write on terminal after login with telnet to remote machine 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},{"Question":"url = \"www.someurl.com\"\n\nrequest = urllib2.Request(url,header={\"User-agent\" : \"Mozilla\/5.0\"})\n\ncontentString = urllib2.url(request).read()\n\ncontentFile = StringIO.StringIO(contentString)\n\nfor i in range(0,2):\n    html = contentFile.readline()\n\nprint html\n\nThe above code runs fine from commandline but if i add it to a cron job it throws the following error:\n  File \"\/usr\/lib64\/python2.6\/urllib2.py\", line 409, in _open\n    '_open', req)\n  File \"\/usr\/lib64\/python2.6\/urllib2.py\", line 369, in _call_chain\n    result = func(*args)\n  File \"\/usr\/lib64\/python2.6\/urllib2.py\", line 1186, in http_open\n    return self.do_open(httplib.HTTPConnection, req)\n  File \"\/usr\/lib64\/python2.6\/urllib2.py\", line 1161, in do_open\n    raise URLError(err)\nurllib2.URLError: \n\nI did look at some tips on the other forums and tried it but it has been of no use.\nAny help will be much appreciated.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":603,"Q_Id":14827296,"Users Score":1,"Answer":"The environment variables that were used by crontab and from the command line were different.\nI fixed this by adding *\/15 * * * * . $HOME\/.profile; \/path\/to\/command. \nThis made the crontab to pick up enivronment variables that were specified for the system.","Q_Score":1,"Tags":"python,urllib2,python-2.6","A_Id":14847414,"CreationDate":"2013-02-12T07:10:00.000","Title":"Urllib2 runs fine if i run the program independently but throws error when i add it to a cronjob","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},{"Question":"I installed paramiko in my Ubuntu box \"sudo apt-get install python-paramkio\". \nBut when import the paramiko module i am getting error.\nImportError:No Module named paramiko\nWhen i list the python modules using help('modules'). i couldn't find paramiko listed.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":4876,"Q_Id":14830722,"Users Score":0,"Answer":"To use python libraries, you must have development version of python like python2.6-dev, which can be installed using sudo apt-get install python2.6-dev.\nThen you may install any additional development libraries that you want in your code to run.\nWhatever you install using sudo apt-get install python-paramkio or python setup.py install will then be available to you.","Q_Score":0,"Tags":"python,ubuntu,import,paramiko","A_Id":14832457,"CreationDate":"2013-02-12T10:47:00.000","Title":"paramiko installation \" Unable to import ImportError\"","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},{"Question":"I have to decode a string. This one comes from Flash AS3 and I want to decode it in Python. I don't have any problems with PHP, but I cannot decode the following string with Python 2.6 'base64.b64decode'.\n\nf3hvQgQaBFp9IC4NQhYZQiAhNhxBAkwIJC0pDR8fBl12ZjkWXwMEWn57bU0dGgBfcWdsTwAbGB4xLmVLAh0FXXd5a0gGHQRWdy5iQANNVAl\/KmNLAhUBXyV8PkFQHwNefntjGgpPU18nK21OURtSC35wPE4FHFUJdi4\/TlMUVFwlez9JVxtVDH0TB0IGHAc%Pr\n\nPython returns \"TypeError: Incorrect Padding\". It seems to have superfious characters at the end of the string (from the '%'). But why Python base64 library do not manage this?\nThank you for your answer.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":471,"Q_Id":14837251,"Users Score":0,"Answer":"It seems to me you are not feeding a valid string to the function - it tells you so. You can't expect a function to \"guess\" what you wanted, and base its response on that. You have to use a valid parameter, or the function doesn't work.","Q_Score":1,"Tags":"python,actionscript-3,base64,decode","A_Id":14837350,"CreationDate":"2013-02-12T16:33:00.000","Title":"Base64 decode does not work every time 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},{"Question":"When I open my Command Prompt,\nthe default path is C:\\Users\\acer>\nso I want to change the path to C:\\Python27\nthe method is as follows\ni enter cd.. 2 times..\nthen I enter cd.. Python27 \nas my Python27 folder located in C:\\\nhowever, I got this message \"the system cannot find the path specified\"\nCan anyone help me?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":7184,"Q_Id":14846333,"Users Score":0,"Answer":"Instead of \ncd.. Python27 \nyou need to type\ncd \\python27","Q_Score":0,"Tags":"python,windows-7","A_Id":14846374,"CreationDate":"2013-02-13T04:20:00.000","Title":"The system cannot find the path specified in 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":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"When I open my Command Prompt,\nthe default path is C:\\Users\\acer>\nso I want to change the path to C:\\Python27\nthe method is as follows\ni enter cd.. 2 times..\nthen I enter cd.. Python27 \nas my Python27 folder located in C:\\\nhowever, I got this message \"the system cannot find the path specified\"\nCan anyone help me?","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":7184,"Q_Id":14846333,"Users Score":1,"Answer":"No need for cd .. mumbo jumbo, just go cd C:\/Python27.","Q_Score":0,"Tags":"python,windows-7","A_Id":14846408,"CreationDate":"2013-02-13T04:20:00.000","Title":"The system cannot find the path specified in 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":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I'm generating Python script with c#. But I have to know if word is keyword. The question : is there any library for c# which i can get the python keywords ?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":114,"Q_Id":14852823,"Users Score":1,"Answer":"No, there isn't. Roll your own.","Q_Score":0,"Tags":"c#,python","A_Id":14852879,"CreationDate":"2013-02-13T11:46:00.000","Title":"How can I get python keywords 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},{"Question":"I'm trying to write a python script which will run when Maya loads. The script should check a number stored in the file somewhere, possibly just a names object, and compare it to the latest revision of the file in perforce. \nif the number stored in maya is not the latest revision, it should show a warning. is this possible?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":813,"Q_Id":14859956,"Users Score":0,"Answer":"To ask if the contents of your file on your workstation matches the content of the current head revision of the file on the server, you can do something like 'p4 diff -f \/\/depot\/path\/to\/file#head'.","Q_Score":0,"Tags":"python,perforce,maya","A_Id":14867059,"CreationDate":"2013-02-13T18:00:00.000","Title":"get the revision number of a specific file in perforce from 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":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a cron who execute 2 python scripts. How I can see with the \"ps\" command if the process are running ?\nmy scripts names are:\njson1.py\njson2.py","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":127,"Q_Id":14864378,"Users Score":0,"Answer":"ps aux | grep json ought to do it, or just pgrep -lf json.","Q_Score":0,"Tags":"python,linux,process","A_Id":14864397,"CreationDate":"2013-02-13T22:23:00.000","Title":"Unix process running 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},{"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},{"Question":"I am writing a CLI python application that has dependencies on a few libraries (Paramiko etc.).\nIf I download their source and just place them under my main application source, I can import them and everything works just fine. \nWhy would I ever need to run their setup.py installers or deal with python package managers?\nI understand that when deploying server side applications it is OK for an admin to run easy_install\/pip commands etc to install the prerequsites, but for a script like CLI apps that have to be distributed as a self-contained apps that only depend on a python binary, what is the recommented approach?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":251,"Q_Id":14895234,"Users Score":2,"Answer":"Several reasons:\n\nNot all packages are pure-python packages. It's easy to include C-extensions in your package and have setup.py automate the compilation process.\nAutomated dependency management; dependencies are declared and installed for you by the installer tools (pip, easy_install, zc.buildout). Dependencies can be declared dynamically too (try to import json, if that fails, declare a dependency on simplejson, etc.).\nCustom resource installation setups. The installation process is highly configurable and dynamic. The same goes for dependency detection; the cx_Oracle has to jump through quite some hoops to make installation straightforward with all the various platforms and quirks of the Oracle library distribution options it needs to support, for example.\n\nWhy would you still want to do this for CLI scripts? That depends on how crucial the CLI is to you; will you be maintaining this over the coming years? Then I'd still use a setup.py, because it documents what the dependencies are, including minimal version needs. You can add tests (python setup.py test), and deploy to new locations or upgrade dependencies with ease.","Q_Score":3,"Tags":"python","A_Id":14895361,"CreationDate":"2013-02-15T12:57:00.000","Title":"why run setup.py, can I just embed 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":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am using Apatana Studio 3.3.1 with PyDev 2.7 and writing code in Python 3.3.\nI was debugging my code by setting up break point in my code and click on Run>Debug, but the code has not been stopped at the breakpoint and has run through till the end.\nIn the Interpreter - Python setting, I have included the following in my libraries > System PYTHONPATH:\nC:\\Python33\\DLLs\nC:\\Python33\\lib\nC:\\Python33\nC:\\Python33\\lib\\site-packages\nThanks for any help.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":260,"Q_Id":14923821,"Users Score":1,"Answer":"You need to make sure that the run\/debug configuration uses the correct main module otherwise it will take the current windows source file to be the main module. If there is no executable code in that file, i.e. there is nothing in global scope, the file will simply run to completion.","Q_Score":2,"Tags":"debugging,python-3.x,aptana,pydev","A_Id":19110870,"CreationDate":"2013-02-17T17:23:00.000","Title":"Does Aptana Studio 3.3.1 support debugging of Python 3.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},{"Question":"I have a few thousand of very big radio-telemetry array fields of the same area in a database. The georeference of the pixels is the same for all of the array fields. An array can be loaded into memory in an all or nothing approach.\nI want to extract the pixel for a specific geo-coordinate from all the array fields. Currently I query for the index of the specific pixel for a specific geocoordinate and then load all array fields from the database into memory. However that is very IO intensive and overloads our systems. \nI'd imagine the following: I save the arrays to disk and then sequentially open them and seek to the byte-position corresponding to the pixel. I imagine that this is far less wasteful and much speedier than loading them all to memory. \nIs seeking to a position considered a fast operation or would one not do such a thing?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":95,"Q_Id":14933700,"Users Score":2,"Answer":"The time it takes for a seek operation would be measured in low milliseconds, probably less than 10 in most cases. So that wouldn't be a bottleneck.\nHowever, if you have to retrieve and save all the records from the database either way, you may end up with roughly the same IO load and perhaps greater. The IO time for writing a file is certainly greater than reading into memory.\nTime for a small-ish experiment :)  Try it with a few arrays and time the performance, then you can do the math to see how it would scale.","Q_Score":0,"Tags":"python,arrays,file,file-io,multidimensional-array","A_Id":14934694,"CreationDate":"2013-02-18T10:04:00.000","Title":"Save byte-arrays to disk to reduce memory consumption and increase speed?","Data Science and Machine Learning":0,"Database and SQL":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},{"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},{"Question":"I can see messages have a sent time when I view them in the SQS message view in the AWS console. How can I read this data using Python's boto library?","AnswerCount":2,"Available Count":1,"Score":0.2913126125,"is_accepted":false,"ViewCount":4489,"Q_Id":14945604,"Users Score":3,"Answer":"When you read a message from a queue in boto, you get a Message object.  This object has at attribute called attributes.  It is a dictionary of attributes that SQS keeps about this message.  It includes SentTimestamp.","Q_Score":7,"Tags":"python,amazon-web-services,boto,amazon-sqs","A_Id":14967271,"CreationDate":"2013-02-18T21:29:00.000","Title":"SQS: How can I read the sent time of an SQS message using Python's boto library","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},{"Question":"Is there a \"good way\" to install Pyramid without the templating systems? The templating systems I speak of are Mako and Chameleon. In Single Page Applications (SPA) there is very little need for server-side templating since all of the templates are rendered on the client-side with javascript. I like the power of Pyramid but the template system is unnecessary baggage in some cases.\nI have a feeling that the only way to accomplish this task is to fork Pyramid and modify the setup.py to remove these dependencies. That may break things,but then again, Pyramid is built in such a way that it may not care as long as nothing tries to call a renderer for one of these templates. Who knows?","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":314,"Q_Id":14949586,"Users Score":2,"Answer":"There is a project to eventually remove those templating dependancies and make them available as separate packages. The work started at last year pycon sprints and can be continued this year, who knows. OTOH having those packages installed in your venv doesn't really affect your app so just avoid using them and only use the JSON renderer or any other renderers. Instead of forking Pyramid and removing those dependancies in setup.py I propose you to join us and work on the removal project so we can all benefit the same features.","Q_Score":1,"Tags":"python,pyramid","A_Id":14950809,"CreationDate":"2013-02-19T03:57:00.000","Title":"Installing Pyramid without the template systems (Mako and Chameleon)","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I'm trying to get caught up on unit testing, and I've looked over a few books - Debugging Django, Web Dev. with Django, and the official docs, but none seem to cover unit testing thoroughly enough for me. I'm also not an expert in Python web development, so maybe that's why.\nWhat I'm looking for is something that starts at an intermediate level of python skill\/knowledge and covers Django unit testing from scratch, with a few good real-world examples.\nAny recommendations on such resources? Much appreciated.","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":311,"Q_Id":14961151,"Users Score":0,"Answer":"Did you try core developer Karen Tracy's book Django 1.1 Testing And Debugging? Although the title implies it's out of date, most of the advice is still applicable.","Q_Score":2,"Tags":"python,django,unit-testing","A_Id":14961957,"CreationDate":"2013-02-19T15:29:00.000","Title":"Learning Django 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":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"I have an Amazon Ubuntu instance which I stop and start (not terminate). I was wondering if it is possible to run a script on start and stop of the server. Specifically, I am looking at writting a python boto script to take my RDS volume offline when the EC2 server is not running.\nCan anyone tell me if this is possible please?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1561,"Q_Id":14962414,"Users Score":1,"Answer":"It is possible. You just have to write an init script and setup proper symbolic links in \/etc\/rc#.d directories. It will be started with a parameter start or stop depending on if machine is starting up or shutting down.","Q_Score":1,"Tags":"python,linux,amazon-web-services,amazon-ec2,amazon-rds","A_Id":14966165,"CreationDate":"2013-02-19T16:26:00.000","Title":"Running a script on EC2 start and stop","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":1},{"Question":"I have a python script that runs once a day, connects to our Zabbix monitoring database and pulls out all the active monitoring checks and documents them into Confluence.\nMy problem is that each hosts' confluence page gets updated every time the script runs, even if the monitoring hasn't changed.\nA quick hack would be to get a hash of the page content and compare it with a hash of the script-generated content and only replace when the hashes don't match. Obviously the problems with this are that the script still needs to generate whole page content for comparison, and that it replaces the whole page or not at all, loosing confluence's built-in diff checker.\nI'm hoping to find a more elegant solution, especially one that may allow me to update only the differences...","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":412,"Q_Id":14997400,"Users Score":0,"Answer":"This might not be the solution you are looking for, but you could have the updates generate an external html page and then use an {html-include} in confluence. So the confluence pages wouldn't be updated, but their displayed content would be correct.\nThe problem with this is that none of the confluence pages would be updated, so if you want a feed to notify people of the changes on confluence it wouldn't get the job done.","Q_Score":0,"Tags":"python,string-comparison,confluence,zabbix","A_Id":15069936,"CreationDate":"2013-02-21T08:12:00.000","Title":"Automatic Zabbix -> Confluence, creating too many updates","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"What is the best way to include a 'helper' shell script in setup.py that is used by a python module? I don't want to include is as a script since it is not run on it's own.\nAlso, data_files just copies things in the the install path (not the module install path) so that does not really seem like the best route.\nI guess the question is: is there a way of including non-python (non-C) scripts\/binaries in a python distutils package in a generic way?","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1820,"Q_Id":15009146,"Users Score":0,"Answer":"Another issue might be that such pypi packages containing Bash scripts might not run correctly on e.g. Windows?","Q_Score":3,"Tags":"python","A_Id":47823714,"CreationDate":"2013-02-21T17:59:00.000","Title":"python distutils include shell scripts in module 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},{"Question":"I want to create a serialized Python object from outside of Python (in this case, from Java) in such a way that Python can read it and treat it as if it were an object in Python. I'll start with simpler objects (int, float, String, and so on) but I'd love to know if this can be done with classes as well.\nFunctionality is first, but being able to do it quickly is a close second. The idea is that I have some data in Java land, but some business logic in Python land. I want to be able to stream data through the python logic as quickly as possible...right now, this data is being serialized as strings and I think this is fairly wasteful.\nThank you in advance","AnswerCount":1,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":65,"Q_Id":15027601,"Users Score":8,"Answer":"The best answer is to use a standardized format, such as JSON, and write up something to create the objects from that format in Python, and produce the data from Java. For simple things, this will be virtually no effort, but naturally, it'll scale up.\nTrying to emulate pickle from within Java will be more effort than it's worth, but I guess you could look into Jython if you were really set on the idea.","Q_Score":0,"Tags":"python","A_Id":15027654,"CreationDate":"2013-02-22T15:32:00.000","Title":"Is there a way to efficiently create Python objects from outside 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":1,"System Administration and DevOps":0,"Web Development":1},{"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},{"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},{"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},{"Question":"I am using pytest to run tests and, during the execution of a test, interrupted with ctrl-C. \nNo matter how many times I ctrl-C to get out of the test session (I've also tried ctrl-D to get out of the environment I'm using), my terminal prompt does not return.\nI accidentally pressed F as well... test.py ^CF^C Does the F have something to do with my being stuck in the captured stderr section and the prompt not returning?\nAre there any logic explanations why I'm stuck here, and if so, are there any alternatives to exiting this state without closing the window and force exiting the session?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1083,"Q_Id":15073210,"Users Score":7,"Answer":"I would suggest trying control-Z.  That should suspend it; you can then do kill %1 (or kill -9 %1) to kill it (assuming you don't have anything else running in the background)\nWhat I'm guessing is happening (from personal experience) is that one of your tests is running in a try \/ except that is catching all exceptions (including the keyboard interrupt which control c triggers) and is inside a while loop \/ ignoring the exception.","Q_Score":2,"Tags":"python,terminal,pytest","A_Id":15073287,"CreationDate":"2013-02-25T17:52:00.000","Title":"Unable to exit with ^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},{"Question":"Is there a bug in the Mayavi font rendering that prevents changing the font size? I am using the Mayavi2 GUI to change the font size of the axis labels on a volumetric plot.\nTo get there I go to: Scene -> Scalar Field -> Colors and Legends -> Axes -> Label Text (tab) -> Font Size\nChanging this number does not affect the size of the fonts in the image. Is this a known bug? I have seen no reference to it on Google. How do you change the text size on your mayavi figures?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1563,"Q_Id":15077984,"Users Score":0,"Answer":"I've just downloaded, and installed it, and I seem to be having the same problem. On Windows 8 right now. This is probably a bug.","Q_Score":6,"Tags":"python,text,fonts,mayavi,mayavi.mlab","A_Id":19346840,"CreationDate":"2013-02-25T22:44:00.000","Title":"Does Mayavi \"Font Size\" text property 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":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"In ipython terminal :\n%pastebin -d \"my description\" 1-150\nreturns the url to the gist. However, I want to paste it as a logged in user, into my github account. Additionally, is there a way to create private gist (rather than public) from within ipython.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":472,"Q_Id":15087499,"Users Score":1,"Answer":"It is not possible with the current code, it is not even planned on the Roadmap. \nStill this could be done as an extension.\nYou can also propose patches to current magic, Pull Request are always welcomed.","Q_Score":1,"Tags":"github,ipython,gist","A_Id":15089524,"CreationDate":"2013-02-26T11:06:00.000","Title":"How to put gist as user (and not anonymous)?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"Working with large in memory objects and was wondering if there's a way to check how much memory a python CGI process is allocated from within a script?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":149,"Q_Id":15105983,"Users Score":0,"Answer":"It is very unlikely there is a standard way to do this. If the value is not in the environment, you can not find it programmatically. How is the script run (server, module...)?","Q_Score":0,"Tags":"python,memory,cgi","A_Id":15106075,"CreationDate":"2013-02-27T06:57:00.000","Title":"find memory limit programmatically in cgi 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},{"Question":"I need to extract process details from top command on a few *nix systems I monitor. The details needed are username, command executed, PID, PPID, username and resident memory consumption.\nIf memory usage is greater than a threshold or command is illegal, I need to send a warning to the user at username@company.com\nI am writing a script to do this in python and get the required data by executing 'top -bc -n 1' and grepping for command keyword. However, I also need to extract username for the illegal processes to send the mail warning. \nHowever, top automatically truncates usernames greater than 8 characters. How do I retrieve the full user names?","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":2320,"Q_Id":15110982,"Users Score":2,"Answer":"Consider using ps instead of top as I don't know any reasons why top would be better for this task. You can configure ps output much more flexibly than top one.","Q_Score":0,"Tags":"python,unix","A_Id":15111135,"CreationDate":"2013-02-27T11:29:00.000","Title":"How to get full user name in the output of 'top' command in *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},{"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},{"Question":"What I want to do is protect a Python program from being stolen by people with no computer knowledge. I accept the inevitability of the program being pirated, all I want to do is protect it from average users.\nI have come up with two ideas.\n1.)Set a time restriction by checking online for the date and time. I.E. 10 days from downloaded time.\n2.)Checking the IP or Name of the computer that downloaded it and make the program only runs on that computer. (to prevent friends from simply sharing the file).\nThe problem with both of these is that I'll need to create a .py file \"on the fly\" and then use something like pytoexe to make it into an .exe so that the user doesn't need to have Python installed.\nThe problem with the second is that to my understanding ip's change and getting the computer name is a security risk and might scare away users.\nSo to sum it up, here are my two questions:\n1.) Is there a good way in python to only allow the program to run on that single computer?\n2.) What is the best way to implement a \"on the fly\" creation of the exe? (I was going to host the website on my computer and learn php(?)\/servers.\nI have moderate c\/c++ and basic html\/css, java, and python experience.\nThank you for your time!","AnswerCount":4,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":2860,"Q_Id":15152785,"Users Score":1,"Answer":"Give each user a customized installer that has a unique key in it. When it runs, it contacts a server (with the key) and requests the actual program. Server-side, you check if the key is valid and if so, serve the program customized with the key, and mark the key as used. The installer saves the program somewhere the user can access it, and creates a hidden file that contains the key somewhere deep in the bowels of the computer, where the \"average user\" won't think of looking. When the program is run, the first thing it does is check if the hidden file exists and if it contains the correct key, and refuses to run if not.\n(I am assuming that unzipping an executable and reading source code is beyond the ability of the \"average user\" (read: \"grandma\"), so using py2exe is ok.)","Q_Score":0,"Tags":"python,html,css,server-side","A_Id":15152990,"CreationDate":"2013-03-01T07:34:00.000","Title":"How to protect my 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":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I could use cron, but I can't figure out if there's a way to set the right schedule. I can also check the date in Python, running the script via cron everyday, but checking the right date inside my (Python) script (which I assume has more powerful conditions).\nI thought on limiting one run on fridays between 1 and 7, and the other one on fridays between  15 and 21. But this option would have a problem on months like 3\/2013 which have 5 fridays.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2630,"Q_Id":15159027,"Users Score":0,"Answer":"Why not run the cron job each friday, but add code to write the last date ran in a file.  Check to see if two weeks has passed, rewrite the file, and run the rest of the cron job","Q_Score":2,"Tags":"python,cron,scheduled-tasks","A_Id":15159989,"CreationDate":"2013-03-01T13:33:00.000","Title":"How do I run a script on friday, once every two weeks?","Data Science and Machine Learning":0,"Database and SQL":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},{"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},{"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},{"Question":"I am calling a Python script from my Java code. This is the code : \n\nimport java.io.BufferedReader;\nimport java.io.IOException;\nimport java.io.InputStreamReader;\n\npublic class JavaRunCommand {\n    public static void main(String args[]) throws IOException {\n\n        \/\/ set up the command and parameter\n        String pythonScriptPath = \"my-path\";\n        String[] cmd = new String[2];\n        cmd[0] = \"python2.6\";\n        cmd[1] = pythonScriptPath;\n\n        \/\/ create runtime to execute external command\n        Runtime rt = Runtime.getRuntime();\n            Process pr = rt.exec(cmd);\n\n        \/\/ retrieve output from python script\n        BufferedReader bfr = new BufferedReader(new InputStreamReader(\n                pr.getInputStream()));\n        String line = \"\";\n        while ((line = bfr.readLine()) != null) {\n            \/\/ display each output line form python script\n            System.out.println(line);\n        }\n    }\n\n}\n\n\n python.py  which works\n\nimport os\nfrom stat import *\n\nc = 5\nprint c \n\n python.py  which does not works\n\nimport MySQLdb\nimport os\nfrom stat import *\n\nc = 5\nprint c \n# some database code down \n\nSo, I am at a critical stage where I have a deadline for my startup and I have to show my MVP project to the client and I was thinking of calling Python script like this. It works when I am printing anything without dB connection and MySQLdb library. But when I include them, it does not run the python script. Whats wrong here. Isnt it suppose to run the process handling all the inputs. I have MySQLdb installed and the script runs without the java code. \nI know this is not the best way to solve the issue. But to show something to the client I need this thing working. Any suggestions ?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":534,"Q_Id":15263854,"Users Score":0,"Answer":"So, I discovered that the issue was with the arguments that I was passing in Java to run the python program.\nThe first argument was - python 2.6 but it should have rather been just python not some version number because there was compatibility issue with MySQLdB and python.\nI finally decided to use MySQL Python connector instead of MySQLdB in python code. It worked like charm and the problems got solved !","Q_Score":3,"Tags":"java,python,jakarta-ee","A_Id":15318731,"CreationDate":"2013-03-07T05:33:00.000","Title":"Calling Python script from JAVA MySQLdb imports","Data Science and Machine Learning":0,"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},{"Question":"I want to search inside a simulink model for a particular object and point out it's directory.(Model path).","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":575,"Q_Id":15269513,"Users Score":0,"Answer":"You could also just run a MATLAB script that does a find_system on model filenames passed in and spits out the names of the blocks, thus avoiding any compatibility issues.","Q_Score":1,"Tags":"python,matlab,simulink","A_Id":15504906,"CreationDate":"2013-03-07T11:05:00.000","Title":"How can i access simulink by 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},{"Question":"I'm working on a Raspberry Pi project and I have a python script that accepts some serial input and plays sounds depending on the input. I have the script set up and it works just fine when I run it from within the GUI (i.e. startx). If I log out of the GUI and try to run the script from the command line the script executes just fine but my sounds don't play. I just get a momentary static click. I can tell the script is running because I have it printing debug code and the print's work just fine. Is there a way to get the sounds to work from the command line?\nI want this script to execute when the Raspberry Pi is turned on without user input which I believe means it will be running from the command line. If there is some reason the sounds simply won't play until the GUI starts up how would I set it up to load the GUI and then execute the script on startup without any user input?\nThis will be embedded in a prop and will play sounds when some buttons (connected through arduino i.e. serial input) are pressed. So I need a solution that will have it from power on automatically run the script and be able to play the sounds with no keyboard, mouse, or monitor attached.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1725,"Q_Id":15282925,"Users Score":0,"Answer":"Turns out it was file path naming. If I have the command line test to the root directory it doesn't work but if I \"cd Desktop\/containingFolder\" then the sounds play. I'll play with how I have the files set up in the python script so it will work.\nUpdating the path names fixed the issue. I just needed them to be full paths instead of relative ones.","Q_Score":2,"Tags":"python,audio,raspberry-pi","A_Id":15306454,"CreationDate":"2013-03-07T22:21:00.000","Title":"pygame.mixer sound not playing when script run 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":0,"Web Development":0},{"Question":"I have written a very simple command line utility for myself. The setup consists of:\n\nA single .py file containing the application\/source.\nA single executable (chmod +x) shell script which runs the python script.\nA line in my .bash_profile which aliases my command like so: alias cmd='. shellscript' (So it runs in the same terminal context.)\n\nSo effectively I can type cmd to run it, and everything works great.\nMy question is, how can I distribute this to others? Obviously I could just write out these instructions with my code and be done with it, but is there a faster way? I've occasionally seen those one-liners that you paste into your console to install something. How would I do that? I seem to recall them involving curl and piping to sh but I can't remember.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":894,"Q_Id":15283483,"Users Score":1,"Answer":"chmod +x cmd.py \nthen they can type .\/cmd.py \nthey can also use it piped.\nI would add that unix users would probably already know how to make a file executable and run it, so all you'd have to do is make the file available to them.\nDo make sure they know what version(s) of python they need to run your script.","Q_Score":5,"Tags":"python,bash,shell","A_Id":15283656,"CreationDate":"2013-03-07T22:59:00.000","Title":"How to distribute my Python\/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":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"For any particular bit of code, is there a way to easily get a breakdown of how long it took each line to execute?","AnswerCount":4,"Available Count":1,"Score":0.1488850336,"is_accepted":false,"ViewCount":2579,"Q_Id":15305899,"Users Score":3,"Answer":"Python code is not executed as is, the program you typed in is compiled into an intermediate format that is optimized. So the same line can very well take different times depending on the surrounding lines. Also, Python has complex operations on its data, the time an operation takes will depend on the exact values handled.","Q_Score":2,"Tags":"python,performance","A_Id":15305953,"CreationDate":"2013-03-09T00:57:00.000","Title":"In Python, what is the best way to determine how long each line of code takes to execute?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm building a small tool that I want to scan over a music collection, read the ID3 info of a track, and store it as long as that particular artist does not have a song that has been accessed more than twice. I'm planning on using Mutagen for reading the tags. \nHowever, the music collections of myself and many others are massive, exceeding 20,000 songs. As far as I know, libraries like Mutagen have to open and close every song to get the ID3 info from it. While MP3s aren't terribly performance-heavy, that's a lot of songs. I'm already planning a minor optimization in the form of keeping a count of each artist and not storing any info if their song count exceeds 2, but as far as I can tell I still need to open every song to check the artist ID3 tag. \nI toyed with the idea of using directories as a hint for the artist name and not reading any more info in that directory once the artist song count exceeds 2, but not everyone has their music set up in neat Artist\/Album\/Songs directories. \nDoes anyone have any other optimizations in mind that might cut down on the overhead of opening so many MP3s?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":330,"Q_Id":15325056,"Users Score":1,"Answer":"Beware of premature optimization. Are you really sure that this will be a performance problem? What are your requirements -- how quickly does the script need to run? How fast does it run with the na\u00efve approach? Profile and evaluate before you optimize. I think there's a serious possibility that you're seeing a performance problem where none actually exists.\nYou can't avoid visiting each file once if you want a guaranteed correct answer. As you've seen, optimizations that entirely skip files will basically amount to automated guesswork.\nCan you keep a record of previous scans you've done, and on a subsequent scan use the last-modified dates of the files to avoid re-scanning files you've already scanned once? This could  mean that your first scan might take a little bit of time, but subsequent scans would be faster.\nIf you need to do a lot of complex queries on a music collection quickly, consider importing the metadata of the entire collection into a database (for instance SQLite or MySQL). Importing will take time -- updating to insert new files will take a little bit of time (checking the last-modified dates as above). Once the data is in your database, however, everything should be fairly snappy assuming that the database is set up sensibly.","Q_Score":0,"Tags":"python,id3,mutagen","A_Id":15325204,"CreationDate":"2013-03-10T17:11:00.000","Title":"Optimizing a Mass ID3 Tag Scan","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I am running this python pyramid server. Strangely, when I moved my server code to a different machine, pserve stopped serving flash videos in my static folder. Whereas it serves other static files, like images, fine ! What could be a reason for this ?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":138,"Q_Id":15331039,"Users Score":1,"Answer":"I possibly ran into a similar problem on my pyramid app.  I'm using TinyMCE and had placed the files in the static folder.  Everything worked on my dev server, but moved to test and prod and static .html files related to TinyMCE couldn't be found.  \nMy web host had me add a symlink basically I think hardcoding to the server software (nginix in this case) the web address to my static HTML to the server path and that worked.  \nI'll have to check out the mimetypes thing, though, too.","Q_Score":1,"Tags":"python,flash,pyramid","A_Id":15347393,"CreationDate":"2013-03-11T04:05:00.000","Title":"Pyramid server not serving flash 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":0,"System Administration and DevOps":0,"Web Development":1},{"Question":"Are Python Decorators the same or similar, or fundamentally different to Java annotations or something like Spring AOP, or Aspect J?","AnswerCount":4,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":19358,"Q_Id":15347136,"Users Score":29,"Answer":"This is a very valid question that anyone dabbling in both these languages simultaneously, can get. I have spent some time on python myself, and have recently been getting myself up to speed with Java and here's my take on this comparison. \nJava annotations are - just that: annotations. They are markers; containers of additional metadata about the underlying object they are marking\/annotating. Their mere presence doesn't change execution flow of the underlying, or doesn't add encapsulation\/wrapper of some sort on top of the underlying. So how do they help? They are read and processed by - Annotation Processors. The metadata they contain can be used by custom-written annotation processors to add some auxiliary functionality that makes lives easier; BUT, and again, they NEITHER alter execution flow of an underlying, NOR wrap around them. \nThe stress on \"not altering execution flow\" will be clear to someone who has used python decorators. Python decorators, while being similar to Java annotations in look and feel, are quite different under the hood. They take the underlying and wrap themselves around it in any which way, as desired by the user, possibly even completely avoiding running the underlying itself as well, if one chooses to do so. They take the underlying, wrap themselves around it, and replace the underlying with the wrapped ones. They are effectively 'proxying' the underlying! \nNow that is quite similar to how Aspects work in Java! Aspects per se are quite evolved in terms of their mechanism and flexibility. But in essence what they do is - take the 'advised' method (I am talking in spring AOP nomenclature, and not sure if it applies to AspectJ as well), wrap functionality around them, along with the predicates and the likes, and 'proxy' the 'advised' method with the wrapped one. \nPlease note these musings are at a very abstract and conceptual level, to help get the big picture. As you start delving deeper, all these concepts - decorators, annotations, aspects - have quite an involving scope. But at an abstract level, they are very much comparable. \nTLDR\nIn terms of look and feel, python decorators can be considered similar to Java annotations, but under the hood, they work very very similar to the way Aspects work in Java.","Q_Score":63,"Tags":"java,python,python-decorators,java-annotations","A_Id":49356738,"CreationDate":"2013-03-11T19:40:00.000","Title":"Is a Python Decorator the same as Java annotation, or Java with Aspects?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I am trying to write a dictionary containing values with unicode characters to a text file and was thinking of using UnicodeWriter as mentioned in the python csv documentation. But I am unable to import it as the module is not recognized by python. I was wondering whether this is a problem with my version of python? Also if it is not possible to do it this way, is there any way to specify encoding while using the dictWriter class in python.","AnswerCount":1,"Available Count":1,"Score":0.537049567,"is_accepted":false,"ViewCount":743,"Q_Id":15347414,"Users Score":3,"Answer":"UnicodeWriter isn't an actual module in any version of Python. The code given in the documentation is an example which you'll have to copy into your own project.","Q_Score":2,"Tags":"python,csv,unicode,dictionary","A_Id":15347536,"CreationDate":"2013-03-11T19:55:00.000","Title":"unable to import UnicodeWriter 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":0,"Web Development":0},{"Question":"I'm building a website using Python which uses LaTeX to generate PDF files. But I want to put most of the website on Google App Engine, and I can't run LaTeX on that. So I want to do the LaTeX part on another server.\nIt seemed like a simple problem at first---I thought the best way to do it would be to POST the LaTeX to the server and have it respond with the PDF. But LaTeX files can take a while to compile sometimes if they're long, so I'm starting to think this isn't the best way to do it. What's the standard way of doing something like this? It must be a pretty common problem.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":368,"Q_Id":15348710,"Users Score":0,"Answer":"can you send it by email just like amazon , send a file to server , when it's ok , the server send it by email","Q_Score":2,"Tags":"python,http,pdf,web-applications,latex","A_Id":15352337,"CreationDate":"2013-03-11T21:10:00.000","Title":"Web server which generates PDF 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":0,"System Administration and DevOps":0,"Web Development":1},{"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},{"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},{"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},{"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},{"Question":"I have written a very simple script for my raspberry pi that loads an uncompressed WAV and plays it - however when I run the script as root (to be able to use GPIO and ServoBlaster), there is no sound output.  \nI have set the default audio device to a USB sound card, and this works - I have tested this using aplay fx.wav.\nRunning the pygame script without sudo, the sound plays fine.  \nWhat is going on here?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1087,"Q_Id":15405082,"Users Score":1,"Answer":"The issue was the sudo command changing the directory in which the script was being run - so running python with sudo -s or simply using an absolute path for the sound fixed it.","Q_Score":0,"Tags":"python,audio,pygame,sudo,raspberry-pi","A_Id":15428577,"CreationDate":"2013-03-14T09:08:00.000","Title":"When running a pygame script as root, no sound is output?","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},{"Question":"I doubt this is even possible, but here is the problem and proposed solution (the feasibility of the proposed solution is the object of this question):\n\n\n\nI have some \"global data\" that needs to be available for all requests. I'm persisting this data to Riak and using Redis as a caching layer for access speed (for now...). The data is split into about 30 logical chunks, each about 8 KB.\nEach request is required to read 4 of these 8KB chunks, resulting in 32KB of data read in from Redis or Riak. This is in ADDITION to any request-specific data which would also need to be read (which is quite a bit).\nAssuming even 3000 requests per second (this isn't a live server so I don't have real numbers, but 3000ps is a reasonable assumption, could be more), this means 96KBps of transfer from Redis or Riak in ADDITION to the already not-insignificant other calls being made from the application logic. Also, Python is parsing the JSON of these 8KB objects 3000 times every second.\n\n\n\nAll of this - especially Python having to repeatedly deserialize the data - seems like an utter waste, and a perfectly elegant solution would be to just have the deserialized data cached in an in-memory native object in Python, which I can refresh periodically as and when all this \"static\" data becomes stale. Once in a few minutes (or hours), instead of 3000 times per second.\nBut I don't know if this is even possible. You'd realistically need an \"always running\" application for it to cache any data in its memory. And I know this is not the case in the nginx+uwsgi+python combination (versus something like node) - python in-memory data will NOT be persisted across all requests to my knowledge, unless I'm terribly mistaken.\nUnfortunately this is a system I have \"inherited\" and therefore can't make too many changes in terms of the base technology, nor am I knowledgeable enough of how the nginx+uwsgi+python combination works in terms of starting up Python processes and persisting Python in-memory data - which means I COULD be terribly mistaken with my assumption above!\n\n\n\nSo, direct advice on whether this solution would work + references to material that could help me understand how the nginx+uwsgi+python would work in terms of starting new processes and memory allocation, would help greatly. \nP.S:\n\nHave gone through some of the documentation for nginx, uwsgi etc but haven't fully understood the ramifications per my use-case yet. Hope to make some progress on that going forward now\nIf the in-memory thing COULD work out, I would chuck Redis, since I'm caching ONLY the static data I mentioned above, in it. This makes an in-process persistent in-memory Python cache even more attractive for me, reducing one moving part in the system and at least FOUR network round-trips per request.","AnswerCount":4,"Available Count":2,"Score":0.049958375,"is_accepted":false,"ViewCount":4976,"Q_Id":15443732,"Users Score":1,"Answer":"\"python in-memory data will NOT be persisted across all requests to my knowledge, unless I'm terribly mistaken.\"\nyou are mistaken.\nthe whole point of using uwsgi over, say, the CGI mechanism is to persist data across threads and save the overhead of initialization for each call. you must set processes = 1 in your .ini file, or, depending on how uwsgi is configured, it might launch more than 1 worker process on your behalf. log the env and look for 'wsgi.multiprocess': False and 'wsgi.multithread': True, and all uwsgi.core threads for the single worker should show the same data.\nyou can also see how many worker processes, and \"core\" threads under each, you have by using the built-in stats-server.\nthat's why uwsgi provides lock and unlock functions for manipulating data stores by multiple threads.\nyou can easily test this by adding a \/status route in your app that just dumps a json representation of your global data object, and view it every so often after actions that update the store.","Q_Score":8,"Tags":"python,optimization,nginx,redis,uwsgi","A_Id":45383617,"CreationDate":"2013-03-15T23:31:00.000","Title":"Persistent in-memory Python object for nginx\/uwsgi 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":1,"Web Development":1},{"Question":"I doubt this is even possible, but here is the problem and proposed solution (the feasibility of the proposed solution is the object of this question):\n\n\n\nI have some \"global data\" that needs to be available for all requests. I'm persisting this data to Riak and using Redis as a caching layer for access speed (for now...). The data is split into about 30 logical chunks, each about 8 KB.\nEach request is required to read 4 of these 8KB chunks, resulting in 32KB of data read in from Redis or Riak. This is in ADDITION to any request-specific data which would also need to be read (which is quite a bit).\nAssuming even 3000 requests per second (this isn't a live server so I don't have real numbers, but 3000ps is a reasonable assumption, could be more), this means 96KBps of transfer from Redis or Riak in ADDITION to the already not-insignificant other calls being made from the application logic. Also, Python is parsing the JSON of these 8KB objects 3000 times every second.\n\n\n\nAll of this - especially Python having to repeatedly deserialize the data - seems like an utter waste, and a perfectly elegant solution would be to just have the deserialized data cached in an in-memory native object in Python, which I can refresh periodically as and when all this \"static\" data becomes stale. Once in a few minutes (or hours), instead of 3000 times per second.\nBut I don't know if this is even possible. You'd realistically need an \"always running\" application for it to cache any data in its memory. And I know this is not the case in the nginx+uwsgi+python combination (versus something like node) - python in-memory data will NOT be persisted across all requests to my knowledge, unless I'm terribly mistaken.\nUnfortunately this is a system I have \"inherited\" and therefore can't make too many changes in terms of the base technology, nor am I knowledgeable enough of how the nginx+uwsgi+python combination works in terms of starting up Python processes and persisting Python in-memory data - which means I COULD be terribly mistaken with my assumption above!\n\n\n\nSo, direct advice on whether this solution would work + references to material that could help me understand how the nginx+uwsgi+python would work in terms of starting new processes and memory allocation, would help greatly. \nP.S:\n\nHave gone through some of the documentation for nginx, uwsgi etc but haven't fully understood the ramifications per my use-case yet. Hope to make some progress on that going forward now\nIf the in-memory thing COULD work out, I would chuck Redis, since I'm caching ONLY the static data I mentioned above, in it. This makes an in-process persistent in-memory Python cache even more attractive for me, reducing one moving part in the system and at least FOUR network round-trips per request.","AnswerCount":4,"Available Count":2,"Score":0.049958375,"is_accepted":false,"ViewCount":4976,"Q_Id":15443732,"Users Score":1,"Answer":"You said nothing about writing this data back, is it static? In this case, the solution is every simple, and I have no clue what is up with all the \"it's not feasible\" responses.\nUwsgi workers are always-running applications. So data absolutely gets persisted between requests. All you need to do is store stuff in a global variable, that is it. And remember it's per-worker, and workers do restart from time to time, so you need proper loading\/invalidation strategies.\nIf the data is updated very rarely (rarely enough to restart the server when it does), you can save even more. Just create the objects during app construction. This way, they will be created exactly once, and then all the workers will fork off the master, and reuse the same data. Of course, it's copy-on-write, so if you update it, you will lose the memory benefits (same thing will happen if python decides to compact its memory during a gc run, so it's not super predictable).","Q_Score":8,"Tags":"python,optimization,nginx,redis,uwsgi","A_Id":45384113,"CreationDate":"2013-03-15T23:31:00.000","Title":"Persistent in-memory Python object for nginx\/uwsgi 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":1,"Web Development":1},{"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},{"Question":"I will be creating a connection between my Linux server and a cellular modem where the modem will act as a server for serial over TCP.\nThe modem itself is connected to a modbus device (industrial protocol) via an RS232 connection.\nI would like to use pymodbus to facilitate talking to the end modbus device. However, I cannot use the TCP modbus option in PyModbus as the end device speaks serial modbus (Modbus RTU). And I cannot use the serial modbus option in Pymodbus as it expects to open an actual local serial port (tty device) on the linux server.\nHow can I bridge the serial connection such that the pymodbus library will see the connection as a local serial device?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":1866,"Q_Id":15489371,"Users Score":0,"Answer":"There is no straightforward solution to trick your linux server into thinking that a MODBUS RTU is actually of MODBUS TCP connection.\nIn all cases, your modem will have to transfer data from TCP to serial (and the other way around). So I assume that:\n1) somehow you can program your modem and instruct it to do whatever you want\n2) the manufacturer of the modem has provided a built-in mechanism to do that.\nIf 1): you should program your modem so that it can replace TCP ADUs by RTU ADUs (and the other way around) when copying data from the TCP connection to the RS link.\nIf 2): simply provide your RTU frame to whatever API the manufacturer devised.","Q_Score":0,"Tags":"python,serial-port,tty,modbus","A_Id":15494099,"CreationDate":"2013-03-19T00:20:00.000","Title":"Pymodbus (Serial) over a tcp serial connection","Data Science and Machine Learning":0,"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},{"Question":"I will be creating a connection between my Linux server and a cellular modem where the modem will act as a server for serial over TCP.\nThe modem itself is connected to a modbus device (industrial protocol) via an RS232 connection.\nI would like to use pymodbus to facilitate talking to the end modbus device. However, I cannot use the TCP modbus option in PyModbus as the end device speaks serial modbus (Modbus RTU). And I cannot use the serial modbus option in Pymodbus as it expects to open an actual local serial port (tty device) on the linux server.\nHow can I bridge the serial connection such that the pymodbus library will see the connection as a local serial device?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":1866,"Q_Id":15489371,"Users Score":0,"Answer":"I actually was working on something similar and decided to make my own Serial\/TCP bridge. Using virtual serial ports to handle the communication with each of the modems. \nI used the minimalmodbus library although I had to modify it a little in order to handle the virtual serial ports.\nI hope you solved your problem and if you didn't I can try to help you out.","Q_Score":0,"Tags":"python,serial-port,tty,modbus","A_Id":16742894,"CreationDate":"2013-03-19T00:20:00.000","Title":"Pymodbus (Serial) over a tcp serial connection","Data Science and Machine Learning":0,"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},{"Question":"I have a library (PyModbus) I would like to use that requires a tty device as it will be communicating with a device using serial connection. However, the device I am going to talk to is going to be behind a modem that supports serial over tcp (the device plugs into a com port on the modem). \nWithout the modem in the way it would be trivial. I would connect a usb serial cable to the device and the other end to the computer. With the modem in the way, the server has to connect to a tcp port on the modem and pump serial data through that. The modem passes the data received to the device connected to the com port.\nIn linux, whats the best way to create a fake tty from the \"serial over tcp connection\" for momentary use and then be destroyed. This would happen periodically, and an individual linux server may have 10~500 of these emulated device open at any given time.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":1308,"Q_Id":15491308,"Users Score":1,"Answer":"if i do understand, you need make a connection of this manner:\n[pyModbus <-(fake serial)->process]<-(tcp\/ip)->[modem<-(serial)->device]\nI suggest use socat for this","Q_Score":1,"Tags":"python,serial-port,tty,modbus","A_Id":15680046,"CreationDate":"2013-03-19T04:07:00.000","Title":"Create a fake TTY device from a serial-over TCP connection","Data Science and Machine Learning":0,"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},{"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},{"Question":"I'm doing a file sync between a client, server and Dropbox (Mac client, Debian server). I'm looking at the mod times of files to determine which is newest. On the client I'm using os.path.getmtime(filePath) to get the modified time. \nWhen I check the last modification time of the file on the client and then, after uploading I check again on the server or Dropbox there is a varying difference in the time between them all for the same file. I thought file mod times were associated with the file rather than os they are on, so if the file was last modified on the client, that mod time stamp should be the same when checked on the server? \nCould anyone clarify if uploading the file has an impact on the mod time, or suggest where this variation in time for one file could be coming from? Any advice would be greatly appreciated!","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":77,"Q_Id":15510254,"Users Score":1,"Answer":"The modified time on the Dropbox server isn't necessarily going to be the modified time on the client, but rather the time the file was uploaded to the server. You can use the 'rev' property on files from the \/metadata call to keep track of files instead.","Q_Score":0,"Tags":"python,unix,python-2.7,unix-timestamp,dropbox-api","A_Id":15529123,"CreationDate":"2013-03-19T20:55:00.000","Title":"File Mod Time Discrepancies On Upload","Data Science and Machine Learning":0,"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},{"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},{"Question":"I just recently installed the PyDev 2.6 plugin for Eclipse (I run Eclipse SDK 4.2.1) and when I try to configure the Python interpreter to the path: > C:\\Python27\\python.exe , it gives me an \"Error info on interpreter\" and in error log it says: \n\ncom.sun.org.apache.xerces.internal.impl.io.MalformedByteSequenceException: unvalid Byte 2 of the sequence UTF-8 of 3 bytes\n\nI have read other similar questions on this website about the same issue but the solutions do not suit my situation, as I don't have any unicode char in my path. I run Python 2.7.3. I would really appreciate any help or advice on how to solve this issue, as I would really love to start coding Python in Eclipse soon. Cheers.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":362,"Q_Id":15538867,"Users Score":0,"Answer":"I've faced same problem. The solution was reinstalling Aptana (or Eclipse, tested also on Kepler 4.2.x).\nThe source of problem was in path to your eclipse\/aptana installition. I think that trouble here is determined by diacritic symbols in your name 'Andres Diaz', according to your username here))) (my case is: cyrillic username and user's home folder '\u041c\u0438\u0445\u0430\u0438\u043b' in Windows8). Path to your python interpreter does not matter here.\nThe cure is: move\/reinstall your Eclipse to folder with the path which does not contain any non-acsii character. In my case I've moved Aptana Studio from C:\\Users\\\u041c\u0438\u0445\u0430\u0438\u043b\\Aptana3 to C:\\Aptana3 and (maybe it's not necesarry, I don't know) its' workspace also to root C:\\ folder. \nP.S. I think it can be useful for those who also faced such problem cause I was not able to find any answer about how to solve this troubles but a lot of similar questions.\nP.P.S. Sorry for my English, languages are not my leading skill)))","Q_Score":1,"Tags":"python,eclipse,configuration,pydev,interpreter","A_Id":18466358,"CreationDate":"2013-03-21T03:17:00.000","Title":"Error when configuring Python interpreter for PyDev 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":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"Does embedding c++ code in python using ctypes, boost.python, etc make your python application faster?\nSuppose I am making an application in pygtk and I need some functions which need to be fast. So if I use c++ for certain tasks in my application will it be beneficial? \nAnd what are other options to make python code faster?","AnswerCount":2,"Available Count":1,"Score":0.2913126125,"is_accepted":false,"ViewCount":624,"Q_Id":15543783,"Users Score":3,"Answer":"It depends, there's not a definitive answer. If you write bad code in C++ it could be even slower than well written Python code.\nAssuming that you can write good quality C++ code, you can expect speedups up to 20x in the performance critical parts.\nAs the other answer says, NumPy is a good option for numerical bottlenecks (if you think in matrix operations rather than loops!); and SciPy comes with weaver, that allows you to embed inline C++ and other goodies.","Q_Score":11,"Tags":"c++,python,c,ctypes,embedding","A_Id":15544287,"CreationDate":"2013-03-21T09:34:00.000","Title":"Does embedding c++ code in python make your python application faster?","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},{"Question":"I've got some tests which log to stdout, and I'd like to change the log level in my test script based on the verbosity that nose is running on. \nHow can I access the verbosity of the running nose instance, from within one of the tests being run?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":930,"Q_Id":15555468,"Users Score":1,"Answer":"It looks like the expected way to handle this in nose is to use the logger framework within your tests, and then control the level to be captured with the --logging-level option.\nBy default nose will capture all logs made by the tests, but a filter can be specified using --logging-filter config parameter.","Q_Score":4,"Tags":"python,nose","A_Id":15581683,"CreationDate":"2013-03-21T18:35:00.000","Title":"Accessing nose verbosity programmatically","Data Science and Machine Learning":0,"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},{"Question":"I have a test suit for my app. As the test suit grew organically, the tests have a lot of repeated code which can be refactored.\nHowever I would like to ensure that the test suite doesn't change with the refactor. How can test that my tests are invariant with the refactor.\n(I am using Python+UnitTest), but I guess the answer to this can be language agnostic.","AnswerCount":8,"Available Count":6,"Score":0.0,"is_accepted":false,"ViewCount":432,"Q_Id":15566117,"Users Score":0,"Answer":"I can't see an easy way to refactor a test suite, and depending on the extent of your refactor you're obviously going to have to change the test suite. How big is your test suite?\nRefactoring properly takes time and attention to detail (and a lot of Ctrl+C Ctrl+V!). Whenever I've refactored my tests I don't try and find any quick ways of doing things, besides find & replace, because there is too much risk involved.\nYou're best of doing things properly and manually albeit slowly if you want to make keep the quality of your tests.","Q_Score":9,"Tags":"python,unit-testing,testing,language-agnostic","A_Id":15566501,"CreationDate":"2013-03-22T08:49:00.000","Title":"How do i test\/refactor my 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},{"Question":"I have a test suit for my app. As the test suit grew organically, the tests have a lot of repeated code which can be refactored.\nHowever I would like to ensure that the test suite doesn't change with the refactor. How can test that my tests are invariant with the refactor.\n(I am using Python+UnitTest), but I guess the answer to this can be language agnostic.","AnswerCount":8,"Available Count":6,"Score":0.049958375,"is_accepted":false,"ViewCount":432,"Q_Id":15566117,"Users Score":2,"Answer":"Interesting question - I'm always keen to hear discussions of the type \"how do I test the tests?!\". And good points from @marksweb above too.\nIt's always a challenge to check your tests are actually doing what you want them to do and testing what you intend, but good to get this right and do it properly.  I always try to consider the rule-of-thumb that testing should make up 1\/3 of development effort in any project... regardless of project time constraints, pressures and problems that inevitably crop up.\nIf you intend to continue and grow your project have you considered refactoring like you say, but in a way that creates a proper test framework that allows test driven development (TDD) of any future additions of functionality or general expansion of the project?","Q_Score":9,"Tags":"python,unit-testing,testing,language-agnostic","A_Id":15566738,"CreationDate":"2013-03-22T08:49:00.000","Title":"How do i test\/refactor my 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},{"Question":"I have a test suit for my app. As the test suit grew organically, the tests have a lot of repeated code which can be refactored.\nHowever I would like to ensure that the test suite doesn't change with the refactor. How can test that my tests are invariant with the refactor.\n(I am using Python+UnitTest), but I guess the answer to this can be language agnostic.","AnswerCount":8,"Available Count":6,"Score":0.0,"is_accepted":false,"ViewCount":432,"Q_Id":15566117,"Users Score":0,"Answer":"Don't refactor the test suite.\nThe purpose of refactoring is to make it easier to maintain the code, not to satisfy some abstract criterion of \"code niceness\". Test code doesn't need to be nice, it doesn't need to avoid repetition, but it does need to be thorough. Once you have a test that is valid (i.e. it really does test necessary conditions on the code under test), you should never remove it or change it, so test code doesn't need to be easy to maintain en masse.\nIf you like, you can rewrite the existing tests to be nice, and run the new tests in addition to the old ones. This guarantees that the new combined test suite catches all the errors that the old one did (and maybe some more, as you expand the new code in future).\nThere are two ways that a test can be deemed invalid -- you realise that it's wrong (i.e. it sometimes fails falsely for correct code under test), or else the interface under test has changed (to remove the API tested, or to permit behaviour that previously was a test failure). In that case you can remove a test from the suite. If you realise that a whole bunch of tests are wrong (because they contain duplicated code that is wrong), then you can remove them all and replace them with a refactored and corrected version. You don't remove tests just because you don't like the style of their source.\nTo answer your specific question: to test that your new test code is equivalent to the old code, you would have to ensure (a) all the new tests pass on your currently-correct-as-far-as-you-known code base, which is easy, but also (b) the new tests detect all the errors that the old tests detect, which is usually not possible because you don't have on hand a suite of faulty implementations of the code under test.","Q_Score":9,"Tags":"python,unit-testing,testing,language-agnostic","A_Id":15566925,"CreationDate":"2013-03-22T08:49:00.000","Title":"How do i test\/refactor my 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},{"Question":"I have a test suit for my app. As the test suit grew organically, the tests have a lot of repeated code which can be refactored.\nHowever I would like to ensure that the test suite doesn't change with the refactor. How can test that my tests are invariant with the refactor.\n(I am using Python+UnitTest), but I guess the answer to this can be language agnostic.","AnswerCount":8,"Available Count":6,"Score":0.024994793,"is_accepted":false,"ViewCount":432,"Q_Id":15566117,"Users Score":1,"Answer":"In theory you could write a test for the test, mocking the actualy object under test.But I guess that is just way to much work and not worth it.\nSo what you are left with are some strategies, that will help, but not make this fail safe.\n\nWork very carefully and slowly. Use the features of you IDEs as much as possible in order to limit the chance of human error.\nWork in pairs. A partner looking over your shoulder might just spot the glitch that you missed.\nCopy the test, then refactor it. When done introduce errors in the production code to ensure, both tests find the the problem in the same (or equivalent) ways. Only then remove the original test.\nThe last step can be done by tools, although I don't know the python flavors. The keyword to search for is 'mutation testing'. \n\nHaving said all that, I'm personally satisfied with steps 1+2.","Q_Score":9,"Tags":"python,unit-testing,testing,language-agnostic","A_Id":15567104,"CreationDate":"2013-03-22T08:49:00.000","Title":"How do i test\/refactor my 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},{"Question":"I have a test suit for my app. As the test suit grew organically, the tests have a lot of repeated code which can be refactored.\nHowever I would like to ensure that the test suite doesn't change with the refactor. How can test that my tests are invariant with the refactor.\n(I am using Python+UnitTest), but I guess the answer to this can be language agnostic.","AnswerCount":8,"Available Count":6,"Score":0.0,"is_accepted":false,"ViewCount":432,"Q_Id":15566117,"Users Score":0,"Answer":"Test code can be the best low level documentation of your API since they do not outdate as long as they pass and are correct. But messy test code doesn't serve that purpose very well. So refactoring is essential.\nAlso might your tested code change over time. So do the tests. If you want that to be smooth, code duplication must be minimized and readability is a key. \nTests should be easy to read and always test one thing at once and make the follwing explicit:\n\nwhat are the preconditions?\nwhat is being executed?\nwhat is the expected outcome?\n\nIf that is considered, it should be pretty safe to refactor the test code. One step at a time and, as @Don Ruby mentioned, let your production code be the test for the test.\nFor many refactoring you can often safely rely on advanced IDE tooling \u2013 if you beware of side effects in the extracted code.\nAlthough I agree that refactoring without proper test coverage should be avoided, I think writing tests for your tests is almost absurd in usual contexts.","Q_Score":9,"Tags":"python,unit-testing,testing,language-agnostic","A_Id":15587332,"CreationDate":"2013-03-22T08:49:00.000","Title":"How do i test\/refactor my 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},{"Question":"I have a test suit for my app. As the test suit grew organically, the tests have a lot of repeated code which can be refactored.\nHowever I would like to ensure that the test suite doesn't change with the refactor. How can test that my tests are invariant with the refactor.\n(I am using Python+UnitTest), but I guess the answer to this can be language agnostic.","AnswerCount":8,"Available Count":6,"Score":0.0748596907,"is_accepted":false,"ViewCount":432,"Q_Id":15566117,"Users Score":3,"Answer":"Coverage.py is your friend.\nMove over all the tests you want to refactor into \"system tests\" (or some such tag). Refactor the tests you want (you would be doing unit tests here right?) and monitor the coverage:\n\nAfter running your new unit tests but before running the system tests\nAfter running both the new unit tests and the system tests.\n\nIn an ideal case, the coverage would be same or higher but you can thrash your old system tests.\nFWIW, py.test provides mechanism for easily tagging tests and running only the specific tests and is compatible with unittest2 tests.","Q_Score":9,"Tags":"python,unit-testing,testing,language-agnostic","A_Id":15649053,"CreationDate":"2013-03-22T08:49:00.000","Title":"How do i test\/refactor my 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},{"Question":"I was wondering if anyone knew a code fix to the pstorm python script where you could exclude directories from being indexed in a directory when you open it from the command line.\nI know this is not currently a feature in the IDE but maybe there is a work around someone knows of.\nThanks","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":174,"Q_Id":15570452,"Users Score":1,"Answer":"Use Settings | File Types | Ignore Files and Folders to exclude directories by name or pattern.","Q_Score":1,"Tags":"python,phpstorm","A_Id":16013655,"CreationDate":"2013-03-22T12:34:00.000","Title":"Exclude Directories when using Pstorm in PhpStorm","Data Science and Machine Learning":0,"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},{"Question":"Is there a way to get a good call hierarchy in PyDev?\nI want to be able to select a function and see in which files it is called and eventually by which other functions. I tried the Hierarchy View in Eclipse by pressing F4, but it does not output what I want.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":4318,"Q_Id":15572295,"Users Score":14,"Answer":"PyDev has a find references with Ctrl+Shift+G (not sure that'd be what you're calling a call hierarchy).","Q_Score":12,"Tags":"python,eclipse,pydev","A_Id":15580217,"CreationDate":"2013-03-22T14:04:00.000","Title":"Good Call Hierarchy in Eclipse\/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},{"Question":"Why modulo operator is not working as intended in C and Java?","AnswerCount":4,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":963,"Q_Id":15577185,"Users Score":3,"Answer":"Python's %-operator calculates the mathematical remainder, not the modulus. The remainder is by definition a number between 0 and the divisor, it doesn't depend on the sign of the dividend like the modulus.","Q_Score":4,"Tags":"java,python,c,modulo","A_Id":15577257,"CreationDate":"2013-03-22T18:13:00.000","Title":"Why -1%26 = -1 in Java and C, and why it is 25 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},{"Question":"I wonder, what is the advantage of using selenium for automation if at the end of the test he emits no reports where the test passed or failed?","AnswerCount":3,"Available Count":2,"Score":1.0,"is_accepted":false,"ViewCount":590,"Q_Id":15578942,"Users Score":6,"Answer":"Selenium isn't actually a testing framework, it's a browser driver.  You don't write tests in Selenium any more than you write GUI apps in OpenGL.  You usually write tests in a unit testing framework like unittest, or something like nose or lettuce built on top of it.  Your tests then use Selenium to interact with a browser, as they use a database API to access the DB or an HTTP library to communicate with web services.","Q_Score":0,"Tags":"python,selenium","A_Id":15579077,"CreationDate":"2013-03-22T20:02:00.000","Title":"Selenium Webdriver Testing - 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},{"Question":"I wonder, what is the advantage of using selenium for automation if at the end of the test he emits no reports where the test passed or failed?","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":590,"Q_Id":15578942,"Users Score":0,"Answer":"Its up to the discretion of the user what to do with the selenium webdriver automation and how to report the test results. Selenium webdriver will give you the power to control your web browser and to automate your web application tests. \nSame as how you have to program in any other automation tool the conditions for checking your pass or fail criteria for any tests, in Selenium also it has to be programmed.It is totally up to the programmer how to report their results and the template to be followed. You will have to write your own code to format and store the test results.","Q_Score":0,"Tags":"python,selenium","A_Id":15594935,"CreationDate":"2013-03-22T20:02:00.000","Title":"Selenium Webdriver Testing - 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},{"Question":"So, I have decided to write my next project with python3, why? Due to the plan for Ubuntu to gradually drop all Python2 support within the next year and only support Python3. (Starting with Ubuntu 13.04)\ngevent and the memcached modules aren't officially ported to Python3.\nWhat are some alternatives, already officially ported to Python3, for gevent and pylibmc or python-memcached?","AnswerCount":4,"Available Count":1,"Score":0.049958375,"is_accepted":false,"ViewCount":5262,"Q_Id":15608933,"Users Score":1,"Answer":"for memcached you probably know alternative: redis+python3","Q_Score":10,"Tags":"python,python-3.x,gevent,python-memcached","A_Id":20068405,"CreationDate":"2013-03-25T06:29:00.000","Title":"Python3: Looking for alternatives to gevent and pylibmc\/python-memcached","Data Science and Machine Learning":0,"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},{"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},{"Question":"This is more of a design question.\nI was planning on writing some web-services which implement CPU intensive algorithms. The problem that I am trying to solve is - higher level languages such as python, perl or java make it easy to write web services. While lower level languages such as C, C++ make it possible to fine tune the performance of your code.\nSo I was looking at what I could do bridge two languages. Here's the options I came up with:\nLanguage specific bindings\nUse something like perl-xs or python's ctypes\/loadlibrary or java's JNI. The up-side is that I can write extensions which can execute in the same process. There is small overhead of converting between the native language types to C and back.\nImplement a separate daemon\nUse something like thrift \/ avro and have a separate daemon that runs the C\/C++ code. The upside is, it's loosely coupled from the higher level language. I can quickly replace the high level language. The downside being that the overhead of serializing and local unix domain sockets might be higher than executing the code in the same address space (offered by the previous option.)\nWhat do you guys think?","AnswerCount":4,"Available Count":1,"Score":0.049958375,"is_accepted":false,"ViewCount":1376,"Q_Id":15609918,"Users Score":1,"Answer":"If your C\/C++ code already exists, your best bet is to publish it as a service, with an API matching what functionality you already have.  You can then write new services in the language of your choice, matching the API you need, and they can call the C\/C++ services.\nIf your C\/C++ code does not exist yet, and you are set to create the majority of code in a higher level language such as Java or C#, consider implementing the performance critical parts initially in that language as well.  Only after profiling shows a particular performance problem, and after you exhaust the most basic optimization techniques within the language, such as avoiding allocations inside the hottest loops, you should consider rewriting the bits that have been proven to consume the most cycles into another language using glue such as JNI.\nIn other words, do not optimize until you have numbers in hand.  There is also no fundamental reason why you couldn't squeeze out (almost) the same performance level from Java as you can from C++, with enough trying.  You have a real chance to end up with a simpler architecture than you expect.","Q_Score":2,"Tags":"java,c++,python,c,thrift","A_Id":15610243,"CreationDate":"2013-03-25T07:43:00.000","Title":"Bridging between different 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":1,"Web Development":0},{"Question":"Launching Python has encounterd a problem. Unable to get project for the run\nIt would let me put the word problem in the title.\nThe title is the exact message i get when i try to run\/debug a file in Aptana 3.\nI have always been able to run Python in Eclipse without problems. Does anyone know what causes this error?\nFor testing purposes i just created a new Pydev project with only 1 file in it.","AnswerCount":4,"Available Count":4,"Score":1.2,"is_accepted":true,"ViewCount":10294,"Q_Id":15616093,"Users Score":6,"Answer":"I had the same problem with Aptana and just solved it. In my case I had configured another interpreter (IronPython) for running another script. When I got back to a previous script I got the same error message as you \"Unable to get project for the run\" because it was trying to run it with IronPython instead of Python.\nI would therefore recommand the following:\n1) Check your interpreter configuration.\n-> Window -> Preferences -> Pydev -> Interpreter Python\nIf you have no interpreter there try autoconfig. If it doesn't work you will have to browse it yourself by clicking New (then it should be somewhere like C:\\Python27\\python.exe)\n2) If you have an interpreter, it means that Aptana is trying to run your script with another interpreter. In that case right click on your script file in Aptana -> Run as -> Python run.\nThat worked for me.\nGood luck !","Q_Score":8,"Tags":"python,python-3.x,aptana","A_Id":26059272,"CreationDate":"2013-03-25T13:25:00.000","Title":"Launching Python has encounterd a. Unable to get project for the run","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"Launching Python has encounterd a problem. Unable to get project for the run\nIt would let me put the word problem in the title.\nThe title is the exact message i get when i try to run\/debug a file in Aptana 3.\nI have always been able to run Python in Eclipse without problems. Does anyone know what causes this error?\nFor testing purposes i just created a new Pydev project with only 1 file in it.","AnswerCount":4,"Available Count":4,"Score":0.0,"is_accepted":false,"ViewCount":10294,"Q_Id":15616093,"Users Score":0,"Answer":"Go to Run -> Run configurations -> Python run \ndelete \"New configuration\" \nthen it must work","Q_Score":8,"Tags":"python,python-3.x,aptana","A_Id":48852418,"CreationDate":"2013-03-25T13:25:00.000","Title":"Launching Python has encounterd a. Unable to get project for the run","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"Launching Python has encounterd a problem. Unable to get project for the run\nIt would let me put the word problem in the title.\nThe title is the exact message i get when i try to run\/debug a file in Aptana 3.\nI have always been able to run Python in Eclipse without problems. Does anyone know what causes this error?\nFor testing purposes i just created a new Pydev project with only 1 file in it.","AnswerCount":4,"Available Count":4,"Score":0.0,"is_accepted":false,"ViewCount":10294,"Q_Id":15616093,"Users Score":0,"Answer":"It occurs when you create a New configuration for run a program.\ngo to Run > run configuration > python run\nselect \"New configuration\" \npress on delete icon \nand again Run the program .\nthis is worked for me .","Q_Score":8,"Tags":"python,python-3.x,aptana","A_Id":52572793,"CreationDate":"2013-03-25T13:25:00.000","Title":"Launching Python has encounterd a. Unable to get project for the run","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"Launching Python has encounterd a problem. Unable to get project for the run\nIt would let me put the word problem in the title.\nThe title is the exact message i get when i try to run\/debug a file in Aptana 3.\nI have always been able to run Python in Eclipse without problems. Does anyone know what causes this error?\nFor testing purposes i just created a new Pydev project with only 1 file in it.","AnswerCount":4,"Available Count":4,"Score":0.0,"is_accepted":false,"ViewCount":10294,"Q_Id":15616093,"Users Score":0,"Answer":"I had similar issue. Below action solved my problem.\nGo to Run > run configuration > python run\nDelete all the configurations below python run - it may not be a great option if you have any custom configuration settings.","Q_Score":8,"Tags":"python,python-3.x,aptana","A_Id":55316981,"CreationDate":"2013-03-25T13:25:00.000","Title":"Launching Python has encounterd a. Unable to get project for the run","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I need to analyze a set of GPS coordinates in python. I need to find out what is the most frequent location. Given precision issues of the GPS data, the precision of the locations is not very high. Difficult to explan (and to search for infos on google), therefore an example:\n\nI drive from home to work every day for 2 months\nI start my gps logger for each trip and stop at the end of the trip \nOccasionally, I go somewhere else\n\nIf I run the script I need to analyse the coordinates where drives started and stopped, with a location radius precision of let's say 20m, I'll find out that the most frequent place is my home and my work (each with a radius of 20m). It does not matter where did I park within this radius.\nIs there any library in python that can perform such operations? What do you recommend? \nThanks","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1235,"Q_Id":15623866,"Users Score":0,"Answer":"For counting most frequent locations, a simple approach is to use only the first 3 digits after the latitdue\/longitude decimal point, or better round to 3 digits after comma.\nAt aequator: \n4 digits: 11 m\n3 digits  111m\n2 digits 1.1km\n1 digits 11.1km\n0 digits 111.111 km (distance between two meridians):  40 000 000 \/ 360\nThen you could use as hashtable, multiply with e,g 1000 to get rid of the 3 decimal points, \nand store as java.awt.Point in the hashtable.\nThere are better solutions, but this gives an first idea.","Q_Score":0,"Tags":"python,geolocation,gps","A_Id":15624093,"CreationDate":"2013-03-25T20:13:00.000","Title":"Python: Find out most frequent locations on a set of gps coordinates","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"Right now I'm testing the waters with Apache Thrift, and I'm currently using a TThreadedServer written in Python, but when I run the server, it is not daemonized. Is there any way to make it run as a daemon, or is there another way to run thrift in a production environment?","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":1136,"Q_Id":15627698,"Users Score":3,"Answer":"Daemonizing processes has nothing to do with thrift. Thrift only provides the communication layer for different platforms and you can run the server in one of the several programming languages thrift supports (that is - great majority of what you can think of). No matter if you write the server in Java, C++ (I've tried those so far) or python, none of them will create a daemon. This feature is not supported (e.g. PHP natively doesn't support neither multithreading nor daemonizing).\nI've just seen supervisord, didn't play with it much, but it seems to be a good choice to manage processes like thrift servers.","Q_Score":2,"Tags":"python,thrift","A_Id":15634347,"CreationDate":"2013-03-26T01:18:00.000","Title":"Running thrift server as 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":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"Right now I'm testing the waters with Apache Thrift, and I'm currently using a TThreadedServer written in Python, but when I run the server, it is not daemonized. Is there any way to make it run as a daemon, or is there another way to run thrift in a production environment?","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":1136,"Q_Id":15627698,"Users Score":1,"Answer":"I think you are looking for this:\nnohup hbase thrift start &\nThis is the only way I found to keep thrift working after my disconnect from Linuxsession.","Q_Score":2,"Tags":"python,thrift","A_Id":15873194,"CreationDate":"2013-03-26T01:18:00.000","Title":"Running thrift server as 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":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"I wanted to know if there is a way to find out the status of the ssh server in the system using Python. I just want to know if the server is active or not (just yes\/no). It would help even if it is just a linux command so that I can use python's popen from subprocess module and run that command.\nThanks\nPS: I'm using openssh-server on linux (ubuntu 12.04)","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1422,"Q_Id":15638882,"Users Score":0,"Answer":"Run service sshd status (e.g. via Popen()) and read what it tells you.","Q_Score":0,"Tags":"python,python-2.7,ssh,openssh","A_Id":15639004,"CreationDate":"2013-03-26T13:56:00.000","Title":"SSH Server status 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},{"Question":"My idea is to track a specific file on a file-system over time between two points in time, T1 and T2. The emphasis here lies on looking at a file as a unique entity on a file-system. One that can change in data and attributes but still maintain its unique identity.\nThe ultimate goal is to determine whether or not the data of a file has (unwillingly) changed between T1 and T2 by capturing and recording the data-hash and creation\/modification attributes of the file at T1 and comparing them with the equivalents at T2. If all attributes are unchanged but the hash doesn't validate we can say that there is a problem. In all other cases we might be willing to say that a changed hash is the result of a modification and an unchanged hash and unchanged modification-attribute the result of no change on the file(data) at all.\nNow, there are several ways to refer to a file and corresponding drawbacks:\n\nThe path to the file: However, if the file is moved to a different location this method fails.\nA data-hash of the file-data: Would allow a file, or rather (a) pointer to the file-data on disk, to be found, even if the pointer has been moved to a different directory, but the data cannot change or this method fails as well.\n\nMy idea is to retrieve a fileId for that specific file at T1 to track the file at T2, even if it has changed its location so it doesn't need to be looked at as a new file.\nI am aware of two methods pywin offers. win32file.GetFileInformationByHandle() and win32file.GetFileInformationByHandleEx(), but they obviously are restricted to specific file-systems, break cross-platform-compatibility and sway away from a universal approach to track the file.\nMy question is simple: Are there any other ideas\/theories to track a file, ideally accross platforms\/FSs?\nAny brainstormed food for thought is welcome!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":303,"Q_Id":15651666,"Users Score":4,"Answer":"It's not really feasible in general, because the idea of file identity is an illusion (similar to the illusion of physical identity, but this isn't a philosophy forum).\n\nYou cannot track identity using file contents, because contents change.\nYou cannot track by any other properties attached to the file, because many file editors will save changes by deleting the old file and creating a new one.\n\nVersion control systems handle this in three ways:\n\n(CVS) Don't track move operations.\n(Subversion) Track move operations manually.\n(Git) Use a heuristic to label operations as \"move\" operations based on changes to the contents of a file (e.g., if a new file differs from an existing file by less than 50%, then it's labeled as a copy).\n\nThings like inode numbers are not stable and not to be trusted.  Here, you can see that editing a file with Vim will change the inode number, which we can examine with stat -f %i:\n\n$ touch file.txt\n$ stat -f %i file.txt\n4828200\n$ vim file.txt\n...make changes to file.txt...\n$ stat -f %i file.txt \n4828218","Q_Score":1,"Tags":"python,file,file-io,filesystems","A_Id":15651767,"CreationDate":"2013-03-27T03:58:00.000","Title":"Tracking a file over 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},{"Question":"Is there any performance difference between from package import * and import package?","AnswerCount":1,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":181,"Q_Id":15655224,"Users Score":16,"Answer":"No, the difference is not a question of performance. In both cases, the entire module must be parsed, and any module-level code will be executed. The only difference is in namespaces: in the first, all the names in the imported module will become names in the current module; in the second, only the package name is defined in the current module.\nThat said, there's very rarely a good reason to use from foo import *. Either import the module, or import specific names from it.","Q_Score":8,"Tags":"python,performance,python-import","A_Id":15655265,"CreationDate":"2013-03-27T09:14:00.000","Title":"Performance between \"from package import *\" and \"import 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},{"Question":"The CPython headers define a macro to declare a method that is run to initialize your module on import: PyMODINIT_FUNC\nMy initializer creates references to other python objects, what is the best way to ensure that these objects are properly cleaned up \/ dereferenced when my module is unloaded?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":353,"Q_Id":15688954,"Users Score":1,"Answer":"You can't unload C extension modules at all.  There is just no way to do it, and I know for sure that most of the standard extension modules would leak like crazy if there was.","Q_Score":0,"Tags":"python,cpython,python-c-extension","A_Id":15692895,"CreationDate":"2013-03-28T17:59:00.000","Title":"What's the proper way to clean up static python object references in a CPython extension 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},{"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},{"Question":"I have a CGI script that I wrote in python to use as the home page of the website I am creating. Everything works properly except when you view the page instead of seeing the page that it outputs you see the source code of the page, why is this? I dont mean that it shows me the source code of the .py file, it shows me all the printed information as if I were looking at a .htm file in notepad.","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":426,"Q_Id":15726843,"Users Score":1,"Answer":"The default Content Type is text, and if you forgot to send the appropriate header in your CGI file, you will end up with what you are seeing.","Q_Score":0,"Tags":"python,html,apache,cgi","A_Id":15726928,"CreationDate":"2013-03-31T06:01:00.000","Title":"Python CGI - Script outputs source of generated page","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I have a CGI script that I wrote in python to use as the home page of the website I am creating. Everything works properly except when you view the page instead of seeing the page that it outputs you see the source code of the page, why is this? I dont mean that it shows me the source code of the .py file, it shows me all the printed information as if I were looking at a .htm file in notepad.","AnswerCount":2,"Available Count":2,"Score":0.1973753202,"is_accepted":false,"ViewCount":426,"Q_Id":15726843,"Users Score":2,"Answer":"Add the following before you print anything\nprint \"Content-type: text\/html\"\nProbably your script is not getting executed.\nIs your python script executable?\nCheck whether you have the script under cgi-bin directory.","Q_Score":0,"Tags":"python,html,apache,cgi","A_Id":15726936,"CreationDate":"2013-03-31T06:01:00.000","Title":"Python CGI - Script outputs source of generated page","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I am making a pyramid webapp running in apache webserver using mod_wsgi. Is there anyway I could make user session never timed out? (The idea is so that once user logged in, the system will never kicked them out unless they logged out themselves). I cant find any information regarding this in apache, mod_wsgi or pyramid documentation. Thanks!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":284,"Q_Id":15737993,"Users Score":0,"Answer":"This entirely depends on the authentication policy that you use. The default AuthTktAuthenticationPolicy sets a cookie in the browser which (by default) does not expire. Again though, this depends on how you are tracking authenticated users.","Q_Score":1,"Tags":"python,apache,session,mod-wsgi,pyramid","A_Id":15778904,"CreationDate":"2013-04-01T05:17:00.000","Title":"Making Pyramid application without session timeout","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"My setup looks like this: A 64-bit box running Windows 7 Professional is connected to a Beaglebone running Angstrom Linux.\nI'm currently controlling the beaglebone via a putty command line on the windows box.\nWhat I'd like to do is run an OpenCV script to pull some vision information, process it on the windows box, and send some lightweight data (e.g a True or False, a triplet, etc.) over the (or another) USB connection to the beaglebone.\nMy OpenCV program is running using Python bindings, so any piping I can do with python would be preferable. I've played around with pyserial to receive data on a windows box via a COM port, so it seems like I could use that on the windows side... at a total loss though on the embedded linux front","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":956,"Q_Id":15744495,"Users Score":0,"Answer":"Normally on the linux front, if the usb dongle is of the right type, you will see something like \/dev\/usbserial or similar device. Maybe check dmesg after plugging the cable.\n(on linux you can run find \/dev | grep usb to list all usb related devices)\nJust a side note, I've seen the beaglebone has an ethernet port, why not just using a network socket? It's all easier than reinventing a protocol on usb.","Q_Score":2,"Tags":"python,linux,windows,usb,pyserial","A_Id":15745200,"CreationDate":"2013-04-01T13:34:00.000","Title":"How to send data from Windows to embedded linux over USB","Data Science and Machine Learning":0,"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},{"Question":"Wondering what the real difference is when writing files from Python. From what I can see if I use w or wb I am getting the same result with text. \nI thought that saving as a binary file would show only binary values in a hex editor, but it also shows text and then ASCII version of that text.\nCan both be used interchangably when saving text? (Windows User)","AnswerCount":1,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":19466,"Q_Id":15750660,"Users Score":8,"Answer":"Only in Windows, in the latter case, .write('\\n') writes one byte with a value of 10. In the former case, it writes two bytes, with the values 13 and 10.\nYou can prove this to yourself by looking at the resulting file size, and examining the files in a hex editor.\nIn POSIX-related operating systems (UNIX, SunOS, MacOS, Linux, etc.), there is no difference beetween 'w' and 'wb'.","Q_Score":7,"Tags":"python,text,binary,ascii","A_Id":15750957,"CreationDate":"2013-04-01T19:50:00.000","Title":"Python file IO 'w' vs 'wb'","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to use z3 in pydev, I add the path of z3py and libz3.dll to window\/preferences\/pydev\/jython-interpreter, but i got the error as the following\nTraceback (most recent call last):\n  File \"C:\\Users\\linda\\workspace\\LearningPyDev\\main.py\", line 11, in \n    import z3\n  File \"C:\\Users\\linda\\z3\\python\\z3.py\", line 45, in \n    from z3printer import *\n  File \"C:\\Users\\linda\\z3\\python\\z3printer.py\", line 8, in \n    import sys, io, z3\nImportError: No module named io\nWhat is the io module anyway? Is it possible to run z3 in pydev?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":1273,"Q_Id":15772909,"Users Score":1,"Answer":"io is a core Python module. It was added in 2.6 and has been present in every subsequent version. Are you on a very old version of Python? If you're running Python version 2.5 or earlier (you can check with python --version in any commandline), you'll need to update Python to a newer version.","Q_Score":0,"Tags":"python,z3","A_Id":15773638,"CreationDate":"2013-04-02T19:40:00.000","Title":"error in import z3","Data Science and Machine Learning":0,"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},{"Question":"I have an email interface client, and I am using IMAP for my requests. I want to be able to show, in real-time, basic email data, for a list view.\nAs in, for example, the GMail list  view. For that, I need to do an IMAP request to obtain the subject of all emails, the date of all emails, etc. This works so far.\nThe problem is, I want to also show the first characters of the body text. If I use the BODYSTRUCTURE call to obtain the index of the text\/HTML part it takes too long (for emails with thousands of characters it might take well over a second per email, while using only the subject\/date\/etc calls takes about 0.02 seconds max.\nI tried using the BODY[INDEX]<0.XYZ> bytes where XYZ is the number of the first bytes we want to obtain, but to my dismay, it takes as long as using the BODY[INDEX] call. Sometimes even more.\nIs there another way to obtain the first text characters, but in a quick manner? If I want to list 300 emails on my interface I cannot afford to spend 1 second per email just to obtain the first text characters.\nI'm using Python with imaplib for this, even though probably not relevant.","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":1047,"Q_Id":15792128,"Users Score":2,"Answer":"If you really want to fetch the beginning of the first textual part of a message, you will have to parse the BODYSTRUCTURE. After you obtain the part ID of the desired textual part, use the BODY[number]<0.size> syntax.\nThe suggestion given in the other answer will fail on multipart messages (like if you have a text\/plain and text\/html, which is most common format today.","Q_Score":3,"Tags":"python,imap,imaplib","A_Id":15875488,"CreationDate":"2013-04-03T15:54:00.000","Title":"Obtain partial IMAP text part","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},{"Question":"I understand that \".pyc\" files are compiled versions of the plain-text \".py\" files, created at runtime to make programs run faster. However I have observed a few things:\n\nUpon modification of \"py\" files, program behavior changes. This indicates that the \"py\" files are compiled or at least go though some sort of hashing process or compare time stamps in order to tell whether or not they should be re-compiled.\nUpon deleting all \".pyc\" files (rm *.pyc) sometimes program behavior will change. Which would indicate that they are not being compiled on update of \".py\"s.\n\nQuestions:\n\nHow do they decide when to be compiled?\nIs there a way to ensure that they have stricter checking during development?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":54648,"Q_Id":15839555,"Users Score":88,"Answer":"The .pyc files are created (and possibly overwritten) only when that python file is imported by some other script. If the import is called, Python checks to see if the .pyc file's internal timestamp is not older than the corresponding .py file.  If it is, it loads the .pyc; if it isn't or if the .pyc does not yet exist, Python compiles the .py file into a .pyc and loads it.\nWhat do you mean by \"stricter checking\"?","Q_Score":99,"Tags":"python,python-internals,pyc","A_Id":15839646,"CreationDate":"2013-04-05T17:05:00.000","Title":"When are .pyc files refreshed?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":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},{"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},{"Question":"5 sites setup using named vhosts.\n\nsite1.domain.net (PHP) \nsite2.domain.net (Python) \nsite3.domain.net (Ruby)\nsite4.domain.net (PHP)\nsite5.domain.net (PHP)\n\nIn the vhost for site1 I also have the ServerAlias set to *.domain.net as I want any undefined addresses to go to that address. \nWhen I add the *.domain.net to that vhost, the python and the ruby sites redirect to site1 instead of their named vhost. All the php sites work fine.\nMy guess is the fact that the python and ruby sites are using wsgi and passenger respectively has something to do with why it is loading incorrectly. \nI was reading something about UseCanonicalNames but I don't see how that impacts this. \nI am not just interested in a solution but also a reason why (or how) these other two languages handle their vhost config and why such a change makes a difference.\nThank you for your time and help.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":39,"Q_Id":15905487,"Users Score":0,"Answer":"I don't think it has anything to do with the usage of mod_wsgi and Phusion Passenger. I think that's just how ServerAlias works.\nYou can try this alternative:\n\nRemove the ServerAlias.\nSetup a vhost for '*.domain.net' (or, if that doesn't work, '.domain.net' or 'domain.net') which redirects to site1.domain.net.\n\nThis also has the advantage that your users cannot bookmark a non-canonical subdomain name.\nBy the way did you know that Phusion Passenger also supports WSGI?","Q_Score":0,"Tags":"php,python,ruby,apache2,vhosts","A_Id":15921626,"CreationDate":"2013-04-09T15:02:00.000","Title":"Apache2 Ruby and Python load default website when *.domain.net is set in vhost 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":1},{"Question":"I'm just trying to do a simple batch insert test for 2k nodes and this is timing out. I'm sure it's not a memory issue because I'm testing with a ec2 xLarge instance and I changed the neo4j java heap and datastore memory parameters. What could be going wrong?","AnswerCount":3,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":211,"Q_Id":15920449,"Users Score":1,"Answer":"There is an existing bug with large batches due to Python's handling of the server streaming format. There will be a fix for this released in version 1.5 in a few weeks' time.","Q_Score":0,"Tags":"python,neo4j,py2neo","A_Id":15927439,"CreationDate":"2013-04-10T08:16:00.000","Title":"py2neo Batch Insert timing out for even 2k nodes","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"It seems the definition of weak typing (not to be confused with dynamic typing) is that a binary operator can work when both values are a different type.\nPython programmers argue that Python is strongly typed because 1+\"hello\" will fail instead of silently doing something else. In contrast, other languages which are commonly considered weakly typed (e.g. PHP, JavaScript, Perl) will silently convert one or both of the operands. For example, in JavaScript, 1+\"hello\" -> \"1hello\", while in Perl, 1+\"hello\" -> 1, but 1+\"5\" -> 6.\nNow, I had the impression that Java is considered a strongly typed language, yet auto(un)boxing and widening conversions seem to contradict this. For example, 1+new Integer(1) -> 2, hello+\"1\" -> \"hello1\", 'A'+1 -> 66, and long can be converted into float automatically even though it typically gets truncated. Is Java weakly typed? What's the difference between weak typing, autoboxing, and widening conversions?","AnswerCount":1,"Available Count":1,"Score":0.6640367703,"is_accepted":false,"ViewCount":1195,"Q_Id":15935699,"Users Score":4,"Answer":"Weak Typing is when certain conversions and ad-hoc polymorphisms are implicitly performed if the compiler\/interpreter feels the need for it.\nAutoboxing is when when literals and non-object types are automatically converted to their respective Object types when needed. (For example, Java will allow you to call methods on a string literal as if it were a string object.) This has nothing to do with the typing system. It's really just syntactic sugar to avoid having to create objects explicitly.\nWidening conversions are a form of weak typing. In a very strict strongly typed language, this wouldn't be allowed. But in languages like Java, it is allowed because it has no negative side effects. Something as tiny as this is hardly enough to no longer consider Java a strongly typed language.\nJava also overloads the + operator for string concatenation. It's definitely a feature seen in weakly typed languages, but again, not a big enough deal to call Java weakly typed. (Even though I think it's a really stupid idea.)","Q_Score":0,"Tags":"java,php,javascript,python,weak-typing","A_Id":15936117,"CreationDate":"2013-04-10T20:23:00.000","Title":"What is the difference between weak typing, autoboxing, widening conversions?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have installed the tramp on my emacs properly. I can use it to edit the remote txt files, however, once I create an *.py file on the remote host and edit it, after I input 2 letters, the whole emacs freeze, it doesn't respond. Could anyone give me some hints for this issus?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":480,"Q_Id":15940277,"Users Score":1,"Answer":"I figured out my mistake. Tramp seems incompatible with one of the python's auto-complete package, and I removed it. Then tramp works well.","Q_Score":0,"Tags":"python,emacs,tramp","A_Id":15959250,"CreationDate":"2013-04-11T03:33:00.000","Title":"How to use emacs tramp to edit remote python 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},{"Question":"I have a C++ project that is called in Python (via boost-python) and I want to debug the C++ code from python process. How can I do that? In Windows with Visual Studio I can use the functionality attach to process. How to achieve the same in Eclipse?\nThanks","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":750,"Q_Id":15944011,"Users Score":0,"Answer":"For me it works great just adding a debug configuration in C\/C++ for the program \/usr\/bin\/python (or whatever search path you have to the python interpreter) and then put the python program you want to run as the arguments. Put the breakpoints you want in the C-code and you should be all set for running the debug configuration and opening the debug perspective.\nIf it still does not work you may also check that you are using Legacy (or Standard) Process Launcher. For some reason the GDB process launcher does not seem to work here.","Q_Score":1,"Tags":"c++,python,eclipse,debugging,eclipse-cdt","A_Id":30459774,"CreationDate":"2013-04-11T08:26:00.000","Title":"Debug a Python C++ extension from Eclipse (under 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},{"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},{"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},{"Question":"I am building a two-factor authentication system based on the TOTP\/HOTP.\nIn order to verify the otp both server and the otp device must know the shared secret.\nSince HOTP secret is quite similar to the user's password, I assumed that similar best practices should apply. Specifically it is highly recommended to never store unencrypted passwords, only keep a salted hash of the password.\nNeither RFCs, nor python implementations of HOTP\/TOTP seem to cover this aspect.\nIs there a way to use one-way encryption of the OTP shared secret, or is it a stupid idea?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":3075,"Q_Id":15962195,"Users Score":0,"Answer":"Definition: HOTP(K,C) = Truncate(HMAC(K,C)) & 0x7FFFFFFF - where Kis a secret key and C is a counter. It is designed so that hackers cannot obtain K and C if they have the HOTP string since HMAC is a one-way hash (not bidirectional encryption).\nK & C needs to be protected since losing that will compromise the entire OTP system. Having said that, if K is found in a dictionary and we know C (eg: current time), we can generate the entire dictionary of HOTP\/TOTP and figure out K.\nApplying one way encryption to HOTP\/TOTP (ie: double encryption) would mathematically make it harder to decode, although it doesn't prevent other forms of attack (eg: keystroke logging) or applying the same encryption to the dictionary list of HOTP\/TOTP.\nIt is human nature to reuse the same set of easily-remembered-password for EVERYTHING and hence the need to hide this password on digital devices or when transmitting over the internet. \nImplementation of security procedure or protocol is also crucial, it is like choosing a good password K but leave it lying around the desk for everyone, or the server holding K (for HMAC) is not inside a private network protected by a few layers of firewall.","Q_Score":15,"Tags":"python,authentication,encryption,google-authenticator","A_Id":16110166,"CreationDate":"2013-04-12T02:39:00.000","Title":"Is it possible to salt and or hash HOTP\/TOTP secret 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":0},{"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},{"Question":"I am using a C++ broker with clients written in C++, Python, and Java.  If we run the system overnight, it reliably does not send\/receive messages by morning.  All messages are exchanged over topics with subjects designating the destination.  I have 3 questions:\n1.) Should we be using queues?  Is there an advantage to using queues over topics?  What is the design decision that picks a queue over a topic?  Queues seem more rigid (i.e. if you know node A sent a request and wants a response, you would send a response right back; pub\/sub).\n2.) If a message goes unacknowledged, what can happen?  I discovered that the Python module was missing a session.acknowledge().  Could this be causing our overnight failures?  I discovered this problem today so I will hopefully have more insight tomorrow.  The remedy has been to restart the qpidd service.  (We are running on x64 Linux).\n3.) Is this a good reason to use cluster fail over?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":329,"Q_Id":15973821,"Users Score":0,"Answer":"1) That depends on architecture.  Both methods, queues and topics, can get messages from many sources to many destinations.  Topics get messages to all listeners, queues get message to one of the listeners - whoever grabs the message first.\n2) Are there any error or log messages pertaining to failure?  I suspect you are running out of resources.\n3) No, you should figure out why your messaging fails before 24 hours.","Q_Score":0,"Tags":"python,qpid","A_Id":16147555,"CreationDate":"2013-04-12T14:21:00.000","Title":"Qpid reliability","Data Science and Machine Learning":0,"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},{"Question":"If I take multiple images in different fluorescent channels (after staining the cells with some antibody\/maker), how can I automatically quantitate the fraction of cells positive for each marker? Has anyone done something like this in Python?\nI can already use Fiji (ImageJ) to count the cells containing only one staining type, but I can't make it run a selective count on merged images which contain two staining types. Since Fiji interacts well with python, I was thinking of writing a script that looks at each respective image containing only one staining type and then obtain the x-y coordinates of the respective image and check for matches between. I am not sure if that's a good idea though and I was wondering, if anyone has done something similar or has a more efficient way of getting the task done?\nThanks for your help!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1007,"Q_Id":15986114,"Users Score":0,"Answer":"You could use cont = cv2.findcontours to find the almost round shaped cells and count them \nwith len(cont).","Q_Score":0,"Tags":"python,opencv,imaging,imagej","A_Id":15991413,"CreationDate":"2013-04-13T09:03:00.000","Title":"Cell Counting: Selective; Only count cells positive for all stainings","Data Science and Machine Learning":0,"Database and SQL":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},{"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},{"Question":"I'm using pytest for my test suite. While catching bugs in complex inter-components test, I would like to place import ipdb; ipdb.set_trace() in the middle of my code to allow me to debug it.\nHowever, since pytest traps sys.stdin\/sys.stdout ipdb fails. How can I use ipdb while testing with pytest.\nI'm not interested in jumping to pdb or ipdb after a failure, but to place breaks anywhere in the code and be able to debug it there before the failure occurs.","AnswerCount":5,"Available Count":1,"Score":0.1194272985,"is_accepted":false,"ViewCount":36627,"Q_Id":16022915,"Users Score":3,"Answer":"This is what I use\npy.test tests\/ --pdbcls=IPython.core.debugger:Pdb -s","Q_Score":115,"Tags":"python,pytest","A_Id":58883629,"CreationDate":"2013-04-15T19:05:00.000","Title":"How to execute ipdb.set_trace() at will while running pytest 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":0},{"Question":"I have a Unicode string in Python. I am looking for a way to determine if there is any Chinese\/Japanese character in the string. If possible it'll be better to be able to locate those characters.\nIt seems this is a bit different from a language detection problem. My string can be a mixture of English and Chinese texts.\nMy code has Internet access.","AnswerCount":3,"Available Count":1,"Score":0.1325487884,"is_accepted":false,"ViewCount":4416,"Q_Id":16027450,"Users Score":2,"Answer":"You can use this regex [\\u2E80-\\u9FFF] to match CJK characters.","Q_Score":6,"Tags":"python","A_Id":16027565,"CreationDate":"2013-04-16T01:46:00.000","Title":"Is there a way to know whether a Unicode string contains any Chinese\/Japanese character 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},{"Question":"I've written a high level motor controller in Python, and have got to a point where I want to go a little lower level to get some speed, so I'm interested in coding those bits in C.\nI don't have much experience with C, but the math I'm working on is pretty straightforward, so I'm sure I can implement with a minimal amount of banging my head against the wall. What I'm not sure about is how best to invoke this compiled C program in order to pipe it's outputs back into my high-level python controller.\nI've used a little bit of ctypes, but only to pull some functions from a manufacfturer-supplied DLL...not sure if that is an appropriate path to go down in this case.\nAny thoughts?","AnswerCount":4,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":1391,"Q_Id":16027942,"Users Score":0,"Answer":"You can use Cython for setting the necessary c types and compile your python syntax code.","Q_Score":2,"Tags":"python,c","A_Id":16451937,"CreationDate":"2013-04-16T02:46:00.000","Title":"Best way to call C-functions 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},{"Question":"I've written a high level motor controller in Python, and have got to a point where I want to go a little lower level to get some speed, so I'm interested in coding those bits in C.\nI don't have much experience with C, but the math I'm working on is pretty straightforward, so I'm sure I can implement with a minimal amount of banging my head against the wall. What I'm not sure about is how best to invoke this compiled C program in order to pipe it's outputs back into my high-level python controller.\nI've used a little bit of ctypes, but only to pull some functions from a manufacfturer-supplied DLL...not sure if that is an appropriate path to go down in this case.\nAny thoughts?","AnswerCount":4,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":1391,"Q_Id":16027942,"Users Score":0,"Answer":"you can use SWIG, it is very simple to use","Q_Score":2,"Tags":"python,c","A_Id":16028391,"CreationDate":"2013-04-16T02:46:00.000","Title":"Best way to call C-functions 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},{"Question":"I'm working with custom a build system that manages a large number of git repositories and written primarily in python.\nIt would save me a lot of time if I could write a command that would report the current branch of all repositories, then report if the head of \"branch\" is the same as the head of \"remotes\/origin\/branch\".\nWe already have a command that will run a shell command inside every git repository, what I'm looking for is a method of getting some simply formatted information from git with regards to the relative position of branch and remotes\/origin\/branch. Something which is either going to be number of commits difference or a simple boolean value.\nWhat's the method of getting this information out of git which is going to minimize the amount of parsing and processing I've got to do on the python side?","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":2039,"Q_Id":16037623,"Users Score":1,"Answer":"git status shows how many commits you are ahead\/behind the remote tracking branch. You need to perform git fetch first though, because otherwise git cannot know if anything new went into remote.","Q_Score":7,"Tags":"python,git","A_Id":16037728,"CreationDate":"2013-04-16T12:53:00.000","Title":"simplest possible way git can output the number of commits between \"branch\" and \"remotes\/origin\/branch\"","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I am using pydev through Aptana Studio 3 on a mac.  Shortly after opening up Aptana, my computer heats way up, the fans go full power, and Aptana uses over 100% cpu even when it's not doing anything.  I also have pydev on eclipse, but this spike doesn't occur.  Has anyone else seen this? Is there any way to stop it?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":284,"Q_Id":16051571,"Users Score":1,"Answer":"The only way to really know what's going on would be connecting jvisualvm (or some profiler or debugger) to your process to see what's going on (and then report an issue). On jvisualvm you can get a dump with the current processes, which may be enough already if you can say which is the thread that's running.\nNote that the title should probably be 'aptana studio 3 massive cpu usage' if you're able to reproduce it there but not in pydev...","Q_Score":0,"Tags":"python,aptana,pydev","A_Id":16058892,"CreationDate":"2013-04-17T04:34:00.000","Title":"pydev massive cpu usage","Data Science and Machine Learning":0,"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},{"Question":"Is there an easy way to work in binary with Python? \nI have a file of data I am receiving (in 1's and 0's) and would like to scan through it and look for certain patterns in binary. It has to be in binary because due to my system, I might be off by 1 bit or so which would throw everything off when converting to hex or ascii. \nFor example, I would like to open the file, then search for '0001101010111100110' or some string of binary and have it tell me whether or not it exists in the file, where it is, etc.\nIs this doable or would I be better off working with another language?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":105,"Q_Id":16071286,"Users Score":0,"Answer":"You would be better working off another language. Python could do it (if you use for example,\nfile = open(\"file\", \"wb\")\n(appending the b opens it in binary), and then using a simple search, but to be honest, it is much easier and faster to do it in a lower-level language such as C.","Q_Score":0,"Tags":"python,search,binary","A_Id":16071379,"CreationDate":"2013-04-17T22:23:00.000","Title":"Workin with binary 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},{"Question":"I am just starting out with pyramid and I am doing the tutorial. I would like to use some of the tutorial code as a starting point for the project that I am going to start, but I don't want to keep the project name as tutorial. It seems like once you give a project a name that name is used in many places. Is there a way to easily change the project name? I am sure I will have to manually edit some stuff. Just wondering if there may be an easy way to do this.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":468,"Q_Id":16085288,"Users Score":3,"Answer":"It's not a \"project name\". It's the name of a python package. Yes, you'll have to search\/replace and rename that package everywhere in your code. You're probably better off just starting from a new project with the right name if you are only at the tutorial stage.","Q_Score":3,"Tags":"python,pyramid","A_Id":16088122,"CreationDate":"2013-04-18T14:08:00.000","Title":"How do you change the name of a pyramid 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":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"is there a way to trace all the calls made by a web page when loading it? Say for example I went in a video watching site, I would like to trace all the GET calls recursively until I find an mp4\/flv file. I know a way to do that would be to follow the URLs recursively, but this solution is not always suitable and quite limitative( say there's a few thousand links, or the links are in a file which can't be read). Is there a way to do this? Ideally, the implementation could be in python, but PHP as well as C is fine too","AnswerCount":4,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":98,"Q_Id":16114358,"Users Score":0,"Answer":"Chrome provides a built-in tool for seeing the network connections. Press Ctrl+Shift+J to open the JavaScript Console. Then open the Network tab to see all of the GET\/POST calls.","Q_Score":0,"Tags":"php,python,html,networking","A_Id":16115090,"CreationDate":"2013-04-19T22:23:00.000","Title":"Tracing GET\/POST calls","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},{"Question":"I had putty on one server and run a python script available on that server. That script keep on throwing output on terminal. Later on, my internet connection went off but even then i was expecting my script to complete it job as script is on running on that server. But when internet connection resumed, I found that script has not done its job.\nSo is this expected ? If yes, then what to do to make sure that script runs on server even though internet connection goes off in-between?\nThanks in advance !!!","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":289,"Q_Id":16117044,"Users Score":0,"Answer":"On the server, you can install tmux or screen. These programs run the program in the background and enable you to open a 'window', If I use tmux:\nOpen tmux: tmux\nDetach (run in background): press Ctrl-b d\nreattach (open a 'window'): tmux attach","Q_Score":0,"Tags":"python,shell,python-2.7,putty","A_Id":16117169,"CreationDate":"2013-04-20T05:37:00.000","Title":"to keep the script running even after internet connection goes off","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},{"Question":"I have a an application with two processes, one in C and one in Python. The C process is where all the heavy lifting is done, while the Python process handles the user interface.\nThe C program writes to a large-ish buffer 4 times per second, and the Python process reads this data. To this point the communication to the Python process has been done by AMQP. I would much rather setup some for of memory sharing between the two processes to reduce overhead and increase performance.\nWhat are my options here? Ideally I would simply have the Python process read the physical memory straight (preferable from memory and not from disk), and then taking care of race conditions with Semaphores or something similar. This is however something I have little experience with, so I'd appreciate any help I can get.\nI am using Linux btw.","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":12308,"Q_Id":16120373,"Users Score":0,"Answer":"How about writing the weight-lifting code as a library in C and then providing a Python module as wrapper around it? That is actually a pretty usual approach, in particular it allows prototyping and profiling in Python and then moving the performance-critical parts to C.\nIf you really have a reason to need two processes, there is an XMLRPC package in Python that should facilitate such IPC tasks. In any case, use an existing framework instead of inventing your own IPC, unless you can really prove that performance requires it.","Q_Score":9,"Tags":"python,c,ipc","A_Id":16121274,"CreationDate":"2013-04-20T12:30:00.000","Title":"How can I handle IPC between C 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},{"Question":"In a file a.py, I have the lines:\n\n\nimport gevent\ngevent.monkey.patch_all()\n\nimport b\n# etc, etc\n\n\nIn file b.py is it necessary to monkey patch again? Is there anything wrong with monkey patching multiple times?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1320,"Q_Id":16139929,"Users Score":0,"Answer":"Normally there's just one entry in sys.modules for each module. ie, the same module object is shares, so it affects the module as long as it's imported the same way.\nIt's possible to have the same module in sys.modules under two or more entries if it is imported differently.","Q_Score":2,"Tags":"python,gevent,monkeypatching","A_Id":16140423,"CreationDate":"2013-04-22T05:22:00.000","Title":"Is Python's monkey patching local to the current 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},{"Question":"I'm trying to install a xlrd 0.9.2 package on Python3.2 on windows 7. When I launch the setup.py install I receive encoding error: 'utf8' codec can't decode... \nThe module (licenses.py) where the installer stops has an encoding declaration: \n# -*- coding: cp1252 -*-\nbut it seems the python is ignoring it. \nI was using Win cmd but also checked cygwin and have the same problem.\nFew days ago I also had a problem with reading txt file that was in cp1252 even though I set this declaration in my script. I was using IDLE to run the script.\nI'm not sure now if my python install has something missing or this is operating system issue","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":315,"Q_Id":16148615,"Users Score":0,"Answer":"Upgraded to Python 3.3 and the library got installed ok. Not sure if that's a problem with Python 3.2 or the instance I had.","Q_Score":0,"Tags":"python,encoding,installation,xlrd","A_Id":16168365,"CreationDate":"2013-04-22T13:41:00.000","Title":"python encoding error at xlrd installation","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to compiling an autodiff python library, pyadolc, on Windows with Mingw. It requires boost python to call the underlying c++ library, adol-c.\nI first compiled boost_python library (dll) with mingw. The dll generated are namead as libboost_python-mgw46-mt-1_53.dll and libboost_python-mgw46-mt-1_53.dll.a, sitting in \/mingw\/bin and \/mingw\/lib respectively.\nThen when I build the pyadolc, the build script tries with command -lboost_python. It failed because the dll is named as libboost_python-mgw46-mt-1_53.dll, not libboost_python.dll.\nSo I renamed the dll as libboost_python.dll in \/mingw\/bin. It works and everything links fine.\nHowever, when I tred in python shell\nimport adolc\nit gave me an error: ImportError: No dll found for _adolc (something like that). Then I found that it was because it was looking for libboost_python-mgw46-mt-1_53.dll.\nMy question is: how does the dll naming work? what's the proper way to handle this kind of situation? Should I modify the build script or should I just rename the dll? I know in linux, I probably can just create a symbolic link of libboost_python.so to libboost_python-xxxx-mt-1_53.so. But in Windows xp, symbolic link to a file is not that easy.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":118,"Q_Id":16153597,"Users Score":0,"Answer":"The best possibility is to change your build script to point to -lboost_python-mgw46-mt-1_53.dll\nIf you rename  libboost_python-mgw46-mt-1_53.dll you have to rename libboost_python-mgw46-mt-1_53.dll.a to.\nOften have dll's a reciprocal reference, if you now, only renames, the original names are not found.\nSo do not rename, instead use copy\ncopy\nlibboost_python-mgw46-mt-1_53.dll.a to libboost_python.a\nand copy\nlibboost_python-mgw46-mt-1_53.dll to libboost_python.dll\nWith this method you have both versions.","Q_Score":0,"Tags":"python,windows,mingw,msys","A_Id":16485372,"CreationDate":"2013-04-22T17:55:00.000","Title":"How should I handle an \"incorrectly\" named dll?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am facing an encoding issue while trying to pass a string from two C# modules using Ironpython code as a bridge.\nSpecial characters like \u20ac , \u00a9 gets distorted when the string is received by the recipient module. \nCan anyone please advise if its a IronPython issue ? and how to fix this type of issue\nThanks,\nAmit","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":387,"Q_Id":16157636,"Users Score":0,"Answer":"Probably you are doing something wrong. There is no issues with encoding and IronPython. Check encoding for script you load before..","Q_Score":0,"Tags":"c#,special-characters,ironpython","A_Id":16273312,"CreationDate":"2013-04-22T22:13:00.000","Title":"special character encoding C# and 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":1},{"Question":"I have written a python27 module and installed it using python setup.py install.\nPart of that module has a script which I put in my bin folder within the module before I installed it. I think the module has installed properly and works (has been added to site-packages and scripts). I have built a simple script \"test.py\" that just runs functions and the script from the module. The functions work fine (the expected output prints to the console) but the script does not. \nI tried from [module_name] import [script_name] in test.py which did not work.\nHow do I run a script within the bin of a module from the command line?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":106,"Q_Id":16170268,"Users Score":1,"Answer":"Are you using distutils or setuptools?\nI tested right now, and if it's distutils, it's enough to have\nscripts=['bin\/script_name']\nin your setup() call\nIf instead you're using setuptools you can avoid to have a script inside bin\/ altogether and define your entry point by adding\nentry_points={'console_scripts': ['script_name =  module_name:main']}\ninside your setup() call (assuming you have a main function inside module_name)\nare you sure that the bin\/script_name is marked as executable?\nwhat is the exact error you get when trying to run the script? what are the contents of your setup.py?","Q_Score":2,"Tags":"python-2.7,module","A_Id":16173774,"CreationDate":"2013-04-23T13:11:00.000","Title":"How to execute python script from a module I have made","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":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},{"Question":"I have my own package in python and I am using it very often. what is the most elegant or conventional directory where i should put my package so it is going to be imported without playing with PYTHONPATH or sys.path?\nWhat about site-packages for example?\n\/usr\/lib\/python2.7\/site-packages.\nIs it common in python to copy and paste the package there ?","AnswerCount":6,"Available Count":2,"Score":1.0,"is_accepted":false,"ViewCount":102848,"Q_Id":16196268,"Users Score":29,"Answer":"So if your a novice like myself and your directories are not very well organized you may want to try this method.\nOpen your python terminal. Import a module that you know works such as numpy in my case and do the following.\n Import numpy\nnumpy.__file__\nwhich results in\n'\/Library\/Frameworks\/Python.framework\/Versions\/3.4\/lib\/python3.4\/site-                       packages\/numpy\/__init__.py'\nThe result of numpy.__file__ is the location you should put the python file with your module (excluding the numpy\/__init__.py) so for me that would be \n\/Library\/Frameworks\/Python.framework\/Versions\/3.4\/lib\/python3.4\/site-                            packages\nTo do this just go to your terminal and type\nmv \"location of your module\" \"\/Library\/Frameworks\/Python.framework\/Versions\/3.4\/lib\/python3.4\/site-                            packages\"\nNow you should be able to import your module.","Q_Score":103,"Tags":"python,python-2.7","A_Id":31109017,"CreationDate":"2013-04-24T15:38:00.000","Title":"Where should I put my own python module so that it can be imported","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have my own package in python and I am using it very often. what is the most elegant or conventional directory where i should put my package so it is going to be imported without playing with PYTHONPATH or sys.path?\nWhat about site-packages for example?\n\/usr\/lib\/python2.7\/site-packages.\nIs it common in python to copy and paste the package there ?","AnswerCount":6,"Available Count":2,"Score":0.0333209931,"is_accepted":false,"ViewCount":102848,"Q_Id":16196268,"Users Score":1,"Answer":"On my Mac, I did a sudo find \/ -name \"site-packages\". That gave me a few paths like \/Library\/Python\/2.6\/site-packages, \/Library\/Python\/2.7\/site-packages, and \/opt\/X11\/lib\/python2.6\/site-packages.\nSo, I knew where to put my modules if I was using v2.7 or v2.6. \nHope it helps.","Q_Score":103,"Tags":"python,python-2.7","A_Id":38079471,"CreationDate":"2013-04-24T15:38:00.000","Title":"Where should I put my own python module so that it can be imported","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"What's the best way to automatically query several dozen MySQL databases with a script on a nightly basis? The script usually returns no results, so I'd ideally have it email or notify me if any are ever returned.\nI've looked into PHP, Ruby and Python for this, but I'm a little stumped as to how best to handle this.","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":307,"Q_Id":16203859,"Users Score":1,"Answer":"I believe the only one can answer this question is you. All 3 examples you gave can do what you need to do with cron to automate the job. But the best script language to be used is the one you are most comfortable to use.","Q_Score":0,"Tags":"php,python,mysql,sql,ruby","A_Id":16203901,"CreationDate":"2013-04-24T23:19:00.000","Title":"What's the best way to automate running MySQL scripts on several databases on a daily basis?","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},{"Question":"I have a (single) .py script. In it, I need to import a library. \nIn order for this library to be found, I need to call sys.path.append. However, I do not want to hardcode the path to the library, but pass it as a parameter. \nSo my problem is that if I make a function (set_path) in this file, I need to import the file, and import fails because the path is not yet appended. \nWhat are good ways to solve this problem?\nClarification after comments:\n\nI am using IronPython, and the library path is the path to CPython\/lib. This path is (potentially) different on every system. \nAs far as I know, I cannot pass anything via sys.argv, because the script is run in an embedded python interpreter, and there is no main function.","AnswerCount":2,"Available Count":1,"Score":0.2913126125,"is_accepted":false,"ViewCount":741,"Q_Id":16218288,"Users Score":3,"Answer":"You should not do the import globally, but inside a function which gets called after you appended the path.","Q_Score":2,"Tags":"python,ironpython,python-import","A_Id":16218323,"CreationDate":"2013-04-25T15:03:00.000","Title":"Python: sys.path.append vs. import?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"When I do next(ByteIter, '')<<8 in python, I got a name error saying\n\n\"global name 'next' is not defined\"\n\nI'm guessing this function is not recognized because of python version?  My version is 2.5.","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":2002,"Q_Id":16224901,"Users Score":1,"Answer":"though you could call ByteIter.next() in 2.6. This is not recommended however, as the method has been renamed in python 3 to next().","Q_Score":2,"Tags":"python,next","A_Id":16225009,"CreationDate":"2013-04-25T21:18:00.000","Title":"Python: next() is not recognized","Data Science and Machine Learning":0,"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},{"Question":"Is there a way to check what a function or a method does inside of python itself similar to the help function in Matlab. I want to get the definition of the function without having to Google it.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":2004,"Q_Id":16225782,"Users Score":1,"Answer":"The help() function gives you help on almost everything but if your searching for something (like a module to use) then type help('modules') and it will search for available modules.\nThen if you need to find information about a module load it and type dir(module_name) to see the methods that are defined in the module.","Q_Score":2,"Tags":"python","A_Id":16225924,"CreationDate":"2013-04-25T22:27:00.000","Title":"Python: Function Documentation","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"We have multiple branches in SVN and use Hudson CI jobs to maintain our builds. We use SVN revision number as part of our application version number. The issue is when a Hudson job check out HEAD of a brach, it is getting HEAD number of SVN not last committed revision of that brach. I know, SVN maintains revision numbers globally, but we want to reflect last committed number of particular brach in our version.\nis there a way to get last committed revision number of a brach using python script so that I can checkout that branch using that revision number?\nor better if there a way to do it in Hudson itself? \nThanks.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1110,"Q_Id":16244894,"Users Score":0,"Answer":"Except svn info you can also use svn log -q -l 1 URL or svn ls -v --depth empty URL","Q_Score":1,"Tags":"python,svn,jenkins,hudson","A_Id":16254689,"CreationDate":"2013-04-26T20:42:00.000","Title":"Using actual branch head revision number in 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":0},{"Question":"I am able to easily call a python script from php using system(), although there are several options. They all work fine, except they all fail. Through trial and error I have narrowed it down to it failing on \nimport MySQLdb\nI am not too familiar with php, but I am using it in a pinch. I understand while there could be reasons why such a restriction would be in place, but this will be on a local server, used in house, and the information in the mysql db is backed up and not to critical. Meaning such a restriction can be reasonably ignored. \nBut how to allow php to  call a python script that imports mysql? I am on a Linux machine (centOs) if that is relevant.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":322,"Q_Id":16281823,"Users Score":1,"Answer":"The Apache user (www-data in your case) has a somewhat restricted environment. Check where the Python MySQLdb package is installed and edit the Apache user's env (cf Apache manual and your distrib's one about this) so it has a usable Python environment with the right PYTHONPATH etc.","Q_Score":0,"Tags":"php,python,mysql,linux","A_Id":16282538,"CreationDate":"2013-04-29T14:55:00.000","Title":"call python script from php that connects to MySQL","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},{"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},{"Question":"There is a node where I ssh into and start a script remotely by Robot Framework (SSHLibrary.Start Command or Execute Command). This remote script starts a telnet connection to another node which is hidden from outside. This telnet call seems to be a blocking event to Robot. I use RIDE for test execution and it simply stops working. I can send stop signals inefficiently. Is it possible to spawn telnet within ssh?","AnswerCount":3,"Available Count":1,"Score":0.1325487884,"is_accepted":false,"ViewCount":2735,"Q_Id":16298022,"Users Score":2,"Answer":"We haven't exactly used the method with telnet but with another ssh session or other shells that we cannot access otherwise...\nOpen an ssh connection to the first machine. \nOn this connection, use SSHLibrary keywords like Set Prompt, Write and Read or Read Until Prompt to manually open a telnet connection to the next machine.\nWrite and Read Keywords can be used a bit like the expect and spawn...","Q_Score":4,"Tags":"python,testing,ssh,telnet,robotframework","A_Id":16315259,"CreationDate":"2013-04-30T10:47:00.000","Title":"Is there a way to use telnet within an ssh connection in Robot Framework?","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},{"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},{"Question":"How do I fire a Ctrl+C with fabric, in other words is it possible to trigger KeyboardInterrupt manually via bash?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":414,"Q_Id":16336919,"Users Score":2,"Answer":"ctrl+c generates a SIGINT signal.  \nYou can send a signal with kill -SIGINT pid where pid is the process id. you wish to signal.  kill is a Bash built-in.","Q_Score":2,"Tags":"python,bash,fabric","A_Id":16337848,"CreationDate":"2013-05-02T11:28:00.000","Title":"Simulate KeyboardInterrupt with fabric","Data Science and Machine Learning":0,"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},{"Question":"I have a question about using a hash which has strings as keys. Let's say I have a hash which maps strings to doubles.\nThe questions is, I've heard some say that it is better to tokenize the strings into ints and have the hash map ints to doubles and not string to doubles? Will this generally be faster in Python or C++ (2 questions) or will it not matter. Let's say that we're using boost unsorted_map in C++ so it's ore like a Python dictionary.\nWill this matter if the keys are actually (string, string) -- > double or in c++ unsorted_map>?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":136,"Q_Id":16344677,"Users Score":0,"Answer":"If you tokenize string you should be carefull not to have to different strings with same token. The std::unordered_map will also use hashes for quick search but also will take care of string with same hash but with different values. Of course it will take some time.\nIf you can tokenize the strings in such way that two strings would never have the same token, using map with ints as key is very good idea.","Q_Score":0,"Tags":"c++,python,string,hash,dictionary","A_Id":16344775,"CreationDate":"2013-05-02T17:59:00.000","Title":"tokenizing strings to int for faster hash maps","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm currently in the process of writing some unit tests I want to constantly run every few minutes. If any of them ever fail, I want to grab the errors that are raised and do some custom processing on them (sending out alerts, in my case). Is there a standard way of doing this? I've been looking at unittest.TestResult, but haven't found any good example usage. Ideas?","AnswerCount":2,"Available Count":2,"Score":0.2913126125,"is_accepted":false,"ViewCount":127,"Q_Id":16369398,"Users Score":3,"Answer":"We use a continious integration server jenkins for such task. It has cron like scheduling and can send an email when build becomes unstable (a test fails). There is an extention to python's unittest module to produce junit style xml report supported by jenkins.","Q_Score":3,"Tags":"python,unit-testing","A_Id":16394313,"CreationDate":"2013-05-04T00:31:00.000","Title":"Custom onFailure Call in Unittest?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I'm currently in the process of writing some unit tests I want to constantly run every few minutes. If any of them ever fail, I want to grab the errors that are raised and do some custom processing on them (sending out alerts, in my case). Is there a standard way of doing this? I've been looking at unittest.TestResult, but haven't found any good example usage. Ideas?","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":127,"Q_Id":16369398,"Users Score":0,"Answer":"In the end, I wound up running the test and returning the TestResult object. I then look at the failures attribute of that object, and run post processing on each test in the suite that failed. This works well enough for me, and let's me custom design my post-process.\nFor any extra meta data per test that I need, I subclass unittest.TestResult and add to the addFailure method anything extra that I need.","Q_Score":3,"Tags":"python,unit-testing","A_Id":16395234,"CreationDate":"2013-05-04T00:31:00.000","Title":"Custom onFailure Call in Unittest?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I setup a new Ubuntu 12.10 Server on VPN hosting. I have installed all the required setup like Nginx, Python, MySQL etc. I am configuring this to deploy a Flask + Python app using uWSGI. Its working fine.\nBut to create a basic app i used Putty tool (from Windows) and created required app .py files.\nBut I want to setup a Git functionality so that i can push my code to required directory say \/var\/www\/mysite.com\/app_data so that i don't have to use SSH or FileZilla etc everytime i make some changes into my website.\nSince i use both Ubuntu & Windows for development of app, setting up a Git kind of functionality would help me push or change my data easily to my Cloud Server.\nHow can i setup a Git functionality in Ubuntu ? and How could i access it and Deploy data using tools like GitBash etc. ?\nPlease Suggest","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1205,"Q_Id":16370283,"Users Score":0,"Answer":"Create a bare repository on your server.\nConfigure your local repository to use the repository on the server as a remote.\nWhen working on your local workstation, commmit your changes and push them to the repository on your server.\nCreate a post-receive hook in the server repository that calls \"git archive\" and thus transfers your files to some other directory on the server.","Q_Score":1,"Tags":"python,windows,git,ubuntu","A_Id":16375343,"CreationDate":"2013-05-04T03:28:00.000","Title":"How to setup Git to deploy python app files into Ubuntu 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":1,"Web Development":0},{"Question":"I'm running a python CGI script on my localhost that needs to import and use another python module that I wrote. I placed the CGI script in the Apache cgi-bin directory (I'm running this on windows). I've tried placing my custom module in the same directory, but it doesn't seem to be able to import that module. I would prefer to not have the custom module be another CGI script that is called via exec().","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":520,"Q_Id":16376048,"Users Score":0,"Answer":"You need to put your Python module somewhere that Python's import can see it.  The easy ways to do that are:  \n\nMake a directory for the module, and add that directory to your PYTHONPATH environment variable.  \nCopy the module into your Python site-packages directory, which is under your Python installation directory.\n\nIn either case, you will need to make sure your module's name is not the same as the name of some other module that might be imported by Python in your CGI script.","Q_Score":1,"Tags":"python,apache,cgi","A_Id":16376236,"CreationDate":"2013-05-04T15:42:00.000","Title":"Using custom module with 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":0,"System Administration and DevOps":0,"Web Development":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},{"Question":"After several hours of looking for the answer I've had no luck.\nCan anyone point me to an example of how to create a torrent and seed that brand new torrent in python?\nSo far I can download just fine and I can produce torrent files.  However, when I try to start my own torrent I get stuck on downloading rather than seeding.  Obviously this is a problem since the swarm contains only my host, which is supposed to be the seeder.\nAny advice?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":765,"Q_Id":16379844,"Users Score":0,"Answer":"Make sure to set the download directory to the place where the original files reside, when adding the torrent to the session. The torrent will detect that the files are already there and hash them to verify that they are correct, and seed any pieces that matched the expected hash.\nYou can force libtorrent to trust you that the pieces\/files are all there by setting the seed_mode in the add_torrent_params when adding the torrent. This will make libtorrent assume the files are there and not check them until they are requested.","Q_Score":0,"Tags":"python,bittorrent,libtorrent","A_Id":16382906,"CreationDate":"2013-05-04T23:18:00.000","Title":"How do I seed a directory or file using python-libtorrent?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I am new to Eclipse & PyDev (on Ubuntu 13.04) and want to try Python3.3 programming.\nBut I cannot choose python3.3 iterpreter, - I try to choose it in usr\\lib\\python3.3 , but:\n- when I try to choose PYTHONPATH by clicking \"New folder\" - window doesn't open (I can do it onl after choosing auto-config, which will add python2.7 pates);\n- I don't know the file in usr\\lib\\python3.3, which I need to choose, as python3.3 interpreter (auto-config returns me only 2.7 objects).\nCan you advice me how to choose python3.3 interpreter (maybe the main is the file\\path I need to choose in \" usr\\lib\\python3.3\" as interpreter file - in windows Eclipse I see python3.3.exe, - I need to find its equal in Ubuntu I think)?\nThanks!","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":986,"Q_Id":16382769,"Users Score":0,"Answer":"Use the auto-config option. It will automatically find the libraries.","Q_Score":1,"Tags":"eclipse,python-3.x,settings,pydev,interpreter","A_Id":19039512,"CreationDate":"2013-05-05T08:30:00.000","Title":"Choosing Python3.3 interpreter in Eclipse problems","Data Science and Machine Learning":0,"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},{"Question":"I am new to Eclipse & PyDev (on Ubuntu 13.04) and want to try Python3.3 programming.\nBut I cannot choose python3.3 iterpreter, - I try to choose it in usr\\lib\\python3.3 , but:\n- when I try to choose PYTHONPATH by clicking \"New folder\" - window doesn't open (I can do it onl after choosing auto-config, which will add python2.7 pates);\n- I don't know the file in usr\\lib\\python3.3, which I need to choose, as python3.3 interpreter (auto-config returns me only 2.7 objects).\nCan you advice me how to choose python3.3 interpreter (maybe the main is the file\\path I need to choose in \" usr\\lib\\python3.3\" as interpreter file - in windows Eclipse I see python3.3.exe, - I need to find its equal in Ubuntu I think)?\nThanks!","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":986,"Q_Id":16382769,"Users Score":0,"Answer":"You set the path usr\\lib\\python3.3 by typing it directly in the 'Interpreter Executable' field! You don't have to search for the Interpreter file. This will do the Auto Config for you. Afterwards you declare a name and you're done.","Q_Score":1,"Tags":"eclipse,python-3.x,settings,pydev,interpreter","A_Id":19208342,"CreationDate":"2013-05-05T08:30:00.000","Title":"Choosing Python3.3 interpreter in Eclipse problems","Data Science and Machine Learning":0,"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},{"Question":"Would like to know if there is a simple, easy way to have uWSGI pretty print exception messages (for Python specifically, not sure if the settings are particular to Python or not).\nThanks very much!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":823,"Q_Id":16408074,"Users Score":2,"Answer":"If you mean getting the exception message in the browser, just add --catch-exceptions\nIMPORTANT: it could expose sensitive informations, do not use in production !!!","Q_Score":1,"Tags":"python,debugging,exception,uwsgi,pretty-print","A_Id":16416281,"CreationDate":"2013-05-06T22:07:00.000","Title":"How to get uWSGI Python exception message pretty printing?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"Is there some way to speed up the repeated execution of pytest? It seems to spend a lot of time collecting tests, even if I specify which files to execute on the command line. I know it isn't a disk speed issue either since running pyflakes across all the .py files is very fast.\n\nThe various answers represent different ways pytest can be slow. They helped sometimes, did not in others. I'm adding one more answer that explains a common speed problem. But it's not possible to select \"The\" answer here.","AnswerCount":8,"Available Count":4,"Score":0.0,"is_accepted":false,"ViewCount":20629,"Q_Id":16417546,"Users Score":0,"Answer":"Pytest imports all modules in the testpaths directories to look for tests. The import itself can be slow. This is the same startup time you'd experience if you ran those tests directly, however, since it imports all of the files it will be a lot longer. It's kind of a worst-case scenario.\nThis doesn't add time to the whole test run though, as it would need to import those files anyway to execute the tests.\nIf you narrow down the search on the command line, to specific files or directories, it will only import those ones. This can be a significant speedup while running specific tests.\nSpeeding up those imports involves modifying those modules. The size of the module, and the transitive imports, slow down the startup. Additionally look for any code that is executed -- code outside of a function. That also needs to be executed during the test collection phase.","Q_Score":56,"Tags":"python,performance,pytest","A_Id":67071786,"CreationDate":"2013-05-07T11:11:00.000","Title":"How to speed up 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":0,"Web Development":0},{"Question":"Is there some way to speed up the repeated execution of pytest? It seems to spend a lot of time collecting tests, even if I specify which files to execute on the command line. I know it isn't a disk speed issue either since running pyflakes across all the .py files is very fast.\n\nThe various answers represent different ways pytest can be slow. They helped sometimes, did not in others. I'm adding one more answer that explains a common speed problem. But it's not possible to select \"The\" answer here.","AnswerCount":8,"Available Count":4,"Score":0.049958375,"is_accepted":false,"ViewCount":20629,"Q_Id":16417546,"Users Score":2,"Answer":"If you have some antivirus software running, try turning it off. I had this exact same problem. Collecting tests ran incredibly slow. It turned out to be my antivirus software (Avast) that was causing the problem. When I disabled the antivirus software, test collection ran about five times faster. I tested it several times, turning the antivirus on and off, so I have no doubt that was the cause in my case.\nEdit: To be clear, I don't think antivirus should be turned off and left off. I just recommend turning it off temporarily to see if it is the source of the slow down. In my case, it was, so I looked for other antivirus solutions that didn't have the same issue.","Q_Score":56,"Tags":"python,performance,pytest","A_Id":45336546,"CreationDate":"2013-05-07T11:11:00.000","Title":"How to speed up 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":0,"Web Development":0},{"Question":"Is there some way to speed up the repeated execution of pytest? It seems to spend a lot of time collecting tests, even if I specify which files to execute on the command line. I know it isn't a disk speed issue either since running pyflakes across all the .py files is very fast.\n\nThe various answers represent different ways pytest can be slow. They helped sometimes, did not in others. I'm adding one more answer that explains a common speed problem. But it's not possible to select \"The\" answer here.","AnswerCount":8,"Available Count":4,"Score":0.0748596907,"is_accepted":false,"ViewCount":20629,"Q_Id":16417546,"Users Score":3,"Answer":"For me, adding PYTHONDONTWRITEBYTECODE=1 to my environment variables achieved a massive speedup! Note that I am using network drives which might be a factor.\n\nWindows Batch: set PYTHONDONTWRITEBYTECODE=1\nUnix: export PYTHONDONTWRITEBYTECODE=1\nsubprocess.run: Add keyword env={'PYTHONDONTWRITEBYTECODE': '1'}\nPyCharm already set this variable automatically for me.\n\nNote that the first two options only remain active for your current terminal session.","Q_Score":56,"Tags":"python,performance,pytest","A_Id":65135225,"CreationDate":"2013-05-07T11:11:00.000","Title":"How to speed up 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":0,"Web Development":0},{"Question":"Is there some way to speed up the repeated execution of pytest? It seems to spend a lot of time collecting tests, even if I specify which files to execute on the command line. I know it isn't a disk speed issue either since running pyflakes across all the .py files is very fast.\n\nThe various answers represent different ways pytest can be slow. They helped sometimes, did not in others. I'm adding one more answer that explains a common speed problem. But it's not possible to select \"The\" answer here.","AnswerCount":8,"Available Count":4,"Score":0.0748596907,"is_accepted":false,"ViewCount":20629,"Q_Id":16417546,"Users Score":3,"Answer":"In bash, try { find -name '*_test.py'; find -name 'test_*.py'; } | xargs pytest.\nFor me, this brings total test time down to a fraction of a second.","Q_Score":56,"Tags":"python,performance,pytest","A_Id":62249933,"CreationDate":"2013-05-07T11:11:00.000","Title":"How to speed up 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":0,"Web Development":0},{"Question":"I am using Raspberry Pi to function as a mini web server. At first, i came across web2py and started to learn it. It was tough for a beginner like me. Later, a friend in a forum introduced CherryPy to me and i started to work on the web application skeleton that he gave me. Soon, I abandoned web2py and proceeded with cherrypy as it is fairly straightforward. \nSomehow, I think web2py could be a good choice too. Web application for both are written in python, with html, css and javascripts. So whatever i've done using cherrypy may be possible to transfer over to web2py. (is it true?)\nI would like to find out what are the main differences between those 2 and their respective pros and cons. I hope to find out more about fellow users' experiences in using web2py and cherrypy. In such way, future visitors can make a comparison before they proceed in choosing which one to use. Thank you!","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":1858,"Q_Id":16431207,"Users Score":1,"Answer":"web2py is using MVC model and each of the scripts are nicely separated. It can be deployed at pythoneverywhere.com. not too sure about cherrypy.","Q_Score":2,"Tags":"javascript,python,web2py,cherrypy","A_Id":16431335,"CreationDate":"2013-05-08T01:27:00.000","Title":"Which one is better to create a web application? web2py or cherrypy","Data Science and Machine Learning":0,"Database and SQL":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},{"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},{"Question":"Will i have any advantage of using Node.js for task queue worker instead of any other language, like PHP\/Python\/Ruby?\nI want to learn Redis for simple task queue tasks like sending big ammounts of email and do not want keeping users to wait for establishing connection etc.\nSo the questions is: does async nature of node.js help in this scenario or is it useless?\nP.S. i know that node is faster than any of this language in memory consumption and computation because of effecient V8 engine, maybe it's possible to win on this field?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1154,"Q_Id":16456682,"Users Score":0,"Answer":"I have used Node.js for task worker for jobs that call runnable webpages written in PHP or running commands on certain hosts. In both these instances Node is just initializing (triggering) the job, waiting for and then evaluating the result. The heavy lifting \/ CPU intensive work is done by another system \/ program.\nHope this helps!","Q_Score":2,"Tags":"php,python,ruby,node.js,redis","A_Id":16471242,"CreationDate":"2013-05-09T07:31:00.000","Title":"Any advantage of using node.js for task queue worker instead of other 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":1},{"Question":"Any reason to try and replace it with something else? I'm a beginner to python, but have encountered problems with C and importing CGI. List of instance where import cgi would not be the best option would be great for further understanding of language use.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":91,"Q_Id":16467684,"Users Score":0,"Answer":"You should choose WSGI instead of CGI. CGI applications are generally slow as they need re- invocation of interpreter for every request, WSGI on the other hand pools them and is much more efficient. WSGI is also more mainstream. Do a little research on web and you will get better and more detailed answers.\nIn the past I have used CGI with python but generally the usage has been for image\/chart generation,where the core lib was implemented in c\/c++.","Q_Score":0,"Tags":"python,python-3.x,cgi","A_Id":16467920,"CreationDate":"2013-05-09T17:33:00.000","Title":"Any reason not to just import CGI 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},{"Question":"Any reason to try and replace it with something else? I'm a beginner to python, but have encountered problems with C and importing CGI. List of instance where import cgi would not be the best option would be great for further understanding of language use.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":91,"Q_Id":16467684,"Users Score":0,"Answer":"List of instance where import cgi would not be the best option\n\nIf you're writing a script which will be installed and run as a CGI script on a web server, and you're not using some other framework that replaces it, import cgi is always the best option.\nSo, the cases where it's not the best option:\n\nYou're not writing a CGI script.\nYou don't need access to FieldStorage or anything else from the gateway.\nYou're using a framework with its own replacement for cgi.\n\nThat's about it.\nIf you're not sure whether you want to use CGI or not in the first place\u2026 you probably don't. If you want the same general style of coding as CGI, WSGI is just as simple, more flexible, and usually faster. \nBut if you're just starting at this stuff, that may not even be the style you want. Start at the high level. Do you want to template web pages, or serve JSON to JavaScript code that does the dynamic stuff in the browser? What features do you need on your user sessions? And so on. Once you know what you want, then see if there's a framework\u2014Django, Tornado, CherryPy, whatever\u2014that looks like it'll make your design easier. Only then ask yourself whether you want WSGI, CGI, mod_python, an embedded server, \u2026","Q_Score":0,"Tags":"python,python-3.x,cgi","A_Id":16468659,"CreationDate":"2013-05-09T17:33:00.000","Title":"Any reason not to just import CGI 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},{"Question":"I'm writing a Python module that has only about twenty interesting types and global methods, but lots of constants and exceptions (about 70 constants for locales, 60 constants for encodings, 20 formatting attributes, more than 200 exceptions, and so on). As a result help() on this module produces about 16,000 lines of text and is littered with nearly identical descriptions of each exception. The constants are not that demanding, but it's still difficult to navigate them.\nWhat would be a pythonic way to organize such a module? Just leave it as is and rely on other documentation? Move constants into separate dicts? Into submodules? Add them as class-level constants, where appropriate?\nNote that this is a C extension so I cannot easily add a real submodule here. I've heard that sys.modules doesn't really check if the object there is a module, so one could add dictionaries there; this way I could probably create mymodule.locales, mymodule.encoding, and mymodule.exceptions and add them into sys.modules when my module is imported. Would this be a good idea or it's too hackish?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":776,"Q_Id":16481015,"Users Score":1,"Answer":"There are really two options to solve your problem. The first approach is to classify all the constants and exceptions, and have a smaller number of broader categories. This would allow you to easily navigate into which categories you want. A dictionary (or probably nested dictionaries) would be a good way to implement this, as you could maintain groups with titles in them. A second way you could do this if you wanted to customize the management a little bit more would be to make a class that would act a bit like a dictionary. It would have a list of children objects. This way, you could make unique, easier to access methods to navigate through all of your constants and exceptions, such as a new exception class that handles several similar exceptions. The other way to make it cleaner, which would require access to the source, would be to make all of those exceptions into a smaller group of exceptions that can each handle groups of similar problems. This would probably be a better way to deal with the exceptions, but you may not have access to the source to modify this.","Q_Score":5,"Tags":"python,exception,constants,organization","A_Id":20154892,"CreationDate":"2013-05-10T11:14:00.000","Title":"How to organize a Python module with lots of constants and exceptions?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am writing a Windows python program that needs to query WMI. I am planning to do this by using the subprocess module to call WMIC with the arguments I need.\nI see a lot of examples online of using WMI via PowerShell, usually using the \"commandlet\" Get-WmiObject or the equivalent gwmi.\nHow do you do the equivalent of Get-WmiObject without using PowerShell, but rather with WMIC?\nSpecificially, from within CMD.EXE, I want to do powershell gwmi Win32_USBControllerDevice, but without using powershell; rather, I want to invoke WMIC directly.\nThanks, and sorry for the beginner question!","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1863,"Q_Id":16491077,"Users Score":0,"Answer":"From CMD.EXE, I think the command I need is wmic path Win32_USBControllerDevice get *\nSo most likely the general pattern is:\n\nPowerShell: gwmi MYCLASSNAME \ntranslates into:\nCMD.EXE: wmic path\nMYCLASSNAME get *","Q_Score":1,"Tags":"python,windows,wmi,wmic","A_Id":16491345,"CreationDate":"2013-05-10T21:27:00.000","Title":"Get-WmiObject without PowerShell","Data Science and Machine Learning":0,"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},{"Question":"I'm trying to get test unit coverage with Sonar. To do so, I have followed these steps :\n\nGenerating report with python manage.py jenkins --coverage-html-report=report_coverage\nSetting properties in \/sonar\/sonar-3.5.1\/conf\/sonar.properties:\n\nsonar.dynamicAnalysis=reuseReports\nsonar.cobertura.reportPath=\/var\/lib\/jenkins\/workspace\/origami\/DEV\/SRC\/origami\/reports\/coverage.xml\nWhen I launch the tests, the reports are generated in the right place. However, no unit tests are detected by Sonar.\nAm I missing a step or is everything just wrong?","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":6621,"Q_Id":16518002,"Users Score":0,"Answer":"On Jenkins I found that coverage.xml has paths that are relative to the directory in which manage.py jenkins is run.\nIn my case I need to run unit tests on a different machine than Jenkins. To allow Sonar to use the generated coverage.xml, it was necessary for me to run the tests from a folder in the same spot relative to the project as the workspace directory on Jenkins.\n\nSay I have the following on Jenkins\n\/local\/jenkins\/tmp\/workspace\/my_build\n   + my_project\n       + app1\n       + app2\nSay on test machine I have the following\n\/local\/test\n   + my_project\n      + app1\n      + app2\n\nI run unit tests from \/local\/test on the test machine. Then coverage.xml has the correct relative paths, which look like my_project\/app1\/source1.py or my_project\/app2\/source2.py","Q_Score":4,"Tags":"python,django,jenkins,code-coverage,sonarqube","A_Id":19887503,"CreationDate":"2013-05-13T08:46:00.000","Title":"How to get tests coverage using Django, Jenkins and Sonar?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I am using ipdb to debug a python script.\nI want to print a very long variable. Is there any ipdb pager like more or less used in shells?\nThanks","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":725,"Q_Id":16541847,"Users Score":3,"Answer":"You might want to create a function which accepts a text, puts this text into a temporary file, and calls os.system('less %s' % temporary_file_name).\nTo make it easier for everyday use: Put the function into a file (e.g: ~\/.pythonrc) and specify it in your PYTHONSTARTUP.\nAlternatively you can just install bpython (pip install bpython), and start the bpython shell using bpython. This shell has a \"pager\" functionality which executes less with your last output.","Q_Score":4,"Tags":"python,debugging,printing,pager,pdb","A_Id":16565699,"CreationDate":"2013-05-14T11:20:00.000","Title":"Is there any ipdb print pager?","Data Science and Machine Learning":0,"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},{"Question":"Well thats the question. Are there any projects for other languages which try to imitate what stackless python is doing for python?","AnswerCount":3,"Available Count":2,"Score":0.3215127375,"is_accepted":false,"ViewCount":372,"Q_Id":16542897,"Users Score":5,"Answer":"If you mean the stackless compilation with lightweight concurrency, Haskell has done that from the very beginning.  IIRC the first compilation scheme for Haskell was called the G-machine.  Later that was replaced by the STG-machine.  This is actually necessary for efficient laziness, but easy concurrency and parallelism comes as an additional bonus.\nAnother notable language in this sector is Erlang and its bad joke imitation language Go, as well as continuation-based languages like Scheme.  Unlike Haskell they don't use an STG compilation scheme.","Q_Score":2,"Tags":"python,haskell,compiler-construction,lisp,interpreter","A_Id":16543659,"CreationDate":"2013-05-14T12:16:00.000","Title":"Are there any Stackless Python like projects for other languages (Java, Lisp, Haskell, Go etc)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"Well thats the question. Are there any projects for other languages which try to imitate what stackless python is doing for python?","AnswerCount":3,"Available Count":2,"Score":0.2605204458,"is_accepted":false,"ViewCount":372,"Q_Id":16542897,"Users Score":4,"Answer":"Both Haskell and Erlang contain (in the standard implementation) microthreads\/green threads with multi-core support, a preemptive scheduler, and some analogue of channels. The only rather unique feature of Stackless that I can think of is serialisation of threads, although you can sometimes fake it by providing a way of serializing function state.","Q_Score":2,"Tags":"python,haskell,compiler-construction,lisp,interpreter","A_Id":16543577,"CreationDate":"2013-05-14T12:16:00.000","Title":"Are there any Stackless Python like projects for other languages (Java, Lisp, Haskell, Go etc)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":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},{"Question":"My python program consists of several files: \n\nthe main execution python script\npython modules in *.py files\nconfig file\nlog files\nexecutables scripts of other languages.\n\nAll this files should be available only for root. The main script should run on startup, e.g. via upstart.\nWhere I should put all this files in Linux filesystem? \nWhat's the better way for distribution my program? pip, easy_install, deb, ...? I haven't worked with any of these tool, so I want something easy for me.\nThe minimum supported Linux distributive should be Ubuntu.","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":14785,"Q_Id":16565363,"Users Score":13,"Answer":"For sure, if this program is to be available only for root, then the main execution python script have to go to \/usr\/sbin\/.\nConfig files ought to go to \/etc\/, and log files to \/var\/log\/.\nOther python files should be deployed to \/usr\/share\/pyshared\/.\nExecutable scripts of other languages will go either in \/usr\/bin\/ or \/usr\/sbin\/ depending on whether they should be available to all users, or for root only.","Q_Score":12,"Tags":"python,linux,open-source","A_Id":16565499,"CreationDate":"2013-05-15T12:45:00.000","Title":"Where I should put my python scripts 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":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"My python program consists of several files: \n\nthe main execution python script\npython modules in *.py files\nconfig file\nlog files\nexecutables scripts of other languages.\n\nAll this files should be available only for root. The main script should run on startup, e.g. via upstart.\nWhere I should put all this files in Linux filesystem? \nWhat's the better way for distribution my program? pip, easy_install, deb, ...? I haven't worked with any of these tool, so I want something easy for me.\nThe minimum supported Linux distributive should be Ubuntu.","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":14785,"Q_Id":16565363,"Users Score":1,"Answer":"If only root should access the scripts, why not put it in \/root\/ ?\nSecondly, if you're going to distribute your application you'll probably need easy_install or something similar, otherwise just tar.gz the stuff if only a few people will access it?\nIt all depends on your scale..\nPyglet, wxPython and similar have a hughe userbase.. same for BeautifulSoup but they still tar.gz the stuff and you just use setuptools to deply it (whcih, is another option).","Q_Score":12,"Tags":"python,linux,open-source","A_Id":16565490,"CreationDate":"2013-05-15T12:45:00.000","Title":"Where I should put my python scripts 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":1,"System Administration and DevOps":1,"Web Development":0},{"Question":"I want to design a website with minimal front end and a backend for periodic processing. Some 200 users will use the site.I have choosen php vs python. I have done few defect fixes in PHP and some automation scription in python and I have absolutely no web development experience. But I have application development experience in c++.\nI want to develop the site with ease and minimum effort(no CMS as I want to learn the language). Can anyone suggest me which one choose ?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":164,"Q_Id":16566430,"Users Score":1,"Answer":"I personally think if you have little web development experience you should go with PHP. You can directly embed it in your HTML and perhaps that will make it easier to understand for you. That's of course if you don't want to make complicated websites (yet).\nAfter you familiarise yourself with web development, you can then decide again whether to use PHP or Python depending on the platform you want to use and what you want to achieve.\nMoreover if you have C++ experience, PHP's syntax is IMO closer to C++.","Q_Score":0,"Tags":"php,python,web","A_Id":16566525,"CreationDate":"2013-05-15T13:31:00.000","Title":"from c++ development to PHP 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":0,"Web Development":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},{"Question":"In the Visual Event description, it says that it extracts \"which elements have events attached to them\". I can confirm this by running the bookmarklet and seeing all the colour highlights.\nI would like to extract this information without the fancy presentation so that I can play around with it into a script (Ruby\/Python\/Perl). In other words, I would like to get a list of the divs (and their info ideally) from Visual Event.\nIs there any way to do this without digging through the code on GitHub? Not to say that I'm not willing to do this, I was just wondering if there was an easier way.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":67,"Q_Id":16577725,"Users Score":0,"Answer":"There is no way to accomplish this very oddly specific task without digging through the code, although this isn't as hard as it seems considering it's quite legible and easy to build on your own system, even if you don't have any previous experience with JavaScript.","Q_Score":0,"Tags":"javascript,python,ruby,perl","A_Id":16579794,"CreationDate":"2013-05-16T01:43:00.000","Title":"Extracting Visual Event 2 output into 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},{"Question":"I'm currently looking for a mature GA library for python 3.x. But the only GA library can be found are pyevolve and pygene. They both support python 2.x only. I'd appreciate if anyone could help.","AnswerCount":6,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":11702,"Q_Id":16587145,"Users Score":2,"Answer":"Not exactly a GA library, but the book \"Genetic Algorithms with Python\" from Clinton Sheppard is quite useful as it helps you build your own GA library specified for your needs.","Q_Score":5,"Tags":"python,genetic-algorithm","A_Id":45485156,"CreationDate":"2013-05-16T12:14:00.000","Title":"Any Genetic Algorithms module 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":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying finding a library of Python that could detect the model of a graphics card. For a better graphics card, there is a higher score associated with it, because I need to configure a game's display based on the performance of graphic card.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":252,"Q_Id":16591538,"Users Score":0,"Answer":"If you take this approach, you will have to maintain an ever changing database of graphics cards and the performance capabilities of each. Typically, options are available to the user for changing texture quality, terrain\/water detail, shadows, lighting, anti-aliasing, etc. There is also usually a test where the game renders a scene, and based on the frame rate the game can set ideal presets for most of the graphics options.","Q_Score":2,"Tags":"python,graphic","A_Id":22495380,"CreationDate":"2013-05-16T15:25:00.000","Title":"Python Library Can Detect Graphic Card","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"Is it possible to run Python code from within the vim editor?\nWhat is necessary to install the support along with Python syntax highlighting?\nHow would I install \"python.vim : Enhanced version of the python syntax highlighting script\" ? \nI did not automatically create ~\/.vim\/syntax and I'm using a Mac, all I downloaded was the .app file, an executable that I don't know of its purpose and a readme file.\nI've tried also creating a folder for the python.vim file, but that didn't work out either.","AnswerCount":3,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":11604,"Q_Id":16597216,"Users Score":18,"Answer":"Personally:\n\nWhen inside Vim editing my Python scripts, I simply hit CtrlZ so as to return in console mode.\nRun my script with command $ python my_script.py.\nWhen done, I enter $ fg in the command line and that gets me back inside Vim, in the state I was before hitting CtrlZ. (fg as in foreground)\n\n\nEdit\nRecently I have started using the :terminal mode of vim much more frequently.\nI tend to prefer it to CtrlZZ because it may happen that I forget that I used Ctrl-z and open an additional vim session: it may become messy. Also, having a terminal pane is easier for dealing with line number in errors message, since the two views are available at the same time.\nSo the workflow I'm using nowadays has become:\n\n:terminal  (in my case I have a vim mapping with leader key) tm :terminal so that I don't even type :terminal manually)\nRun my script with command $ python my_script.py.\n$ exit in the bash command line if I want to close the terminal pane","Q_Score":1,"Tags":"python,vim","A_Id":16606672,"CreationDate":"2013-05-16T20:49:00.000","Title":"Can Python be run from within the vim 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},{"Question":"I would like to make an authentication system where users or an administrator can choose which login system they prefer. The problem is that different systems have different Login-Systems and different client-informations. \nI thought I will make an simple User-Class in the c++ application and an administrator can extend this class with its own one or more User-Login-Systems in Python. Off course this service runs on a server.\nHow can I organize the different Login-Systems on the server and automatically use the prefered Login-System with the correct user-information class on the client application?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":398,"Q_Id":16604125,"Users Score":1,"Answer":"Assuming that you would like to support login systems such as User\/Pass, LDAP, OpenID, Oauth etc.. you have to model your authentication layer to be able to support all these mechanisms. I usually consider the above authentication methods as strategies.\nLets say you have an Authentication class with an authenticate method which accepts an object that implements an interface \"AuthStrategy\"  and the various authentication methods can implement this interface.\nHope the object model is clear.","Q_Score":0,"Tags":"c++,python,login,operating-system","A_Id":16604457,"CreationDate":"2013-05-17T07:53:00.000","Title":"handling multiple login systems","Data Science and Machine Learning":0,"Database and SQL":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},{"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},{"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},{"Question":"So I have been taking a few classes on python and the whole time, I was wondering about modules. I can install them and run them with Eclipse but if I compile that program, so if it has an 'exe' extension, how would the module react on a computer that doesn't have it installed.\nExample:\nIf I made some random little thing with something like pygame. I installed the pygame module on my computer, made an application with the pygame module and compiled it into an executable, how does the other computer that I run that file on. Or does it not work at all?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":148,"Q_Id":16682410,"Users Score":0,"Answer":"Python modules are already executable - you don't compile them. If you want to run them on another computer, you can install python and any other dependent module such as pygame on that computer, copy the scripts over and run them. \nPython has many ways to wrap scripts up into an installer to do the work for you. Its common to use python distutils to write a setup.py file which handles the install. From there you can use setup.py to bundle your scripts into zip files, tarballs, executables, rpms, etc... for other machines. You can document what the user needs to make your stuff go or you can use something like pip or distribute to write dependency files to automatically install pygame (and etc...).\nThere are many ways to handle this and its not particularly easy the first time round. For starters, read up on distutils in the standard python docs and then google for the pip installer.","Q_Score":0,"Tags":"python,module","A_Id":16682782,"CreationDate":"2013-05-22T02:13:00.000","Title":"Python modules on different devices","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am trying to come out with a small python script to monitor the battery state of my ubuntu laptop and sound alerts if it's not charging as well as do other stuff (such as suspend etc).\nI really don't know where to start, and would like to know if there is any library for python i can use.\nAny help would be greatly appreciated.\nThanks","AnswerCount":4,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":5179,"Q_Id":16699883,"Users Score":0,"Answer":"You do not need to use any module for this. \nSimply you can navigate to\n\/sys\/class\/power_supply\/BAT0.\nHere you will find a lot of files with information about your battery. \nYou will get current charge in charge_now file and total charge in charge_full file. \nThen you can calculate battery percentage by using some math.\nNote:- You may need root access for this. You can use sudo nautilus command to open directories in root mode.","Q_Score":5,"Tags":"python,linux,ubuntu","A_Id":56511789,"CreationDate":"2013-05-22T19:15:00.000","Title":"Use Python to Access Battery Status 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},{"Question":"I am trying to come out with a small python script to monitor the battery state of my ubuntu laptop and sound alerts if it's not charging as well as do other stuff (such as suspend etc).\nI really don't know where to start, and would like to know if there is any library for python i can use.\nAny help would be greatly appreciated.\nThanks","AnswerCount":4,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":5179,"Q_Id":16699883,"Users Score":0,"Answer":"The the \"power\" library on pypi is a good bet, it's cross platform too.","Q_Score":5,"Tags":"python,linux,ubuntu","A_Id":39884293,"CreationDate":"2013-05-22T19:15:00.000","Title":"Use Python to Access Battery Status 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},{"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},{"Question":"I have heard many times that C and Python\/Ruby code can be integrated.  \nNow, my question is, can I use, for example a Python\/Ruby ORM from within C?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":70,"Q_Id":16751639,"Users Score":3,"Answer":"Yes, but the API would be unlikely to be very nice, especially because the point of an ORM is to return objects and C doesn't have objects, hence making access to the nice OOP API unwieldy.\nEven in C++ is would be problematic as the objects would be Python\/Ruby objects and the values Python\/Ruby objects\/values, and you would need to convert back and forth.\nYou would be better off using a nice database layer especially made for C.","Q_Score":1,"Tags":"python,c,ruby","A_Id":16751766,"CreationDate":"2013-05-25T16:34:00.000","Title":"Can I use a Python\/Ruby ORM inside 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},{"Question":"When writing unit tests, it often happens that some tests sort of \"depend\" on other tests.\nFor example, lets suppose I have a test that checks I can instantiate a class.  I have other tests that go right ahead and instantiate it and then test other functionality.\nLets also suppose that the class fails to instantiate, for whatever reason.\nThis results in a ton of tests giving errors.  This is bad, because I can't see where the problem really is.  What I need is a way of skipping these tests if my instantiation test has failed.\nIs there a way of doing this with Python's unittest module?\nIf this isn't what I should do, what should I do so as to see where the problem really is when something breaks?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":500,"Q_Id":16760786,"Users Score":0,"Answer":"I have no suggestion how to avoid running \"dependent\" tests, but I have a suggestion how you might better live with them: Make the dependencies more apparent and therefore make it easier to analyse test failures later.  One simple possibility is the following:\n\nIn the test-code, you put the tests for the lower-level aspects at the top of the file, and the more dependent tests further to the bottom. Then, when several tests fail, first look at the test that is closest to the top of the file.","Q_Score":5,"Tags":"python,unit-testing","A_Id":53884422,"CreationDate":"2013-05-26T15:34:00.000","Title":"Ignore unittests that depend on success of other 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},{"Question":"Im trying to make a algorithm in python to detect if my phone is in the area. Im using this to find my device:\nbluetooth.discover_devices()\nBut it only detects my phone if I set my Bluetooth on my phone to \"visible\". \nIs there a function or command to detect my phone when it's set to hidden?\nIm fairly new to python so any form of help is very welcome! \nThanks in advance!","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1954,"Q_Id":16794658,"Users Score":0,"Answer":"You could attempt to connect to your phone.  If it's nearby, the connection will succeed.  Devices can be connectable when they are not discoverable.  You would have to already know the device address of your phone (via discovery when your phone was visible) in order to initiate the connection.","Q_Score":1,"Tags":"python,bluetooth,hidden,device","A_Id":16795191,"CreationDate":"2013-05-28T14:29:00.000","Title":"How to find bluetooth devices not set to visible 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},{"Question":"I am creating an application related to files. And I was looking for ways to compute checksums for files. I want to know what's the best hashing method to calculate checksums of files md5 or SHA-1 or something else based on this criterias\n\nThe checksum should be unique. I know its theoretical but still I want the probablity of collisions to be very very small.\nCan compare two files to be equal if there checksums are equal or not.\nSpeed(not very important, but still)\n\nPlease feel free to as elaborative as possible.","AnswerCount":4,"Available Count":1,"Score":0.049958375,"is_accepted":false,"ViewCount":2494,"Q_Id":16799088,"Users Score":1,"Answer":"md5 tends to work great for checksums ... same with SHA-1 ... both have very small probability of collisions although I think SHA-1 has slightly smaller collision probability since it uses more bits\nif you are really worried about it, you could use both checksums (one md5 and one sha1) the chance that both match and the files differ is infinitesimally small (still not 100% impossible but very very very unlikely) ... (this seems like bad form and by far the slowest solution)\ntypically (read: in every instance I have ever encountered) an MD5 OR an SHA1 match is sufficient to assume uniqueness \nthere is no way to 100% guarantee uniqueness short of byte by byte comparisson","Q_Score":4,"Tags":"python,django,file,checksum","A_Id":16799533,"CreationDate":"2013-05-28T18:37:00.000","Title":"File Checksums 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},{"Question":"I'm looking for a game which will allow me to test various artificial intelligence, reinforcement learning and machine learning algorithms. It would be great, if there will be good documentation or even helpful framework for writing AI. I know about TORCS, but do you know other games? It doesn't matter in which language it is written. It can be any arcade game, simulator, FPS, etc.","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":520,"Q_Id":16813243,"Users Score":2,"Answer":"Quake 3 is an ideal candidate for bot design. \n\nopen source code base.\nRealistic scenario (compared to robocode which is a toy domain).\nexisting bots and I believe the first bots used in Quake 3 where the output of a Ph.D.\nlots of documentation.","Q_Score":0,"Tags":"java,c++,python,machine-learning,artificial-intelligence","A_Id":16813957,"CreationDate":"2013-05-29T11:57:00.000","Title":"Game which allows to test AI 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},{"Question":"I'm using Python with a Cygwin environment to develop data processing scripts and Python packages  I'd like to actively use the scripts while also updating the packages on which those scripts depend.    My question is what is the best practice, recommendation for managing the module loading path to isolate and test my development changes but not affect the working of a production script.   \nPython imports modules in the following order (see M. Lutz, Learning Python)\n\nHome directory. \nPYTHONPATH directories.\nStandard library directories.\nThe contents of any *.pth file.\n\nMy current solution is to install my packages in a local (not in \/usr\/lib\/python2.x\/ ) site-packages directory and add a *.pth file in the global site-packages directory so these are loaded by default.   In the development directory I then simply modify PYTHONPATH to load the packages I'm actively working on with local changes.  \nIs there a more standard way of handling this situation? Setting up a virtualenv or some other way of manipulating the module load path?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":170,"Q_Id":16817623,"Users Score":1,"Answer":"This is just my opinion, but I would probably use a combination of virtualenvs and Makefiles\/scripts in this case. I haven't done it for your specific use case, but I often set up multiple virtualenvs for a project, each with a different python version. Then I can use Makefiles to run my code or tests in one or all of my virtualenvs.  Seems like it wouldn't be too hard to set up a makefile that would let you type make devel to run in the development envionment, and make production for the production environment.\nAlternatively, you could use git branches to do this. Keep your production scripts on master, and use feature branches to isolate and test changes while still having your production scripts just a git checkout master away.","Q_Score":2,"Tags":"python","A_Id":16817965,"CreationDate":"2013-05-29T15:10:00.000","Title":"Separate Python paths for development and 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":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"i am trying to find if it is possible to send a message over Bluetooth to consoles like playstation 3 to make it turn on or off? since it is possible to be done from controllers. I been reading around about it. but was wondering if there is any information or exapmles that could help. as all i could find was python code which i am not really a pro in.\nAny information will be much appreciated.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":150,"Q_Id":16817777,"Users Score":0,"Answer":"Im pretty sure you need an emulator for this. Correct me if Im wrong.","Q_Score":1,"Tags":"java,android,python,bluetooth,playstation","A_Id":16818550,"CreationDate":"2013-05-29T15:17:00.000","Title":"Android to Playstation and other consoles","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"PyDev has its own jython interpreter, inside pydev.jython.VERSION\nthat jython has its own python libraries i.e. pydev.jython.VERSION\/LIB\/zipfile.py\nNow if I write a jython script for pydev-jython-scripting, it will load only its internal Lib  pydev.jython.VERSION\/LIB\/\nHow do I have this pydev-jython recognize PYTHONPATH, I tried appending to sys.path but there is some python version problem some invalid syntax\nMy system python installation has all the .py source, my pydev interpreter configuration has python interpreter setup and NOT jython and NOT ironpython\npydev-jython script does not recognize many of regular system python modules, why?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":205,"Q_Id":16824942,"Users Score":0,"Answer":"The version that PyDev uses internally is Jython 2.1, so, you can't add newer libraries to that version unless they're compatible... \nIf you need to use a different version, you'd need to first update the version used inside PyDev itself (it wasn't updated so far because the current Jython size is too big -- PyDev has currently 7.5 MB and just the newer Jython jar is 10 MB -- with libs it goes to almost 16 MB, so making PyDev have 22 MB just for this upgrade is something I'm trying to avoid... now, I think there's probably too much bloat there in Jython, so, if that can be removed, it's something that may be worth revisiting...).","Q_Score":2,"Tags":"python,eclipse,pydev,jython","A_Id":18384815,"CreationDate":"2013-05-29T22:26:00.000","Title":"pydev eclipse, jython scripting , syspath","Data Science and Machine Learning":0,"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},{"Question":"my function reads from a file, and a doctest needs to be written in a way independent of an absolute path. What's the best way of wrting a doctest? Writing a temp file is expensive and not failproof.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":1135,"Q_Id":16831701,"Users Score":1,"Answer":"Your doctest could use module StringIO to provide a file object from a string.","Q_Score":4,"Tags":"python,doctest","A_Id":16831858,"CreationDate":"2013-05-30T08:50:00.000","Title":"How to write a doctest for a function that reads from 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},{"Question":"I have a question which has been on my mind for a while. I'm aware that languages like C are faster than Python and are therefore used to write operating systems. I've read somewhere that an operating system written in Python will be very slow. So here is my question:\nAs processor speed is continuously improved, does the execution speed of a particular language become less of a factor in operation system development? Will it be possible, in the future, to write an operating system solely in Python that will be running almost on the same speed with one written in C? Thank you.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":190,"Q_Id":16853789,"Users Score":1,"Answer":"No. Think about it: If Python is slower than C for a processor running at speed X, what can you say about the speed of Python vs. C for a processor running at speed 2X?\nBut then... You can write operating systems in dynamic languages. And people do. Once you bootstrap the interpreter. But this won't become mainstream. At least not anytime soon. Because: The mainstream operating systems are already... well... mainstream. And people want to use all that processing power in their new processors for... um... processing stuff. And not for providing the underpinnings to... um... process stuff.","Q_Score":1,"Tags":"python","A_Id":16853869,"CreationDate":"2013-05-31T09:12:00.000","Title":"Python's speed in operating system 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},{"Question":"I have created a python script that uses selenium to automate an online task. The script works perfect on my local machine (windows 7) and gives the output i am looking for. I am now trying to get it up and running from PHP on my hostmonster shared server which is running linux and having no luck. \nI have installed this version of selenium on both my win7 comp and the server:  pypi.python.org\/pypi\/selenium\nPython version: 2.7.5\nThe script i wrote gets the following error at \"import selenium\":ImportError: No module named selenium\nWhen i log into the server through ssh shell, i can type in \"import selenium\" and receive no errors. I can also type in \"from selenium import webdriver\" in the ssh shell and receive no errors.\nAny help\/guidance would be greatly appreciated.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":238,"Q_Id":16881335,"Users Score":0,"Answer":"when i enter\nimport sys\nand then\nprint sys.path\ninto ssh shell I receive the following:\n['', '\/home2\/klickste\/python\/lib\/python2.7\/site-packages\/setuptools-0.6c11-py2.7.egg', '\/home2\/klickste\/python\/lib\/python2.7\/site-packages\/mechanize-0.2.5-py2.7.egg', '\/home2\/klickste\/python\/lib\/python2.7\/site-packages\/html2text-3.200.3-py2.7.egg', '\/home2\/klickste\/python\/lib\/python2.7\/site-packages\/pip-1.3.1-py2.7.egg', '\/home2\/klickste\/python\/lib\/python27.zip', '\/home2\/klickste\/python\/lib\/python2.7', '\/home2\/klickste\/python\/lib\/python2.7\/plat-linux2', '\/home2\/klickste\/python\/lib\/python2.7\/lib-tk', '\/home2\/klickste\/python\/lib\/python2.7\/lib-old', '\/home2\/klickste\/python\/lib\/python2.7\/lib-dynload', '\/home2\/klickste\/python\/lib\/python2.7\/site-packages']","Q_Score":0,"Tags":"php,python,selenium,hostmonster","A_Id":16975487,"CreationDate":"2013-06-02T09:08:00.000","Title":"Import selenium error on hostmonster shared linux server","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},{"Question":"I have created a python script that uses selenium to automate an online task. The script works perfect on my local machine (windows 7) and gives the output i am looking for. I am now trying to get it up and running from PHP on my hostmonster shared server which is running linux and having no luck. \nI have installed this version of selenium on both my win7 comp and the server:  pypi.python.org\/pypi\/selenium\nPython version: 2.7.5\nThe script i wrote gets the following error at \"import selenium\":ImportError: No module named selenium\nWhen i log into the server through ssh shell, i can type in \"import selenium\" and receive no errors. I can also type in \"from selenium import webdriver\" in the ssh shell and receive no errors.\nAny help\/guidance would be greatly appreciated.","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":238,"Q_Id":16881335,"Users Score":1,"Answer":"I have resolved the issue. I used the following command to install selenium outside of the python folder.\neasy_install --prefix=$HOME\/.local\/ selenium\nI also added these lines at the bottom of my .bashrc file located in my home directory\nexport PYTHONPATH=$HOME\/.local\/lib\/python\/site-packages:$PYTHONPATH\nexport PYTHONPATH=$HOME\/.local\/lib\/python2.7\/site-packages:$PYTHONPATH\nexport PATH=$HOME\/.local\/bin:$PATH","Q_Score":0,"Tags":"php,python,selenium,hostmonster","A_Id":16991512,"CreationDate":"2013-06-02T09:08:00.000","Title":"Import selenium error on hostmonster shared linux server","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},{"Question":"I am building a back end that will handle requests from web apps and mobile device apps.\nI am trying to decide if an TCP server is appropriate for this vs. Regular http GET and POST requests.\nUse case 1:\n1. Client on mobile device executes a search on the device for the word \"red\".\n\nWord sent to server (unclear wether JSON or TCP somehow) \nThe word red goes to the server and the server pulls all rows from a mysql db that have red as their color (this could be ~5000 results).\nAlternate step 2 (maybe TCP should make more sense here):  there is a hashmap built with the word red as the key and the value a pointer to an array of all the objects with the word red (I think this will be a faster look up time).\nData is sent to the phone (either JSON or some other way, not sure). I am unclear on this step.\nThe phone parses, etc...\n\nThere is a possibility that I may want to keep the array alive on the server until the user finishes the query (since they could continue to filter down results).\nBased on this example, what is the architecture I should be looking at?\nAny different way is highly appreciated.\nThank you","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":110,"Q_Id":16889768,"Users Score":1,"Answer":"In your case I would use the HTTP because:\n\nYour service is stateless.\nIf you use TCP you will have problem scaling up your service (since every request will be directed to the server that establish the TCP connection ), this relate to that your service is stateless. In HTTP you just add more servers behind load balane\nFor TCP you will need to state some port which can be block due to firewall and ect' - you can use port 80\/8080 but I don't think this is good practice \nif you service were more like suggestion that change as the use typein his word you may want to use TCP\/HTTP Socket\nTCP is used for more long term connection - like Security system that report the state of the system every X seconds - which is not the case","Q_Score":0,"Tags":"python,http,ftp","A_Id":16889799,"CreationDate":"2013-06-03T03:51:00.000","Title":"Should I build a TCP server or use simple http messages for a back-end?","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},{"Question":"I have a script that downloads a lot of fairly large (20MB+) files. I would like to be able to check if the copy I have locally is identical to the remote version. I realize I can just use a combination of date modified and length, but is there something even more accurate I can use (that is also available via paramiko) that I can use to ensure this? Ideally some sort of checksum?\nI should add that the remote system is Windows and I have SFTP access only, no shell access.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":614,"Q_Id":16901650,"Users Score":0,"Answer":"I came with a similar scenario. the solution I currently take is to compare the remote file's size by using item.st_size for item in sftp.listdir_attr(remote_dir)  with the local file's size by using os.path.getsize(local_file). when the two files are around 1MB or smaller,this solution is fine. However, a weird thing might happen:  when the files are around 10MB or larger, the two size might differ slightly,e.g., one is 10000 Byte, another is 10003 Byte.","Q_Score":2,"Tags":"python,sftp,checksum,paramiko","A_Id":68450855,"CreationDate":"2013-06-03T16:41:00.000","Title":"Python + Paramiko - Checking whether two files are identical without downloading","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},{"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},{"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},{"Question":"If this is a stupid question, please don't mind me. But I spent some time trying to find the answer but I couldn't get anything solid. Maybe this is a hardware question, but I figured I'd try here first. \nDoes Serial Communication only work one to one? The reason this came up is because I had an arduino board listening for communication on its serial port. I had a python script feed bytes to the port as well. However, whenever I opened up the arduino's serial monitor, the connection with the python script failed. The serial monitor also connects to the serial port for communication for its little text input field.\nSo what's the deal? Does serial communication only work between a single client and a single server? Is there a way to get multiple clients writing to the server? I appreciate your suggestions.","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":1057,"Q_Id":16949369,"Users Score":1,"Answer":"Edit:\nI forgot about RS-485, which 'jdr5ca' was smart enough to recommend.  My explanation below is restricted to RS-232, the more \"garden variety\" serial port.  As 'jdr5ca' points out, RS-485 is a much better alternative for the described problem.\nOriginal:\nTo expand on zmo's answer a bit, it is possible to share serial at the hardware level, and it has been done before, but it is rarely done in practice.\nLikewise, at the software driver level, it is again theoretically possible to share, but you run into similar problems as the hardware level, i.e. how to \"share\" the link to prevent collisions, etc.\nA \"typical\" setup would be two serial (hardware) devices attached to each other 1:1.  Each would run a single software process that would manage sending\/receiving data on the link.  \nIf it is desired to share the serial link amongst multiple processes (on either side), the software process that manages the link would also need to manage passing the received data to each reading process (keeping track of which data each process had read) and also arbitrate which sending process gets access to the link during \"writes\".\nIf there are multiple read\/write processes on each end of the link, the handshaking\/coordination of all this gets deep as some sort of meta-signaling arrangement may be needed to coordinate the comms between the process on each end.\nEither a real mess or a fun challenge, depending on your needs and how you view such things.","Q_Score":1,"Tags":"python,serial-port,arduino,pyserial","A_Id":16951886,"CreationDate":"2013-06-05T20:35:00.000","Title":"Serial Communication one to one","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},{"Question":"Which one should I use to maximize performance? os.path.isfile(path) or open(path)?","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":3684,"Q_Id":16962528,"Users Score":0,"Answer":"Afaik isfile() will be faster while open(path) is more secure, in the sence that if open() is able to actually open the file, you can be sure it's there.","Q_Score":2,"Tags":"python,file,exists","A_Id":16962634,"CreationDate":"2013-06-06T12:47:00.000","Title":"checking if file exists: performance of isfile Vs open(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":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I have a directory containing N subdirectories each of which contains setup.py file. I want to write a python script that iterates through all subdirectories, issues python setup.py bdist_egg --dist-dir=somedir, and finally removes build and *.egg-info from each subdirectory and I have two questions:\n\nCan I invoke bdist_egg without using os.system? Some python interface would be nicer.\nCan I tell bdist_egg not to generate build and *.egg-info or is there any complementary command for setup.py that cleans this for me?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":97,"Q_Id":16966095,"Users Score":0,"Answer":"I would use subprocess. I believe setup.py command line arguments should be your interface.\nCheck setup.py clean --all","Q_Score":0,"Tags":"python,setuptools,distutils,setup.py,distribute","A_Id":16966255,"CreationDate":"2013-06-06T15:26:00.000","Title":"automated build of python eggs","Data Science and Machine Learning":0,"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},{"Question":"I have a directory containing N subdirectories each of which contains setup.py file. I want to write a python script that iterates through all subdirectories, issues python setup.py bdist_egg --dist-dir=somedir, and finally removes build and *.egg-info from each subdirectory and I have two questions:\n\nCan I invoke bdist_egg without using os.system? Some python interface would be nicer.\nCan I tell bdist_egg not to generate build and *.egg-info or is there any complementary command for setup.py that cleans this for me?","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":97,"Q_Id":16966095,"Users Score":0,"Answer":"It turned out that Fabric is the right way!","Q_Score":0,"Tags":"python,setuptools,distutils,setup.py,distribute","A_Id":17346341,"CreationDate":"2013-06-06T15:26:00.000","Title":"automated build of python eggs","Data Science and Machine Learning":0,"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},{"Question":"When I create a unittest.TestCase, I can define a setUp() function that will run before every test in that test case. Is it possible to skip the setUp() for a single specific test?\nIt's possible that wanting to skip setUp() for a given test is not a good practice. I'm fairly new to unit testing and any suggestion regarding the subject is welcome.","AnswerCount":4,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":10928,"Q_Id":16991901,"Users Score":9,"Answer":"In setUp(), self._testMethodName contains the name of the test that will be executed. It's likely better to put the test into a different class or something, of course, but it's in there.","Q_Score":28,"Tags":"python,unit-testing,testing,python-unittest","A_Id":24315867,"CreationDate":"2013-06-07T19:48:00.000","Title":"Is it possible to skip setUp() for a specific test in python's unittest?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm having an issue which seems to be related with the way Python & PyV8's garbage collection interact. I've temporarily solved the issue by disabling python's garbage collection, and calling gc.collect and PyV8.JSEngine.collect together every few seconds when no JavaScript is being run. However, this seems like a pretty hackish fix... in particular, I'm worried PyV8 might decide to collect at an inopportune time and cause problems, anyway. Is there any way to disable PyV8's automatic garbage collection for good, at least until I have a few days to spend figuring out exactly what is going on and thus to actually fix the issue?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":482,"Q_Id":17006134,"Users Score":4,"Answer":"It's possible to disable garbage collection for good by changing the source code of V8.\nIn V8's source, edit src\/heap.cc, and put a return statement in the beginning of Heap::CollectGarbage.\nOther than that, it's not possible (AFAICT): V8 will always invoke garbage collection when it's about to run out of memory. There is no (configurable) way to not have it do that.","Q_Score":4,"Tags":"javascript,python,garbage-collection,v8,pyv8","A_Id":17597335,"CreationDate":"2013-06-09T03:30:00.000","Title":"PyV8 disable automatic garbage collection","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"After installation, I would like to make soft-links to some of the configuration & data files created by installation.\nHow can I determine the location of a new package's files installed from within the package's setup.py?\nI initially hard-coded the path \"\/usr\/local\/lib\/python2.7\/dist-packages\", but that broke when I tried using a virtual environment. (Created by virtualenv.)\nI tried distutils.sysconfig.get_python_lib(), and that works inside the virtualenv. When installed on the real system, however, it returns \"\/usr\/lib\/python2.7\/dist-packages\" (Note the \"local\" directory isn't present.)\nI've also tried site.getsitepackages():\nRunning a Python shell from the base environment:\n\n\n\n\nimport site\n\n\n\n\n\n\n\n\nsite.getusersitepackages()\n\n\n\n\n\n'\/home\/sarah\/.local\/lib\/python2.7\/site-packages'\n\n\n\n\n\nsite.getsitepackages()\n\n\n\n\n\n['\/usr\/local\/lib\/python2.7\/dist-packages', '\/usr\/lib\/python2.7\/dist-packages']\n\nRunning a Python shell from a virtual environment \"testenv\":\n\n\n\n\nimport site\n\n\n\n\n\n\n\n\nsite.getsitepackages()\n\n\n\n\n\nTraceback (most recent call last):\n\n\nFile \"\", line 1, in \n\n\nAttributeError: 'module' object has no attribute 'getsitepackages'\n\nI'm running \"Python 2.7.3 (default, Aug  1 2012, 05:14:39)\" with \"[GCC 4.6.3] on linux2\" on Ubuntu. I can probably cobble something together with try-except blocks, but it seems like there should be some variable set \/ returned by distutils \/ setuptools. (I'm agnostic about which branch to use, as long as it works.)\nThanks.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":3205,"Q_Id":17030327,"Users Score":0,"Answer":"This will probably not answer your question, but if you need to access the source code of a package you have installed, or any other file within this package, the best way to do it is to install this package in develop mode (by downloading the sources, putting it wherever you want and then running python setup.py develop in the base directory of the package sources). This way you know where the package is found.","Q_Score":10,"Tags":"python,path,installation,setup.py","A_Id":17296790,"CreationDate":"2013-06-10T18:21:00.000","Title":"Detect python package installation path from within setup.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":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I am looking for an easy-to-use tool which can visualize the 'inner working' of a class, written e.g. in PHP. What I would like to see are the different class methods, and how they are related (method A calls method B etc). Is there such a tool to create such a graph?\nIn a further step, maybe there is a tool which also visualizes the 'inner working' of a class (in a reverse-engineering way) of really how the workflow is, i.e. with all if-else decisions etc, what methods are called in what case? \nIf anyone can refer me to such a tool (preferably for PHP and Python) I would appreciate it.","AnswerCount":4,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":885,"Q_Id":17048540,"Users Score":0,"Answer":"Although a lot of suggestions point towards pycallgraph and phpcallgraph I don't think these will do what you want to do - these are for runtime analysis, whereas what it sounds like you want to do static analysis.\nI'm not aware of any tools for this, but, given that you're only interested in the workings of a single class and the relationships within that class, with a little effort you should be able to hack something together in your scripting language of choice which\n\nParses all function names and variable declarations inside the class and stores them somewhere\nUses the information from step 1 to identify variable usages, variable assignments and function calls, along with the functions in which these occur.\nConvert this information into the graph format used by dot and then use dot to generate a directed graph showing dependencies.\n\nGiven the effort involved, if the class is not too large I would be tempted just to do it by hand!\nGood luck, and if you do find a solution would love to see it.","Q_Score":6,"Tags":"php,python,code-analysis","A_Id":17223867,"CreationDate":"2013-06-11T15:54:00.000","Title":"What tools are available to visualize in-class dependencies (e.g. for 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":0},{"Question":"I'm using the Python C API, and numerous times now I've tried using PySys_SetPath() to redirect the interpreter to a path where I've stored all of my scripts. Yet, every time I try it, I get the following error:\nUnhandled exception at 0x1e028482 in app.exe: 0xC0000005: Access violation reading location 0x00000004.\nI use it in the following syntax: PySys_SetPath(\"\/Python\/\"). Is that incorrect? Why does it keep crashing? Thanks in advance.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":3054,"Q_Id":17055472,"Users Score":0,"Answer":"I had the same problem but when I fixed all the \\ to \/ and added a . at the beginning of the path it worked  ie. the path should look sth like that PySys_SetPath(\".\/Python\/\") or PySys_SetPath(\"C:\/full\/path\/Python\/\")","Q_Score":1,"Tags":"c++,python,c,api","A_Id":44001898,"CreationDate":"2013-06-11T23:25:00.000","Title":"Why won't PySys_SetPath() 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":0,"System Administration and DevOps":1,"Web Development":0},{"Question":"We currently have pytest with the coverage plugin running over our tests in a tests directory.\nWhat's the simplest way to also run doctests extracted from our main code?  --doctest-modules doesn't work (probably since it just runs doctests from tests).  Note that we want to include doctests in the same process (and not simply run a separate invocation of py.test) because we want to account for doctest in code coverage.","AnswerCount":4,"Available Count":2,"Score":0.049958375,"is_accepted":false,"ViewCount":7851,"Q_Id":17056138,"Users Score":1,"Answer":"Could you try with the repo version of pytest and paste a session log?  I'd think --doctest-modules should pick up any .py files.","Q_Score":26,"Tags":"python,testing,pytest,doctest","A_Id":17083687,"CreationDate":"2013-06-12T00:55:00.000","Title":"How to make pytest run doctests as well as normal tests 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},{"Question":"We currently have pytest with the coverage plugin running over our tests in a tests directory.\nWhat's the simplest way to also run doctests extracted from our main code?  --doctest-modules doesn't work (probably since it just runs doctests from tests).  Note that we want to include doctests in the same process (and not simply run a separate invocation of py.test) because we want to account for doctest in code coverage.","AnswerCount":4,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":7851,"Q_Id":17056138,"Users Score":0,"Answer":"worked with doctest as well as with plain tests in one module. for a non-doctest test to be picked up, standard py.test discovery mechanism applies: a module name with test prefix, test function with test prefix.","Q_Score":26,"Tags":"python,testing,pytest,doctest","A_Id":53343424,"CreationDate":"2013-06-12T00:55:00.000","Title":"How to make pytest run doctests as well as normal tests 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},{"Question":"It is always said that Python is not so efficient as other languages such as C\/C++, Java etc. And it is also recommended to write the bottleneck part in C. But I've never run into such problems, maybe it's because most of the time it is the way you solve the problem rather than the efficiency of the language to bother. \nCan anybody illustrate any real circumstances? Some simple codes will be great.","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":1860,"Q_Id":17061118,"Users Score":1,"Answer":"There isn't a specific set of circumstances in which C or C++ win. Pretty much any CPU-heavy code you write in C or C++ will run many times faster than the equivalent Python code.\nIf you haven't noticed, it's simply because, for the problems you've had to solve in Python, performance has never been an issue.","Q_Score":7,"Tags":"python,performance","A_Id":17061230,"CreationDate":"2013-06-12T08:38:00.000","Title":"Any real examples to show python's inefficiency\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},{"Question":"This question just came up in a discussion and i am curious to know .\nIs it possible to have a debugger that can debug 2 languages . For example . If i have  Java program that references\/opens\/accesses\/ a script (Perl or Python) then is it possible to have a debugger to be able to debug the Perl\/Python script ? \nNote : Logging is not an acceptable debugging technique here .","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":39,"Q_Id":17063168,"Users Score":0,"Answer":"Yes, alter the host program (the java program ) so that it runs the perl program in a debugger\nYou might well run into problems with the way that debuggers \"attach\" in different programming language environments.  perl -d assumes a tty is there for interactive commands whereas java does something completely different","Q_Score":0,"Tags":"java,python,perl,debugging","A_Id":17064348,"CreationDate":"2013-06-12T10:26:00.000","Title":"Dual debugger Java + (Perl\/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},{"Question":"I was looking at the option of embedding python into fortran90 to add python functionality to my existing fortran90 code. I know that it can be done the other way around by extending python with fortran90 using the f2py from numpy. But, i want to keep my super optimized main loop in fortran and add python to do some additional tasks \/ evaluate further developments before I can do it in fortran, and also to ease up code maintenance. I am looking for answers for the following questions:\n1) Is there a library that already exists from which I can embed python into fortran? (I am aware of f2py and it does it the other way around)\n2) How do we take care of data transfer from fortran to python and back?\n3) How can we have a call back functionality implemented? (Let me describe the scenario a bit....I have my main_fortran program in Fortran, that call Func1_Python module in python. Now, from this Func1_Python, I want to call another function...say Func2_Fortran in fortran)\n4) What would be the impact of embedding the interpreter of python inside fortran in terms of performance....like loading time, running time, sending data (a large array in double precision) across etc.\nThanks a lot in advance for your help!!\nEdit1: I want to set the direction of the discussion right by adding some more information about the work I am doing. I am into scientific computing stuff. So, I would be working a lot on huge arrays \/ matrices in double precision and doing floating point operations. So, there are very few options other than fortran really to do the work for me. The reason i want to include python into my code is that I can use NumPy for doing some basic computations if necessary and extend the capabilities of the code with minimal effort. For example, I can use several libraries available to link between python and some other package (say OpenFoam using PyFoam library).","AnswerCount":7,"Available Count":1,"Score":0.1137907297,"is_accepted":false,"ViewCount":9062,"Q_Id":17075418,"Users Score":4,"Answer":"There is a very easy way to do this using f2py. Write your python method and add it as an input to your Fortran subroutine. Declare it in both the cf2py hook and the type declaration as EXTERNAL and also as its return value type, e.g. REAL*8. Your Fortran code will then have a pointer to the address where the python method is stored. It will be SLOW AS MOLASSES, but for testing out algorithms it can be useful. I do this often (I port a lot of ancient spaghetti Fortran to python modules...) It's  also a great way to use things like optimised Scipy calls in legacy fortran","Q_Score":8,"Tags":"python,fortran,embed","A_Id":23725918,"CreationDate":"2013-06-12T21:09:00.000","Title":"Embed python into fortran 90","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},{"Question":"I'm using Selenium with Python to test a web application. The app has a Flash component that I'd like to test. The only references I've seen to using Selenium with Flash refer to Flash-Selenium which hasn't been updated in several years. Is testing Flash with Selenium even possible?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":3667,"Q_Id":17094940,"Users Score":0,"Answer":"As long as you have access to the flash source code it is possible (although it requires some work).  To do that you have to expose the flash actions you want to test using selenium.  This requires that you make the methods available in Flash to execute via Javascript.  Once you can do that, you should be able to automate the process with using selenium's ability to execute javascript.","Q_Score":2,"Tags":"python,flash,selenium","A_Id":17096754,"CreationDate":"2013-06-13T19:00:00.000","Title":"Selenium\/Python\/Flash - How?","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},{"Question":"I need to send out Instant Messages to a Lync\/OCS server from Linux programmatically as an alerting mechanism.\nI've looked into using python dbus and pidgin-sipe with finch or pidgin, but they aren't really good for sending one-off instant messages  (finch and pidgin need to be running all the time).\nIdeally, I'd have a python script or java class that could spit out Instant Messages to users when needed.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":3151,"Q_Id":17099581,"Users Score":1,"Answer":"Well, if you are on Lync 2013, you can have a look at UCWA ucwa.lync.com. It's a web service that allows to log in to Lync and use IM, presence, etc.\nYou can use then any language you want. I played with it using Node on Mac OS X, for example.","Q_Score":2,"Tags":"java,python,sip,lync,office-communicator","A_Id":17125543,"CreationDate":"2013-06-14T01:00:00.000","Title":"Sending out IMs to Lync\/OCS programmatically","Data Science and Machine Learning":0,"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},{"Question":"My project currently uses NumPy, only for memory-efficient arrays (of bool_, uint8, uint16, uint32).\nI'd like to get it running on PyPy which doesn't support NumPy. (failed to install it, at any rate)\nSo I'm wondering: Is there any other memory-efficient way to store arrays of numbers in Python? Anything that is supported by PyPy? Does PyPy have anything of it's own?\nNote: array.array is not a viable solution, as it uses a lot more memory than NumPy in my testing.","AnswerCount":1,"Available Count":1,"Score":0.537049567,"is_accepted":false,"ViewCount":919,"Q_Id":17099850,"Users Score":3,"Answer":"array.array is a memory efficient array. It packs bytes\/words etc together, so there is only a few bytes of extra overhead for the entire array.\nThe one place where numpy can use less memory is when you have a sparse array (and are using one of the sparse array implementations)\nIf you are not using sparse arrays, you simply measured it wrong.\narray.array also doesn't have a packed bool type, so you can implement that as wrapper around an array.array('I') or a bytearray() or even just use bit masks with a Python long","Q_Score":3,"Tags":"python,arrays,numpy,pypy","A_Id":17101084,"CreationDate":"2013-06-14T01:39:00.000","Title":"PyPy and efficient 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":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I was trying to install autoclose.vim to Vim. I noticed I didn't have a ~\/.vim\/plugin folder, so I accidentally made a ~\/.vim\/plugins folder (notice the extra 's' in plugins). I then added au FileType python set rtp += ~\/.vim\/plugins to my .vimrc, because from what I've read, that will allow me to automatically source the scripts in that folder.  \nThe plugin didn't load for me until I realized my mistake and took out the extra 's' from 'plugins'. I'm confused because this new path isn't even defined in my runtime path. I'm basically wondering why the plugin loaded when I had it in ~\/.vim\/plugin but not in ~\/.vim\/plugins?","AnswerCount":4,"Available Count":1,"Score":0.049958375,"is_accepted":false,"ViewCount":938,"Q_Id":17128878,"Users Score":1,"Answer":"All folders in the rtp (runtimepath) option need to have the same folder structure as your $VIMRUNTIME ($VIMRUNTIME is usually \/usr\/share\/vim\/vim{version}). So it should have the same subdirectory names e.g. autoload, doc, plugin (whichever you need, but having the same names is key). The plugins should be in their corresponding subdirectory.\nLet's say you have \/path\/to\/dir (in your case it's ~\/.vim) is in your rtp, vim will\n\nlook for global plugins in \/path\/to\/dir\/plugin\nlook for file-type plugins in \/path\/to\/dir\/ftplugin\nlook for syntax files in \/path\/to\/dir\/syntax\nlook for help files in \/path\/to\/dir\/doc\n\nand so on...\nvim only looks for a couple of recognized subdirectories\u2020 in \/path\/to\/dir. If you have some unrecognized subdirectory name in there (like \/path\/to\/dir\/plugins), vim won't see it.\n\u2020 \"recognized\" here means that a subdirectory of the same name can be found in \/usr\/share\/vim\/vim{version} or wherever you have vim installed.","Q_Score":3,"Tags":"python,vim,plugins","A_Id":17131966,"CreationDate":"2013-06-15T23:28:00.000","Title":"Vim plugins don't always load?","Data Science and Machine Learning":0,"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},{"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},{"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},{"Question":"I'm looking at using inotify to watch about 200,000 directories for new files. On creation, the script watching will process the file and then it will be removed. Because it is part of a more compex system with many processes, I want to benchmark this and get system performance statistics on cpu, memory, disk, etc while the tests are run.\nI'm planning on running the inotify script as a daemon and having a second script generating test files in several of the directories (randomly selected before the test).\nI'm after suggestions for the best way to benchmark the performance of something like this, especially the impact it has on the Linux server it's running on.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":780,"Q_Id":17138569,"Users Score":1,"Answer":"I would try and remove as many other processes as possible in order to get a repeatable benchmark.  For example, I would set up a separate, dedicated server with an NFS mount to the directories.  This server would only run inotify and the Python script.  For simple server measurements, I would use top or ps to monitor CPU and memory.\nThe real test is how quickly your script \"drains\" the directories, which depends entirely on your process.  You could profile the script and see where it's spending the time.","Q_Score":0,"Tags":"python,linux,benchmarking,inotify","A_Id":17139897,"CreationDate":"2013-06-16T23:09:00.000","Title":"Benchmarking System performance of Python 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},{"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},{"Question":"I have the following setup: \n\nDjango-Celery project A registers task foo\nProject B: Uses Celery's send_task to call foo\nProject A and project B have the same configuration: SQS, msgpack \nfor serialization, gzip, etc. \nEach project lives on a different github repository \n\nI've unit-tested calls to \"foo\" in project A, without using Celery at all, just foo(1,2,3) and assert the result. I know that it works. \nI've unit-tested that send_task in project B sends the right parameters. \nWhat I'm not testing, and need your advise on is the integration between the two projects. I would like to have a unittest that would: \n\nStart a worker in the context of project A \nSend a task using the code of project B \nAssert that the worker started in the first step gets the task, with the parameters I sent in the second step, and that the foo function returned the expected result. \n\nIt seems to be possible to hack this by using python's subprocess and parsing the output of the worker, but that's ugly. What's the recommended approach to unit-testing in cases like this? Any code snippet you could share? Thanks!","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":774,"Q_Id":17181923,"Users Score":1,"Answer":"I'm not sure if it's worthwhile to explicitly test the transportation mechanism (i.e. the sending of the task parameters through celery) using a unit test. Personally, I would write my test as follows (can be split up in several unit tests):\n\nUse the code from project B to generate a task with sample parameters.\nEncode the task parameters using the same method used by Celery (i.e. pickling the parameters or encoding them as JSON). \nDecode the task parameters again, checking that no corruption occured.\nCall the task function, making sure that it produces the correct result.\nPerform the same encoding\/decoding sequence for the results of the task function.\n\nUsing this method, you will be able to test that\n\nThe task generation works as intended\nThe encoding & decoding of the task parameters and results works as expected\n\nIf necessary, you can still independently test the functioning of the transportation mechanism using a system test.","Q_Score":6,"Tags":"python,unit-testing,integration-testing,celery","A_Id":18316377,"CreationDate":"2013-06-19T02:20:00.000","Title":"Running a Celery worker in unittest","Data Science and Machine Learning":0,"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},{"Question":"I would like to have a function in my class, which I am going to use only inside methods of this class. I will not call it outside the implementations of these methods. In C++, I would use a method declared in the private section of the class. What is the best way to implement such a function in Python?\nI am thinking of using a static decorator for this case. Can I use a function without any decorators and the self word?","AnswerCount":5,"Available Count":1,"Score":0.1194272985,"is_accepted":false,"ViewCount":48236,"Q_Id":17193457,"Users Score":3,"Answer":"Python just doesn't do private. If you like you can follow convention and precede the name with a single underscore, but it's up to other coders to respect that in a gentlemanly\u2020 fashion\n\u2020 or gentlewomanly","Q_Score":25,"Tags":"python,oop,static-methods","A_Id":17193588,"CreationDate":"2013-06-19T14:08:00.000","Title":"Private methods 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},{"Question":"The business case...\nThe app server (Ubuntu\/nginx\/postgresql\/python) that I use writes gzipped system log files as root to \/var\/log\nI need to present data from these log files to users' browsers\nMy approach\nI need to do a fair bit of searching and string manipulation server side so I have a python script that deals with the opening and processing and then returns a nicely formatted JSON result set. The python (cgi) script is then called using ajax from the web page.\nMy problem\nThe script works perfectly when called from the command line as SU but (...obviously) the file opening method I'm using ( gzip.open(filename) ) is failing when invoked as user www-data by the webserver. \nOther useful info\nThe app server concerned is (contractually rather than physically) a bit of a black box - I have SU access, I can write scripts, I can read anything but I can't change file permissions, add additional python libs or or mess with config.\nThe subset of users who can would use this log extract also have the SU password so could be presented with a login dialog that I could pass to the script.\nGiven the restrictions I have, how would you go about it?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":746,"Q_Id":17207280,"Users Score":1,"Answer":"One option would be to do this somewhat sensitive \"su\" work in a background process that is disconnected from the web.\nLikely running via cron, this script would take the root owned log files, possibly change them to a format that the web-side code could deal with easily like loading them into a database, or merely unzipping them and placing them into a different location with slightly more laxed permissions.\nThen the web-side code could easily have access to the data without having to jump through the \"su\" hoops.\nFrom my perspective this plan does not seem to violate your contractual rules. The web server config, permissions, etc remain intact.","Q_Score":0,"Tags":"python,file-io,permissions","A_Id":17207385,"CreationDate":"2013-06-20T07:05:00.000","Title":"Open root owned system files for reading 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},{"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},{"Question":"I was curious if there was any indication of which of operator.itemgetter(0) or lambda x:x[0] is better to use, specifically in sorted() as the key keyword argument as that's the use that springs to mind first. Are there any known performance differences? Are there any PEP related preferences or guidance on the matter?","AnswerCount":3,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":10179,"Q_Id":17243620,"Users Score":20,"Answer":"Leaving aside the speed issue, which is often based on where you make the itemgetter or lambda function, I personally find that itemgetter is really nice for getting multiple items at once: for example, itemgetter(0, 4, 3, 9, 19, 20) will create a function that returns a tuple of the items at the specified indices of the listlike object passed to it. To do that with a lambda, you'd need lambda x:x[0], x[4], x[3], x[9], x[19], x[20], which is a lot clunkier. (And then some packages such as numpy have advanced indexing, which works a lot like itemgetter() except built in to normal bracket notation.)","Q_Score":40,"Tags":"python,python-2.7,python-3.x","A_Id":17243722,"CreationDate":"2013-06-21T20:16:00.000","Title":"operator.itemgetter or lambda","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I come from a PHP (as well as a bunch of other stuff) background and I am playing around with Python. In PHP when I want to include another file I just do include or require and everything in that file is included.\nBut it seems the recommended way to do stuff in python is from file import but that seems to be more for including libraries and stuff? How do you separate your code amongst several files? Is the only way to do it, to have a single file with a whole bunch of function calls and then import 15 other files?","AnswerCount":5,"Available Count":3,"Score":0.0399786803,"is_accepted":false,"ViewCount":7295,"Q_Id":17254603,"Users Score":1,"Answer":"Interesting question. As you know, in PHP, you can separate your code by using include, which literally takes all the code in the included file and puts it wherever you called include. This is convenient for writing web applications because you can easily divide a page into parts (such as header, navigation, footer, etc).\nPython, on the other hand, is used for way more than just web applications. To reuse code, you must rely on functions or good old object-oriented programming. PHP also has functions and object-oriented programming FYI. \nYou write functions and classes in a file and import it in another file. This lets you access the functions or use the classes you defined in the other file. \nLets say you have a function called foo in file file1.py. From file2.py, you can write\nimport file1. Then, call foo with file1.foo(). Alternatively, write from file1 import foo and then you can call foo with foo(). Note that the from lets you call foo directly. For more info, look at the python docs.","Q_Score":5,"Tags":"python,python-2.7,import,module","A_Id":17254692,"CreationDate":"2013-06-22T19:39:00.000","Title":"Little confused with import 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},{"Question":"I come from a PHP (as well as a bunch of other stuff) background and I am playing around with Python. In PHP when I want to include another file I just do include or require and everything in that file is included.\nBut it seems the recommended way to do stuff in python is from file import but that seems to be more for including libraries and stuff? How do you separate your code amongst several files? Is the only way to do it, to have a single file with a whole bunch of function calls and then import 15 other files?","AnswerCount":5,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":7295,"Q_Id":17254603,"Users Score":0,"Answer":"There's an execfile() function which does something vaguely comparable with PHP's include, here, but it's almost certainly something you don't want to do. As others have said, it's just a different model and a different programming need in Python. Your code is going to go from function to function, and it doesn't really make a difference in which order you put them, as long as they're in an order where you define things before you use them. You're just not trying to end up with some kind of ordered document like you typically are with PHP, so the need isn't there.","Q_Score":5,"Tags":"python,python-2.7,import,module","A_Id":17257186,"CreationDate":"2013-06-22T19:39:00.000","Title":"Little confused with import 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},{"Question":"I come from a PHP (as well as a bunch of other stuff) background and I am playing around with Python. In PHP when I want to include another file I just do include or require and everything in that file is included.\nBut it seems the recommended way to do stuff in python is from file import but that seems to be more for including libraries and stuff? How do you separate your code amongst several files? Is the only way to do it, to have a single file with a whole bunch of function calls and then import 15 other files?","AnswerCount":5,"Available Count":3,"Score":0.0399786803,"is_accepted":false,"ViewCount":7295,"Q_Id":17254603,"Users Score":1,"Answer":"On a technical level, a Python import is very similar to a PHP require, as it will execute the imported file. But since Python isn't designed to ultimately generate an HTML file, the way you use it is very different.\nTypically a Python file will on the module level not include much executable code at all, but definitions of functions and classes. You them import them and use them as a library.\nHence having things like  header() and footer() makes no sense in Python. Those are just functions. Call them like that, and the result they generate will be ignored.\nSo how do you split up your Python code? Well, you split it up into functions and classes, which you put into different files, and then import.","Q_Score":5,"Tags":"python,python-2.7,import,module","A_Id":17255642,"CreationDate":"2013-06-22T19:39:00.000","Title":"Little confused with import 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},{"Question":"I want to suppress certain warning messages when Python is running in a test context.\nIs there any way to detect this globally in Python?","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":61,"Q_Id":17308521,"Users Score":2,"Answer":"No, you can't really detect whether or not you're in a test context, or you'd do it with a lot of unnecessary processing. For example: having a state variable in the testing package that you set up when you're running your tests. But then you would include that module (or variable) in all of your modules, which would be far from being elegant. Globals are evil.\nThe best way to implement filtering output based on the execution context is to use the logging module and make all unnecessary warning messages at a low level (like DEBUG) and ignore them when you run your tests.\nAnother option would be to add a level for all of the messages you explicitly ignore when running the tests.","Q_Score":1,"Tags":"python,testing","A_Id":17308545,"CreationDate":"2013-06-25T22:16:00.000","Title":"Is there a way to detect that Python is running a test?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I've written a Python script, but running it is taking a lot longer than I had anticipated, and I've no obvious candidate for particuklar lines in the script taking up runtime. \nIs there anything I can put in my code to check how long its taking to run through each line?\nMany thanks.","AnswerCount":3,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":6436,"Q_Id":17314366,"Users Score":3,"Answer":"timeit is a standard module since python 2.3 take a look at the documentation for it.","Q_Score":4,"Tags":"python,performance,profiling","A_Id":17314426,"CreationDate":"2013-06-26T07:46:00.000","Title":"Check running time per line 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},{"Question":"Is there any way to algorithmically determine audio quality from a .wav or .mp3 file?\nBasically I have users with diverse recording setups (i.e. they are from all over the world and I have no control over them) recording audio to mp3\/wav files. At which point the software should determine whether their setup is okay or not (tragically, for some reason they are not capable of making this determination just by listening to their own recordings, and so occasionally we get recordings that are basically impossible to understand due to low volume or high noise).\nI was doing a volume check to make sure the microphone level was okay; unfortunately this misses cases where the volume is high but the clarity is low. I'm wondering if there is some kind of standard scan I can do (ideally in Python) that detects when there is a lot of background noise.\nI realize one possible solution is to ask them to record total silence and then compare to the spoken recording and consider the audio \"bad\" if the volume of the \"silent\" recording is too close to the volume of the spoken recording. But that depends on getting a good sample from the speaker both times, which may or may not be something I can depend on.\nSo I'm wondering if instead there's just a way to scan through an audio file (these would be ~10 seconds long) and recognize whether the sound file is \"noisy\" or clear.","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":3067,"Q_Id":17323142,"Users Score":0,"Answer":"Not quite my field but I suspect that if you get a spectrum, (do a Fourier transform maybe), and compare \"good\" and \"noisy\" recordings you will find that the noise contributes to a cross spectrum level that is higher in the bad recordings than the good.  Take a look at the signal processing section in SciPy - this can probably help.","Q_Score":2,"Tags":"python,audio,noise","A_Id":17323482,"CreationDate":"2013-06-26T14:37:00.000","Title":"Determining sound quality from an audio recording?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"Is there any way to algorithmically determine audio quality from a .wav or .mp3 file?\nBasically I have users with diverse recording setups (i.e. they are from all over the world and I have no control over them) recording audio to mp3\/wav files. At which point the software should determine whether their setup is okay or not (tragically, for some reason they are not capable of making this determination just by listening to their own recordings, and so occasionally we get recordings that are basically impossible to understand due to low volume or high noise).\nI was doing a volume check to make sure the microphone level was okay; unfortunately this misses cases where the volume is high but the clarity is low. I'm wondering if there is some kind of standard scan I can do (ideally in Python) that detects when there is a lot of background noise.\nI realize one possible solution is to ask them to record total silence and then compare to the spoken recording and consider the audio \"bad\" if the volume of the \"silent\" recording is too close to the volume of the spoken recording. But that depends on getting a good sample from the speaker both times, which may or may not be something I can depend on.\nSo I'm wondering if instead there's just a way to scan through an audio file (these would be ~10 seconds long) and recognize whether the sound file is \"noisy\" or clear.","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":3067,"Q_Id":17323142,"Users Score":1,"Answer":"It all depends on what your quality problems are, which is not 100% clear from your question, but here are some suggestions:\nIn the case where volume is high and clarity is low, I'm guessing the problem is that the user has the input gain too high. After the recording, you can simply check for distortion. Even better, you can use Automatic Gain Control (AGC) durring recording to prevent this from happening in the first place.\nIn the case of too much noise, I'm assuming the issue is that the speaker is too far from the mike. In this case Steve's suggestion might work, but to make it really work, you'd need to do a ton of work comparing sample recordings and developing statistics to see how you can discriminate. In practice, I think this is too much work. A simpler alternative that I think will be easier and more likely to work (although not necessarily guaranteed) would be to create an envelope of your signal, then create a histogram from that and see how the histogram compares to existing good and bad recordings. If we are talking about speech only, you could divide the signal into three frequency bands (with a time-domain filter, not an FFT) to give you an idea of how much is noise (the high and low bands) and how much is sound you care about (the center band).\nAgain, though, I would use an AGC durring recording and if the AGC finds it needs to set the input gain too high, it's probably a bad recording.","Q_Score":2,"Tags":"python,audio,noise","A_Id":17326588,"CreationDate":"2013-06-26T14:37:00.000","Title":"Determining sound quality from an audio recording?","Data Science and Machine Learning":0,"Database and SQL":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},{"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},{"Question":"I have a Python code calling some C code (.so file).\nIs there a way, from within the C code, go get the line number it has been called from at the Python side?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":208,"Q_Id":17348492,"Users Score":3,"Answer":"I eventually found the PyFrame_GetLineNumber(PyFrameObject *f) C function, whose source is located in frameobject.c.","Q_Score":3,"Tags":"python,c,python-c-api","A_Id":17471190,"CreationDate":"2013-06-27T16:29:00.000","Title":"Python calling C: how could C send Python's line number it has been called from?","Data Science and Machine Learning":0,"Database and SQL":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},{"Question":"I am trying to use C++ lib with python using SWIG,\nmy problem is that the main class symbol is missing,\n\n\n\n    $ ldd -r -d _rf24.so 2>&1|grep RF24\n    undefined symbol: _ZN4RF24C1Ehh (.\/_rf24.so)\n\n    $ objdump -t librf24-bcm.so.1.0 |grep RF24\n    .\n    .\n    .\n    000032cc g     F .text  00000044              _ZN4RF24C1Ehhj\n    000032cc g     F .text  00000044              _ZN4RF24C2Ehhj\n    .\n    .\n    .\n\n\npython exception:\n\n\n        ImportError: .\/_rf24.so: undefined symbol: _ZN4RF24C1Ehh\n\n\nI tried using the lib objs from the original Makefile or tried to compile them with some flags but the result is the same\nbuild lines:\n\n\n    $ gcc -c RF24_wrap.cxx -I\/usr\/include\/python2.7\n    $ gcc -lstdc++ -shared bcm2835.o RF24.o RF24_wrap.o -o _rf24.so\n\n\nRF24.i (the SWIG file):\n\n\n    %module rf24\n    %{\n    #include \"RF24.h\"\n    %}\n\n    %include \"RF24.h\"\n    \/\/%include \"bcm2835.h\"\n    %include \"carrays.i\"\n    %array_class(char, byteArray);\n\n\nRF24.h (relevant part of the class header file):\n\n\n        .\n        .\n        .\n        \/\/ bla bla bla enums...\n\n        class RF24\n        {\n        private:\n        \/\/ bla bla bla\n\n        protected:\n        \/\/ bla bla bla\n\n        public:\n             RF24(uint8_t _cepin, uint8_t _cspin);\n             RF24(uint8_t _cepin, uint8_t _cspin, uint32_t spispeed )\n\n        \/\/bla bla bla","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":215,"Q_Id":17362909,"Users Score":0,"Answer":"Problem Solved! After using c++filt, I have found out that one of the constructors in the lib wasn't defined, after deleting it problem solved","Q_Score":0,"Tags":"c++,python,swig,porting,symbols","A_Id":37594931,"CreationDate":"2013-06-28T10:44:00.000","Title":"Missing \/ wrong signature whan converting c++ library to python using 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},{"Question":"I'd like to scrape contact info from about 1000-2000 different restaurant websites. Almost all of them have contact information either on the homepage or on some kind of \"contact\" page, but no two websites are exactly alike (i.e., there's no common pattern to exploit). How can I reliably scrape email\/phone # info from sites like these without specifically pointing the Python script to a particular element on the page (i.e., the script needs to be structure agnostic, since each site has a unique HTML structure, they don't all have, e.g., their contact info in a \"contact\" div).\nI know there's no way to write a program that will be 100% effective, I'd just like to maximize my hit rate.\nAny guidance on this\u2014where to start, what to read\u2014would be much appreciated.\nThanks.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":2766,"Q_Id":17366528,"Users Score":1,"Answer":"In most countries the telephone number follows one of a very few well defined patterns that can be matched with a simple regexp - likewise email addresses have an internationally recognised format - simply scrape the homepage, contacts or contact us page and then parse with regular expressions - you should easily achieve better than 90% accuracy.\nAlternatively of course you simply submit the restaurant name and town to the local equivalent of the Yellow Pages web site.","Q_Score":3,"Tags":"python,web-scraping,beautifulsoup,screen-scraping","A_Id":17366729,"CreationDate":"2013-06-28T14:03:00.000","Title":"Scraping Contact Information from Several Unique Sites 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":1},{"Question":"I am new at pyramid framework and I recently started to play with it. However, I'm a bit confused about how a tarball created with 'sdist' gets installed in a production virtual environment. My scenario is as follows:\n\nAfter finishing a project I created in pyramid called 'myapp', I run: python setup.py sdist in order to create the distribution tarball.\nThe tarball gets created under 'dist' folder and it contains all my project sources as well as the .ini files (development and production).\nI then create a new production virtual environment by executing: virtualenv --no-site-packages envprod\nTo install the 'myapp' distribution tarball I execute: envprod\/bin\/easy_install src\/myapp\/dist\/myapp0-0.tar.gz.\nIt then starts to download and install all the requirements for the project and it also installs the sources of my application under envprod\/lib\/python2.7\/site-packages\/myapp\n\nThe problem is that neither development.ini nor production.ini are installed in the new prod environment so I have no way to execute 'pserve' since it needs the .ini file.\nAm I doing something wrong? Or is there a way to start serving 'myapp' without the .ini files?\nThanks!","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":637,"Q_Id":17374249,"Users Score":0,"Answer":"As stated by Mikhail, code and configuration are note the same. \nYou may want to deploy your package manytimes and not to overwrite already installed configuration and data.\nPlease note that the db, if present and on file system (sqlite), is not distributed inside the package as well. I guess it's done to allow you to update the code easily.\nIf your intent is to deploy the package in production environment all you need to do is to copy both the ini you want to use and the database (if sqlite) or to run the initilize_db script (that is installed in bin) before starting the app.\nNote that it's always a good idea to test the production ini in a non production environment to be sure that settings are good for you, in particular about logging, because you'll have no console logging.\nThough it's good enough for dev\/prod environment, it may be a problem for distribution to 3rd party. \nI'm just trying to address similar problems and I think that the main point is to properly configure setup.py and MANIFEST.in, to include what you need in the egg and properly extract them when installing. \nThe problem seems to be that easy_install skip all files outside your app folder (so ini files, that are one dir back).\nA workaround for that, is to skip easy_install, and just untaz your tarball and then enter your project folder and use:\n  pip install -e . --pre\n(the --pre is only required if you included pre-release package in your project, maybe because they are a dependency of formalchemy, as I did).\nThis seems the easiest way toi distribute to other people.\nYou may want to create the database somehow, anyway, to have it work, unless you include it in the distribution explicitly adding it to MANIFEST file.","Q_Score":0,"Tags":"python,pyramid","A_Id":27862172,"CreationDate":"2013-06-28T21:53:00.000","Title":"Deploy a pyramid application with sdist","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I made a small application that prints unicode special characters(i.e. superscript, subscript...). When it runs locally there are no problems but when it runs in a ssh session I always get a UnicodeEncodeError. \nSpecifically: UnicodeEncodeError 'ascii' can't encode characters in position 0-1: ordinal not in range(128)\nI tried different ssh clients, computers and double checked the sessions encoding but the result is the same.\nThis is really weird. Why does this happen? Is this really related to ssh?","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":1171,"Q_Id":17374526,"Users Score":2,"Answer":"The problem might be not your Python code, check your ssh ENV. LANG should be en_US.UTF-8 (containing UTF-8) not ASCII","Q_Score":5,"Tags":"python,unicode,encoding,python-3.x,ssh","A_Id":17374821,"CreationDate":"2013-06-28T22:22:00.000","Title":"UnicodeEncodeError when using python from 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},{"Question":"I've written some python modules that I'd like to be able to import anytime on Mac OS X.  I've done some googling and I've gotten some mixed responses so I'd like to know what the \"best\" practice is for storing those files safely.\nI'm running Python2.7 and I want to make sure I don't mess with the Mac install of Python or anything like that.  Thanks for the help","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":498,"Q_Id":17407276,"Users Score":1,"Answer":"The standard directory which is already searched by python depends on the version of python.\nFor the Apple installed python 2.7 it is \/Library\/Python\/2.7\/site-packages\nthe README in that directory says\n\nThis directory exists so that 3rd party packages can be installed\n  here.  Read the source for site.py for more details.","Q_Score":0,"Tags":"python,macos,python-2.7","A_Id":17407429,"CreationDate":"2013-07-01T14:46:00.000","Title":"Good location to store .py files 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":1,"Web Development":0},{"Question":"I'm using Eclipse \/ PyDev and PyUnit on OSX for development. It was recommended to me that I use Nose to execute our suite of tests.\nWhen I configure Nose as the test runner, however, output from the interactive console (either standalone or during debugging) disappears. I can type commands but do not see any output.\nIs this normal, or am I missing some configuration?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":969,"Q_Id":17409127,"Users Score":2,"Answer":"I eventually found in the Preferences > PyDev > PyUnit menu that adding -s to the Parameters for test running stopped this. The parameter prevents the capture of stdout that nose does by default.\nThe alternate --nocapture parameter should work too.","Q_Score":2,"Tags":"python,eclipse,nose,python-unittest","A_Id":19227424,"CreationDate":"2013-07-01T16:18:00.000","Title":"Where does console output go when Eclipse PyUnit Test Runner configured to use Nose","Data Science and Machine Learning":0,"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},{"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},{"Question":"The other day I was coding when suddenly I discovered myself struggling with a simple problem but confuse solution (at least in a pythonic way to go).\nThe code was supposed to just download some files, for that, it would call some DownloadController passing it a callback so to received events such as init, progress, error and success.\nHowever, my code didn't need at all these events. With this came to my mind some solutions\n\nChange DownloadController to have a default callback=None and check for it so to ignore sending events in this case\nHave NullCallbackImpl which adheres to callback interface but do nothing (just pass on each event)\n\nFirst approach didn't like it because the code would be kind of messy and not well-design.\nSo, I stick with the second approach... Questions:\n\nHow good (maybe 'how bad') would it be to have a null_callback = mock.Mock()? (using python mock library from Michael Foord) \n\nIs there any library that do this?\n\nOr should I stick with creating a NullCallbackImpl implementing each method with a simple pass?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":67,"Q_Id":17479480,"Users Score":1,"Answer":"You discovered a new use case for DownloadController - \"Let the user customize the callback\". It sounds like you have control over the Downloadcontroller source. It could define a DownloadCallback class that exposes the events as methods but does nothing with them. The Controller would accept None (do nothing) or anything that implements the DownloadController interface.\nI think using mock for real code is more than a bit odd... it creates yet another dependency that needs to be met for users of your module.","Q_Score":1,"Tags":"python,design-patterns,mocking","A_Id":17479627,"CreationDate":"2013-07-05T00:10:00.000","Title":"Which is the recommended way to use the Null Pattern 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},{"Question":"In Python 3, when I opened a text file with mode string 'rb', and then did f.read(), I was taken aback to find the file contents enclosed in single quotes after the character 'b'.\nIn Python 2 I just get the file contents.\nI'm sure this is well known, but I can't find anything about it in the doco.  Could someone point me to it?","AnswerCount":3,"Available Count":2,"Score":0.1325487884,"is_accepted":false,"ViewCount":2045,"Q_Id":17485920,"Users Score":2,"Answer":"First of all, the Python 2 str type has been renamed to bytes in Python 3, and byte literals use the b'' prefix. The Python 2 unicode type is the new Python 3 str type.\nTo get the Python 3 file behaviour in Python 2, you'd use io.open() or codecs.open(); Python 3 decodes text files to Unicode by default.\nWhat you see is that for binary files, Python 3 gives you the exact same thing as in Python 2, namely byte strings. What changed then, is that the repr() of a byte string is prefixed with b and the print() function will use the repr() representation of any object passed to it except for unicode values.\nTo print your binary data as unicode text with the print() function., decode it to unicode first. But then you could perhaps have opened the file as a text file instead anyway.\nThe bytes type has some other improvements to reflect that you are dealing with binary data, not text. Indexing individual bytes or iterating over a bytes value gives you int values (between 0 and 255) and not characters, for example.","Q_Score":1,"Tags":"python,file,python-3.x","A_Id":17486121,"CreationDate":"2013-07-05T09:49:00.000","Title":"Python 3 file input change in binary 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},{"Question":"In Python 3, when I opened a text file with mode string 'rb', and then did f.read(), I was taken aback to find the file contents enclosed in single quotes after the character 'b'.\nIn Python 2 I just get the file contents.\nI'm sure this is well known, but I can't find anything about it in the doco.  Could someone point me to it?","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":2045,"Q_Id":17485920,"Users Score":0,"Answer":"Sometimes we need (needed?) to know whether a text file had single-character newlines (0A) or double character newlines (0D0A).\nWe used to avoid confusion by opening the text file in binary mode, recognising 0D and 0A, and treating other bytes as regular text characters.\nOne could port such code by finding all binary\ufdd3mode reads and replacing them with a new function oldread() that stripped off the added  material, but it\u2019s a bit painful.\nI suppose the Python theologians thought of keeping \u2018rb\u2019 as it was, and adding  a new \u2018rx\u2019 or something for the new behaviour.  It seems a bit high-handed just to abolish something.\nBut, there it is, the question is certainly answered by a search for \u2018rb\u2019 in Lennert\u2019s document.","Q_Score":1,"Tags":"python,file,python-3.x","A_Id":17494245,"CreationDate":"2013-07-05T09:49:00.000","Title":"Python 3 file input change in binary 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},{"Question":"is PEP8 simply a style guide, or does it actually help the interpreter make optimizations to run your code faster? I'm simply curious since I really like PEP8 and wanted to know of any other benefits other than more readable code.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":247,"Q_Id":17499343,"Users Score":4,"Answer":"There is a single item in PEP8 that clearly has potential performance consequences:\n\nCode should be written in a way that does not disadvantage other implementations of Python (PyPy, Jython, IronPython, Cython, Psyco, and such).\n\nThat is, PEP8 recommends that code be written such that it performs well across a variety of Python implementations.  This is a bit hand-wavy, of course (do you have to try all the available implementations?).\nOther than that, nothing in PEP8 stands out as likely to impact performance or anything measurable apart from the storage space required for the code itself (e.g. four-space indentation).","Q_Score":2,"Tags":"python","A_Id":17499406,"CreationDate":"2013-07-06T03:17:00.000","Title":"Does following the PEP8 guidelines make your code run faster than if you did not follow 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},{"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},{"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},{"Question":"I have the source code to a python package that is typically installed using pup or easy-install. How do I locally install the code after I've made changes? I'd like to be able to run commands on the terminal as if I've installed it with pip and then reinstall\/have it detect code changes to try it again.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":78,"Q_Id":17518614,"Users Score":2,"Answer":"You can use pip -e install  to install a package in editable mode. Then, you can make changes to the source code, and not have to install it again.\nThis is best done, as always, in a virtualenv, so it is isolated from the rest of your system.","Q_Score":1,"Tags":"python","A_Id":17518734,"CreationDate":"2013-07-08T03:00:00.000","Title":"Testing Python 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":1,"System Administration and DevOps":1,"Web Development":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},{"Question":"Could you please tell me what is the closest data type in C++ to python list? If there is nothing similar, how would you build it in C++?","AnswerCount":5,"Available Count":2,"Score":0.0798297691,"is_accepted":false,"ViewCount":21803,"Q_Id":17528657,"Users Score":2,"Answer":"There is no real equivalent, and it would be extremely difficult\nto provide one.  Python and C++ are radically different\nlanguages, and providing one really wouldn't make much sense in\nthe context of C++.  The most important differences are that\neverything in Python is dynamically allocated, and is an\n\"object\", and that Python uses duck typing.\nFWIW: one very early library (before templates) in C++ did offer\ncontainers of Object*, with derived classes to box int,\ndouble, etc.  Actual experience showed very quickly that it\nwasn't a good idea.  (And I'm curious: does any one else\nremember it?  And particularly, exactly what it was \ncalled---something with NHS in it, but I can't remember more.)","Q_Score":15,"Tags":"c++,python,list","A_Id":17529258,"CreationDate":"2013-07-08T14:03:00.000","Title":"Python list equivalent 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":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"Could you please tell me what is the closest data type in C++ to python list? If there is nothing similar, how would you build it in C++?","AnswerCount":5,"Available Count":2,"Score":0.1973753202,"is_accepted":false,"ViewCount":21803,"Q_Id":17528657,"Users Score":5,"Answer":"Actually no C++ container is equivalent to Python's list, which is partially a result of the very different object models of C++ and Python. In particular, the suggested and upvoted std::list is IMHO not even close to Python's list type, a I'd rather suggest std::vector or maybe std::deque. That said, it isn't clear what exactly it is that you want and how to \"build it\" strongly depends on what exactly \"it\" is, i.e. what you expect from the container.\nI'd suggest you take a look at the C++ containers std::vector, std::deque and std::list to get an overview. Then look at things like Boost.Any and Boost.Variant that you can combine with them, maybe also one of the smart pointers and Boost.Optional. Finally, check out Boost.Container and Boost.Intrusive. If the unlikely case that none of these provide a suitable approximation, you need to provide a better explanation of what your actual goals are.","Q_Score":15,"Tags":"c++,python,list","A_Id":17529154,"CreationDate":"2013-07-08T14:03:00.000","Title":"Python list equivalent 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":0,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to read the arguments passed to a Python script called with Ti.Process.createProcess.\nWhen I run the following code:\n\nimport sys\nsys.argv\n\nI get the error:\n\nFile \"\", line 2, in \nAttributeError: 'module' object has no attribute 'argv'\n\nIt looks like the sys object doesn't have an argv attribute.\nAm I doing something wrong? any suggestions?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":283,"Q_Id":17536779,"Users Score":0,"Answer":"Looks like you have another sys.py in your python path.","Q_Score":0,"Tags":"python,argv,tidesdk,sys","A_Id":17544560,"CreationDate":"2013-07-08T22:05:00.000","Title":"TideSDK Python get arguments with sys.argv","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0},{"Question":"I'm trying to read the arguments passed to a Python script called with Ti.Process.createProcess.\nWhen I run the following code:\n\nimport sys\nsys.argv\n\nI get the error:\n\nFile \"\", line 2, in \nAttributeError: 'module' object has no attribute 'argv'\n\nIt looks like the sys object doesn't have an argv attribute.\nAm I doing something wrong? any suggestions?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":283,"Q_Id":17536779,"Users Score":0,"Answer":"I found the error.\nI was testing the code using this code:\n\n